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. --- demux/demux.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'demux/demux.c') 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 -- cgit v1.2.3