summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorRudolf Polzer <divverent@xonotic.org>2013-11-16 18:50:07 +0100
committerRudolf Polzer <divverent@xonotic.org>2013-11-16 18:50:07 +0100
commit6391453fabaf2f1da0a33ae6b929def361e96ee6 (patch)
treec2e245a4d6c24c026bf82d248417cca99a25714f /audio
parent0d4628a7fd2bb2c0e7b6284d9dd643abb216c16e (diff)
downloadmpv-6391453fabaf2f1da0a33ae6b929def361e96ee6.tar.bz2
mpv-6391453fabaf2f1da0a33ae6b929def361e96ee6.tar.xz
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.
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_lavc.c17
1 files changed, 10 insertions, 7 deletions
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);
}