summaryrefslogtreecommitdiffstats
path: root/stream/stream_lavf.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-12-30 17:39:08 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-01-02 14:59:27 -0800
commit722f9b63c20918cb8f503b65e6bcafcc303e355c (patch)
tree76faea6b5289612bc1a082429de173aa8c2b23a7 /stream/stream_lavf.c
parent6aad532aa39481a8100910612fad039dd75236b9 (diff)
downloadmpv-722f9b63c20918cb8f503b65e6bcafcc303e355c.tar.bz2
mpv-722f9b63c20918cb8f503b65e6bcafcc303e355c.tar.xz
stream_lavf: minor fixes to HTTP reconnection support
Don't drop the stream buffers, because the read call (that must have been failing) might try to extend an existing read buffer in the first place. Just move the messy seek logic to stream_lavf.c. (In theory, stream_lavf should probably make libavformat connect at the correct offset instead of using a seek to reconnect it again. This patch doesn't fix it, but at least it's a good argument to have the messing with the position not in the generic code.) Also update the comment about avio not supporting reconnecting. It has that feature now. Maybe we should use it, but only after it gets fixed.
Diffstat (limited to 'stream/stream_lavf.c')
-rw-r--r--stream/stream_lavf.c17
1 files changed, 13 insertions, 4 deletions
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;