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.
This commit is contained in:
wm4 2014-07-19 12:19:12 +02:00
parent c76958d20c
commit 24efaa3ad7
1 changed files with 4 additions and 2 deletions

View File

@ -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);