summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
Diffstat (limited to 'player')
-rw-r--r--player/command.c22
-rw-r--r--player/command.h3
-rw-r--r--player/loadfile.c21
-rw-r--r--player/main.c4
-rw-r--r--player/playloop.c16
5 files changed, 47 insertions, 19 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);
diff --git a/player/command.h b/player/command.h
index 037dec1164..e980f1715e 100644
--- a/player/command.h
+++ b/player/command.h
@@ -78,7 +78,8 @@ void property_print_help(struct MPContext *mpctx);
int mp_property_do(const char* name, int action, void* val,
struct MPContext *mpctx);
-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);
void mp_notify(struct MPContext *mpctx, int event, void *arg);
void mp_notify_property(struct MPContext *mpctx, const char *property);
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");
}
diff --git a/player/main.c b/player/main.c
index f4c7348af4..cac012a774 100644
--- a/player/main.c
+++ b/player/main.c
@@ -193,6 +193,7 @@ void mp_destroy(struct MPContext *mpctx)
assert(!mpctx->num_abort_list);
talloc_free(mpctx->abort_list);
pthread_mutex_destroy(&mpctx->abort_lock);
+ talloc_free(mpctx->mconfig); // destroy before dispatch
talloc_free(mpctx);
}
@@ -379,8 +380,9 @@ int mp_initialize(struct MPContext *mpctx, char **options)
mpctx->initialized = true;
mpctx->mconfig->option_change_callback = mp_option_change_callback;
mpctx->mconfig->option_change_callback_ctx = mpctx;
+ m_config_set_update_dispatch_queue(mpctx->mconfig, mpctx->dispatch);
// Run all update handlers.
- mp_option_change_callback(mpctx, NULL, UPDATE_OPTS_MASK);
+ mp_option_change_callback(mpctx, NULL, UPDATE_OPTS_MASK, false);
if (handle_help_options(mpctx))
return 1; // help
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;