[vlc-devel] [PATCH 1/2] libvlc: added a formatted log callback

Rémi Denis-Courmont remi at remlab.net
Sat May 18 09:29:08 CEST 2019


Le perjantaina 17. toukokuuta 2019, 11.05.00 EEST Jérémy VIGNELLES a écrit :
> ---
>  include/vlc/libvlc.h | 64 ++++++++++++++++++++++++++++++++++++++++++++
>  lib/libvlc.sym       |  3 +++
>  lib/log.c            | 55 +++++++++++++++++++++++++++++++++++++
>  3 files changed, 122 insertions(+)
> 
> diff --git a/include/vlc/libvlc.h b/include/vlc/libvlc.h
> index 1c2550fe3b..1b21c2da66 100644
> --- a/include/vlc/libvlc.h
> +++ b/include/vlc/libvlc.h
> @@ -433,6 +433,26 @@ LIBVLC_API void libvlc_log_get_object(const
> libvlc_log_t *ctx, typedef void (*libvlc_log_cb)(void *data, int level,
> const libvlc_log_t *ctx, const char *fmt, va_list args);
> 
> +/**
> + * Callback prototype for LibVLC preformatted log message handler.
> + *
> + * \param data data pointer as given to libvlc_log_set()
> + * \param level message level (@ref libvlc_log_level)
> + * \param ctx message context (meta-information about the message)
> + * \param message the message, already formatted
> + * \note Log message handlers <b>must</b> be thread-safe.
> + * \warning The message context pointer, and the message string parameters
> + *          are only valid until the callback returns.
> + */
> +typedef void (*libvlc_log_preformatted_cb)(void *data, int level, const
> libvlc_log_t *ctx, +                              const char *message);

There is no logic there. Many languages will either not support callbacks at 
all, or have no ways to make them thread safe, or will be unable to marshall 
pointers from callbacks, etc.

And the libvlc_log_t is definitely not supported in higher level languages, 
neither are many other compound types. In fact, even 'int' is iffy, since 
typically only fixed-size types are handeld.

We *used* to have a log API that was "easy" to call from other languages. We 
removed it because it was so incredibly broken and intrinsically unfixable.

LibVLC is not, or rather no longer for a decade or so, meant to be called 
directly from foreign interfaces.

-- 
Rémi Denis-Courmont
http://www.remlab.net/





More information about the vlc-devel mailing list