diff options
author | wm4 <wm4@nowhere> | 2016-09-21 15:56:54 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-09-21 17:35:00 +0200 |
commit | 75d12c174f0b5bb03c71872241f965ac674221d7 (patch) | |
tree | 39fb3f2026bdad9c3daece97183d048bef3b96be /player | |
parent | 14c232bdbfbb16f427632d579430fa1a522f7f73 (diff) | |
download | mpv-75d12c174f0b5bb03c71872241f965ac674221d7.tar.bz2 mpv-75d12c174f0b5bb03c71872241f965ac674221d7.tar.xz |
options: make input options generally runtime-settable
Diffstat (limited to 'player')
-rw-r--r-- | player/command.c | 21 | ||||
-rw-r--r-- | player/main.c | 14 |
2 files changed, 26 insertions, 9 deletions
diff --git a/player/command.c b/player/command.c index 3a496e6de1..4bb26303b1 100644 --- a/player/command.c +++ b/player/command.c @@ -97,6 +97,9 @@ struct command_ctx { int64_t hook_seq; // for hook_handler.seq struct ao_hotplug *hotplug; + + char *cur_ipc; + char *cur_ipc_input; }; struct overlay { @@ -5581,6 +5584,7 @@ void mp_notify(struct MPContext *mpctx, int event, void *arg) void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags) { struct MPContext *mpctx = ctx; + struct command_ctx *cmd = mpctx->command_ctx; if (flags & UPDATE_TERM) mp_update_logging(mpctx); @@ -5608,6 +5612,23 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags) mp_force_video_refresh(mpctx); } } + + if (flags & UPDATE_INPUT) { + mp_input_update_opts(mpctx->input); + + // Rather coarse change-detection, but sufficient effort. + struct MPOpts *opts = mpctx->opts; + if (!bstr_equals(bstr0(cmd->cur_ipc), bstr0(opts->ipc_path)) || + !bstr_equals(bstr0(cmd->cur_ipc_input), bstr0(opts->input_file))) + { + talloc_free(cmd->cur_ipc); + talloc_free(cmd->cur_ipc_input); + cmd->cur_ipc = talloc_strdup(cmd, opts->ipc_path); + cmd->cur_ipc_input = talloc_strdup(cmd, opts->input_file); + mp_uninit_ipc(mpctx->ipc_ctx); + mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global); + } + } } void mp_notify_property(struct MPContext *mpctx, const char *property) diff --git a/player/main.c b/player/main.c index c3488fc60c..676f82946c 100644 --- a/player/main.c +++ b/player/main.c @@ -408,6 +408,8 @@ int mp_initialize(struct MPContext *mpctx, char **options) return r == M_OPT_EXIT ? -2 : -1; } + mp_get_resume_defaults(mpctx); + // From this point on, all mpctx members are initialized. mpctx->initialized = true; mpctx->mconfig->option_set_callback = mp_on_set_option; @@ -434,12 +436,12 @@ int mp_initialize(struct MPContext *mpctx, char **options) return -1; } - MP_STATS(mpctx, "start init"); - if (!mpctx->playlist->first && !opts->player_idle_mode) return -3; - mp_input_load(mpctx->input); + MP_STATS(mpctx, "start init"); + + mp_input_load_config(mpctx->input); #if HAVE_ENCODING if (opts->encode_opts->file && opts->encode_opts->file[0]) { @@ -459,17 +461,11 @@ int mp_initialize(struct MPContext *mpctx, char **options) MP_WARN(mpctx, "There will be no OSD and no text subtitles.\n"); #endif - mp_get_resume_defaults(mpctx); - - // Lua user scripts (etc.) can call arbitrary functions. Load them at a point - // where this is safe. mp_load_scripts(mpctx); if (opts->force_vo == 2 && handle_force_window(mpctx, false) < 0) return -1; - mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global); - #ifdef _WIN32 if (opts->w32_priority > 0) SetPriorityClass(GetCurrentProcess(), opts->w32_priority); |