summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-10 23:45:57 +0100
committerwm4 <wm4@nowhere>2014-03-10 23:47:31 +0100
commitd7dfd2cca37598ff86de7b7db5cba69b55acee1f (patch)
treeb182dcbccc752f7f8f1863e8e0d8f1306533a254 /player
parentccce58d6d63538911fa7bdd216a32e8444ea36b8 (diff)
downloadmpv-d7dfd2cca37598ff86de7b7db5cba69b55acee1f.tar.bz2
mpv-d7dfd2cca37598ff86de7b7db5cba69b55acee1f.tar.xz
Revert "player: simplify audio reset when seeking"
This reverts commit 75dd3ec2106701cb865f52966de66c51cb6f9204. This broke seeking with ordered chapters in some situations. While the reverted commit was perfectly fine for playback of normal files, it overlooked that in the ordered chapters case switching segments actually reinitialized the audio chain completely, including the decoder. And decoders still read packets on initialization. We can restore the original commit as soon as decoders stop doing this.
Diffstat (limited to 'player')
-rw-r--r--player/playloop.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/player/playloop.c b/player/playloop.c
index c5dd55e396..e2f6a14de8 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -175,14 +175,14 @@ void add_step_frame(struct MPContext *mpctx, int dir)
}
}
-static void seek_reset(struct MPContext *mpctx, bool reset_ao)
+static void seek_reset(struct MPContext *mpctx, bool reset_ao, bool reset_ac)
{
if (mpctx->d_video) {
video_reset_decoding(mpctx->d_video);
vo_seek_reset(mpctx->video_out);
}
- if (mpctx->d_audio) {
+ if (mpctx->d_audio && reset_ac) {
audio_reset_decoding(mpctx->d_audio);
if (reset_ao)
clear_audio_output_buffers(mpctx);
@@ -213,9 +213,6 @@ static void seek_reset(struct MPContext *mpctx, bool reset_ao)
}
// return -1 if seek failed (non-seekable stream?), 0 otherwise
-// timeline_fallthrough: true if used to explicitly switch timeline - in this
-// case, don't drop buffered AO audio data, so that
-// timeline segment transition is seemless
static int mp_seek(MPContext *mpctx, struct seek_params seek,
bool timeline_fallthrough)
{
@@ -262,6 +259,9 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek,
seek.amount += get_current_time(mpctx);
}
+ /* At least the liba52 decoder wants to read from the input stream
+ * during initialization, so reinit must be done after the demux_seek()
+ * call that clears possible stream EOF. */
bool need_reset = false;
double demuxer_amount = seek.amount;
if (mpctx->timeline) {
@@ -280,7 +280,6 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek,
}
if (need_reset) {
reinit_video_chain(mpctx);
- reinit_audio_chain(mpctx);
reinit_subs(mpctx, 0);
reinit_subs(mpctx, 1);
}
@@ -305,8 +304,10 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek,
demuxer_amount -= hr_seek_offset;
int seekresult = demux_seek(mpctx->demuxer, demuxer_amount, demuxer_style);
if (seekresult == 0) {
- if (need_reset)
- seek_reset(mpctx, !timeline_fallthrough);
+ if (need_reset) {
+ reinit_audio_chain(mpctx);
+ seek_reset(mpctx, !timeline_fallthrough, false);
+ }
return -1;
}
@@ -324,7 +325,11 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek,
}
}
- seek_reset(mpctx, !timeline_fallthrough);
+ if (need_reset)
+ reinit_audio_chain(mpctx);
+ /* If we just reinitialized audio it doesn't need to be reset,
+ * and resetting could lose audio some decoders produce during init. */
+ seek_reset(mpctx, !timeline_fallthrough, !need_reset);
if (timeline_fallthrough) {
// Important if video reinit happens.
@@ -589,7 +594,7 @@ bool mp_seek_chapter(struct MPContext *mpctx, int chapter)
if (res >= 0) {
if (pts == -1) {
// for DVD/BD - seek happened via stream layer
- seek_reset(mpctx, true);
+ seek_reset(mpctx, true, true);
mpctx->seek = (struct seek_params){0};
return true;
}