Skip to contentSkip to conversation

OSS MIDI output loses data

PATCH New Clemens Ladisch 1 participant 1 message Nov 28, 2002 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 OSS MIDI output loses data

In the 2.1.6 kernel, the output loop in midi_poll() was changed to enable interrupts during the outputc() call. Unfortunately, the check whether the device has accepted the current byte ("ok") was moved behind the code which removes the byte from the output queue, so one byte would be lost every time the hardware FIFO is full.

Signature · 25 lines
Clemens


--- linux-2.4.19/drivers/sound/midibuf.c	Wed Nov 27 12:34:56 2002
+++ linux/drivers/sound/midibuf.c	Wed Nov 27 16:32:31 2002
@@ -129,15 +129,16 @@
 		for (dev = 0; dev < num_midis; dev++)
 			if (midi_devs[dev] != NULL && midi_out_buf[dev] != NULL)
 			{
-				int ok = 1;
-
-				while (DATA_AVAIL(midi_out_buf[dev]) && ok)
+				while (DATA_AVAIL(midi_out_buf[dev]))
 				{
+					int ok;
 					int c = midi_out_buf[dev]->queue[midi_out_buf[dev]->head];

 					restore_flags(flags);	/* Give some time to others */
 					ok = midi_devs[dev]->outputc(dev, c);
 					cli();
+					if (!ok)
+						break;
 					midi_out_buf[dev]->head = (midi_out_buf[dev]->head + 1) % MAX_QUEUE_SIZE;
 					midi_out_buf[dev]->len--;
 				}