mirror of https://github.com/mpv-player/mpv
stream: tweaks to network reconnection code
Don't reconnect to the cache (since the cached stream already handles
reconnection). This is necessary, because since commit 0b428e44
the
"streaming" field (which also controls whether attempting to reconnect
makes sense at all) is inherited to the cache stream wrapper.
Also, let the stream reset its own position on reconnect. This removes
some assumptions and messy handling from the reconnect function.
Make sure the cache is dropped on reconnect. This takes care of
readjusting the stream position if necessary. (Also drop the cache on
DVB channel switching commands.)
This commit is contained in:
parent
66f158b89b
commit
ac2502141d
|
@ -415,6 +415,9 @@ static bool control_needs_flush(int stream_ctrl)
|
|||
case STREAM_CTRL_AVSEEK:
|
||||
case STREAM_CTRL_SET_ANGLE:
|
||||
case STREAM_CTRL_SET_CURRENT_TITLE:
|
||||
case STREAM_CTRL_RECONNECT:
|
||||
case STREAM_CTRL_DVB_SET_CHANNEL:
|
||||
case STREAM_CTRL_DVB_STEP_CHANNEL:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -384,7 +384,7 @@ static int stream_reconnect(stream_t *s)
|
|||
{
|
||||
#define MAX_RECONNECT_RETRIES 5
|
||||
#define RECONNECT_SLEEP_MAX_MS 500
|
||||
if (!s->streaming)
|
||||
if (!s->streaming || s->uncached_stream)
|
||||
return 0;
|
||||
if (!s->seekable)
|
||||
return 0;
|
||||
|
@ -404,8 +404,6 @@ static int stream_reconnect(stream_t *s)
|
|||
return 0;
|
||||
|
||||
s->eof = 1;
|
||||
s->pos = 0;
|
||||
s->buf_pos = s->buf_len = 0;
|
||||
|
||||
int r = stream_control(s, STREAM_CTRL_RECONNECT, NULL);
|
||||
if (r == STREAM_UNSUPPORTED)
|
||||
|
|
|
@ -252,6 +252,8 @@ static int open_f(stream_t *stream)
|
|||
stream->close = close_f;
|
||||
// enable cache (should be avoided for files, but no way to detect this)
|
||||
stream->streaming = true;
|
||||
stream->pos = 0; // reset specifically for STREAM_CTRL_RECONNECT
|
||||
stream->buf_pos = stream->buf_len = 0;
|
||||
res = STREAM_OK;
|
||||
|
||||
out:
|
||||
|
|
Loading…
Reference in New Issue