[MPlayer-dev-eng] Re: Re: [patch] release /dev/dsp on pause

Eric Lammerts eric at lammerts.org
Wed Aug 28 20:57:04 CEST 2002


On Wed, Aug 28, 2002 at 06:27:14PM +0200, Alex Beregszaszi wrote:
> > I have a patch similar to yours, but in my case mplayer doesn't crash
> > when I unpause and the device is busy. It simply blocks until /dev/dsp
> > is released by the other app. (because the open() in reset() has no
> > O_NONBLOCK).

> Could you post your patch too?

Here it is; the only difference with Richard's patch is that this one is
guarded against multiple uninit()'s. Reset() starts with an uninit(), so
this really happens.

Without the check, if a file was opened between audio_pause() and
audio_resume(), it could get the same fd as audio_fd, and be closed
accidentally on resume. Maybe that is causing the crashes.

Eric


Index: libao2/ao_oss.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_oss.c,v
retrieving revision 1.29
diff -u -r1.29 ao_oss.c
--- libao2/ao_oss.c	4 Aug 2002 18:33:26 -0000	1.29
+++ libao2/ao_oss.c	28 Aug 2002 19:00:10 -0000
@@ -225,10 +225,12 @@
 
 // close audio device
 static void uninit(){
+    if(audio_fd == -1) return;
 #ifdef SNDCTL_DSP_RESET
     ioctl(audio_fd, SNDCTL_DSP_RESET, NULL);
 #endif
     close(audio_fd);
+    audio_fd = -1;
 }
 
 // stop playing and empty buffers (for seeking/pause)
@@ -255,13 +257,13 @@
 // stop playing, keep buffers (for pause)
 static void audio_pause()
 {
-    // for now, just call reset();
-    reset();
+    uninit();
 }
 
 // resume playing, after audio_pause()
 static void audio_resume()
 {
+    reset();
 }
 
 



More information about the MPlayer-dev-eng mailing list