[MPlayer-dev-eng] [PATCH] smooth playback with NAS and all audio drivers

Arpi arpi at thot.banki.hu
Tue Sep 24 00:31:02 CEST 2002


Hi,

> >   o A new variable "delay_avg" stores either the last delay measurement
> >     from audio_out->get_delay(), or a corrected one calculated by my
> 
> the problem is here.
> you should not store the result of audio_out->get_delay(), it's variable in

rethinking your problem...

so, you have (and several ppl with broken sounddcard drivers) jerky values
from the ao->get_delay().

my first thought was that just average this value, like this:

float new_get_delay(){
   float delay=audio_out->get-delay();
   if(!avgdelay) return delay; // old way
   if(avg_delay==0)
	avg_delay=delay;	// for teh initial value...
   else
	avg_delay = avg_delay*0.99 + delay*0.01;
   return avg_delay;
}

your code does something like the above, in a less cleaner way and the
problems mentioned in my prev. mail.

this thing has a big problem: the filling of the audio buffer is not linear
- it is not done by fixed size chunks, at least not for all codecs.
sh_audio->timer is updated when sending data to the audio driver, while your
delay is averaged and will lost this info.

so, the best thing to dom to solve the real problem, is emulating a perfect
soundcard driver, while syncronizing it to the real one.
ao_null.c does it - it implements get_delay() using gettimeofday().

you should implement such code, calculating virtual audio position based on
samplerate & real time clock, altered by play() amounts, and using it for
get_delay(). it must be syncronized to the real driver, for example in teh
fake get_delay() impl you can call the real get_delay(), calc & average teh
difference between get-delay values, and correct the virtual timer by it.
it should provide better result.


A'rpi / Astral & ESP-team

--
Developer of MPlayer, the Movie Player for Linux - http://www.MPlayerHQ.hu



More information about the MPlayer-dev-eng mailing list