summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-04 23:35:11 +0200
committerAlessandro Ghedini <alessandro@ghedini.me>2014-09-05 12:01:26 +0200
commit1871f2a703d5863d9839427a6c9de9d0cf281846 (patch)
treec12ecea7e5c6750c6d4c647809b0c24e70c1b4c9
parent4a8e5ea26922f57287c04e3c548c574d7e334f44 (diff)
downloadmpv-1871f2a703d5863d9839427a6c9de9d0cf281846.tar.bz2
mpv-1871f2a703d5863d9839427a6c9de9d0cf281846.tar.xz
audio: fix obscure audio resync failure with timelines
Somehow, there was a larger misunderstanding in the code: ao_buffer does not need to be preserved over audio reinit for proper support of gapless audio. The actual AO internal buffer takes care of this. In fact, preserving ao_buffer just breaks audio resync. In the ordered chapter case, end_pts is used, which means not all audio data in the buffer is played, thus some data is left over when audio decoding resumes on the next segment. This triggers some code that aborts resync if there's "audio decoded" (ao_buffer contains something), but no PTS is known (nothing was actually decoded yet). Simplify, and always bind the output buffer to the decoder. CC: @mpv-player/stable (maybe)
-rw-r--r--player/audio.c6
-rw-r--r--player/loadfile.c3
2 files changed, 6 insertions, 3 deletions
diff --git a/player/audio.c b/player/audio.c
index 29fe4b3eaa..200d04d927 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -96,6 +96,8 @@ void reset_audio_state(struct MPContext *mpctx)
{
if (mpctx->d_audio)
audio_reset_decoding(mpctx->d_audio);
+ if (mpctx->ao_buffer)
+ mp_audio_buffer_clear(mpctx->ao_buffer);
mpctx->audio_status = mpctx->d_audio ? STATUS_SYNCING : STATUS_EOF;
}
@@ -120,15 +122,13 @@ void reinit_audio_chain(struct MPContext *mpctx)
mpctx->d_audio->opts = opts;
mpctx->d_audio->header = sh;
mpctx->d_audio->replaygain_data = sh->audio->replaygain_data;
+ mpctx->ao_buffer = mp_audio_buffer_create(NULL);
if (!audio_init_best_codec(mpctx->d_audio, opts->audio_decoders))
goto init_error;
reset_audio_state(mpctx);
}
assert(mpctx->d_audio);
- if (!mpctx->ao_buffer)
- mpctx->ao_buffer = mp_audio_buffer_create(mpctx);
-
struct mp_audio in_format;
mp_audio_buffer_get_format(mpctx->d_audio->decode_buffer, &in_format);
diff --git a/player/loadfile.c b/player/loadfile.c
index 119362bd3b..6431feedb4 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -86,8 +86,11 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask)
mixer_uninit_audio(mpctx->mixer);
audio_uninit(mpctx->d_audio);
mpctx->d_audio = NULL;
+ talloc_free(mpctx->ao_buffer);
mpctx->audio_status = STATUS_EOF;
reselect_demux_streams(mpctx);
+ if (mpctx->ao_buffer)
+ mp_audio_buffer_clear(mpctx->ao_buffer);
}
if (mask & INITIALIZED_SUB) {