summaryrefslogtreecommitdiffstats
path: root/demux/demux_mkv_timeline.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-06 20:09:56 +0200
committerwm4 <wm4@nowhere>2016-09-06 20:09:56 +0200
commitd4d8b3a4fcf8d50af9cef9766cfefc5538be28f4 (patch)
tree1eb69ef2876dcf541bab2018e733dbe1053a0fe3 /demux/demux_mkv_timeline.c
parent9f0e7bb9982eef36bf2f14fd750bbe6a359011ba (diff)
downloadmpv-d4d8b3a4fcf8d50af9cef9766cfefc5538be28f4.tar.bz2
mpv-d4d8b3a4fcf8d50af9cef9766cfefc5538be28f4.tar.xz
demux: do not access global options
Don't access MPOpts directly, and always use the new m_config.h functions for accessing them in a thread-safe way. The goal is eventually removing the mpv_global.opts field, and the demuxer/stream-layer specific hack that copies MPOpts to deal with thread-safety issues. This moves around a lot of options. For one, we often change the physical storage location of options to make them more localized, but these changes are not user-visible (or should not be). For shared options on the other hand it's better to do messy direct access, which is worrying as in that somehow renaming an option or changing its type would break code reading them manually, without causing a compilation error.
Diffstat (limited to 'demux/demux_mkv_timeline.c')
-rw-r--r--demux/demux_mkv_timeline.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/demux/demux_mkv_timeline.c b/demux/demux_mkv_timeline.c
index 256e009753..30d669c77f 100644
--- a/demux/demux_mkv_timeline.c
+++ b/demux/demux_mkv_timeline.c
@@ -32,10 +32,10 @@
#include "mpv_talloc.h"
#include "common/msg.h"
-#include "common/global.h"
#include "demux/demux.h"
#include "demux/timeline.h"
#include "demux/matroska.h"
+#include "options/m_config.h"
#include "options/options.h"
#include "options/path.h"
#include "misc/bstr.h"
@@ -46,6 +46,7 @@
struct tl_ctx {
struct mp_log *log;
struct mpv_global *global;
+ struct MPOpts *opts;
struct timeline *tl;
struct demuxer *demuxer;
@@ -209,8 +210,7 @@ static bool check_file_seg(struct tl_ctx *ctx, char *filename, int segment)
MP_TARRAY_APPEND(NULL, ctx->sources, ctx->num_sources, NULL);
}
- if (stream_wants_cache(d->stream, &ctx->global->opts->stream_cache))
- {
+ if (stream_wants_cache(d->stream, ctx->opts->stream_cache)) {
free_demuxer_and_stream(d);
params.disable_cache = false;
params.matroska_wanted_uids = ctx->uids; // potentially reallocated, same data
@@ -247,7 +247,7 @@ static bool missing(struct tl_ctx *ctx)
static void find_ordered_chapter_sources(struct tl_ctx *ctx)
{
- struct MPOpts *opts = ctx->global->opts;
+ struct MPOpts *opts = ctx->opts;
void *tmp = talloc_new(NULL);
int num_filenames = 0;
char **filenames = NULL;
@@ -317,7 +317,7 @@ static int64_t add_timeline_part(struct tl_ctx *ctx,
* early; we don't want to try seeking over a one frame gap. */
int64_t join_diff = start - ctx->last_end_time;
if (ctx->num_parts == 0
- || FFABS(join_diff) > ctx->global->opts->chapter_merge_threshold * 1e6
+ || FFABS(join_diff) > ctx->opts->chapter_merge_threshold * 1e6
|| source != ctx->timeline[ctx->num_parts - 1].source)
{
struct timeline_part new = {
@@ -505,20 +505,22 @@ void build_ordered_chapter_timeline(struct timeline *tl)
if (!demuxer->matroska_data.ordered_chapters)
return;
- if (!demuxer->global->opts->ordered_chapters) {
- MP_INFO(demuxer, "File uses ordered chapters, but "
- "you have disabled support for them. Ignoring.\n");
- return;
- }
-
struct tl_ctx *ctx = talloc_ptrtype(tl, ctx);
*ctx = (struct tl_ctx){
.log = tl->log,
.global = tl->global,
.tl = tl,
.demuxer = demuxer,
+ .opts = mp_get_config_group(ctx, tl->global, NULL),
};
+ if (!ctx->opts->ordered_chapters) {
+ MP_INFO(demuxer, "File uses ordered chapters, but "
+ "you have disabled support for them. Ignoring.\n");
+ talloc_free(ctx);
+ return;
+ }
+
MP_INFO(ctx, "File uses ordered chapters, will build edit timeline.\n");
struct matroska_data *m = &demuxer->matroska_data;