player: do initial seek for external tracks only once

Normally, there can be only one demuxer stream active for each demuxer
of an external file, but this assumption will be broken for multiple
subtitles support.
This commit is contained in:
wm4 2013-12-24 11:30:22 +01:00
parent 1d86134ec1
commit 2b87415f6f
1 changed files with 12 additions and 2 deletions

View File

@ -274,13 +274,23 @@ void reselect_demux_streams(struct MPContext *mpctx)
}
// External demuxers might need a seek to the current playback position.
// Also return the stream for convenience.
struct sh_stream *init_demux_stream(struct MPContext *mpctx, struct track *track)
static void external_track_seek(struct MPContext *mpctx, struct track *track)
{
if (track && track->demuxer && track->selected && track->is_external) {
for (int t = 0; t < mpctx->num_tracks; t++) {
struct track *other = mpctx->tracks[t];
if (other->demuxer == track->demuxer &&
demuxer_stream_is_selected(other->demuxer, other->stream))
return;
}
double pts = get_main_demux_pts(mpctx);
demux_seek(track->demuxer, pts, SEEK_ABSOLUTE);
}
}
struct sh_stream *init_demux_stream(struct MPContext *mpctx, struct track *track)
{
external_track_seek(mpctx, track);
return track ? track->stream : NULL;
}