From 6391453fabaf2f1da0a33ae6b929def361e96ee6 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 16 Nov 2013 18:50:07 +0100 Subject: ao_lavc: write the final audio chunks from uninit() These must be written even if there was no "final frame", e.g. due to the player being exited with "q". Although the issue is mostly of theoretical nature, as most audio codecs don't need the final encoding calls with NULL data. Maybe will be more relevant in the future. --- audio/out/ao_lavc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'audio') diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c index cb8e24d4aa..974d9c5faa 100644 --- a/audio/out/ao_lavc.c +++ b/audio/out/ao_lavc.c @@ -164,8 +164,10 @@ static int init(struct ao *ao) } // close audio device +static int encode(struct ao *ao, double apts, void **data); static void uninit(struct ao *ao, bool cut_audio) { + struct priv *ac = ao->priv; struct encode_lavc_context *ectx = ao->encode_lavc_ctx; if (!encode_lavc_start(ectx)) { @@ -173,6 +175,14 @@ static void uninit(struct ao *ao, bool cut_audio) return; } + if (ac->buffer) { + double outpts = ac->expected_next_pts; + if (!ectx->options->rawts && ectx->options->copyts) + outpts += ectx->discontinuity_pts_offset; + outpts += encode_lavc_getoffset(ectx, ac->stream); + while (encode(ao, outpts, NULL) > 0) ; + } + ao->priv = NULL; } @@ -332,13 +342,6 @@ static int play(struct ao *ao, void **data, int samples, int flags) talloc_free(tmp); } - outpts = ac->expected_next_pts; - if (!ectx->options->rawts && ectx->options->copyts) - outpts += ectx->discontinuity_pts_offset; - outpts += encode_lavc_getoffset(ectx, ac->stream); - - while (encode(ao, outpts, NULL) > 0) ; - return FFMIN(written, samples); } -- cgit v1.2.3