[xiph-commits] r16843 - in trunk/ao/src/plugins: esd oss

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Thu Jan 28 10:53:04 PST 2010


Author: xiphmont
Date: 2010-01-28 10:53:04 -0800 (Thu, 28 Jan 2010)
New Revision: 16843

Modified:
   trunk/ao/src/plugins/esd/ao_esd.c
   trunk/ao/src/plugins/oss/ao_oss.c
Log:
Fixes BZ #1124


Modified: trunk/ao/src/plugins/esd/ao_esd.c
===================================================================
--- trunk/ao/src/plugins/esd/ao_esd.c	2010-01-28 12:03:30 UTC (rev 16842)
+++ trunk/ao/src/plugins/esd/ao_esd.c	2010-01-28 18:53:04 UTC (rev 16843)
@@ -162,10 +162,24 @@
 {
 	ao_esd_internal *internal = (ao_esd_internal *) device->internal;
 
-	if (write(internal->sock, output_samples, num_bytes) < 0)
-		return 0;
-	else
-		return 1;
+
+        while (num_bytes > 0) {
+          ssize_t ret = write(internal->sock, output_samples, num_bytes);
+          if(ret<0){
+            switch(errno){
+            case EAGAIN:
+            case EINTR:
+              break;
+            default:
+              return 0;
+            }
+          }
+
+          output_samples += ret;
+          num_bytes -= ret;
+        }
+
+        return 1;
 }
 
 

Modified: trunk/ao/src/plugins/oss/ao_oss.c
===================================================================
--- trunk/ao/src/plugins/oss/ao_oss.c	2010-01-28 12:03:30 UTC (rev 16842)
+++ trunk/ao/src/plugins/oss/ao_oss.c	2010-01-28 18:53:04 UTC (rev 16843)
@@ -302,15 +302,16 @@
 	ao_oss_internal *internal = (ao_oss_internal *) device->internal;
 
 	while(num_bytes > 0) {
-		send = num_bytes>internal->buf_size?
-			internal->buf_size:num_bytes;
-		ret = write(internal->fd, output_samples, send);
+          send = num_bytes>internal->buf_size?
+            internal->buf_size:num_bytes;
+          ret = write(internal->fd, output_samples, send);
 
-		if (ret <= 0)
-			return 0;
-
-		num_bytes-=ret;
-		output_samples+=ret;
+          if (ret < 0){
+            if(errno == EINTR) continue;
+            return 0;
+          }
+          num_bytes-=ret;
+          output_samples+=ret;
 	}
 
 	return 1;



More information about the commits mailing list