# HG changeset patch # User arpi # Date 1016565361 0 # Node ID 6bbf3271a6941a6079cd23e509b595a73e0b03fd # Parent 2f5ff1968d1cd2d2ca44292ec81152eff9976058 non-blocking open - patch by Fredrik Kuivinen diff -r 2f5ff1968d1c -r 6bbf3271a694 libao2/ao_oss.c --- a/libao2/ao_oss.c Tue Mar 19 18:57:24 2002 +0000 +++ b/libao2/ao_oss.c Tue Mar 19 19:16:01 2002 +0000 @@ -7,6 +7,8 @@ #include #include #include +#include +#include //#include #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; }