mirror of
https://github.com/mpv-player/mpv
synced 2025-03-19 18:05:21 +00:00
demux: reset EOF flag differently
This should be almost equivalent, but is slightly better because the EOF flag is reset earlier.
This commit is contained in:
parent
8cc44a64e8
commit
7fbf87e615
@ -331,6 +331,14 @@ int demuxer_add_packet(demuxer_t *demuxer, struct sh_stream *stream,
|
||||
// first packet in stream
|
||||
ds->head = ds->tail = dp;
|
||||
}
|
||||
/* ds_get_packets() can set ds->eof to 1 when another stream runs out of
|
||||
* buffer space. That makes sense because in that situation the calling
|
||||
* code should not count on being able to demux more packets from this
|
||||
* stream. (Can happen with e.g. badly interleaved files.)
|
||||
* In this case, we didn't necessarily reach EOF, and new packet can
|
||||
* appear. */
|
||||
ds->eof = 0;
|
||||
|
||||
mp_dbg(MSGT_DEMUXER, MSGL_DBG2,
|
||||
"DEMUX: Append packet to %s, len=%d pts=%5.3f pos=%"PRIu64" "
|
||||
"[packs: A=%d V=%d S=%d]\n", stream_type_name(stream->type),
|
||||
@ -380,17 +388,8 @@ static void ds_get_packets(struct sh_stream *sh)
|
||||
mp_dbg(MSGT_DEMUXER, MSGL_DBG3, "ds_get_packets (%s) called\n",
|
||||
stream_type_name(sh->type));
|
||||
while (1) {
|
||||
if (ds->head) {
|
||||
/* The code below can set ds->eof to 1 when another stream runs
|
||||
* out of buffer space. That makes sense because in that situation
|
||||
* the calling code should not count on being able to demux more
|
||||
* packets from this stream.
|
||||
* If however the situation improves and we're called again
|
||||
* despite the eof flag then it's better to clear it to avoid
|
||||
* weird behavior. */
|
||||
ds->eof = 0;
|
||||
if (ds->head)
|
||||
return;
|
||||
}
|
||||
|
||||
if (demux_check_queue_full(demux))
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user