changeset 12145:99798c3cdb93

uninit immed flag
author alex
date Tue, 06 Apr 2004 17:55:36 +0000
parents 1226e0cbb04b
children aaea699d0a67
files libao2/ao_alsa1x.c libao2/ao_alsa5.c libao2/ao_alsa9.c libao2/ao_arts.c libao2/ao_dxr2.c libao2/ao_esd.c libao2/ao_macosx.c libao2/ao_mpegpes.c libao2/ao_nas.c libao2/ao_null.c libao2/ao_oss.c libao2/ao_pcm.c libao2/ao_plugin.c libao2/ao_sdl.c libao2/ao_sgi.c libao2/ao_sun.c libao2/ao_win32.c libao2/audio_out.h mplayer.c
diffstat 19 files changed, 31 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- 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) {
--- 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;
 
--- 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) {
--- 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();
--- 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){
 
 }
 
--- 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);
--- 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;
--- 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){
 
 }
 
--- 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");
 
--- 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){
 
 }
 
--- 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()
--- 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;
--- 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)
--- 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);
--- 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! */
 
--- 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);
 }
--- 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);
--- 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);
--- 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