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

From: Eric Lammerts (eric@scintilla.utwente.nl)
Date: Wed Jan 19 2000 - 18:21:10 EST


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@scintilla.utwente.nl>

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



This archive was generated by hypermail 2b29 : Sun Jan 23 2000 - 21:00:21 EST