[MPlayer-dev-eng] Patch: Low latency audio enhancements

Ed Wildgoose lists at wildgooses.com
Mon Aug 23 18:30:56 CEST 2004


Hi folks,

What do I need to do to try and get this code included please?  It's a 
pretty trivial patch, but it allows mplayer to work with audio cards 
that only have a two period sound buffer.

If there is a problem can you please let me know so that I can rework 
it, but otherwise I would be grateful if I could get this included 
upstream rather than having to patch my local copy.

Thanks

Ed W


Ed Wildgoose wrote:

> The following is a patch which allows mplayer to work with pro sound 
> card like my RME 9632.  These cards only allow two periods in the 
> sound buffer, and this leads to very short audio latency.  This is 
> easily fixed with the patch below which just removes the artificial 
> limit stopping mplayer spinning it's loops more quickly.  (This is 
> less invasive than my previous patch)
>
> There is also a fix for what looks like a slight bugette in the the 
> alsa output code where it seems to always overwrite the defaults for 
> buffer size that are set at the top of the module.  This doesn't look 
> deliberate.
>
> Please check and apply to CVS.
>
> ..next stop: find out why mplayer won't work with the alsa-jack 
> plugin... Anyone tried this? (Yeah I know there is a partial native 
> plugin now).
>
> Thanks
>
> Ed Wildgoose
>
>------------------------------------------------------------------------
>
>--- mplayer.c.orig	2004-07-14 10:25:47.000000000 +0100
>+++ mplayer.c	2004-08-20 17:16:12.848643481 +0100
>@@ -2180,12 +2183,11 @@
>           time_frame=delay-sh_audio->delay;
> 
> 	// delay = amount of audio buffered in soundcard/driver
>-	if(delay>0.25) delay=0.25; else
>-	if(delay<0.10) delay=0.10;
>-	if(time_frame>delay*0.6){
>+	if(delay>0.25) delay=0.25;
>+	if(time_frame>delay*0.25){
> 	    // sleep time too big - may cause audio drops (buffer underrun)
> 	    frame_time_remaining=1;
>-	    time_frame=delay*0.5;
>+	    time_frame=delay*0.25;
> 	}
> 
>       } else {
>@@ -2241,7 +2243,11 @@
> 
> }
> 
>-//if(!frame_time_remaining){	// should we display the frame now?
>+// If frame_time_remaining is non_zero then we are worried about audio underflow
>+// and haven't paused long enough to display the frame yet. 
>+// Go back and supply more audio
>+if (frame_time_remaining) continue;
>+
> 
> //====================== FLIP PAGE (VIDEO BLT): =========================
> 
>--- ../../../mplayer-1.0_pre5-r2.orig/work/MPlayer-1.0pre5/libao2/ao_alsa.c	2004-07-14 16:46:33.000000000 +0100
>+++ libao2/ao_alsa.c	2004-08-05 07:28:18.000000000 +0100
>@@ -470,7 +467,7 @@
>     }
> 
>     //sets buff/chunksize if its set manually
>-    if (ao_data.buffersize) {
>+    if (ao_data.buffersize > 0) {
>       switch (ao_data.buffersize)
> 	{
> 	case 1:
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>MPlayer-dev-eng mailing list
>MPlayer-dev-eng at mplayerhq.hu
>http://mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
>  
>




More information about the MPlayer-dev-eng mailing list