[vlc-commits] objects: pick type ref counting at run-time

Rémi Denis-Courmont git at videolan.org
Sun Mar 17 02:39:07 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Mar 16 09:54:37 2019 +0200| [437eb19e4c17c31f0bc9f1261fdaad6b476c246d] | committer: Rémi Denis-Courmont

objects: pick type ref counting at run-time

In the medium term, using C++ inheritance would probably be better.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=437eb19e4c17c31f0bc9f1261fdaad6b476c246d
---

 include/vlc_objects.h | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/include/vlc_objects.h b/include/vlc_objects.h
index f0088d336d..733335b45f 100644
--- a/include/vlc_objects.h
+++ b/include/vlc_objects.h
@@ -164,12 +164,6 @@ static inline struct vlc_logger *vlc_object_logger(vlc_object_t *obj)
 #define vlc_object_find_name(a,b) \
     vlc_object_find_name( VLC_OBJECT(a),b)
 
-#define vlc_object_hold(a) \
-    vlc_object_hold( VLC_OBJECT(a) )
-
-#define vlc_object_release(a) \
-    vlc_object_release( VLC_OBJECT(a) )
-
 VLC_USED
 static inline libvlc_int_t *vlc_object_instance(vlc_object_t *obj)
 {
@@ -220,6 +214,34 @@ static inline void aout_Release(audio_output_t *aout)
 }
 
 
+/* TODO: remove vlc_object_hold/_release() for GUIs, remove this */
+VLC_DEPRECATED static inline void *vlc_object_hold_dyn(vlc_object_t *o)
+{
+    const char *tn = vlc_object_typename(o);
+
+    if (!strcmp(tn, "input"))
+        input_Hold((input_thread_t *)o);
+    if (!strcmp(tn, "audio output"))
+        aout_Hold((audio_output_t *)o);
+    if (!strcmp(tn, "video output"))
+        vout_Hold((vout_thread_t *)o);
+    return o;
+}
+#define vlc_object_hold(a) vlc_object_hold_dyn(a)
+
+static inline void vlc_object_release_dyn(vlc_object_t *o)
+{
+    const char *tn = vlc_object_typename(o);
+
+    if (!strcmp(tn, "input"))
+        input_Release((input_thread_t *)o);
+    if (!strcmp(tn, "audio output"))
+        aout_Release((audio_output_t *)o);
+    if (!strcmp(tn, "video output"))
+        vout_Release((vout_thread_t *)o);
+}
+#define vlc_object_release(a) vlc_object_release_dyn(a)
+
 /**
  * @defgroup objres Object resources
  *



More information about the vlc-commits mailing list