[Mplayer-cvslog] CVS: main/libao2 ao_oss.c,1.19,1.20

Arpi of Ize arpi at mplayer.dev.hu
Tue Mar 19 20:16:04 CET 2002


Update of /cvsroot/mplayer/main/libao2
In directory mplayer:/var/tmp.root/cvs-serv10675

Modified Files:
	ao_oss.c 
Log Message:
non-blocking open - patch by Fredrik Kuivinen <freku045 at student.liu.se>

Index: ao_oss.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_oss.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ao_oss.c	22 Feb 2002 14:20:15 -0000	1.19
+++ ao_oss.c	19 Mar 2002 19:16:01 -0000	1.20
@@ -7,6 +7,8 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <errno.h>
+#include <string.h>
 //#include <sys/soundcard.h>
 
 #include "../config.h"
@@ -101,12 +103,18 @@
   if (verbose)
     printf("audio_setup: using '%s' dsp device\n", dsp);
 
-  audio_fd=open(dsp, O_WRONLY);
+  audio_fd=open(dsp, O_WRONLY | O_NONBLOCK);
   if(audio_fd<0){
-    printf("Can't open audio device %s  -> nosound\n",dsp);
+    printf("Can't open audio device %s: %s  -> no sound\n", dsp, strerror(errno));
     return 0;
   }
 
+  /* Remove the non-blocking flag */
+  if(fcntl(audio_fd, F_SETFL, 0) < 0) {
+   printf("Can't make filedescriptor non-blocking: %s -> no sound\n", strerror(errno));
+   return 0;
+  }  
+  
   ao_data.bps=channels*rate;
   if(format != AFMT_U8 && format != AFMT_S8)
     ao_data.bps*=2;
@@ -203,9 +211,9 @@
 // stop playing and empty buffers (for seeking/pause)
 static void reset(){
     uninit();
-    audio_fd=open(dsp, O_WRONLY);
-    if(audio_fd<0){
-	printf("\nFatal error: *** CANNOT RE-OPEN / RESET AUDIO DEVICE ***\n");
+    audio_fd=open(dsp, O_WRONLY | O_NONBLOCK);
+    if(audio_fd < 0 || fcntl(audio_fd, F_SETFL, 0) < 0){
+	printf("\nFatal error: *** CANNOT RE-OPEN / RESET AUDIO DEVICE *** %s\n", strerror(errno));
 	return;
     }
 




More information about the MPlayer-cvslog mailing list