summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-02 15:50:54 +0200
committerwm4 <wm4@nowhere>2016-09-02 15:50:54 +0200
commit2c917219cffc74fcc64f04113fe260f2b88d5841 (patch)
treeae874a7185fa23e162219c6d9b27fb656f7d7c9f
parent423e53ba0bad034685e5229720d55548afb1efbe (diff)
downloadmpv-2c917219cffc74fcc64f04113fe260f2b88d5841.tar.bz2
mpv-2c917219cffc74fcc64f04113fe260f2b88d5841.tar.xz
vo: use new option update mechanism
This is still rather basic. run_reconfig() and run_control() update the options because it's needed for panscan (and other video scaling options), and fullscreen, border, ontop updates. In the old model, these options could be accessed only while both playback thread and VO threads were locked (i.e. during synchronous calls like vo_control()), so this should be sufficient in order not to miss any updates. In the future, a more fine-grained update mechanism could be added to handle these updates "exactly". x11_common.c contains an evil hack, as I see no reasonable way to handle this properly. The VO thread can't "lock" the main thread, so this is not simple.
-rw-r--r--options/options.c2
-rw-r--r--options/options.h1
-rw-r--r--video/out/vo.c7
-rw-r--r--video/out/vo.h6
-rw-r--r--video/out/x11_common.c13
5 files changed, 25 insertions, 4 deletions
diff --git a/options/options.c b/options/options.c
index 9c3ec0b776..bd16a0a025 100644
--- a/options/options.c
+++ b/options/options.c
@@ -150,7 +150,7 @@ static const m_option_t mp_vo_opt_list[] = {
{0}
};
-static const struct m_sub_options vo_sub_opts = {
+const struct m_sub_options vo_sub_opts = {
.opts = mp_vo_opt_list,
.size = sizeof(struct mp_vo_opts),
.defaults = &(const struct mp_vo_opts){
diff --git a/options/options.h b/options/options.h
index 1a2bfa68c8..d450675e61 100644
--- a/options/options.h
+++ b/options/options.h
@@ -335,5 +335,6 @@ typedef struct MPOpts {
extern const m_option_t mp_opts[];
extern const struct MPOpts mp_default_opts;
+extern const struct m_sub_options vo_sub_opts;
#endif
diff --git a/video/out/vo.c b/video/out/vo.c
index e37acb1242..b8b55ca58e 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -225,7 +225,6 @@ static struct vo *vo_create(bool probing, struct mpv_global *global,
*vo = (struct vo) {
.log = mp_log_new(vo, log, name),
.driver = desc.p,
- .opts = global->opts->vo,
.global = global,
.encode_lavc_ctx = ex->encode_lavc_ctx,
.input_ctx = ex->input_ctx,
@@ -245,6 +244,9 @@ static struct vo *vo_create(bool probing, struct mpv_global *global,
pthread_mutex_init(&vo->in->lock, NULL);
pthread_cond_init(&vo->in->wakeup, NULL);
+ vo->opts_cache = m_config_cache_alloc(vo, global, &vo_sub_opts);
+ vo->opts = vo->opts_cache->opts;
+
mp_input_set_mouse_transform(vo->input_ctx, NULL, NULL);
if (vo->driver->encode != !!vo->encode_lavc_ctx)
goto error;
@@ -503,6 +505,8 @@ static void run_reconfig(void *p)
struct vo_internal *in = vo->in;
+ m_config_cache_update(vo->opts_cache);
+
mp_image_params_get_dsize(params, &vo->dwidth, &vo->dheight);
talloc_free(vo->params);
@@ -541,6 +545,7 @@ static void run_control(void *p)
struct vo *vo = pp[0];
int request = (intptr_t)pp[1];
void *data = pp[2];
+ m_config_cache_update(vo->opts_cache);
int ret = vo->driver->control(vo, request, data);
if (pp[3])
*(int *)pp[3] = ret;
diff --git a/video/out/vo.h b/video/out/vo.h
index ed2fe94e37..96de569bc1 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -312,9 +312,7 @@ struct vo {
struct osd_state *osd;
struct encode_lavc_context *encode_lavc_ctx;
struct vo_internal *in;
- struct mp_vo_opts *opts;
struct vo_extra extra;
- struct m_config *config;
// --- The following fields are generally only changed during initialization.
@@ -329,6 +327,10 @@ struct vo {
// --- The following fields can be accessed only by the VO thread, or from
// anywhere _if_ the VO thread is suspended (use vo->dispatch).
+ struct m_config_cache *opts_cache; // cache for ->opts
+ struct mp_vo_opts *opts;
+ struct m_config *config; // config for ->priv
+
bool want_redraw; // redraw as soon as possible
// current window state
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index 868d0a1463..aa2185315e 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -26,6 +26,7 @@
#include "config.h"
#include "misc/bstr.h"
#include "options/options.h"
+#include "options/m_config.h"
#include "common/common.h"
#include "common/msg.h"
#include "input/input.h"
@@ -977,6 +978,17 @@ static void vo_x11_update_composition_hint(struct vo *vo)
XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&hint, 1);
}
+// Maximally awful hack to get MPOpts.vo.fullscreen set. The awful part is that
+// this sets a variable which is accessed by command.c without synchronization
+// (and which isn't supposed to need any). The need for this is that there's no
+// way to update this flag in any other way at all.
+static void set_global_fs_flag(struct vo *vo, int fs)
+{
+ struct m_config *rootconfig = mp_get_root_config(vo->global);
+ struct MPOpts *opts = rootconfig->optstruct;
+ opts->vo->fullscreen = fs;
+}
+
static void vo_x11_check_net_wm_state_fullscreen_change(struct vo *vo)
{
struct vo_x11_state *x11 = vo->x11;
@@ -1002,6 +1014,7 @@ static void vo_x11_check_net_wm_state_fullscreen_change(struct vo *vo)
{
vo->opts->fullscreen = is_fullscreen;
x11->fs = is_fullscreen;
+ set_global_fs_flag(vo, is_fullscreen);
if (!is_fullscreen && (x11->pos_changed_during_fs ||
x11->size_changed_during_fs))