diff --git a/core/mplayer.c b/core/mplayer.c index 684991127b..52aa34058c 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -443,8 +443,12 @@ static void preselect_demux_streams(struct MPContext *mpctx) { // Disable all streams, just to be sure no unwanted streams are selected. for (int n = 0; n < mpctx->num_sources; n++) { - for (int type = 0; type < STREAM_TYPE_COUNT; type++) - demuxer_switch_track(mpctx->sources[n], type, NULL); + for (int type = 0; type < STREAM_TYPE_COUNT; type++) { + struct track *track = mpctx->current_track[type]; + if (!(track && track->demuxer == mpctx->sources[n] && + demuxer_stream_is_selected(track->demuxer, track->stream))) + demuxer_switch_track(mpctx->sources[n], type, NULL); + } } for (int type = 0; type < STREAM_TYPE_COUNT; type++) { diff --git a/demux/demux.c b/demux/demux.c index 856951f905..3e27b43f93 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -1214,6 +1214,10 @@ void demuxer_switch_track(struct demuxer *demuxer, enum stream_type type, { assert(!stream || stream->type == type); + // don't flush buffers if stream is already selected + if (stream && demuxer_stream_is_selected(demuxer, stream)) + return; + int old_id = demuxer->ds[type]->id; // legacy