diff options
author | Rudolf Polzer <divVerent@xonotic.org> | 2014-07-16 15:08:06 +0200 |
---|---|---|
committer | Rudolf Polzer <divVerent@xonotic.org> | 2014-07-16 16:18:34 +0200 |
commit | 073b2becfe009262356a56e9369f34d842a43b4c (patch) | |
tree | 8abe436fd23ccb05c17e4d5bd25e3f3c8d704587 /audio | |
parent | e257cbfdbb9fabaa118ef826f9bf37caa27e9fd5 (diff) | |
download | mpv-073b2becfe009262356a56e9369f34d842a43b4c.tar.bz2 mpv-073b2becfe009262356a56e9369f34d842a43b4c.tar.xz |
ao_lavc: Fix design of audio pts handling.
There was confusion about what should go into audio pts calculation and
what not (mainly due to the audio push thread). This has been fixed by
using the playing - not written - audio pts (which properly takes into
account the ao's buffer), and incrementing the samples count only by the
amount of samples actually taken from the buffer (unfortunately this
now forces us to keep the lock too long for my taste).
Diffstat (limited to 'audio')
-rw-r--r-- | audio/out/ao_lavc.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c index bdd3cdac57..72e98655c1 100644 --- a/audio/out/ao_lavc.c +++ b/audio/out/ao_lavc.c @@ -343,7 +343,6 @@ static int play(struct ao *ao, void **data, int samples, int flags) double pts = ectx->last_audio_in_pts; pts += ectx->samples_since_last_pts / (double)ao->samplerate; - ectx->samples_since_last_pts += samples; size_t num_planes = af_fmt_is_planar(ao->format) ? ao->channels.num : 1; @@ -451,6 +450,10 @@ static int play(struct ao *ao, void **data, int samples, int flags) } talloc_free(tempdata); + + int taken = FFMIN(bufpos, orig_samples); + ectx->samples_since_last_pts += taken; + pthread_mutex_unlock(&ectx->lock); if (flags & AOPLAY_FINAL_CHUNK) { @@ -463,7 +466,7 @@ static int play(struct ao *ao, void **data, int samples, int flags) } } - return FFMIN(bufpos, orig_samples); + return taken; } static void drain(struct ao *ao) |