summaryrefslogtreecommitdiffstats
path: root/player/loadfile.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-01-17 07:07:15 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-01-18 01:25:53 -0800
commit082029f8503f68c903ec6eda4bf4e37cc0065760 (patch)
tree778708f90951a8a50f526a163d360925c381c6a0 /player/loadfile.c
parentca67928d7ab176c080a7e99f0d4ce0c5d1070844 (diff)
downloadmpv-082029f8503f68c903ec6eda4bf4e37cc0065760.tar.bz2
mpv-082029f8503f68c903ec6eda4bf4e37cc0065760.tar.xz
player: redo hack for video keyframe seeks with external audio
If you play a video with an external audio track, and do backwards keyframe seeks, then audio can be missing. This is because a backwards seek can end up way before the seek target (this is just how this seek mode works). The audio file will be seeked at the correct seek target (since audio usually has a much higher seek granularity), which results in silence being played until the video reaches the originally intended seek target. There was a hack in audio.c to deal with this. Replace it with a different hack. The new hack probably works about as well as the old hack, except it doesn't add weird crap to the audio resync path (which is some of the worst code here, so this is some nice preparation for rewriting it). As a more practical advantage, it doesn't discard the audio demuxer packet cache. The old code did, which probably ruined seeking in youtube DASH streams. A non-hacky solution would be handling external files in the demuxer layer. Then chaining the seeks would be pretty easy. But we're pretty far from that, because it would either require intrusive changes to the demuxer layer, or wouldn't be flexible enough to load/unload external files at runtime. Maybe later.
Diffstat (limited to 'player/loadfile.c')
-rw-r--r--player/loadfile.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index edba9caa1b..4a886ff156 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -227,6 +227,8 @@ void reselect_demux_stream(struct MPContext *mpctx, struct track *track)
if (pts != MP_NOPTS_VALUE)
pts += get_track_seek_offset(mpctx, track);
demuxer_select_track(track->demuxer, track->stream, pts, track->selected);
+ if (track == mpctx->seek_slave)
+ mpctx->seek_slave = NULL;
}
// Called from the demuxer thread if a new packet is available.
@@ -548,6 +550,9 @@ bool mp_remove_track(struct MPContext *mpctx, struct track *track)
sub_destroy(track->d_sub);
+ if (mpctx->seek_slave == track)
+ mpctx->seek_slave = NULL;
+
int index = 0;
while (index < mpctx->num_tracks && mpctx->tracks[index] != track)
index++;