From 6bfbca9912c2d86d6b28dc5000bb878fb5fbe849 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 29 May 2013 14:54:51 +0200 Subject: core: avoid deselecting and reselecting stream needlessly The core deselected all streams on initialization, and then selected the streams it actually wanted. This was no problem for demux_mkv/demux_lavf, but old demuxers (like demux_asf) could lose some packets. The problem is that these demuxers can buffer some data on initialization, which then is flushed on track switching. Fix this by explicitly avoiding deselecting a wanted stream. --- core/mplayer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'core/mplayer.c') 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++) { -- cgit v1.2.3