Lines Matching defs:runtime

101 static inline bool __snd_rawmidi_ready(struct snd_rawmidi_runtime *runtime)
103 return runtime->avail >= runtime->avail_min;
112 ready = __snd_rawmidi_ready(substream->runtime);
120 struct snd_rawmidi_runtime *runtime = substream->runtime;
122 return runtime->avail >= runtime->avail_min &&
123 (!substream->append || runtime->avail >= count);
128 struct snd_rawmidi_runtime *runtime =
131 if (runtime->event)
132 runtime->event(runtime->substream);
136 static inline void snd_rawmidi_buffer_ref(struct snd_rawmidi_runtime *runtime)
138 runtime->buffer_ref++;
141 static inline void snd_rawmidi_buffer_unref(struct snd_rawmidi_runtime *runtime)
143 runtime->buffer_ref--;
151 while (substream->runtime->buffer_ref) {
165 struct snd_rawmidi_runtime *runtime;
167 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
168 if (!runtime)
170 runtime->substream = substream;
171 init_waitqueue_head(&runtime->sleep);
172 INIT_WORK(&runtime->event_work, snd_rawmidi_input_event_work);
173 runtime->event = NULL;
174 runtime->buffer_size = PAGE_SIZE;
175 runtime->avail_min = 1;
177 runtime->avail = 0;
179 runtime->avail = runtime->buffer_size;
180 runtime->buffer = kvzalloc(runtime->buffer_size, GFP_KERNEL);
181 if (!runtime->buffer) {
182 kfree(runtime);
185 runtime->appl_ptr = runtime->hw_ptr = 0;
186 substream->runtime = runtime;
188 runtime->align = 3;
193 static inline int get_align(struct snd_rawmidi_runtime *runtime)
196 return runtime->align;
202 #define get_aligned_size(runtime, size) ((size) & ~get_align(runtime))
206 struct snd_rawmidi_runtime *runtime = substream->runtime;
208 kvfree(runtime->buffer);
209 kfree(runtime);
210 substream->runtime = NULL;
227 cancel_work_sync(&substream->runtime->event_work);
230 static void __reset_runtime_ptrs(struct snd_rawmidi_runtime *runtime,
233 runtime->drain = 0;
234 runtime->appl_ptr = runtime->hw_ptr = 0;
235 runtime->avail = is_input ? 0 : runtime->buffer_size;
244 if (substream->opened && substream->runtime)
245 __reset_runtime_ptrs(substream->runtime, is_input);
261 struct snd_rawmidi_runtime *runtime;
264 runtime = substream->runtime;
265 if (!substream->opened || !runtime || !runtime->buffer) {
268 snd_rawmidi_buffer_ref(runtime);
269 runtime->drain = 1;
275 timeout = wait_event_interruptible_timeout(runtime->sleep,
276 (runtime->avail >= runtime->buffer_size),
282 if (runtime->avail < runtime->buffer_size && !timeout) {
285 (long)runtime->avail, (long)runtime->buffer_size);
288 runtime->drain = 0;
301 snd_rawmidi_buffer_unref(runtime);
529 if (rawmidi_file->input && rawmidi_file->input->runtime)
530 rawmidi_file->input->runtime->oss = (maj == SOUND_MAJOR);
531 if (rawmidi_file->output && rawmidi_file->output->runtime)
532 rawmidi_file->output->runtime->oss = (maj == SOUND_MAJOR);
576 if (substream->runtime->private_free)
577 substream->runtime->private_free(substream);
731 struct snd_rawmidi_runtime *runtime = substream->runtime;
741 if (params->buffer_size & get_align(runtime))
743 if (params->buffer_size != runtime->buffer_size) {
748 if (runtime->buffer_ref) {
753 oldbuf = runtime->buffer;
754 runtime->buffer = newbuf;
755 runtime->buffer_size = params->buffer_size;
756 __reset_runtime_ptrs(runtime, is_input);
760 runtime->avail_min = params->avail_min;
813 struct snd_rawmidi_runtime *runtime = substream->runtime;
818 status->avail = runtime->avail;
826 struct snd_rawmidi_runtime *runtime = substream->runtime;
831 status->avail = runtime->avail;
832 status->xruns = runtime->xruns;
833 runtime->xruns = 0;
1104 struct snd_rawmidi_runtime *runtime = substream->runtime;
1109 int align = get_align(runtime);
1112 if (snd_BUG_ON((runtime->hw_ptr & 0x1f) != 0))
1116 if ((int)(runtime->buffer_size - runtime->avail) < frame_size) {
1117 runtime->xruns += src_count;
1123 frame.length = get_aligned_size(runtime, src_count);
1131 dest_ptr = (struct snd_rawmidi_framing_tstamp *) (runtime->buffer + runtime->hw_ptr);
1133 runtime->avail += frame_size;
1134 runtime->hw_ptr += frame_size;
1135 runtime->hw_ptr %= runtime->buffer_size;
1174 struct snd_rawmidi_runtime *runtime;
1181 runtime = substream->runtime;
1182 if (!runtime || !runtime->buffer) {
1189 count = get_aligned_size(runtime, count);
1197 if (runtime->avail < runtime->buffer_size) {
1198 runtime->buffer[runtime->hw_ptr++] = buffer[0];
1199 runtime->hw_ptr %= runtime->buffer_size;
1200 runtime->avail++;
1203 runtime->xruns++;
1207 count1 = runtime->buffer_size - runtime->hw_ptr;
1210 if (count1 > (int)(runtime->buffer_size - runtime->avail))
1211 count1 = runtime->buffer_size - runtime->avail;
1212 count1 = get_aligned_size(runtime, count1);
1215 memcpy(runtime->buffer + runtime->hw_ptr, buffer, count1);
1216 runtime->hw_ptr += count1;
1217 runtime->hw_ptr %= runtime->buffer_size;
1218 runtime->avail += count1;
1224 if (count1 > (int)(runtime->buffer_size - runtime->avail)) {
1225 count1 = runtime->buffer_size - runtime->avail;
1226 runtime->xruns += count - count1;
1229 memcpy(runtime->buffer, buffer, count1);
1230 runtime->hw_ptr = count1;
1231 runtime->avail += count1;
1237 if (runtime->event)
1238 schedule_work(&runtime->event_work);
1239 else if (__snd_rawmidi_ready(runtime))
1240 wake_up(&runtime->sleep);
1254 struct snd_rawmidi_runtime *runtime = substream->runtime;
1259 snd_rawmidi_buffer_ref(runtime);
1260 while (count > 0 && runtime->avail) {
1261 count1 = runtime->buffer_size - runtime->appl_ptr;
1264 if (count1 > (int)runtime->avail)
1265 count1 = runtime->avail;
1267 /* update runtime->appl_ptr before unlocking for userbuf */
1268 appl_ptr = runtime->appl_ptr;
1269 runtime->appl_ptr += count1;
1270 runtime->appl_ptr %= runtime->buffer_size;
1271 runtime->avail -= count1;
1274 memcpy(kernelbuf + result, runtime->buffer + appl_ptr, count1);
1278 runtime->buffer + appl_ptr, count1))
1288 snd_rawmidi_buffer_unref(runtime);
1308 struct snd_rawmidi_runtime *runtime;
1314 runtime = substream->runtime;
1319 while (!__snd_rawmidi_ready(runtime)) {
1327 add_wait_queue(&runtime->sleep, &wait);
1331 remove_wait_queue(&runtime->sleep, &wait);
1337 if (!runtime->avail) {
1364 struct snd_rawmidi_runtime *runtime;
1369 runtime = substream->runtime;
1370 if (!substream->opened || !runtime || !runtime->buffer) {
1375 result = runtime->avail >= runtime->buffer_size;
1394 struct snd_rawmidi_runtime *runtime = substream->runtime;
1396 if (runtime->buffer == NULL) {
1402 if (runtime->avail >= runtime->buffer_size) {
1407 *buffer = runtime->buffer[runtime->hw_ptr];
1410 count1 = runtime->buffer_size - runtime->hw_ptr;
1413 if (count1 > (int)(runtime->buffer_size - runtime->avail))
1414 count1 = runtime->buffer_size - runtime->avail;
1415 count1 = get_aligned_size(runtime, count1);
1418 memcpy(buffer, runtime->buffer + runtime->hw_ptr, count1);
1422 if (count > (int)(runtime->buffer_size - runtime->avail - count1))
1423 count = runtime->buffer_size - runtime->avail - count1;
1424 count = get_aligned_size(runtime, count);
1427 memcpy(buffer + count1, runtime->buffer, count);
1456 if (!substream->opened || !substream->runtime)
1475 struct snd_rawmidi_runtime *runtime = substream->runtime;
1477 if (runtime->buffer == NULL) {
1482 snd_BUG_ON(runtime->avail + count > runtime->buffer_size);
1483 count = get_aligned_size(runtime, count);
1484 runtime->hw_ptr += count;
1485 runtime->hw_ptr %= runtime->buffer_size;
1486 runtime->avail += count;
1489 if (runtime->drain || __snd_rawmidi_ready(runtime))
1490 wake_up(&runtime->sleep);
1512 if (!substream->opened || !substream->runtime)
1560 struct snd_rawmidi_runtime *runtime;
1565 runtime = substream->runtime;
1566 if (substream->opened && runtime &&
1567 runtime->avail < runtime->buffer_size) {
1568 count = runtime->buffer_size - runtime->avail;
1583 struct snd_rawmidi_runtime *runtime = substream->runtime;
1588 if (snd_BUG_ON(!runtime->buffer))
1594 if ((long)runtime->avail < count) {
1599 snd_rawmidi_buffer_ref(runtime);
1600 while (count > 0 && runtime->avail > 0) {
1601 count1 = runtime->buffer_size - runtime->appl_ptr;
1604 if (count1 > (long)runtime->avail)
1605 count1 = runtime->avail;
1607 /* update runtime->appl_ptr before unlocking for userbuf */
1608 appl_ptr = runtime->appl_ptr;
1609 runtime->appl_ptr += count1;
1610 runtime->appl_ptr %= runtime->buffer_size;
1611 runtime->avail -= count1;
1614 memcpy(runtime->buffer + appl_ptr,
1618 if (copy_from_user(runtime->buffer + appl_ptr,
1630 count1 = runtime->avail < runtime->buffer_size;
1631 snd_rawmidi_buffer_unref(runtime);
1651 struct snd_rawmidi_runtime *runtime;
1656 runtime = substream->runtime;
1658 if (substream->append && count > runtime->buffer_size)
1671 add_wait_queue(&runtime->sleep, &wait);
1675 remove_wait_queue(&runtime->sleep, &wait);
1681 if (!runtime->avail && !timeout) {
1698 while (runtime->avail != runtime->buffer_size) {
1700 unsigned int last_avail = runtime->avail;
1703 add_wait_queue(&runtime->sleep, &wait);
1707 remove_wait_queue(&runtime->sleep, &wait);
1710 if (runtime->avail == last_avail && !timeout)
1722 struct snd_rawmidi_runtime *runtime;
1727 runtime = rfile->input->runtime;
1729 poll_wait(file, &runtime->sleep, wait);
1732 runtime = rfile->output->runtime;
1733 poll_wait(file, &runtime->sleep, wait);
1763 struct snd_rawmidi_runtime *runtime;
1789 runtime = substream->runtime;
1791 buffer_size = runtime->buffer_size;
1792 avail = runtime->avail;
1798 runtime->oss ? "OSS compatible" : "native",
1816 runtime = substream->runtime;
1818 buffer_size = runtime->buffer_size;
1819 avail = runtime->avail;
1820 xruns = runtime->xruns;
2124 if (s->runtime)
2125 wake_up(&s->runtime->sleep);