summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
Diffstat (limited to 'options')
-rw-r--r--options/m_property.c29
-rw-r--r--options/m_property.h4
2 files changed, 33 insertions, 0 deletions
diff --git a/options/m_property.c b/options/m_property.c
index 2ef5a62123..431e16a51a 100644
--- a/options/m_property.c
+++ b/options/m_property.c
@@ -36,6 +36,32 @@
#include "common/msg.h"
#include "common/common.h"
+static int m_property_multiply(struct mp_log *log,
+ const struct m_property *prop_list,
+ const char *property, double f, void *ctx)
+{
+ union m_option_value val = {0};
+ struct m_option opt = {0};
+ int r;
+
+ r = m_property_do(log, prop_list, property, M_PROPERTY_GET_CONSTRICTED_TYPE,
+ &opt, ctx);
+ if (r != M_PROPERTY_OK)
+ return r;
+ assert(opt.type);
+
+ if (!opt.type->multiply)
+ return M_PROPERTY_NOT_IMPLEMENTED;
+
+ r = m_property_do(log, prop_list, property, M_PROPERTY_GET, &val, ctx);
+ if (r != M_PROPERTY_OK)
+ return r;
+ opt.type->multiply(&opt, &val, f);
+ r = m_property_do(log, prop_list, property, M_PROPERTY_SET, &val, ctx);
+ m_option_free(&opt, &val);
+ return r;
+}
+
struct m_property *m_property_list_find(const struct m_property *list,
const char *name)
{
@@ -107,6 +133,9 @@ int m_property_do(struct mp_log *log, const struct m_property *prop_list,
struct mpv_node node = { .format = MPV_FORMAT_STRING, .u.string = arg };
return m_property_do(log, prop_list, name, M_PROPERTY_SET_NODE, &node, ctx);
}
+ case M_PROPERTY_MULTIPLY: {
+ return m_property_multiply(log, prop_list, name, *(double *)arg, ctx);
+ }
case M_PROPERTY_SWITCH: {
if (!log)
return M_PROPERTY_ERROR;
diff --git a/options/m_property.h b/options/m_property.h
index d71ec033aa..9ad4ccf9f6 100644
--- a/options/m_property.h
+++ b/options/m_property.h
@@ -79,6 +79,10 @@ enum mp_property_action {
// arg: mpv_node*
M_PROPERTY_SET_NODE,
+ // Multiply numeric property with a factor.
+ // arg: double*
+ M_PROPERTY_MULTIPLY,
+
// Pass down an action to a sub-property.
// arg: struct m_property_action_arg*
M_PROPERTY_KEY_ACTION,