/*****************************************************************************
* Prototypes
*****************************************************************************/
-VLC_API void msg_Generic( vlc_object_t *, int, const char *, const char *, ... ) VLC_FORMAT( 4, 5 );
-VLC_API void msg_GenericVa( vlc_object_t *, int, const char *, const char *, va_list args );
-#define msg_GenericVa(a, b, c, d, e) msg_GenericVa(VLC_OBJECT(a), b, c, d, e)
+VLC_API void vlc_Log(vlc_object_t *, int,
+ const char *, const char *, ...) VLC_FORMAT( 4, 5 );
+VLC_API void vlc_vaLog(vlc_object_t *, int,
+ const char *, const char *, va_list);
+#define msg_GenericVa(a, b, c, d, e) vlc_vaLog(VLC_OBJECT(a), b, c, d, e)
#define msg_Info( p_this, ... ) \
- msg_Generic( VLC_OBJECT(p_this), VLC_MSG_INFO, \
- MODULE_STRING, __VA_ARGS__ )
+ vlc_Log( VLC_OBJECT(p_this), VLC_MSG_INFO, MODULE_STRING, __VA_ARGS__ )
#define msg_Err( p_this, ... ) \
- msg_Generic( VLC_OBJECT(p_this), VLC_MSG_ERR, \
- MODULE_STRING, __VA_ARGS__ )
+ vlc_Log( VLC_OBJECT(p_this), VLC_MSG_ERR, MODULE_STRING, __VA_ARGS__ )
#define msg_Warn( p_this, ... ) \
- msg_Generic( VLC_OBJECT(p_this), VLC_MSG_WARN, \
- MODULE_STRING, __VA_ARGS__ )
+ vlc_Log( VLC_OBJECT(p_this), VLC_MSG_WARN, MODULE_STRING, __VA_ARGS__ )
#define msg_Dbg( p_this, ... ) \
- msg_Generic( VLC_OBJECT(p_this), VLC_MSG_DBG, \
- MODULE_STRING, __VA_ARGS__ )
+ vlc_Log( VLC_OBJECT(p_this), VLC_MSG_DBG, MODULE_STRING, __VA_ARGS__ )
typedef struct msg_cb_data_t msg_cb_data_t;
*/
typedef void (*msg_callback_t) (msg_cb_data_t *, const msg_item_t *);
-VLC_API msg_subscription_t* msg_Subscribe( libvlc_int_t *, msg_callback_t, msg_cb_data_t * ) VLC_USED;
-VLC_API void msg_Unsubscribe( msg_subscription_t * );
+VLC_API msg_subscription_t *vlc_Subscribe(msg_callback_t, msg_cb_data_t *) VLC_USED;
+VLC_API void vlc_Unsubscribe(msg_subscription_t *);
/**
* @}
memset( p_intf->p_sys, 0, sizeof( *p_intf->p_sys ) );
/* subscribe to LibVLCCore's messages */
- p_intf->p_sys->p_sub = msg_Subscribe( p_intf->p_libvlc, MsgCallback, NULL );
+ p_intf->p_sys->p_sub = vlc_Subscribe( MsgCallback, NULL );
p_intf->pf_run = Run;
p_intf->b_should_run_on_first_thread = true;
[o_mainwindow release];
/* unsubscribe from libvlc's debug messages */
- msg_Unsubscribe( p_intf->p_sys->p_sub );
+ vlc_Unsubscribe( p_intf->p_sys->p_sub );
[o_msg_arr removeAllObjects];
[o_msg_arr release];
memset(p_sys->msgs, 0, sizeof p_sys->msgs);
p_sys->i_msgs = 0;
p_sys->i_verbosity = var_InheritInteger(p_intf, "verbose");
- p_sys->p_sub = msg_Subscribe(p_intf->p_libvlc, MsgCallback, msg_cb_data);
+ p_sys->p_sub = vlc_Subscribe(MsgCallback, msg_cb_data);
p_sys->i_box_type = BOX_PLAYLIST;
p_sys->b_plidx_follow = true;
endwin(); /* Close the ncurses interface */
- msg_Unsubscribe(p_sys->p_sub);
+ vlc_Unsubscribe(p_sys->p_sub);
vlc_mutex_destroy(&p_sys->msg_lock);
vlc_mutex_destroy(&p_sys->pl_lock);
for(unsigned i = 0; i < sizeof p_sys->msgs / sizeof *p_sys->msgs; i++)
/* Hook up to LibVLC messaging */
cbData = new msg_cb_data_t;
cbData->self = this;
- sub = msg_Subscribe( p_intf->p_libvlc, MsgCallback, cbData );
+ sub = vlc_Subscribe( MsgCallback, cbData );
}
MessagesDialog::~MessagesDialog()
{
writeSettings( "Messages" );
- msg_Unsubscribe( sub );
+ vlc_Unsubscribe( sub );
delete cbData;
};
// Suscribe to messages bank
#if 0
- p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
+ p_intf->p_sys->p_sub = vlc_Subscribe( p_intf );
#endif
p_intf->p_sys->p_input = NULL;
// Unsubscribe from messages bank
#if 0
- msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
+ vlc_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
#endif
// Destroy structure
#endif
}
- p_sys->p_sub = msg_Subscribe( p_intf->p_libvlc, Overflow, &p_sys->msg );
+ p_sys->p_sub = vlc_Subscribe( Overflow, &p_sys->msg );
return 0;
}
/* Flush the queue and unsubscribe from the message queue */
/* FIXME: flush */
- msg_Unsubscribe( p_sys->p_sub );
+ vlc_Unsubscribe( p_sys->p_sub );
switch( p_sys->msg.i_mode )
{
vlc_spin_init( &p_log->data.lock );
p_log->data.count = 0;
p_log->data.verbosity = p_instance->verbosity;
- p_log->p_messages = msg_Subscribe(p_instance->p_libvlc_int, handler, &p_log->data);
+ p_log->p_messages = vlc_Subscribe(handler, &p_log->data);
if( !p_log->p_messages )
{
return;
assert( p_log->p_messages );
- msg_Unsubscribe(p_log->p_messages);
+ vlc_Unsubscribe(p_log->p_messages);
libvlc_release( p_log->p_instance );
libvlc_log_clear( p_log );
vlc_spin_destroy( &p_log->data.lock );
module_unneed
vlc_module_load
vlc_module_unload
-msg_Generic
-msg_GenericVa
-msg_Subscribe
-msg_Unsubscribe
+vlc_Log
+vlc_vaLog
+vlc_Subscribe
+vlc_Unsubscribe
msleep
mstrtime
mwait
* @param opaque data for the callback function
* @return a subscription pointer, or NULL in case of failure
*/
-msg_subscription_t *msg_Subscribe (libvlc_int_t *instance, msg_callback_t cb,
- msg_cb_data_t *opaque)
+msg_subscription_t *vlc_Subscribe (msg_callback_t cb, msg_cb_data_t *opaque)
{
msg_subscription_t *sub = malloc (sizeof (*sub));
if (sub == NULL)
* Unsubscribe from the message queue.
* This function waits for the message callback to return if needed.
*/
-void msg_Unsubscribe (msg_subscription_t *sub)
+void vlc_Unsubscribe (msg_subscription_t *sub)
{
vlc_rwlock_wrlock (&msg_lock);
if (sub->next != NULL)
free (sub);
}
-/*****************************************************************************
- * msg_*: print a message
- *****************************************************************************
- * These functions queue a message for later printing.
- *****************************************************************************/
-void msg_Generic( vlc_object_t *p_this, int i_type, const char *psz_module,
- const char *psz_format, ... )
+/**
+ * Emit a log message.
+ * \param obj VLC object emitting the message
+ * \param type VLC_MSG_* message type (info, error, warning or debug)
+ * \param module name of module from which the message come
+ * (normally MODULE_STRING)
+ * \param format printf-like message format
+ */
+void vlc_Log (vlc_object_t *obj, int type, const char *module,
+ const char *format, ... )
{
va_list args;
- va_start( args, psz_format );
- msg_GenericVa (p_this, i_type, psz_module, psz_format, args);
- va_end( args );
+ va_start (args, format);
+ vlc_vaLog (obj, type, module, format, args);
+ va_end (args);
}
-#undef msg_GenericVa
/**
- * Add a message to a queue
- *
- * This function provides basic functionnalities to other msg_* functions.
- * It adds a message to a queue (after having printed all stored messages if it
- * is full). If the message can't be converted to string in memory, it issues
- * a warning.
+ * Emit a log message. This function is the variable argument list equivalent
+ * to vlc_Log().
*/
-void msg_GenericVa (vlc_object_t *p_this, int i_type, const char *psz_module,
- const char *psz_format, va_list args)
+void vlc_vaLog (vlc_object_t *obj, int type, const char *module,
+ const char *format, va_list args)
{
- assert (p_this);
+ assert (obj != NULL);
- if( p_this->i_flags & OBJECT_FLAGS_QUIET )
+ if (obj->i_flags & OBJECT_FLAGS_QUIET)
return;
/* C locale to get error messages in English in the logs */
#ifndef __GLIBC__
/* Expand %m to strerror(errno) - only once */
- char buf[strlen( psz_format ) + 2001], *ptr;
- strcpy( buf, psz_format );
+ char buf[strlen(format) + 2001], *ptr;
+ strcpy (buf, format);
ptr = (char*)buf;
- psz_format = (const char*) buf;
+ format = (const char*) buf;
for( ;; )
{
static const char nomemstr[] = "<not enough memory to format message>";
char *str;
- if (unlikely(vasprintf (&str, psz_format, args) == -1))
+ if (unlikely(vasprintf (&str, format, args) == -1))
str = (char *)nomemstr;
uselocale (locale);
/* Fill message information fields */
msg_item_t msg;
- msg.i_type = i_type;
- msg.i_object_id = (uintptr_t)p_this;
- msg.psz_object_type = p_this->psz_object_type;
- msg.psz_module = psz_module;
+ msg.i_type = type;
+ msg.i_object_id = (uintptr_t)obj;
+ msg.psz_object_type = obj->psz_object_type;
+ msg.psz_module = module;
msg.psz_msg = str;
msg.psz_header = NULL;
- for (vlc_object_t *o = p_this; o != NULL; o = o->p_parent)
+ for (vlc_object_t *o = obj; o != NULL; o = o->p_parent)
if (o->psz_header != NULL)
{
msg.psz_header = o->psz_header;
break;
}
- PrintMsg( p_this, &msg );
+ PrintMsg (obj, &msg);
vlc_rwlock_rdlock (&msg_lock);
for (msg_subscription_t *sub = msg_head; sub != NULL; sub = sub->next)