summaryrefslogtreecommitdiffstats
path: root/m_option.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-09-18 17:05:11 +0200
committerwm4 <wm4@nowhere>2012-10-12 10:10:31 +0200
commit86ed6efd8acbf86c7f85d69e51c40d08f421a1ca (patch)
treed6893b95bae2d47144ed621d040f1bba21834b79 /m_option.h
parent426640204b409d1034a1c32ad01b9bc547e93684 (diff)
downloadmpv-86ed6efd8acbf86c7f85d69e51c40d08f421a1ca.tar.bz2
mpv-86ed6efd8acbf86c7f85d69e51c40d08f421a1ca.tar.xz
commands: handle property clamping in m_option
Instead of clamping property values to the valid range in each property implementation, handle it in the property layer. The functionality to handle clamping for each type is in m_option.c. It's not really clear whether this is really needed. Normally, the raw values for M_PROPERTY_SET come only from m_option_type.parse (setting properties as string) or from m_option_parse.add (using the "switch" input command). However, since this was already done before, and since we _really_ want to be sure only to write valid values, add this code anyway. The newly added warnings/error messages should never actually be printed during normal operation and are for debugging (if they happen, we definitely want to see them).
Diffstat (limited to 'm_option.h')
-rw-r--r--m_option.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/m_option.h b/m_option.h
index 11e9e620fb..166e38e999 100644
--- a/m_option.h
+++ b/m_option.h
@@ -251,6 +251,13 @@ struct m_option_type {
// add gives merely the direction. The wrap parameter determines whether
// the value is clipped, or wraps around to the opposite max/min.
void (*add)(const m_option_t *opt, void *val, double add, bool wrap);
+
+ // Clamp the value in val to the option's valid value range.
+ // Return values:
+ // M_OPT_OUT_OF_RANGE: val was invalid, and modified (clamped) to be valid
+ // M_OPT_INVALID: val was invalid, and can't be made valid
+ // 0: val was already valid and is unchanged
+ int (*clamp)(const m_option_t *opt, void *val);
};
// Option description