diff options
Diffstat (limited to 'stream')
-rw-r--r-- | stream/stream.c | 3 | ||||
-rw-r--r-- | stream/stream_lavf.c | 17 |
2 files changed, 14 insertions, 6 deletions
diff --git a/stream/stream.c b/stream/stream.c index 44a773cd1f..dba30d5df2 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -341,7 +341,6 @@ static bool stream_reconnect(stream_t *s) if (!s->streaming || s->caching || !s->seekable || !s->cancel) return false; - int64_t pos = s->pos; double sleep_secs = 0; for (int retry = 0; retry < 6; retry++) { if (mp_cancel_wait(s->cancel, sleep_secs)) @@ -350,7 +349,7 @@ static bool stream_reconnect(stream_t *s) int r = stream_control(s, STREAM_CTRL_RECONNECT, NULL); if (r == STREAM_UNSUPPORTED) break; - if (r == STREAM_OK && stream_seek_unbuffered(s, pos) && s->pos == pos) { + if (r == STREAM_OK) { MP_WARN(s, "Reconnected successfully.\n"); return true; } diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c index 80a27bd3e6..2230247f28 100644 --- a/stream/stream_lavf.c +++ b/stream/stream_lavf.c @@ -178,12 +178,21 @@ static int control(stream_t *s, int cmd, void *arg) case STREAM_CTRL_RECONNECT: { if (avio && avio->write_flag) break; // don't bother with this - // avio doesn't seem to support this - emulate it by reopening + // avio supports reconneting for http (as private avio option), but it + // seems somewhat broken and drops part of the stream if the first + // reconnect does not work. emulate it. close_f(s); s->priv = NULL; - stream_drop_buffers(s); - s->pos = 0; - return open_f(s); + int res = open_f(s); + if (res == STREAM_OK) { + if (!seek(s, s->pos)) { + MP_WARN(s, "Reconnecting failed.\n"); + close_f(s); + s->priv = NULL; + return STREAM_UNSUPPORTED; + } + } + return res; } } return STREAM_UNSUPPORTED; |