summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_lavc.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-07 15:23:03 +0100
committerwm4 <wm4@nowhere>2014-03-07 15:23:03 +0100
commit74b7001500c0901b095986fafe7dca3e5c23c7f2 (patch)
treedaee66eb3955ff8bff726b916171a81a4bf0e451 /audio/out/ao_lavc.c
parent4579d9ca58ee50dba6cb45e4f27e85f2ebbb8269 (diff)
downloadmpv-74b7001500c0901b095986fafe7dca3e5c23c7f2.tar.bz2
mpv-74b7001500c0901b095986fafe7dca3e5c23c7f2.tar.xz
encode: don't access ao->pts
This field will be moved out of the ao struct. The encoding code was basically using an invalid way of accessing this field. Since the AO will be moved into its own thread too and will do its own buffering, the AO and the playback core might not even agree which sample a PTS timestamp belongs to. Add some extrapolation code to handle this case.
Diffstat (limited to 'audio/out/ao_lavc.c')
-rw-r--r--audio/out/ao_lavc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c
index 359fbae0fa..9a2df7be22 100644
--- a/audio/out/ao_lavc.c
+++ b/audio/out/ao_lavc.c
@@ -320,7 +320,6 @@ static int play(struct ao *ao, void **data, int samples, int flags)
struct encode_lavc_context *ectx = ao->encode_lavc_ctx;
int bufpos = 0;
double nextpts;
- double pts = ao->pts;
double outpts;
if (!encode_lavc_start(ectx)) {
@@ -328,6 +327,10 @@ static int play(struct ao *ao, void **data, int samples, int flags)
return 0;
}
+ double pts = ectx->last_audio_in_pts;
+ pts += ectx->samples_since_last_pts / ao->samplerate;
+ ectx->samples_since_last_pts += samples;
+
size_t num_planes = af_fmt_is_planar(ao->format) ? ao->channels.num : 1;
if (flags & AOPLAY_FINAL_CHUNK) {