summaryrefslogtreecommitdiffstats
path: root/player/loadfile.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/loadfile.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/loadfile.c')
-rw-r--r--player/loadfile.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index 9d515b2012..603b264f60 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -572,8 +572,11 @@ static void check_previous_track_selection(struct MPContext *mpctx)
// defaults are -1 (default selection), or -2 (off) for secondary tracks.
for (int t = 0; t < STREAM_TYPE_COUNT; t++) {
for (int i = 0; i < NUM_PTRACKS; i++) {
- if (opts->stream_id[i][t] >= 0)
+ if (opts->stream_id[i][t] >= 0) {
opts->stream_id[i][t] = i == 0 ? -1 : -2;
+ m_config_notify_change_opt_ptr(mpctx->mconfig,
+ &opts->stream_id[i][t]);
+ }
}
}
talloc_free(mpctx->track_layout_hash);
@@ -590,8 +593,11 @@ void mp_switch_track_n(struct MPContext *mpctx, int order, enum stream_type type
// Mark the current track selection as explicitly user-requested. (This is
// different from auto-selection or disabling a track due to errors.)
- if (flags & FLAG_MARK_SELECTION)
+ if (flags & FLAG_MARK_SELECTION) {
mpctx->opts->stream_id[order][type] = track ? track->user_tid : -2;
+ m_config_notify_change_opt_ptr(mpctx->mconfig,
+ &mpctx->opts->stream_id[order][type]);
+ }
// No decoder should be initialized yet.
if (!mpctx->demuxer)
@@ -1623,8 +1629,10 @@ terminate_playback:
process_hooks(mpctx, "on_unload");
- if (mpctx->step_frames)
+ if (mpctx->step_frames) {
opts->pause = 1;
+ m_config_notify_change_opt_ptr(mpctx->mconfig, &opts->pause);
+ }
close_recorder(mpctx);
@@ -1730,8 +1738,11 @@ struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction,
if (mpctx->opts->shuffle)
playlist_shuffle(mpctx->playlist);
next = mpctx->playlist->first;
- if (next && mpctx->opts->loop_times > 1)
+ if (next && mpctx->opts->loop_times > 1) {
mpctx->opts->loop_times--;
+ m_config_notify_change_opt_ptr(mpctx->mconfig,
+ &mpctx->opts->loop_times);
+ }
} else {
next = mpctx->playlist->last;
// Don't jump to files that would immediately go to next file anyway
@@ -1852,7 +1863,7 @@ void close_recorder_and_error(struct MPContext *mpctx)
close_recorder(mpctx);
talloc_free(mpctx->opts->record_file);
mpctx->opts->record_file = NULL;
- mp_notify_property(mpctx, "record-file");
+ m_config_notify_change_opt_ptr(mpctx->mconfig, &mpctx->opts->record_file);
MP_ERR(mpctx, "Disabling stream recording.\n");
}