diff libao2/ao_alsa.c @ 34754:9d4720deada1

Use approach used by ao_oss to avoid audio desync when framestepping with ao_alsa and no hardware pause support. This fixes bug #2052.
author reimar
date Thu, 05 Apr 2012 22:29:37 +0000
parents 00ebd36202c6
children 6834d78ac904
line wrap: on
line diff
--- a/libao2/ao_alsa.c	Thu Apr 05 21:59:09 2012 +0000
+++ b/libao2/ao_alsa.c	Thu Apr 05 22:29:37 2012 +0000
@@ -65,6 +65,7 @@
 static size_t bytes_per_sample;
 
 static int alsa_can_pause;
+static int prepause_space;
 
 #define ALSA_DEVICE_SIZE 256
 
@@ -691,6 +692,7 @@
         }
           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 @@
            mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PcmPrepareError, snd_strerror(err));
             return;
         }
+        mp_ao_resume_refill(&audio_out_alsa, prepause_space);
     }
 }