diff options
author | wm4 <wm4@nowhere> | 2014-07-19 12:19:12 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-07-19 12:27:21 +0200 |
commit | 24efaa3ad7a2a23644a1872c6b9535342bc71df1 (patch) | |
tree | b97347bba6120d24c48721d34a3b637ceaae0ca9 /demux | |
parent | c76958d20c69fa83af7ae433f667b40d2734e504 (diff) | |
download | mpv-24efaa3ad7a2a23644a1872c6b9535342bc71df1.tar.bz2 mpv-24efaa3ad7a2a23644a1872c6b9535342bc71df1.tar.xz |
demux: fix a corner case
demux_read_any_packet() attempts to call read_packet(), but if no stream
is active, it can decide not to read anything. The function will return
NULL, which implies EOF. Fix this by explicitly
setting demux_stream->active if needed.
Also use dequeue_packet() instead of demux_read_packet(), because it's
cleaner. (Shouldn't change behavior.)
Possibly fixes #938.
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/demux/demux.c b/demux/demux.c index c7d27f7466..d5be9446e7 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -536,8 +536,10 @@ struct demux_packet *demux_read_any_packet(struct demuxer *demuxer) for (int retry = 0; retry < 2; retry++) { for (int n = 0; n < demuxer->num_streams; n++) { struct sh_stream *sh = demuxer->streams[n]; - if (demux_has_packet(sh)) - return demux_read_packet(sh); + sh->ds->active = sh->ds->selected; // force read_packet() to read + struct demux_packet *pkt = dequeue_packet(sh->ds); + if (pkt) + return pkt; } // retry after calling this pthread_mutex_lock(&demuxer->in->lock); |