From d91434756b1bd16d788d93e6b888c2d1a54f1968 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 8 Nov 2015 17:22:56 +0100 Subject: audio: move PTS setting out of the decoder Instead of requiring the decoder to set the PTS directly on the dec_audio context (including handling absence of PTS etc.), transfer the packet PTS to the decoded audio frame. Marginally simpler, and gives more control to the generic code. --- audio/decode/dec_audio.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'audio/decode/dec_audio.c') diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c index edf26951f7..623951eb22 100644 --- a/audio/decode/dec_audio.c +++ b/audio/decode/dec_audio.c @@ -170,14 +170,18 @@ static int decode_new_frame(struct dec_audio *da) if (ret < 0) return ret; - if (da->pts == MP_NOPTS_VALUE && da->header->missing_timestamps) - da->pts = 0; - if (da->waiting) { + if (da->waiting->pts != MP_NOPTS_VALUE) { + da->pts = da->waiting->pts; + da->pts_offset = 0; + } da->pts_offset += da->waiting->samples; da->decode_format = *da->waiting; mp_audio_set_null_data(&da->decode_format); } + + if (da->pts == MP_NOPTS_VALUE && da->header->missing_timestamps) + da->pts = 0; } return mp_audio_config_valid(da->waiting) ? AD_OK : AD_ERR; } -- cgit v1.2.3