[vlc-commits] objects: get module name from the variable
Rémi Denis-Courmont
git at videolan.org
Mon Mar 4 17:30:52 CET 2019
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Mar 4 18:30:06 2019 +0200| [a51089e4eb3f007367a00ccf006615cf300b3f08] | committer: Rémi Denis-Courmont
objects: get module name from the variable
This is still as racy as before, but at least it does not serialize
against a global lock.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a51089e4eb3f007367a00ccf006615cf300b3f08
---
include/vlc_objects.h | 13 ++++++++++++-
src/libvlccore.sym | 1 -
src/misc/objects.c | 6 ------
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/include/vlc_objects.h b/include/vlc_objects.h
index 49833962e8..56282b2ef5 100644
--- a/include/vlc_objects.h
+++ b/include/vlc_objects.h
@@ -112,7 +112,18 @@ VLC_API const char *vlc_object_typename(const vlc_object_t *obj) VLC_USED;
VLC_API vlc_object_t *vlc_object_parent(vlc_object_t *obj) VLC_USED;
#define vlc_object_parent(o) vlc_object_parent(VLC_OBJECT(o))
-VLC_API char *vlc_object_get_name( const vlc_object_t * ) VLC_USED;
+/**
+ * Tries to get the name of module bound to an object.
+ *
+ * \warning This function is intrinsically race-prone, as a module may be
+ * bound or unbound asynchronously by another thread.
+ * Do not trust the result for any purpose other than debugging/tracing.
+ *
+ * \return Normally, this returns a heap-allocated nul-terminated string
+ * which is the name of the module. If no module are bound to the object, it
+ * returns NULL. It also returns NULL on error.
+ */
+#define vlc_object_get_name(obj) var_GetString(obj, "module-name")
#define vlc_object_create(a,b) vlc_object_create( VLC_OBJECT(a), b )
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index ef9e2d5561..202a6a1d21 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -676,7 +676,6 @@ vlc_object_hold
vlc_object_release
vlc_object_typename
vlc_object_parent
-vlc_object_get_name
vlc_once
vlc_rand_bytes
vlc_drand48
diff --git a/src/misc/objects.c b/src/misc/objects.c
index 2790cc05fd..d680fd2f0e 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -312,12 +312,6 @@ int vlc_object_set_name(vlc_object_t *obj, const char *name)
return VLC_SUCCESS;
}
-char *vlc_object_get_name(const vlc_object_t *obj)
-{
- assert(obj != NULL);
- return NULL;
-}
-
/**
* Destroys a VLC object once it has no more references.
*
More information about the vlc-commits
mailing list