summaryrefslogtreecommitdiffstats
path: root/demux/demux_mkv_timeline.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-02-20 21:56:55 +0100
committerwm4 <wm4@nowhere>2015-02-20 21:56:55 +0100
commit1cac7d1a659faffd1514a3269edf9fcae4d357c1 (patch)
treefeaa280fa28a416691f2fe2e0cd56f588746dcd1 /demux/demux_mkv_timeline.c
parent6aa6778ac46672dd237acc86856353d133917f06 (diff)
downloadmpv-1cac7d1a659faffd1514a3269edf9fcae4d357c1.tar.bz2
mpv-1cac7d1a659faffd1514a3269edf9fcae4d357c1.tar.xz
demux: add a demux_open_url() function
Often stream and a demuxer are opened at the same time. Provide a function for this and replace most of its uses.
Diffstat (limited to 'demux/demux_mkv_timeline.c')
-rw-r--r--demux/demux_mkv_timeline.c51
1 files changed, 11 insertions, 40 deletions
diff --git a/demux/demux_mkv_timeline.c b/demux/demux_mkv_timeline.c
index 64d4583979..71f5b16031 100644
--- a/demux/demux_mkv_timeline.c
+++ b/demux/demux_mkv_timeline.c
@@ -148,36 +148,6 @@ static char **find_files(const char *original_file)
return results;
}
-static int enable_cache(struct mpv_global *global, struct stream **stream,
- struct demuxer **demuxer, struct demuxer_params *params)
-{
- struct MPOpts *opts = global->opts;
-
- if (!stream_wants_cache(*stream, &opts->stream_cache))
- return 0;
-
- char *filename = talloc_strdup(NULL, (*demuxer)->filename);
-
- free_demuxer_and_stream(*demuxer);
- *stream = stream_open(filename, global);
- if (!*stream) {
- talloc_free(filename);
- return -1;
- }
-
- stream_enable_cache(stream, &opts->stream_cache);
-
- *demuxer = demux_open(*stream, params, global);
- if (!*demuxer) {
- talloc_free(filename);
- free_stream(*stream);
- return -1;
- }
-
- talloc_free(filename);
- return 1;
-}
-
static bool has_source_request(struct matroska_segment_uid *uids,
int num_sources,
struct matroska_segment_uid *new_uid)
@@ -202,16 +172,11 @@ static bool check_file_seg(struct tl_ctx *ctx, struct demuxer ***sources,
.matroska_wanted_uids = *uids,
.matroska_wanted_segment = segment,
.matroska_was_valid = &was_valid,
+ .disable_cache = true,
};
- struct stream *s = stream_open(filename, ctx->global);
- if (!s)
+ struct demuxer *d = demux_open_url(filename, &params, NULL, ctx->global);
+ if (!d)
return false;
- struct demuxer *d = demux_open(s, &params, ctx->global);
-
- if (!d) {
- free_stream(s);
- return was_valid;
- }
struct matroska_data *m = &d->matroska_data;
@@ -243,8 +208,14 @@ static bool check_file_seg(struct tl_ctx *ctx, struct demuxer ***sources,
MP_TARRAY_APPEND(NULL, *sources, *num_sources, NULL);
}
- if (enable_cache(ctx->global, &s, &d, &params) < 0)
- continue;
+ if (stream_wants_cache(d->stream, &ctx->global->opts->stream_cache))
+ {
+ free_demuxer_and_stream(d);
+ params.disable_cache = false;
+ d = demux_open_url(filename, &params, NULL, ctx->global);
+ if (!d)
+ continue;
+ }
(*sources)[i] = d;
return true;