Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <st_kost@gmx.de>
Link: https://lore.kernel.org/r/20220106124145.17254-1-st_kost@gmx.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Stefan Sauer and committed by
Takashi Iwai
7560ee03 b81e9e5c

+11
+11
sound/core/seq/seq_virmidi.c
··· 263 263 } 264 264 265 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 + 275 + /* 266 276 * subscribe callback - allow output to rawmidi device 267 277 */ 268 278 static int snd_virmidi_subscribe(void *private_data, ··· 346 336 .open = snd_virmidi_output_open, 347 337 .close = snd_virmidi_output_close, 348 338 .trigger = snd_virmidi_output_trigger, 339 + .drain = snd_virmidi_output_drain, 349 340 }; 350 341 351 342 /*