[vlc-commits] objects: inherit logger pointer

Rémi Denis-Courmont git at videolan.org
Wed Feb 20 19:06:38 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Feb 19 18:51:16 2019 +0200| [c9680947df9ae957effd6014756dede7787815fc] | committer: Rémi Denis-Courmont

objects: inherit logger pointer

At this point, this merely avoids iterating up the objects tree to log
messages. Effectively, the logger pointer takes the place of the libvlc
instance pointer.

Going forward, this should be usable to override logging on a sub-tree.

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

 include/vlc_objects.h | 4 ++++
 src/misc/messages.c   | 8 +++-----
 src/misc/objects.c    | 1 +
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/vlc_objects.h b/include/vlc_objects.h
index 4fdd2c851a..4b77da962e 100644
--- a/include/vlc_objects.h
+++ b/include/vlc_objects.h
@@ -28,6 +28,8 @@
  * Common VLC object defintions
  */
 
+struct vlc_logger;
+
 /**
  * VLC object common members
  *
@@ -37,6 +39,8 @@
  */
 struct vlc_common_members
 {
+    struct vlc_logger *logger;
+
     /** Log messages header
      *
      * Human-readable header for log messages. This is not thread-safe and
diff --git a/src/misc/messages.c b/src/misc/messages.c
index 90d24a95c9..340e13bba2 100644
--- a/src/misc/messages.c
+++ b/src/misc/messages.c
@@ -128,11 +128,8 @@ void vlc_vaLog (vlc_object_t *obj, int type, const char *module,
 #endif
 
     /* Pass message to the callback */
-    if (obj != NULL) {
-        vlc_logger_t *logger = libvlc_priv(vlc_object_instance(obj))->logger;
-
-        vlc_vaLogCallback(logger, type, &msg, format, args);
-    }
+    if (obj != NULL)
+        vlc_vaLogCallback(obj->obj.logger, type, &msg, format, args);
 }
 
 /**
@@ -464,6 +461,7 @@ int vlc_LogPreinit(libvlc_int_t *vlc)
     }
 
     libvlc_priv(vlc)->logger = logger;
+    vlc->obj.logger = logger;
 
     const struct vlc_logger_operations *ops;
     void *opaque;
diff --git a/src/misc/objects.c b/src/misc/objects.c
index c2354d2324..5a48f97e52 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -220,6 +220,7 @@ void *vlc_custom_create (vlc_object_t *parent, size_t length,
     {
         vlc_object_internals_t *papriv = vlc_internals (parent);
 
+        obj->obj.logger = parent->obj.logger;
         obj->obj.flags = parent->obj.flags;
 
         /* Attach the child to its parent (no lock needed) */



More information about the vlc-commits mailing list