diff options
author | wm4 <wm4@nowhere> | 2016-09-06 20:09:56 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-09-06 20:09:56 +0200 |
commit | d4d8b3a4fcf8d50af9cef9766cfefc5538be28f4 (patch) | |
tree | 1eb69ef2876dcf541bab2018e733dbe1053a0fe3 /stream/stream.c | |
parent | 9f0e7bb9982eef36bf2f14fd750bbe6a359011ba (diff) | |
download | mpv-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 'stream/stream.c')
-rw-r--r-- | stream/stream.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/stream/stream.c b/stream/stream.c index 3ecdfb01ad..6e45f0a549 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -784,7 +784,7 @@ bool stream_wants_cache(stream_t *stream, struct mp_cache_opts *opts) // return 1 on success, 0 if the cache is disabled/not needed, and -1 on error // or if the cache is disabled -int stream_enable_cache(stream_t **stream, struct mp_cache_opts *opts) +static int stream_enable_cache(stream_t **stream, struct mp_cache_opts *opts) { stream_t *orig = *stream; struct mp_cache_opts use_opts = check_cache_opts(*stream, opts); @@ -815,6 +815,20 @@ int stream_enable_cache(stream_t **stream, struct mp_cache_opts *opts) return res; } +// Do some crazy stuff to call stream_enable_cache() with the global options. +int stream_enable_cache_defaults(stream_t **stream) +{ + struct mpv_global *global = (*stream)->global; + if (!global) + return 0; + void *tmp = talloc_new(NULL); + struct mp_cache_opts *opts = + mp_get_config_group(tmp, global, &stream_cache_conf); + int r = stream_enable_cache(stream, opts); + talloc_free(tmp); + return r; +} + static uint16_t stream_read_word_endian(stream_t *s, bool big_endian) { unsigned int y = stream_read_char(s); |