lkml.org 
[lkml]   [2000]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] bug in non-blocking use of sound driver

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/

\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.044 / U:1.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site