Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
6682c4ce by Thomas Guillem at 2023-10-27T12:42:48+00:00
tracer: rename vlc_TraceModuleCreate
Use vlc_tracer as a function prefix name
- - - - -
740f0c55 by Thomas Guillem at 2023-10-27T12:42:48+00:00
tracer: rework init/destroy from libvlc
No more deps to libvlc internal in tracer.c.
Add the ability to create a tracer from anywhere (for test/debug
purpose).
- - - - -
93e766ad by Thomas Guillem at 2023-10-27T12:42:48+00:00
tracer: declare the probe signature
- - - - -
4c1c6acb by Thomas Guillem at 2023-10-27T12:42:48+00:00
tracer: improve documentation
Create 3 subgroups: module, API and helpers.
- - - - -
c25f4612 by Thomas Guillem at 2023-10-27T12:42:48+00:00
tracer: pass module_name in vlc_tracer_Create()
Instead of fetching it internally.
- - - - -
ac3bd26b by Thomas Guillem at 2023-10-27T12:42:48+00:00
tracer: expose Create and Destroy functions
As the doc says:
This function is for advanced debugging/testing. Use
vlc_object_get_tracer() to get the existing tracer.
- - - - -
5 changed files:
- include/vlc_tracer.h
- src/libvlc.c
- src/libvlc.h
- src/libvlccore.sym
- src/misc/tracer.c
Changes:
=====================================
include/vlc_tracer.h
=====================================
@@ -29,15 +29,19 @@
#include <vlc_threads.h>
/**
- * \defgroup traces Tracing
+ * \defgroup tracer Tracer module and API
* \ingroup os
- * \brief Message traces
*
* Functions for modules to emit traces.
*
* @{
* \file
* Tracing functions
+ *
+ * \defgroup tracer_module Tracer Module implementation
+ * \ingroup tracer
+ *
+ * @{
*/
/**
@@ -70,20 +74,65 @@ struct vlc_tracer_entry
struct vlc_tracer;
/**
- * Trace logging callback signature.
- *
- * va-args can only be \ref vlc_tracer_entry and the va-args list
- * should be ended by a \ref vlc_tracer_entry with a NULL key.
- * \param data data pointer as provided to vlc_tracer_Trace().
+ * Tracer operations returned by the module probe function
*/
-typedef void (*vlc_trace_cb) (void *data, vlc_tick_t ts, va_list entries);
-
struct vlc_tracer_operations
{
- vlc_trace_cb trace;
- void (*destroy)(void *data);
+ /**
+ * Called when tracing data
+ *
+ * \param sys data pointer set by vlc_tracer_open_cb()
+ * \param ts timestamp of the trace (based on vlc_tick_now())
+ * \param entries can only be \ref vlc_tracer_entry and the va-args list
+ * should be ended by a \ref vlc_tracer_entry with a NULL key.
+ */
+ void (*trace)(void *sys, vlc_tick_t ts, va_list entries);
+
+ /**
+ * Called to clean module specific resources
+ *
+ * \param sys data pointer set by vlc_tracer_open_cb()
+ */
+ void (*destroy)(void *sys);
};
+/**
+ * Module probe/open function signature
+ *
+ * \param obj a valid object
+ * \param[out] sysp to module specific data
+ * \return the operations implemented by the module or NULL in case of error
+ * */
+typedef struct vlc_tracer_operations *(*vlc_tracer_open_cb)(vlc_object_t *obj,
+ void **restrict
sysp);
+
+/**
+ * @}
+ *
+ * \defgroup tracer_api Tracer API
+ * \ingroup tracer
+ *
+ * @{
+ */
+
+/**
+ * Create a tracer object
+ *
+ * \note This function is for advanced debugging/testing.
+ * Use vlc_object_get_tracer() to get the existing tracer.
+ *
+ * \param parent parent object used to create the tracer
+ * \param name module to load or NULL for the default one
+ * \return a valid tracer or NULL in case of error
+ */
+VLC_API struct vlc_tracer *vlc_tracer_Create(vlc_object_t *parent,
+ const char *name);
+
+/**
+ * Destroy a tracer object
+ */
+VLC_API void vlc_tracer_Destroy(struct vlc_tracer *tracer);
+
/**
* Emit traces
*
@@ -99,13 +148,6 @@ VLC_API void vlc_tracer_TraceWithTs(struct vlc_tracer
*tracer, vlc_tick_t ts, ..
#define vlc_tracer_Trace(tracer, ...) \
vlc_tracer_TraceWithTs(tracer, vlc_tick_now(), __VA_ARGS__)
-/**
- * \defgroup tracer Tracer
- * \brief Tracing back-end.
- *
- * @{
- */
-
static inline struct vlc_tracer_entry vlc_tracer_entry_FromInt(const char
*key, int64_t value)
{
vlc_tracer_value_t tracer_value;
@@ -163,8 +205,13 @@ static inline struct vlc_tracer_entry VLC_TRACE(const char
*key, const char *val
#define VLC_TRACE_TICK_NS(key, tick) VLC_TRACE((key), NS_FROM_VLC_TICK((tick)))
-/*
- * Helper trace functions
+/**
+ * @}
+ *
+ * \defgroup tracer_helper Tracer helper functions
+ * \ingroup tracer
+ *
+ * @{
*/
static inline void vlc_tracer_TraceStreamPTS(struct vlc_tracer *tracer, const
char *type,
=====================================
src/libvlc.c
=====================================
@@ -63,6 +63,7 @@
#include <vlc_modules.h>
#include <vlc_media_library.h>
#include <vlc_thumbnailer.h>
+#include <vlc_tracer.h>
#include "libvlc.h"
@@ -180,7 +181,10 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int
i_argc,
}
vlc_LogInit(p_libvlc);
- vlc_tracer_Init(p_libvlc);
+
+ char *tracer_name = var_InheritString(p_libvlc, "tracer");
+ priv->tracer = vlc_tracer_Create(VLC_OBJECT(p_libvlc), tracer_name);
+ free(tracer_name);
/*
* Support for gettext
@@ -394,7 +398,8 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
config_AutoSaveConfigFile( p_libvlc );
vlc_LogDestroy(p_libvlc->obj.logger);
- vlc_tracer_Destroy(p_libvlc);
+ if (priv->tracer != NULL)
+ vlc_tracer_Destroy(priv->tracer);
/* Free module bank. It is refcounted, so we call this each time */
module_EndBank (true);
#if defined(_WIN32) || defined(__OS2__)
=====================================
src/libvlc.h
=====================================
@@ -53,18 +53,11 @@ void vlc_trace (const char *fn, const char *file, unsigned
line);
* Logging
*/
typedef struct vlc_logger vlc_logger_t;
+typedef struct vlc_tracer vlc_tracer_t;
int vlc_LogPreinit(libvlc_int_t *) VLC_USED;
void vlc_LogInit(libvlc_int_t *);
-/*
- * Tracing
- */
-typedef struct vlc_tracer vlc_tracer_t;
-
-void vlc_tracer_Init(libvlc_int_t *);
-void vlc_tracer_Destroy(libvlc_int_t *);
-
/*
* LibVLC exit event handling
*/
=====================================
src/libvlccore.sym
=====================================
@@ -290,6 +290,8 @@ vlc_ntp_time
vlc_Log
vlc_LogSet
vlc_vaLog
+vlc_tracer_Create
+vlc_tracer_Destroy
vlc_tracer_TraceWithTs
vlc_LogHeaderCreate
vlc_LogDestroy
=====================================
src/misc/tracer.c
=====================================
@@ -61,8 +61,7 @@ void vlc_tracer_TraceWithTs(struct vlc_tracer *tracer,
vlc_tick_t ts, ...)
static int vlc_tracer_load(void *func, bool forced, va_list ap)
{
- const struct vlc_tracer_operations *(*activate)(vlc_object_t *,
- void **) = func;
+ vlc_tracer_open_cb activate = func;
struct vlc_tracer_module *module = va_arg(ap, struct vlc_tracer_module *);
(void) forced;
@@ -70,7 +69,7 @@ static int vlc_tracer_load(void *func, bool forced, va_list
ap)
return (module->tracer.ops != NULL) ? VLC_SUCCESS : VLC_EGENERIC;
}
-static struct vlc_tracer *vlc_TraceModuleCreate(vlc_object_t *parent)
+struct vlc_tracer *vlc_tracer_Create(vlc_object_t *parent, const char
*module_name)
{
struct vlc_tracer_module *module;
@@ -78,36 +77,19 @@ static struct vlc_tracer
*vlc_TraceModuleCreate(vlc_object_t *parent)
if (unlikely(module == NULL))
return NULL;
- char *module_name = var_InheritString(parent, "tracer");
if (vlc_module_load(vlc_object_logger(module), "tracer", module_name,
false,
vlc_tracer_load, module) == NULL) {
vlc_object_delete(VLC_OBJECT(module));
- free(module_name);
return NULL;
}
- free(module_name);
return &module->tracer;
}
-/**
- * Initializes the messages tracing system */
-void vlc_tracer_Init(libvlc_int_t *vlc)
-{
- struct vlc_tracer *tracer = vlc_TraceModuleCreate(VLC_OBJECT(vlc));
- libvlc_priv_t *vlc_priv = libvlc_priv(vlc);
- vlc_priv->tracer = tracer;
-}
-
-void vlc_tracer_Destroy(libvlc_int_t *vlc)
+void vlc_tracer_Destroy(struct vlc_tracer *tracer)
{
- libvlc_priv_t *vlc_priv = libvlc_priv(vlc);
-
- if (vlc_priv->tracer == NULL)
- return;
-
struct vlc_tracer_module *module =
- container_of(vlc_priv->tracer, struct vlc_tracer_module, tracer);
+ container_of(tracer, struct vlc_tracer_module, tracer);
if (module->tracer.ops->destroy != NULL)
module->tracer.ops->destroy(module->opaque);
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/409e9fc82cac40899daf4923b81a1a4d5de8b767...ac3bd26b700377da9e4ea8e00d95b84dcb6ff705
--
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/409e9fc82cac40899daf4923b81a1a4d5de8b767...ac3bd26b700377da9e4ea8e00d95b84dcb6ff705
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits