Lines Matching refs:this

33 static int midibuf_is_empty(struct midi_buffer *this)
35 return (this->pos_read == this->pos_write) && !this->full;
38 static int midibuf_is_full(struct midi_buffer *this)
40 return this->full;
43 void line6_midibuf_reset(struct midi_buffer *this)
45 this->pos_read = this->pos_write = this->full = 0;
46 this->command_prev = -1;
49 int line6_midibuf_init(struct midi_buffer *this, int size, int split)
51 this->buf = kmalloc(size, GFP_KERNEL);
53 if (this->buf == NULL)
56 this->size = size;
57 this->split = split;
58 line6_midibuf_reset(this);
62 int line6_midibuf_bytes_free(struct midi_buffer *this)
65 midibuf_is_full(this) ?
67 (this->pos_read - this->pos_write + this->size - 1) % this->size +
71 int line6_midibuf_bytes_used(struct midi_buffer *this)
74 midibuf_is_empty(this) ?
76 (this->pos_write - this->pos_read + this->size - 1) % this->size +
80 int line6_midibuf_write(struct midi_buffer *this, unsigned char *data,
87 if (midibuf_is_full(this) || (length <= 0))
96 bytes_free = line6_midibuf_bytes_free(this);
102 length1 = this->size - this->pos_write;
106 memcpy(this->buf + this->pos_write, data, length);
107 this->pos_write += length;
111 memcpy(this->buf + this->pos_write, data, length1);
112 memcpy(this->buf, data + length1, length2);
113 this->pos_write = length2;
116 if (this->pos_write == this->pos_read)
117 this->full = 1;
123 int line6_midibuf_read(struct midi_buffer *this, unsigned char *data,
137 if (midibuf_is_empty(this))
140 bytes_used = line6_midibuf_bytes_used(this);
145 length1 = this->size - this->pos_read;
147 command = this->buf[this->pos_read];
157 this->buf[this->pos_read] = fixed;
165 this->command_prev = command;
167 if (this->command_prev > 0) {
169 midibuf_message_length(this->command_prev);
185 if (this->buf[this->pos_read + i] & 0x80)
194 if (this->buf[this->pos_read + i] & 0x80)
201 if (this->buf[i] & 0x80)
213 if (!this->split)
224 memcpy(data + repeat, this->buf + this->pos_read, length);
225 this->pos_read += length;
229 memcpy(data + repeat, this->buf + this->pos_read, length1);
230 memcpy(data + repeat + length1, this->buf, length2);
231 this->pos_read = length2;
235 data[0] = this->command_prev;
237 this->full = 0;
241 int line6_midibuf_ignore(struct midi_buffer *this, int length)
243 int bytes_used = line6_midibuf_bytes_used(this);
248 this->pos_read = (this->pos_read + length) % this->size;
249 this->full = 0;
253 void line6_midibuf_destroy(struct midi_buffer *this)
255 kfree(this->buf);
256 this->buf = NULL;