changeset 217:3f2e3c5c30ed trunk

[svn] - make esd plugin assume that write() isn't always successful due to threading contingency. closes #427. patch by <sjleung -at shaw.ca>.
author nenolod
date Sat, 04 Nov 2006 23:03:45 -0800
parents 803734431d3a
children a6f6309ab0a0
files ChangeLog src/esd/audio.c
diffstat 2 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Nov 04 13:14:27 2006 -0800
+++ b/ChangeLog	Sat Nov 04 23:03:45 2006 -0800
@@ -1,3 +1,11 @@
+2006-11-04 21:14:27 +0000  Aaron Sheldon <asheldon@uiuc.edu>
+  revision [432]
+  Works again on x86
+  
+  trunk/src/sap/sap_plug.c |    2 +-
+  1 file changed, 1 insertion(+), 1 deletion(-)
+
+
 2006-11-04 20:18:44 +0000  William Pitcock <nenolod@nenolod.net>
   revision [430]
   - gthread and produce_audio
--- a/src/esd/audio.c	Sat Nov 04 13:14:27 2006 -0800
+++ b/src/esd/audio.c	Sat Nov 04 23:03:45 2006 -0800
@@ -299,10 +299,19 @@
         length =
             ep->mod_samples(&data, length, input_format, input_frequency,
                             input_channels);
-    if (esd_translate)
-        output_bytes += write(fd, esd_translate(data, length), length);
-    else
-        output_bytes += write(fd, data, length);
+    while (length > 0) {
+        int num_written;
+        if (esd_translate)
+            num_written = write(fd, esd_translate(data, length), length);
+        else
+            num_written = write(fd, data, length);
+        if (num_written <= 0)
+            break;
+        length -= num_written;
+        data += num_written;
+        output_bytes += num_written;
+        }
+    }
 }