summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-10-22 16:02:52 +0200
committerwm4 <wm4@nowhere>2016-10-22 16:02:52 +0200
commitbf5c4c42fa4366b707234e8feb5036ca3c03f056 (patch)
tree077f58bd54b1539eaa51e516420bfc720978c94e /player/command.c
parent11b8cbcce7efd02bee5c7427a4fa157bf20199e4 (diff)
downloadmpv-bf5c4c42fa4366b707234e8feb5036ca3c03f056.tar.bz2
mpv-bf5c4c42fa4366b707234e8feb5036ca3c03f056.tar.xz
command: silence deprecation warnings with --reset-on-next-file=all
--reset-on-next-file=all triggers m_config_backup_all_opts(), which backups all options (even deprecated ones). Later, when the option values are reset with m_config_restore_backups(), mp_on_set_option() is called, which in turn calls mp_property_do_silent(), which in turn will call mp_property_generic_option() and m_config_get_co(), which triggers the deprecation message. Unfortunately there's no good way to determine whether an option has actually changed (there's no option value compare operation), so the deprecated options have to be set no matter what. On the other hand, we can't pass through additional flags through the property layer. So we add a dumb global flag to silence the deprecation warnings in these cases. Fortunately m_config_get_co_raw() works to silence the warnings. m_config_get_co() also resolves aliases (deprecated and non-deprecated), but aliased options are handled differently by the option-property bridge, so we don't need to do that here, so the only purpose of it is to trigger a warning for deprecated (non-alias) options.
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/player/command.c b/player/command.c
index 0d5106227c..ea0df509e1 100644
--- a/player/command.c
+++ b/player/command.c
@@ -104,6 +104,8 @@ struct command_ctx {
char *cur_ipc;
char *cur_ipc_input;
+
+ int silence_option_deprecations;
};
struct overlay {
@@ -342,8 +344,13 @@ static int mp_property_generic_option(void *ctx, struct m_property *prop,
MPContext *mpctx = ctx;
const char *optname = prop->name;
int flags = M_SETOPT_RUNTIME;
- struct m_config_option *opt = m_config_get_co(mpctx->mconfig,
- bstr0(optname));
+ struct m_config_option *opt;
+ if (mpctx->command_ctx->silence_option_deprecations) {
+ // This case is specifically for making --reset-on-next-file=all silent.
+ opt = m_config_get_co_raw(mpctx->mconfig, bstr0(optname));
+ } else {
+ opt = m_config_get_co(mpctx->mconfig, bstr0(optname));
+ }
if (!opt)
return M_PROPERTY_UNKNOWN;
@@ -4154,7 +4161,9 @@ static int mp_property_do_silent(const char *name, int action, void *val,
struct MPContext *ctx)
{
struct command_ctx *cmd = ctx->command_ctx;
+ cmd->silence_option_deprecations += 1;
int r = m_property_do(ctx->log, cmd->properties, name, action, val, ctx);
+ cmd->silence_option_deprecations -= 1;
if (r == M_PROPERTY_OK && is_property_set(action, val))
mp_notify_property(ctx, (char *)name);
return r;