[vlc-devel] [PATCH 2/5] variables: rename var_{Add/Del}ListCallback to var_{Add/Del}ChoiceCallback

Thomas Guillem thomas at gllm.fr
Thu Nov 3 10:16:48 CET 2016


---
 include/vlc_common.h    | 12 +++++------
 include/vlc_variables.h |  8 +++----
 lib/media_player.c      | 12 +++++------
 src/libvlccore.sym      |  4 ++--
 src/misc/variables.c    | 57 ++++++++++++++++++++++++++-----------------------
 5 files changed, 48 insertions(+), 45 deletions(-)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index a9683d6..680762a 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -376,13 +376,13 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *,      /* variable's object */
                                    void * );                /* callback data */
 
 /*****************************************************************************
- * List callbacks: called when elements are added/removed from the list
+ * List callbacks: called when elements are added/removed from a choice list
  *****************************************************************************/
-typedef int ( * vlc_list_callback_t ) ( vlc_object_t *,      /* variable's object */
-                                        char const *,            /* variable name */
-                                        int,                  /* VLC_VAR_* action */
-                                        vlc_value_t *,      /* new/deleted value  */
-                                        void *);                 /* callback data */
+typedef int ( *vlc_choice_callback_t ) ( vlc_object_t *,/* variable's object */
+                                         char const *,      /* variable name */
+                                         int,            /* VLC_VAR_* action */
+                                         vlc_value_t *,/* new/deleted value  */
+                                         void *);           /* callback data */
 
 /*****************************************************************************
  * OS-specific headers and thread types
diff --git a/include/vlc_variables.h b/include/vlc_variables.h
index fa17150..f931fac 100644
--- a/include/vlc_variables.h
+++ b/include/vlc_variables.h
@@ -160,15 +160,15 @@ VLC_API void var_AddCallback( vlc_object_t *, const char *, vlc_callback_t, void
 VLC_API void var_DelCallback( vlc_object_t *, const char *, vlc_callback_t, void * );
 VLC_API void var_TriggerCallback( vlc_object_t *, const char * );
 
-VLC_API void var_AddListCallback( vlc_object_t *, const char *, vlc_list_callback_t, void * );
-VLC_API void var_DelListCallback( vlc_object_t *, const char *, vlc_list_callback_t, void * );
+VLC_API void var_AddChoiceCallback( vlc_object_t *, const char *, vlc_choice_callback_t, void * );
+VLC_API void var_DelChoiceCallback( vlc_object_t *, const char *, vlc_choice_callback_t, void * );
 
 #define var_AddCallback(a,b,c,d) var_AddCallback( VLC_OBJECT(a), b, c, d )
 #define var_DelCallback(a,b,c,d) var_DelCallback( VLC_OBJECT(a), b, c, d )
 #define var_TriggerCallback(a,b) var_TriggerCallback( VLC_OBJECT(a), b )
 
-#define var_AddListCallback(a,b,c,d) var_AddListCallback( VLC_OBJECT(a), b, c, d )
-#define var_DelListCallback(a,b,c,d) var_DelListCallback( VLC_OBJECT(a), b, c, d )
+#define var_AddChoiceCallback(a,b,c,d) var_AddChoiceCallback( VLC_OBJECT(a), b, c, d )
+#define var_DelChoiceCallback(a,b,c,d) var_DelChoiceCallback( VLC_OBJECT(a), b, c, d )
 
 /*****************************************************************************
  * helpers functions
diff --git a/lib/media_player.c b/lib/media_player.c
index e43cab0..5424da0 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -905,9 +905,9 @@ libvlc_media_player_event_manager( libvlc_media_player_t *p_mi )
 
 static void add_es_callbacks( input_thread_t *p_input_thread, libvlc_media_player_t *p_mi )
 {
-    var_AddListCallback( p_input_thread, "video-es", input_es_changed, p_mi );
-    var_AddListCallback( p_input_thread, "audio-es", input_es_changed, p_mi );
-    var_AddListCallback( p_input_thread, "spu-es", input_es_changed, p_mi );
+    var_AddChoiceCallback( p_input_thread, "video-es", input_es_changed, p_mi );
+    var_AddChoiceCallback( p_input_thread, "audio-es", input_es_changed, p_mi );
+    var_AddChoiceCallback( p_input_thread, "spu-es", input_es_changed, p_mi );
     var_AddCallback( p_input_thread, "video-es", input_es_selected, p_mi );
     var_AddCallback( p_input_thread, "audio-es", input_es_selected, p_mi );
     var_AddCallback( p_input_thread, "spu-es", input_es_selected, p_mi );
@@ -915,9 +915,9 @@ static void add_es_callbacks( input_thread_t *p_input_thread, libvlc_media_playe
 
 static void del_es_callbacks( input_thread_t *p_input_thread, libvlc_media_player_t *p_mi )
 {
-    var_DelListCallback( p_input_thread, "video-es", input_es_changed, p_mi );
-    var_DelListCallback( p_input_thread, "audio-es", input_es_changed, p_mi );
-    var_DelListCallback( p_input_thread, "spu-es", input_es_changed, p_mi );
+    var_DelChoiceCallback( p_input_thread, "video-es", input_es_changed, p_mi );
+    var_DelChoiceCallback( p_input_thread, "audio-es", input_es_changed, p_mi );
+    var_DelChoiceCallback( p_input_thread, "spu-es", input_es_changed, p_mi );
     var_DelCallback( p_input_thread, "video-es", input_es_selected, p_mi );
     var_DelCallback( p_input_thread, "audio-es", input_es_selected, p_mi );
     var_DelCallback( p_input_thread, "spu-es", input_es_selected, p_mi );
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 574c62e..2784bd6 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -492,11 +492,11 @@ vlc_socketpair
 vlc_accept
 utf8_vfprintf
 var_AddCallback
-var_AddListCallback
+var_AddChoiceCallback
 var_Change
 var_Create
 var_DelCallback
-var_DelListCallback
+var_DelChoiceCallback
 var_Destroy
 var_FreeChoiceLists
 var_Get
diff --git a/src/misc/variables.c b/src/misc/variables.c
index 8c02822..5dd1b98 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -46,9 +46,9 @@ typedef struct callback_entry_t
 {
     union
     {
-        vlc_callback_t       pf_value_callback;
-        vlc_list_callback_t  pf_list_callback;
-        void *               p_callback;
+        vlc_callback_t          pf_value_callback;
+        vlc_choice_callback_t   pf_choice_callback;
+        void *                  p_callback;
     };
     void *         p_data;
 } callback_entry_t;
@@ -99,7 +99,7 @@ struct variable_t
     /** Registered value callbacks */
     callback_table_t    value_callbacks;
     /** Registered list callbacks */
