From c8052da7decba4cbada6c240f2b21c09e385818c Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 16 Jan 2015 20:21:39 +0100 Subject: demux: return EOF when reading from unselected stream Normally the player doesn't read from unselected streams, so this should be a no-op. But unfortunately, some broken files can severely confuse the player, and assign the same demuxer stream to multiple front-end tracks. Then selecting one of the tracks would deselect the other track, with the end result that the demuxer stream for the selected track is deselected. This could happen with mkv files that use the same track number (which is of course broken). timeline_set_part() sets the tracks using demuxer_stream_by_demuxer_id(), using the broken non-unique IDs. The observable effect was that the player never quit, because demux_read_packet_async() told the caller to wait some longer for new packets. Fix by returning EOF instead. Fixes #1481. --- demux/demux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demux/demux.c b/demux/demux.c index 70b0c84f36..c099dbac19 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -576,7 +576,7 @@ int demux_read_packet_async(struct sh_stream *sh, struct demux_packet **out_pkt) if (ds->in->threading) { pthread_mutex_lock(&ds->in->lock); *out_pkt = dequeue_packet(ds); - r = *out_pkt ? 1 : (ds->eof ? -1 : 0); + r = *out_pkt ? 1 : ((ds->eof || !ds->selected) ? -1 : 0); ds->active = ds->selected; // enable readahead ds->in->eof = false; // force retry pthread_cond_signal(&ds->in->wakeup); // possibly read more -- cgit v1.2.3