summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demux/demux.c3
-rw-r--r--demux/demux.h3
-rw-r--r--demux/demux_lavf.c3
-rw-r--r--demux/demux_timeline.c2
-rw-r--r--demux/timeline.c2
5 files changed, 8 insertions, 5 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 0edfaa95bf..5f4c93b84f 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -2200,6 +2200,7 @@ static struct demuxer *open_given_type(struct mpv_global *global,
*demuxer = (struct demuxer) {
.desc = desc,
.stream = stream,
+ .cancel = stream->cancel,
.seekable = stream->seekable,
.filepos = -1,
.global = global,
@@ -3136,7 +3137,7 @@ int demux_stream_control(demuxer_t *demuxer, int ctrl, void *arg)
bool demux_cancel_test(struct demuxer *demuxer)
{
- return mp_cancel_test(demuxer->stream->cancel);
+ return mp_cancel_test(demuxer->cancel);
}
struct demux_chapter *demux_copy_chapter_data(struct demux_chapter *c, int num)
diff --git a/demux/demux.h b/demux/demux.h
index 0150ce1a1a..ccbc6ae94a 100644
--- a/demux/demux.h
+++ b/demux/demux.h
@@ -233,6 +233,9 @@ typedef struct demuxer {
struct mp_tags **update_stream_tags;
int num_update_stream_tags;
+ // Triggered when ending demuxing forcefully. Usually bound to the stream too.
+ struct mp_cancel *cancel;
+
// Since the demuxer can run in its own thread, and the stream is not
// thread-safe, only the demuxer is allowed to access the stream directly.
// You can freely use demux_stream_control() to send STREAM_CTRLs.
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index a0b5ff7472..41c334d309 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -775,8 +775,7 @@ static void update_metadata(demuxer_t *demuxer)
static int interrupt_cb(void *ctx)
{
struct demuxer *demuxer = ctx;
- lavf_priv_t *priv = demuxer->priv;
- return mp_cancel_test(priv->stream->cancel);
+ return mp_cancel_test(demuxer->cancel);
}
static int block_io_open(struct AVFormatContext *s, AVIOContext **pb,
diff --git a/demux/demux_timeline.c b/demux/demux_timeline.c
index 4b9b3124fa..9d92d1879d 100644
--- a/demux/demux_timeline.c
+++ b/demux/demux_timeline.c
@@ -167,7 +167,7 @@ static void reopen_lazy_segments(struct demuxer *demuxer)
.skip_lavf_probing = true,
};
p->current->d = demux_open_url(p->current->url, &params,
- demuxer->stream->cancel, demuxer->global);
+ demuxer->cancel, demuxer->global);
if (!p->current->d && !demux_cancel_test(demuxer))
MP_ERR(demuxer, "failed to load segment\n");
if (p->current->d)
diff --git a/demux/timeline.c b/demux/timeline.c
index 700a6dfd05..c53170b623 100644
--- a/demux/timeline.c
+++ b/demux/timeline.c
@@ -14,7 +14,7 @@ struct timeline *timeline_load(struct mpv_global *global, struct mp_log *log,
*tl = (struct timeline){
.global = global,
.log = log,
- .cancel = demuxer->stream->cancel,
+ .cancel = demuxer->cancel,
.demuxer = demuxer,
.track_layout = demuxer,
};