-    callback_table_t    list_callbacks;
+    callback_table_t    choice_callbacks;
 };
 
 static int CmpBool( vlc_value_t v, vlc_value_t w )
@@ -256,16 +256,16 @@ static void TriggerCallback(vlc_object_t *obj, variable_t *var,
     vlc_cond_broadcast(&priv->var_wait);
 }
 
-static void TriggerListCallback(vlc_object_t *obj, variable_t *var,
-                                const char *name, int action, vlc_value_t *val)
+static void TriggerChoiceCallback(vlc_object_t *obj, variable_t *var,
+                                  const char *name, int action, vlc_value_t *val)
 {
     assert(obj != NULL);
 
-    size_t count = var->list_callbacks.i_entries;
+    size_t count = var->choice_callbacks.i_entries;
     if (count == 0)
         return;
 
-    callback_entry_t *entries = var->list_callbacks.p_entries;
+    callback_entry_t *entries = var->choice_callbacks.p_entries;
     vlc_object_internals_t *priv = vlc_internals(obj);
 
     assert(!var->b_incallback);
@@ -273,7 +273,7 @@ static void TriggerListCallback(vlc_object_t *obj, variable_t *var,
     vlc_mutex_unlock(&priv->var_lock);
 
     for (size_t i = 0; i < count; i++)
-        entries[i].pf_list_callback(obj, name, action, val,
+        entries[i].pf_choice_callback(obj, name, action, val,
                                       entries[i].p_data);
 
     vlc_mutex_lock(&priv->var_lock);
@@ -512,7 +512,8 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
                 ( p_val2 && p_val2->psz_string ) ?
                 strdup( p_val2->psz_string ) : NULL;
 
-            TriggerListCallback(p_this, p_var, psz_name, VLC_VAR_ADDCHOICE, p_val);
+            TriggerChoiceCallback(p_this, p_var, psz_name, VLC_VAR_ADDCHOICE,
+                                  p_val);
             break;
         }
         case VLC_VAR_DELCHOICE:
@@ -536,7 +537,8 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
             REMOVE_ELEM( p_var->choices_text.p_values,
                          p_var->choices_text.i_count, i );
 
-            TriggerListCallback(p_this, p_var, psz_name, VLC_VAR_DELCHOICE, p_val);
+            TriggerChoiceCallback(p_this, p_var, psz_name, VLC_VAR_DELCHOICE,
+                                  p_val);
             break;
         }
         case VLC_VAR_CHOICESCOUNT:
@@ -555,7 +557,8 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
             p_var->choices.p_values = NULL;
             p_var->choices_text.i_count = 0;
             p_var->choices_text.p_values = NULL;
-            TriggerListCallback(p_this, p_var, psz_name, VLC_VAR_CLEARCHOICES, NULL);
+            TriggerChoiceCallback(p_this, p_var, psz_name, VLC_VAR_CLEARCHOICES,
+                                  NULL);
             break;
         case VLC_VAR_SETVALUE:
             /* Duplicate data if needed */
@@ -822,7 +825,7 @@ int var_Get( vlc_object_t *p_this, const char *psz_name, vlc_value_t *p_val )
 typedef enum
 {
     vlc_value_callback,
-    vlc_list_callback
+    vlc_choice_callback
 } vlc_callback_type_t;
 
 static void AddCallback( vlc_object_t *p_this, const char *psz_name,
@@ -849,7 +852,7 @@ static void AddCallback( vlc_object_t *p_this, const char *psz_name,
     if (i_type == vlc_value_callback)
         p_table = &p_var->value_callbacks;
     else
-        p_table = &p_var->list_callbacks;
+        p_table = &p_var->choice_callbacks;
     INSERT_ELEM( p_table->p_entries,
                  p_table->i_entries,
                  p_table->i_entries,
@@ -913,7 +916,7 @@ static void DelCallback( vlc_object_t *p_this, const char *psz_name,
     if (i_type == vlc_value_callback)
         p_table = &p_var->value_callbacks;
     else
-        p_table = &p_var->list_callbacks;
+        p_table = &p_var->choice_callbacks;
 
     for( i_entry = p_table->i_entries ; i_entry-- ; )
     {
@@ -984,39 +987,39 @@ void var_TriggerCallback( vlc_object_t *p_this, const char *psz_name )
     vlc_mutex_unlock( &p_priv->var_lock );
 }
 
-#undef var_AddListCallback
+#undef var_AddChoiceCallback
 /**
- * Register a callback for a list variable
+ * Register a callback for a choice variable
  *
  * The callback is triggered when an element is added/removed from the
  * list or when the list is cleared.
  *
  * See var_AddCallback().
  */
-void var_AddListCallback( vlc_object_t *p_this, const char *psz_name,
-                          vlc_list_callback_t pf_callback, void *p_data )
+void var_AddChoiceCallback( vlc_object_t *p_this, const char *psz_name,
+                            vlc_choice_callback_t pf_callback, void *p_data )
 {
     callback_entry_t entry;
-    entry.pf_list_callback = pf_callback;
+    entry.pf_choice_callback = pf_callback;
     entry.p_data = p_data;
 
-    AddCallback(p_this, psz_name, entry, vlc_list_callback);
+    AddCallback(p_this, psz_name, entry, vlc_choice_callback);
 }
 
-#undef var_DelListCallback
+#undef var_DelChoiceCallback
 /**
- * Remove a callback from a list variable
+ * Remove a callback from a choice variable
  *
  * See var_DelCallback().
  */
-void var_DelListCallback( vlc_object_t *p_this, const char *psz_name,
-                          vlc_list_callback_t pf_callback, void *p_data )
+void var_DelChoiceCallback( vlc_object_t *p_this, const char *psz_name,
+                            vlc_choice_callback_t pf_callback, void *p_data )
 {
     callback_entry_t entry;
-    entry.pf_list_callback = pf_callback;
+    entry.pf_choice_callback = pf_callback;
     entry.p_data = p_data;
 
-    DelCallback(p_this, psz_name, entry, vlc_list_callback);
+    DelCallback(p_this, psz_name, entry, vlc_choice_callback);
 }
 
 /** Parse a stringified option
-- 
2.9.3



More information about the vlc-devel mailing list