diff options
author | wm4 <wm4@nowhere> | 2019-11-29 12:49:15 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-11-29 12:49:15 +0100 |
commit | b16cea750f527088be79772e7cd601f86ce62ef2 (patch) | |
tree | 7bca2775a35f501baacafdbab63060d95ec99469 /player/command.c | |
parent | 5e2658c98196f8fd3558a2ffe40bd789ed27e8a3 (diff) | |
download | mpv-b16cea750f527088be79772e7cd601f86ce62ef2.tar.bz2 mpv-b16cea750f527088be79772e7cd601f86ce62ef2.tar.xz |
player: change m_config to use new option handling mechanisms
Instead of making m_config a special-case, it more or less uses the
underlying m_config_cache/m_config_shadow APIs properly. This makes the
player core a (relatively) equivalent user of the core option API. In
particular, this means that other threads can change core options with
m_config_cache_write_opt() calls (before this commit, this merely led to
diverging option values).
An important change is that before this commit, mpctx->opts contained
the "master copy" of all option data. Now it's just another copy of the
option data, and the shadow copy is considered the master. This is why
whenever mpctx->opts is written, the change needs to be copied to the
master (thus why this commits add a bunch of m_config_notify... calls).
If another thread (e.g. a VO) changes an option, async_change_cb is now
invoked, which funnels the change notification through the player's
layers.
The new self_notification parameter on mp_option_change_callback is so
that m_config_notify... doesn't trigger recursion, and it's used in
cases where the change was already "processed". It's still needed to
trigger libmpv property updates. (I considered using an extra
m_config_cache for that, but it'd only cause problems with no
advantages.)
I think the recent changes actually forgot to send libmpv property
updates in some cases. This should fix this anyway. In some cases,
property updates are reworked, and the potential for bugs should be
lower (probably).
The primary point of this change is to allow external updates, for
example by a VO writing the fullscreen option if the window state is
changed by the window manager (rather than mpv changing it). This is not
used yet, but the following commits will.
Diffstat (limited to 'player/command.c')
-rw-r--r-- | player/command.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/player/command.c b/player/command.c index fea26dbdcf..10359e2352 100644 --- a/player/command.c +++ b/player/command.c @@ -1889,6 +1889,8 @@ static int property_switch_track(void *ctx, struct m_property *prop, // not always do what the user means, but keep the complexity low. mpctx->opts->stream_id[order][type] = mpctx->opts->stream_id[order][type] == -1 ? -2 : -1; + m_config_notify_change_opt_ptr(mpctx->mconfig, + &mpctx->opts->stream_id[order][type]); } return M_PROPERTY_OK; } @@ -3485,11 +3487,7 @@ static const char *const *const mp_event_property_change[] = { E(MPV_EVENT_FILE_LOADED, "*"), E(MP_EVENT_CHANGE_ALL, "*"), E(MPV_EVENT_TRACKS_CHANGED, "track-list"), - E(MPV_EVENT_TRACK_SWITCHED, "vid", "video", "aid", "audio", "sid", "sub", - "secondary-sid"), E(MPV_EVENT_IDLE, "*"), - E(MPV_EVENT_PAUSE, "pause"), - E(MPV_EVENT_UNPAUSE, "pause"), E(MPV_EVENT_TICK, "time-pos", "audio-pts", "stream-pos", "avsync", "percent-pos", "time-remaining", "playtime-remaining", "playback-time", "estimated-vf-fps", "drop-frame-count", "vo-drop-frame-count", @@ -4952,6 +4950,8 @@ static void cmd_track_add(void *p) print_track_list(mpctx, "Track switched:"); } else { mpctx->opts->stream_id[0][t->type] = t->user_tid; + m_config_notify_change_opt_ptr(mpctx->mconfig, + &mpctx->opts->stream_id[0][t->type]); } return; } @@ -4972,6 +4972,8 @@ static void cmd_track_add(void *p) mp_switch_track(mpctx, t->type, t, FLAG_MARK_SELECTION); } else { mpctx->opts->stream_id[0][t->type] = t->user_tid; + m_config_notify_change_opt_ptr(mpctx->mconfig, + &mpctx->opts->stream_id[0][t->type]); } } char *title = cmd->args[2].v.s; @@ -6037,13 +6039,23 @@ static void update_priority(struct MPContext *mpctx) #endif } -void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags) +void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags, + bool self_update) { struct MPContext *mpctx = ctx; struct MPOpts *opts = mpctx->opts; struct command_ctx *cmd = mpctx->command_ctx; void *opt_ptr = co ? co->data : NULL; // NULL on start + if (co) + mp_notify_property(mpctx, co->name); + + if (opt_ptr == &opts->pause) + mp_notify(mpctx, opts->pause ? MPV_EVENT_PAUSE : MPV_EVENT_UNPAUSE, 0); + + if (self_update) + return; + if (flags & UPDATE_TERM) mp_update_logging(mpctx, false); |