diff mbox series

[1/2] ALSA: seq: virmidi: Add a drain operation

Message ID 20220106124145.17254-1-st_kost@gmx.de (mailing list archive)
State Accepted
Commit 7560ee032b3f87fa5c4f03e99a064c6cd326951e
Headers show
Series [1/2] ALSA: seq: virmidi: Add a drain operation | expand

Commit Message

Stefan Sauer Jan. 6, 2022, 12:41 p.m. UTC
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 <st_kost@gmx.de>
---
 sound/core/seq/seq_virmidi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

--
2.34.1

Comments

Takashi Iwai Jan. 6, 2022, 3:08 p.m. UTC | #1
On Thu, 06 Jan 2022 13:41:45 +0100,
Stefan Sauer wrote:
> 
> 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 <st_kost@gmx.de>

Thanks, applied.


Takashi
diff mbox series

Patch

diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c
index 4abc38c70cae..f5cae49500c8 100644
--- a/sound/core/seq/seq_virmidi.c
+++ b/sound/core/seq/seq_virmidi.c
@@ -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
  */
@@ -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,
 };

 /*