From 862d7d8a1a852fc6bb6dd13ca5db90f83b676579 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 29 Jul 2014 17:55:28 +0200 Subject: player: fix desync when seeking and switching external tracks If you for example use --audio-file, disable the external track, seek, and enable the external track again, the playback position of the external file was off, and you would get major A/V desync. This was actually supposed to work, but broke at some time ago (probably commit 2b87415f). It didn't work, because it attempted to seek the stream if it was already selected, which was always true due to reselect_demux_streams() being called before that. Fix by putting the initial selection and the seek together. --- player/misc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'player/misc.c') diff --git a/player/misc.c b/player/misc.c index e50ea6b143..3ae4a8ab9a 100644 --- a/player/misc.c +++ b/player/misc.c @@ -100,8 +100,9 @@ double get_main_demux_pts(struct MPContext *mpctx) double main_new_pos = MP_NOPTS_VALUE; if (mpctx->demuxer) { for (int n = 0; n < mpctx->demuxer->num_streams; n++) { - if (main_new_pos == MP_NOPTS_VALUE) - main_new_pos = demux_get_next_pts(mpctx->demuxer->streams[n]); + struct sh_stream *stream = mpctx->demuxer->streams[n]; + if (main_new_pos == MP_NOPTS_VALUE && stream->type != STREAM_SUB) + main_new_pos = demux_get_next_pts(stream); } } return main_new_pos; -- cgit v1.2.3