Lines Matching refs:hw

55 static void buf_reset(snd_rawmidi_hw_t *hw)
57 hw->buf_fill = 0;
58 hw->buf_pos = 0;
59 hw->buf_fpos = 0;
64 snd_rawmidi_hw_t *hw = rmidi->private_data;
67 hw->open--;
68 if (hw->open)
70 if (close(hw->fd)) {
74 free(hw->buf);
75 free(hw);
81 snd_rawmidi_hw_t *hw = rmidi->private_data;
84 if ((flags = fcntl(hw->fd, F_GETFL)) < 0) {
92 if (fcntl(hw->fd, F_SETFL, flags) < 0) {
101 snd_rawmidi_hw_t *hw = rmidi->private_data;
103 if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_INFO, info) < 0) {
112 snd_rawmidi_hw_t *hw = rmidi->private_data;
115 if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_PARAMS, params) < 0) {
119 buf_reset(hw);
121 if (hw->buf && !tstamp) {
122 free(hw->buf);
123 hw->buf = NULL;
124 hw->buf_size = 0;
132 if (alloc_size != hw->buf_size) {
133 buf = realloc(hw->buf, alloc_size);
136 hw->buf = buf;
137 hw->buf_size = alloc_size;
145 snd_rawmidi_hw_t *hw = rmidi->private_data;
147 if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_STATUS, status) < 0) {
156 snd_rawmidi_hw_t *hw = rmidi->private_data;
158 if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_DROP, &str) < 0) {
162 buf_reset(hw);
168 snd_rawmidi_hw_t *hw = rmidi->private_data;
170 if (ioctl(hw->fd, SNDRV_RAWMIDI_IOCTL_DRAIN, &str) < 0) {
179 snd_rawmidi_hw_t *hw = rmidi->private_data;
181 result = write(hw->fd, buffer, size);
189 snd_rawmidi_hw_t *hw = rmidi->private_data;
191 result = read(hw->fd, buffer, size);
197 static ssize_t read_from_ts_buf(snd_rawmidi_hw_t *hw, struct timespec *tstamp,
204 f = (struct snd_rawmidi_framing_tstamp *)(hw->buf + hw->buf_pos);
205 while (hw->buf_fill >= sizeof(*f)) {
211 hw->buf_pos += sizeof(*f);
212 hw->buf_fill -= sizeof(*f);
215 while (size > 0 && hw->buf_fill >= sizeof(*f)) {
224 flen = f->length - hw->buf_fpos;
227 memcpy(buffer, f->data + hw->buf_fpos, size);
228 hw->buf_fpos += size;
232 memcpy(buffer, f->data + hw->buf_fpos, flen);
233 hw->buf_fpos = 0;
238 hw->buf_pos += sizeof(*f);
239 hw->buf_fill -= sizeof(*f);
248 snd_rawmidi_hw_t *hw = rmidi->private_data;
255 if (hw->buf_fill > 0) {
256 result = read_from_ts_buf(hw, tstamp, buffer, size);
258 hw->buf_fill >= sizeof(struct snd_rawmidi_framing_tstamp))
264 buf_reset(hw);
265 ret = read(hw->fd, hw->buf, hw->buf_size);
270 hw->buf_fill = ret;
271 ret = read_from_ts_buf(hw, tstamp, buffer, size);
279 snd_rawmidi_hw_t *hw = rmidi->private_data;
283 if (ioctl(hw->fd, SNDRV_UMP_IOCTL_ENDPOINT_INFO, buf) < 0)
290 snd_rawmidi_hw_t *hw = rmidi->private_data;
294 if (ioctl(hw->fd, SNDRV_UMP_IOCTL_BLOCK_INFO, buf) < 0)
324 snd_rawmidi_hw_t *hw = NULL;
423 hw = calloc(1, sizeof(snd_rawmidi_hw_t));
424 if (hw == NULL)
426 hw->card = card;
427 hw->device = device;
428 hw->subdevice = subdevice;
429 hw->fd = fd;
442 rmidi->private_data = hw;
444 hw->open++;
458 rmidi->private_data = hw;
460 hw->open++;
467 free(hw);