Skip to content

Commit

Permalink
ALSA: seq: virmidi: Add a drain operation
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Stefan Sauer authored and tiwai committed Jan 6, 2022
1 parent b81e9e5 commit 7560ee0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sound/core/seq/seq_virmidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,16 @@ static int snd_virmidi_output_close(struct snd_rawmidi_substream *substream)
return 0;
}

/*
* drain output work queue
*/
static void snd_virmidi_output_drain(struct snd_rawmidi_substream *substream)
{
struct snd_virmidi *vmidi = substream->runtime->private_data;

flush_work(&vmidi->output_work);
}

/*
* subscribe callback - allow output to rawmidi device
*/
Expand Down Expand Up @@ -336,6 +346,7 @@ static const struct snd_rawmidi_ops snd_virmidi_output_ops = {
.open = snd_virmidi_output_open,
.close = snd_virmidi_output_close,
.trigger = snd_virmidi_output_trigger,
.drain = snd_virmidi_output_drain,
};

/*
Expand Down

0 comments on commit 7560ee0

Please sign in to comment.