From ee653b8a26dcd7b89de046fa6a13baa1c6ca7c27 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 20 Feb 2015 22:08:02 +0100 Subject: [PATCH] demux: timeline: honor quit requests --- demux/demux_cue.c | 2 +- demux/demux_edl.c | 2 +- demux/demux_mkv_timeline.c | 10 ++++++++-- demux/timeline.c | 1 + demux/timeline.h | 1 + 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/demux/demux_cue.c b/demux/demux_cue.c index 93c842dc0d..6db9e29717 100644 --- a/demux/demux_cue.c +++ b/demux/demux_cue.c @@ -192,7 +192,7 @@ static bool try_open(struct timeline *tl, char *filename) || bstrcasecmp(bstr0(tl->demuxer->filename), bfilename) == 0) return false; - struct stream *s = stream_open(filename, tl->global); + struct stream *s = stream_create(filename, STREAM_READ, tl->cancel, tl->global); if (!s) return false; struct demuxer *d = demux_open(s, NULL, tl->global); diff --git a/demux/demux_edl.c b/demux/demux_edl.c index 7986489397..ed014314c9 100644 --- a/demux/demux_edl.c +++ b/demux/demux_edl.c @@ -141,7 +141,7 @@ static struct demuxer *open_source(struct timeline *tl, char *filename) if (strcmp(d->stream->url, filename) == 0) return d; } - struct demuxer *d = demux_open_url(filename, NULL, NULL, tl->global); + struct demuxer *d = demux_open_url(filename, NULL, tl->cancel, tl->global); if (d) { MP_TARRAY_APPEND(tl, tl->sources, tl->num_sources, d); } else { diff --git a/demux/demux_mkv_timeline.c b/demux/demux_mkv_timeline.c index 71f5b16031..06dcfbe296 100644 --- a/demux/demux_mkv_timeline.c +++ b/demux/demux_mkv_timeline.c @@ -47,6 +47,7 @@ struct tl_ctx { struct mp_log *log; struct mpv_global *global; + struct timeline *tl; struct demuxer *demuxer; @@ -174,7 +175,11 @@ static bool check_file_seg(struct tl_ctx *ctx, struct demuxer ***sources, .matroska_was_valid = &was_valid, .disable_cache = true, }; - struct demuxer *d = demux_open_url(filename, ¶ms, NULL, ctx->global); + struct mp_cancel *cancel = ctx->tl->cancel; + if (mp_cancel_test(cancel)) + return false; + + struct demuxer *d = demux_open_url(filename, ¶ms, cancel, ctx->global); if (!d) return false; @@ -212,7 +217,7 @@ static bool check_file_seg(struct tl_ctx *ctx, struct demuxer ***sources, { free_demuxer_and_stream(d); params.disable_cache = false; - d = demux_open_url(filename, ¶ms, NULL, ctx->global); + d = demux_open_url(filename, ¶ms, cancel, ctx->global); if (!d) continue; } @@ -518,6 +523,7 @@ void build_ordered_chapter_timeline(struct timeline *tl) *ctx = (struct tl_ctx){ .log = tl->log, .global = tl->global, + .tl = tl, .demuxer = demuxer, }; diff --git a/demux/timeline.c b/demux/timeline.c index 9910abf46d..73f3ab79a2 100644 --- a/demux/timeline.c +++ b/demux/timeline.c @@ -14,6 +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, .demuxer = demuxer, .track_layout = demuxer, }; diff --git a/demux/timeline.h b/demux/timeline.h index e4d6f67953..edc6a2f7ae 100644 --- a/demux/timeline.h +++ b/demux/timeline.h @@ -10,6 +10,7 @@ struct timeline_part { struct timeline { struct mpv_global *global; struct mp_log *log; + struct mp_cancel *cancel; // main source struct demuxer *demuxer;