summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-04-25 19:13:12 +0200
committerwm4 <wm4@nowhere>2014-04-25 19:13:12 +0200
commit1c2c09adf75dea75c0471e765b955f5dfb7092b2 (patch)
tree98cd7f561de45bc3597602a75ff8b534b6b1ceb1 /stream
parent93de4c81b98cd760530474b71f226729dfa89d31 (diff)
downloadmpv-1c2c09adf75dea75c0471e765b955f5dfb7092b2.tar.bz2
mpv-1c2c09adf75dea75c0471e765b955f5dfb7092b2.tar.xz
stream: use libavformat interrupt callback
This will allow to cancel opening slow/stuck network streams faster. How well his work probably depends on the protocol implementation in libavformat.
Diffstat (limited to 'stream')
-rw-r--r--stream/stream_lavf.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c
index ec46c862f6..c9e714fce4 100644
--- a/stream/stream_lavf.c
+++ b/stream/stream_lavf.c
@@ -119,6 +119,12 @@ static int control(stream_t *s, int cmd, void *arg)
return STREAM_UNSUPPORTED;
}
+static int interrupt_cb(void *ctx)
+{
+ struct stream *stream = ctx;
+ return stream_check_interrupt(stream);
+}
+
static const char * const prefix[] = { "lavf://", "ffmpeg://" };
static int open_f(stream_t *stream, int mode)
@@ -200,7 +206,12 @@ static int open_f(stream_t *stream, int mode)
av_dict_set(&dict, "headers", cust_headers, 0);
av_dict_set(&dict, "icy", "1", 0);
- int err = avio_open2(&avio, filename, flags, NULL, &dict);
+ AVIOInterruptCB cb = {
+ .callback = interrupt_cb,
+ .opaque = stream,
+ };
+
+ int err = avio_open2(&avio, filename, flags, &cb, &dict);
if (err < 0) {
if (err == AVERROR_PROTOCOL_NOT_FOUND)
MP_ERR(stream, "[ffmpeg] Protocol not found. Make sure"