1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-19 13:21:13 +00:00

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.
This commit is contained in:
Rudolf Polzer 2013-11-16 18:50:07 +01:00
parent 0d4628a7fd
commit 6391453fab

View File

@ -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);
}