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

James Zhang muliang.zhang at cs2c.com.cn
Thu Jun 17 09:40:16 CEST 2010


Clemens Ladisch wrote:
> > +    ret = snd_pcm_state(alsa_handler);
> 
> The status has just been read from the device, so you can use
> snd_pcm_status_get_state here.
> 
> > +    if(ret == SND_PCM_STATE_XRUN){  
> 
> There are spaces at the end of the line.  And please use the coding
> style of the surrounding code.
> 
> > +            mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_PcmPrepareError,
> > snd_strerror(ret));
> 
> Your mailer wraps long lines.
> 

Thanks Clemens Ladisch.
Less read from device should be more efficient.

And, I make the patch according to your proposal.

-- 
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, re-prepare it */
+    if(snd_pcm_status_get_state(status) == 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