[MPlayer-dev-eng] [patch] A-V sync tuneup, round 2

Arpi arpi at thot.banki.hu
Wed Nov 7 00:53:04 CET 2001


Hi,

>  this patch do the following things:
>   - shows if latency between two frames is larger than frametime+20% or
> 	is smaller than frametime-20% (last two number in brackets)
>   - implements soft-sleep for much precise sleep timing. it's eats up
> 	+~10% of CPU time, but _just_ the idle CPU time
>   - do smooth A-V sync, doesn't allows 'unexpected' corrections over +-10%
> 	of frametime between two frames.  it's maybe sounds scary, but 10%
> 	is enough for A-V sync

all this should be optional until we see it doesn't break anything and works
better on all systems.

> ps# Arpi, it contains some bugfixes and improvements since previous
> 	version, IMHO it's much cleaner and stable
previous was too messy to even read, not talking about apply.
this one is a bit better, but you should add more comments or do something,
as it's hard to understand what is why.

btw, as reaidng your patch, i've found a bug in my sleeping code:

          if(time_frame<=0.020)
             usec_sleep(0); // sleeps 1 clock tick (10ms)!
          else
             usec_sleep(1000000*(time_frame-0.002));

it's simply bad. it should be  usec_sleep(1000000*(time_frame-0.020));
i doubt i was wrong, maybe when it was converted usleep->usec_sleep.
but i'll check cvslog :)

btw, comment for your note: it is not intel clock limitation or so, it's
linux limitation, especially kernel configuration. value of HZ defaults to
100, it means 100 task switches per second. as usleep() releases mplayer
process and allow scheduler to call something else (idle?) it will took
n*10ms to get the cpu back. note, that on SMP systems it isn't true.
note2: HZ can be set to 1000 at kernel compile time.
note3: RPC timer should be used for timing based on 8khz clock.
note4: RPC is usually disabled for 'average' users. and HZ=100.


A'rpi / Astral & ESP-team

--
mailto:arpi at thot.banki.hu
http://esp-team.scene.hu



More information about the MPlayer-dev-eng mailing list