mirror of
https://github.com/mpv-player/mpv
synced 2025-03-20 02:09:52 +00:00
cache: propagate underlying stream seek errors in some cases
This just put the cache into an endless loop. This can happen simply if any seek call of the underlying stream returns an error.
This commit is contained in:
parent
5ffbe2ba8a
commit
2a43060560
@ -135,6 +135,8 @@ struct priv {
|
|||||||
|
|
||||||
int64_t eof_pos;
|
int64_t eof_pos;
|
||||||
|
|
||||||
|
bool read_seek_failed; // let a read fail because an async seek failed
|
||||||
|
|
||||||
int control; // requested STREAM_CTRL_... or CACHE_CTRL_...
|
int control; // requested STREAM_CTRL_... or CACHE_CTRL_...
|
||||||
void *control_arg; // temporary for executing STREAM_CTRLs
|
void *control_arg; // temporary for executing STREAM_CTRLs
|
||||||
int control_res;
|
int control_res;
|
||||||
@ -246,6 +248,8 @@ static bool cache_update_stream_position(struct priv *s)
|
|||||||
{
|
{
|
||||||
int64_t read = s->read_filepos;
|
int64_t read = s->read_filepos;
|
||||||
|
|
||||||
|
s->read_seek_failed = false;
|
||||||
|
|
||||||
if (needs_seek(s, read)) {
|
if (needs_seek(s, read)) {
|
||||||
MP_VERBOSE(s, "Dropping cache at pos %"PRId64", "
|
MP_VERBOSE(s, "Dropping cache at pos %"PRId64", "
|
||||||
"cached range: %"PRId64"-%"PRId64".\n", read,
|
"cached range: %"PRId64"-%"PRId64".\n", read,
|
||||||
@ -256,9 +260,11 @@ static bool cache_update_stream_position(struct priv *s)
|
|||||||
if (stream_tell(s->stream) != s->max_filepos && s->seekable) {
|
if (stream_tell(s->stream) != s->max_filepos && s->seekable) {
|
||||||
MP_VERBOSE(s, "Seeking underlying stream: %"PRId64" -> %"PRId64"\n",
|
MP_VERBOSE(s, "Seeking underlying stream: %"PRId64" -> %"PRId64"\n",
|
||||||
stream_tell(s->stream), s->max_filepos);
|
stream_tell(s->stream), s->max_filepos);
|
||||||
if (!stream_seek(s->stream, s->max_filepos))
|
if (!stream_seek(s->stream, s->max_filepos)) {
|
||||||
|
s->read_seek_failed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return stream_tell(s->stream) == s->max_filepos;
|
return stream_tell(s->stream) == s->max_filepos;
|
||||||
}
|
}
|
||||||
@ -600,6 +606,11 @@ static int cache_fill_buffer(struct stream *cache, char *buffer, int max_len)
|
|||||||
s->idle = false;
|
s->idle = false;
|
||||||
if (!cache_wakeup_and_wait(s, &retry_time))
|
if (!cache_wakeup_and_wait(s, &retry_time))
|
||||||
break;
|
break;
|
||||||
|
if (s->read_seek_failed) {
|
||||||
|
MP_ERR(s, "error reading after async seek failed\n");
|
||||||
|
s->read_seek_failed = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user