mirror of
https://github.com/mpv-player/mpv
synced 2025-02-18 22:06:59 +00:00
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:
parent
c76958d20c
commit
24efaa3ad7
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user