[MPlayer-dev-eng] [PATCH] re-prepare sound card when XRUN happens

James Zhang muliang.zhang at cs2c.com.cn
Sun Jun 13 12:12:39 CEST 2010


I work under Fedora12 recently from Fedora11. Each one of them have the
same problem which the Mplayer often lost audio. 

So, if the sound card can be re-prepare when it got XRUN, the Mplayer
will be working well.

Here come the patch!

-- 
James Zhang
Fedora/Linux
http://www.cs2c.com.cn/

Index: libao2/ao_alsa.c
===================================================================
--- libao2/ao_alsa.c    (revision 31373)
+++ libao2/ao_alsa.c    (working copy)
@@ -814,6 +814,15 @@
        return 0;
     }

+    /* if the sound card XRUN, reprepare it */
+    ret = snd_pcm_state(alsa_handler);
+    if(ret == SND_PCM_STATE_XRUN){  
+       if((ret = snd_pcm_prepare(alsa_handler)) < 0){
+            mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PcmPrepareError,
snd_strerror(ret));
+            return 0;
+       }
+    }
+
     ret = snd_pcm_status_get_avail(status) * bytes_per_sample;
     if (ret > ao_data.buffersize)  // Buffer underrun?
        ret = ao_data.buffersize;





More information about the MPlayer-dev-eng mailing list