[vlc-devel] [PATCH 1/3] variables: add VLC_VAR_COMPARE_EXCHANGE
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Wed Jun 14 14:34:23 CEST 2017
From: Thomas Guillem <thomas at gllm.fr>
Behaves like atomic_compare_exchange but with vlc variables.
---
include/vlc_variables.h | 2 ++
src/misc/variables.c | 8 ++++++++
2 files changed, 10 insertions(+)
diff --git a/include/vlc_variables.h b/include/vlc_variables.h
index 83752b171f..15f5e7e803 100644
--- a/include/vlc_variables.h
+++ b/include/vlc_variables.h
@@ -101,6 +101,8 @@
#define VLC_VAR_CHOICESCOUNT 0x0026
#define VLC_VAR_SETMINMAX 0x0027
+#define VLC_VAR_COMPARE_EXCHANGE 0x0028
+
/**@}*/
/** \defgroup var_GetAndSet Variable actions
diff --git a/src/misc/variables.c b/src/misc/variables.c
index 121ef5ea70..47131587e2 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -559,6 +559,14 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
p_var->choices_text.p_values = NULL;
TriggerListCallback(p_this, p_var, psz_name, VLC_VAR_CLEARCHOICES, NULL);
break;
+ case VLC_VAR_COMPARE_EXCHANGE:
+ if( p_var->ops->pf_cmp( p_var->val, *p_val ) != 0 )
+ {
+ ret = VLC_EBADVAR;
+ break;
+ }
+ p_val = p_val2;
+ /* Fall through */
case VLC_VAR_SETVALUE:
/* Duplicate data if needed */
newval = *p_val;
--
2.11.0
More information about the vlc-devel
mailing list