OSDN Git Service

ffplay: more precise audio clock based on current time
authorMarton Balint <cus@passwd.hu>
Sun, 14 Aug 2011 18:21:25 +0000 (20:21 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 15 Aug 2011 01:49:07 +0000 (03:49 +0200)
commit10b7b4a6a1585a7c46487b00594798cdd92eed37
treef076ab577eb3db06ef0acfff2e789cb730231f61
parentabf6b0d1ea231cc52008e9eaa1d2902442e1cbba
ffplay: more precise audio clock based on current time

Since SDL has no audio buffer fullness info, one can get a much precise audio
clock based on the last time of the audio callback and the elapsed time since.

To achieve this I introduced the audio_current_pts and audio_current_pts_drift
variables (similar to video_current_pts and video_current_pts_drift) and
calculate them in the end of the audio callback, when VideoState->audio_clock
is already updated. The reference time I use is from the start of the audio
callback, because this way the amount of time used for audio decoding is not
interfereing with calculation.

I also replaced the audio_write_get_buf_size function with a calculated
variable because when the audio frame decoding is in progress audio_buf_size
and audio_buf_index are not stable, so using them from other threads are not a
good idea.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
ffplay.c