mirror of https://github.com/mpv-player/mpv
demux, stream: ignore packets and errors on forced exit
When this happens, network calls are forcibly aborted (more or less), but demuxers might keep going, as most of them do not check for forced exits properly. This can possibly lead to broken packets being added. Also do not attempt to read more packets in this situation. Also do not print a stream open failed message if opening was aborted anyway.
This commit is contained in:
parent
965ba23303
commit
7d10728aaa
|
@ -1183,7 +1183,7 @@ static void adjust_seek_range_on_packet(struct demux_stream *ds,
|
||||||
void demux_add_packet(struct sh_stream *stream, demux_packet_t *dp)
|
void demux_add_packet(struct sh_stream *stream, demux_packet_t *dp)
|
||||||
{
|
{
|
||||||
struct demux_stream *ds = stream ? stream->ds : NULL;
|
struct demux_stream *ds = stream ? stream->ds : NULL;
|
||||||
if (!dp || !dp->len || !ds) {
|
if (!dp || !dp->len || !ds || demux_cancel_test(ds->in->d_thread)) {
|
||||||
talloc_free(dp);
|
talloc_free(dp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1306,7 +1306,7 @@ static bool read_packet(struct demux_internal *in)
|
||||||
in->eof = false;
|
in->eof = false;
|
||||||
in->idle = true;
|
in->idle = true;
|
||||||
|
|
||||||
if (!in->reading || in->blocked)
|
if (!in->reading || in->blocked || demux_cancel_test(in->d_thread))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check if we need to read a new packet. We do this if all queues are below
|
// Check if we need to read a new packet. We do this if all queues are below
|
||||||
|
|
|
@ -302,7 +302,8 @@ struct stream *stream_create(const char *url, int flags,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (r != STREAM_OK) {
|
if (r != STREAM_OK) {
|
||||||
mp_err(log, "Failed to open %s.\n", url);
|
if (!mp_cancel_test(c))
|
||||||
|
mp_err(log, "Failed to open %s.\n", url);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue