Skip to content

Commit 7560ee0

Browse files
Stefan Sauertiwai
authored andcommitted
ALSA: seq: virmidi: Add a drain operation
If a driver does not supply a drain operation for outputs, a default code path will execute msleep(50). Especially for a virtual midi device this severely limmits the throughput. This implementation for the virtual midi driver simply flushes the output workqueue. Signed-off-by: Stefan Sauer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent b81e9e5 commit 7560ee0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sound/core/seq/seq_virmidi.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,16 @@ static int snd_virmidi_output_close(struct snd_rawmidi_substream *substream)
262262
return 0;
263263
}
264264

265+
/*
266+
* drain output work queue
267+
*/
268+
static void snd_virmidi_output_drain(struct snd_rawmidi_substream *substream)
269+
{
270+
struct snd_virmidi *vmidi = substream->runtime->private_data;
271+
272+
flush_work(&vmidi->output_work);
273+
}
274+
265275
/*
266276
* subscribe callback - allow output to rawmidi device
267277
*/
@@ -336,6 +346,7 @@ static const struct snd_rawmidi_ops snd_virmidi_output_ops = {
336346
.open = snd_virmidi_output_open,
337347
.close = snd_virmidi_output_close,
338348
.trigger = snd_virmidi_output_trigger,
349+
.drain = snd_virmidi_output_drain,
339350
};
340351

341352
/*

0 commit comments

Comments
 (0)