summaryrefslogtreecommitdiffstats
path: root/m_property.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-10-14 23:08:39 +0200
committerwm4 <wm4@nowhere>2012-10-14 23:12:03 +0200
commit38eb7f2fcf2a6848f97025ac4b968e3aa3d65815 (patch)
treed752551efad72bc6ca4b3ff62777c0b356d09906 /m_property.c
parent187cbd7aa7a74bf1596b3501c095920441f76dc0 (diff)
downloadmpv-38eb7f2fcf2a6848f97025ac4b968e3aa3d65815.tar.bz2
mpv-38eb7f2fcf2a6848f97025ac4b968e3aa3d65815.tar.xz
command: reduce some property boilerplate
Reduces code needed for implementing string and int64_t read-only properties. Originally, there actually was a m_property_string_ro(), but it was removed, as that would have implicitly strdup'ed the string. But the new name m_property_strdup_ro() should make it quite clear what is happening.
Diffstat (limited to 'm_property.c')
-rw-r--r--m_property.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/m_property.c b/m_property.c
index c8cf4e3dcf..f97bb366a4 100644
--- a/m_property.c
+++ b/m_property.c
@@ -324,6 +324,16 @@ int m_property_int_ro(const m_option_t *prop, int action,
return M_PROPERTY_NOT_IMPLEMENTED;
}
+int m_property_int64_ro(const struct m_option* prop, int action, void* arg,
+ int64_t var)
+{
+ if (action == M_PROPERTY_GET) {
+ *(int64_t *)arg = var;
+ return M_PROPERTY_OK;
+ }
+ return M_PROPERTY_NOT_IMPLEMENTED;
+}
+
int m_property_float_ro(const m_option_t *prop, int action,
void *arg, float var)
{
@@ -343,3 +353,13 @@ int m_property_double_ro(const m_option_t *prop, int action,
}
return M_PROPERTY_NOT_IMPLEMENTED;
}
+
+int m_property_strdup_ro(const struct m_option* prop, int action, void* arg,
+ const char *var)
+{
+ if (action == M_PROPERTY_GET) {
+ *(char **)arg = talloc_strdup(NULL, var);
+ return M_PROPERTY_OK;
+ }
+ return M_PROPERTY_NOT_IMPLEMENTED;
+}