[MPlayer-cvslog] r34842 - in trunk/libao2: ao_alsa.c ao_oss.c audio_out.c audio_out_internal.h

reimar subversion at mplayerhq.hu
Fri Apr 6 00:29:37 CEST 2012


Author: reimar
Date: Fri Apr  6 00:29:37 2012
New Revision: 34842

Log:
Use approach used by ao_oss to avoid audio desync
when framestepping with ao_alsa and no hardware pause
support.
This fixes bug #2052.

Modified:
   trunk/libao2/ao_alsa.c
   trunk/libao2/ao_oss.c
   trunk/libao2/audio_out.c
   trunk/libao2/audio_out_internal.h

Modified: trunk/libao2/ao_alsa.c
==============================================================================
--- trunk/libao2/ao_alsa.c	Thu Apr  5 23:59:09 2012	(r34841)
+++ trunk/libao2/ao_alsa.c	Fri Apr  6 00:29:37 2012	(r34842)
@@ -65,6 +65,7 @@ static snd_pcm_sw_params_t *alsa_swparam
 static size_t bytes_per_sample;
 
 static int alsa_can_pause;
+static int prepause_space;
 
 #define ALSA_DEVICE_SIZE 256
 
@@ -691,6 +692,7 @@ static void audio_pause(void)
         }
           mp_msg(MSGT_AO,MSGL_V,"alsa-pause: pause supported by hardware\n");
     } else {
+        prepause_space = get_space();
         if ((err = snd_pcm_drop(alsa_handler)) < 0)
         {
             mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PcmDropError, snd_strerror(err));
@@ -720,6 +722,7 @@ static void audio_resume(void)
            mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PcmPrepareError, snd_strerror(err));
             return;
         }
+        mp_ao_resume_refill(&audio_out_alsa, prepause_space);
     }
 }
 

Modified: trunk/libao2/ao_oss.c
==============================================================================
--- trunk/libao2/ao_oss.c	Thu Apr  5 23:59:09 2012	(r34841)
+++ trunk/libao2/ao_oss.c	Fri Apr  6 00:29:37 2012	(r34842)
@@ -473,14 +473,8 @@ static void audio_pause(void)
 // resume playing, after audio_pause()
 static void audio_resume(void)
 {
-    int fillcnt;
     reset();
-    fillcnt = get_space() - prepause_space;
-    if (fillcnt > 0 && !(ao_data.format & AF_FORMAT_SPECIAL_MASK)) {
-      void *silence = calloc(fillcnt, 1);
-      play(silence, fillcnt, 0);
-      free(silence);
-    }
+    mp_ao_resume_refill(&audio_out_oss, prepause_space);
 }
 
 

Modified: trunk/libao2/audio_out.c
==============================================================================
--- trunk/libao2/audio_out.c	Thu Apr  5 23:59:09 2012	(r34841)
+++ trunk/libao2/audio_out.c	Fri Apr  6 00:29:37 2012	(r34842)
@@ -189,3 +189,13 @@ const ao_functions_t* init_best_audio_ou
     }
     return NULL;
 }
+
+void mp_ao_resume_refill(const ao_functions_t *ao, int prepause_space)
+{
+    int fillcnt = ao->get_space() - prepause_space;
+    if (fillcnt > 0 && !(ao_data.format & AF_FORMAT_SPECIAL_MASK)) {
+      void *silence = calloc(fillcnt, 1);
+      ao->play(silence, fillcnt, 0);
+      free(silence);
+    }
+}

Modified: trunk/libao2/audio_out_internal.h
==============================================================================
--- trunk/libao2/audio_out_internal.h	Thu Apr  5 23:59:09 2012	(r34841)
+++ trunk/libao2/audio_out_internal.h	Fri Apr  6 00:29:37 2012	(r34842)
@@ -45,4 +45,6 @@ static void audio_resume(void);
 	audio_resume\
 };
 
+void mp_ao_resume_refill(const ao_functions_t *ao, int prepause_space);
+
 #endif /* MPLAYER_AUDIO_OUT_INTERNAL_H */


More information about the MPlayer-cvslog mailing list