# HG changeset patch # User alex # Date 1081274136 0 # Node ID 99798c3cdb934f569aa18c5f86ef53cdd4dee590 # Parent 1226e0cbb04b9266fe52d8f9030bf03a5451d326 uninit immed flag diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_alsa1x.c --- a/libao2/ao_alsa1x.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_alsa1x.c Tue Apr 06 17:55:36 2004 +0000 @@ -736,7 +736,7 @@ /* close audio device */ -static void uninit() +static void uninit(int immed) { if (alsa_handler) { diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_alsa5.c --- a/libao2/ao_alsa5.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_alsa5.c Tue Apr 06 17:55:36 2004 +0000 @@ -236,7 +236,7 @@ } /* close audio device */ -static void uninit() +static void uninit(int immed) { int err; diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_alsa9.c --- a/libao2/ao_alsa9.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_alsa9.c Tue Apr 06 17:55:36 2004 +0000 @@ -723,7 +723,7 @@ /* close audio device */ -static void uninit() +static void uninit(int immed) { if (alsa_handler) { diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_arts.c --- a/libao2/ao_arts.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_arts.c Tue Apr 06 17:55:36 2004 +0000 @@ -100,7 +100,7 @@ return 1; } -static void uninit() +static void uninit(int immed) { arts_close_stream(stream); arts_free(); diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_dxr2.c --- a/libao2/ao_dxr2.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_dxr2.c Tue Apr 06 17:55:36 2004 +0000 @@ -118,7 +118,7 @@ } // close audio device -static void uninit(){ +static void uninit(int immed){ } diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_esd.c --- a/libao2/ao_esd.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_esd.c Tue Apr 06 17:55:36 2004 +0000 @@ -274,7 +274,7 @@ /* * close audio device */ -static void uninit() +static void uninit(int immed) { if (esd_play_fd >= 0) { esd_close(esd_play_fd); diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_macosx.c --- a/libao2/ao_macosx.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_macosx.c Tue Apr 06 17:55:36 2004 +0000 @@ -353,7 +353,7 @@ /* unload plugin and deregister from coreaudio */ -static void uninit() +static void uninit(int immed) { int i; OSErr status; diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_mpegpes.c --- a/libao2/ao_mpegpes.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_mpegpes.c Tue Apr 06 17:55:36 2004 +0000 @@ -131,7 +131,7 @@ } // close audio device -static void uninit(){ +static void uninit(int immed){ } diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_nas.c --- a/libao2/ao_nas.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_nas.c Tue Apr 06 17:55:36 2004 +0000 @@ -476,7 +476,7 @@ } // close audio device -static void uninit(){ +static void uninit(int immed){ mp_msg(MSGT_AO, MSGL_DBG3, "ao_nas: uninit()\n"); diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_null.c --- a/libao2/ao_null.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_null.c Tue Apr 06 17:55:36 2004 +0000 @@ -64,7 +64,7 @@ } // close audio device -static void uninit(){ +static void uninit(int immed){ } diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_oss.c --- a/libao2/ao_oss.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_oss.c Tue Apr 06 17:55:36 2004 +0000 @@ -263,10 +263,16 @@ } // close audio device -static void uninit(){ +static void uninit(int immed){ if(audio_fd == -1) return; +#ifdef SNDCTL_DSP_SYNC + // to get the buffer played + if (!immed) + ioctl(audio_fd, SNDCTL_DSP_SYNC, NULL); +#endif #ifdef SNDCTL_DSP_RESET - ioctl(audio_fd, SNDCTL_DSP_RESET, NULL); + if (immed) + ioctl(audio_fd, SNDCTL_DSP_RESET, NULL); #endif close(audio_fd); audio_fd = -1; @@ -274,7 +280,7 @@ // stop playing and empty buffers (for seeking/pause) static void reset(){ - uninit(); + uninit(1); audio_fd=open(dsp, O_WRONLY); if(audio_fd < 0){ mp_msg(MSGT_AO,MSGL_ERR,"\nFatal error: *** CANNOT RE-OPEN / RESET AUDIO DEVICE *** %s\n", strerror(errno)); @@ -300,7 +306,7 @@ // stop playing, keep buffers (for pause) static void audio_pause() { - uninit(); + uninit(1); } // resume playing, after audio_pause() diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_pcm.c --- a/libao2/ao_pcm.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_pcm.c Tue Apr 06 17:55:36 2004 +0000 @@ -132,7 +132,7 @@ } // close audio device -static void uninit(){ +static void uninit(int immed){ if(ao_pcm_waveheader && fseek(fp, 0, SEEK_SET) == 0){ /* Write wave header */ wavhdr.file_length = wavhdr.data_length + sizeof(wavhdr) - 8; diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_plugin.c --- a/libao2/ao_plugin.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_plugin.c Tue Apr 06 17:55:36 2004 +0000 @@ -197,9 +197,9 @@ } // close audio device -static void uninit(){ +static void uninit(int immed){ int i=0; - driver()->uninit(); + driver()->uninit(immed); while(plugin(i)) plugin(i++)->uninit(); if(ao_plugin_local_data.plugins) diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_sdl.c --- a/libao2/ao_sdl.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_sdl.c Tue Apr 06 17:55:36 2004 +0000 @@ -265,7 +265,7 @@ } // close audio device -static void uninit(){ +static void uninit(int immed){ mp_msg(MSGT_AO,MSGL_V,"SDL: Audio Subsystem shutting down!\n"); while(buffered_bytes > 0) usec_sleep(50000); diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_sgi.c --- a/libao2/ao_sgi.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_sgi.c Tue Apr 06 17:55:36 2004 +0000 @@ -118,7 +118,7 @@ } // close audio device -static void uninit() { +static void uninit(int immed) { /* TODO: samplerate should be set back to the value before mplayer was started! */ diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_sun.c --- a/libao2/ao_sun.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_sun.c Tue Apr 06 17:55:36 2004 +0000 @@ -615,10 +615,11 @@ } // close audio device -static void uninit(){ +static void uninit(int immed){ #ifdef __svr4__ // throw away buffered data in the audio driver's STREAMS queue - ioctl(audio_fd, I_FLUSH, FLUSHW); + if (immed) + ioctl(audio_fd, I_FLUSH, FLUSHW); #endif close(audio_fd); } diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/ao_win32.c --- a/libao2/ao_win32.c Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/ao_win32.c Tue Apr 06 17:55:36 2004 +0000 @@ -167,7 +167,7 @@ } // close audio device -static void uninit() +static void uninit(int immed) { while (buffered_bytes > 0) usec_sleep(50000); diff -r 1226e0cbb04b -r 99798c3cdb93 libao2/audio_out.h --- a/libao2/audio_out.h Tue Apr 06 17:17:28 2004 +0000 +++ b/libao2/audio_out.h Tue Apr 06 17:55:36 2004 +0000 @@ -20,7 +20,7 @@ ao_info_t *info; int (*control)(int cmd,void *arg); int (*init)(int rate,int channels,int format,int flags); - void (*uninit)(); + void (*uninit)(int immed); void (*reset)(); int (*get_space)(); int (*play)(void* data,int len,int flags); diff -r 1226e0cbb04b -r 99798c3cdb93 mplayer.c --- a/mplayer.c Tue Apr 06 17:17:28 2004 +0000 +++ b/mplayer.c Tue Apr 06 17:55:36 2004 +0000 @@ -436,7 +436,7 @@ if(mask&INITED_AO){ inited_flags&=~INITED_AO; current_module="uninit_ao"; - audio_out->uninit(); audio_out=NULL; + audio_out->uninit(1); audio_out=NULL; } #ifdef HAVE_NEW_GUI