summaryrefslogtreecommitdiffstats
path: root/player/playloop.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-29 12:49:15 +0100
committerwm4 <wm4@nowhere>2019-11-29 12:49:15 +0100
commitb16cea750f527088be79772e7cd601f86ce62ef2 (patch)
tree7bca2775a35f501baacafdbab63060d95ec99469 /player/playloop.c
parent5e2658c98196f8fd3558a2ffe40bd789ed27e8a3 (diff)
downloadmpv-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/playloop.c')
-rw-r--r--player/playloop.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/player/playloop.c b/player/playloop.c
index 5c83615a86..0e0c09654d 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -144,16 +144,12 @@ void update_core_idle_state(struct MPContext *mpctx)
void set_pause_state(struct MPContext *mpctx, bool user_pause)
{
struct MPOpts *opts = mpctx->opts;
- bool send_update = false;
- if (opts->pause != user_pause)
- send_update = true;
opts->pause = user_pause;
bool internal_paused = opts->pause || mpctx->paused_for_cache;
if (internal_paused != mpctx->paused) {
mpctx->paused = internal_paused;
- send_update = true;
if (mpctx->ao && mpctx->ao_chain) {
if (internal_paused) {
@@ -177,12 +173,15 @@ void set_pause_state(struct MPContext *mpctx, bool user_pause)
} else {
(void)get_relative_time(mpctx); // ignore time that passed during pause
}
+
+ // For some reason, these events are supposed to be sent even if only
+ // the internal pause state changed (and "pause" property didn't)... OK.
+ mp_notify(mpctx, opts->pause ? MPV_EVENT_PAUSE : MPV_EVENT_UNPAUSE, 0);
}
update_core_idle_state(mpctx);
- if (send_update)
- mp_notify(mpctx, opts->pause ? MPV_EVENT_PAUSE : MPV_EVENT_UNPAUSE, 0);
+ m_config_notify_change_opt_ptr(mpctx->mconfig, &opts->pause);
}
void update_internal_pause_state(struct MPContext *mpctx)
@@ -884,8 +883,10 @@ static void handle_loop_file(struct MPContext *mpctx)
target = ab[0];
prec = MPSEEK_EXACT;
} else if (opts->loop_file) {
- if (opts->loop_file > 0)
+ if (opts->loop_file > 0) {
opts->loop_file--;
+ m_config_notify_change_opt_ptr(mpctx->mconfig, &opts->loop_file);
+ }
target = get_start_time(mpctx, mpctx->play_dir);
}
@@ -1035,6 +1036,7 @@ int handle_force_window(struct MPContext *mpctx, bool force)
err:
mpctx->opts->force_vo = 0;
+ m_config_notify_change_opt_ptr(mpctx->mconfig, &mpctx->opts->force_vo);
uninit_video_out(mpctx);
MP_FATAL(mpctx, "Error opening/initializing the VO window.\n");
return -1;