[PATCH] bug in non-blocking use of sound driver

Eric Lammerts eric en scintilla.utwente.nl
Jue Ene 20 03:51:26 CST 2000


Hi,
I made an app that reads from /dev/dsp in non-blocking mode and I
noticed that with the drivers that use audio.c, read()
returns 0 when no data is available. Ditto for write().

The patch below fixes this. (it's for 2.2.14 and 2.3.x)

Eric

--- linux/drivers/sound/audio.c.orig	Tue Jan 18 21:27:09 2000
+++ linux/drivers/sound/audio.c	Tue Jan 18 21:31:08 2000
@@ -226,7 +226,7 @@
 		{
 			    /* Handle nonblocking mode */
 			if ((file->f_flags & O_NONBLOCK) && err == -EAGAIN)
-				return p;	/* No more space. Return # of accepted bytes */
+				return p? p : -EAGAIN;	/* No more space. Return # of accepted bytes */
 			return err;
 		}
 		l = c;
@@ -306,11 +306,11 @@
 			 *	Nonblocking mode handling. Return current # of bytes
 			 */
 
-			if ((file->f_flags & O_NONBLOCK) && buf_no == -EAGAIN)
-				return p;
-
 			if (p > 0) 		/* Avoid throwing away data */
 				return p;	/* Return it instead */
+
+			if ((file->f_flags & O_NONBLOCK) && buf_no == -EAGAIN)
+				return -EAGAIN;
 
 			return buf_no;
 		}


-- 
Eric Lammerts <eric en scintilla.utwente.nl>


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo en vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



Más información sobre la lista de distribución Ayuda