]> git.sesse.net Git - vlc/commitdiff
Fix namespace, remove useless variable and clean up msg_* functions()
authorRémi Denis-Courmont <remi@remlab.net>
Fri, 19 Aug 2011 18:38:16 +0000 (21:38 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Fri, 19 Aug 2011 20:38:37 +0000 (23:38 +0300)
include/vlc_messages.h
modules/gui/macosx/intf.m
modules/gui/ncurses.c
modules/gui/qt4/dialogs/messages.cpp
modules/gui/skins2/src/skin_main.cpp
modules/misc/logger.c
src/control/log.c
src/libvlccore.sym
src/misc/messages.c

index fd195425cbfaad54e43b227bb71e075b25e68b88..9f8ffde160cc57790efe21a5ee87e7147e624009 100644 (file)
@@ -93,22 +93,20 @@ typedef struct msg_subscription_t msg_subscription_t;
 /*****************************************************************************
  * 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;
 
@@ -118,8 +116,8 @@ 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 *);
 
 /**
  * @}
index b266baea11fbdbd3c29183892a3a4bd2927b8edf..cf1457ed881770a5e97515bc615de7b723627464 100644 (file)
@@ -102,7 +102,7 @@ int OpenIntf ( vlc_object_t *p_this )
     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;
 
@@ -721,7 +721,7 @@ static VLCMain *_o_sharedMainInstance = nil;
     [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];
index fdcec38d10db8835f9a622edfea2c8871356d225..d5d4cb84fa3c3b23f184c08f020680b4de34adab 100644 (file)
@@ -1901,7 +1901,7 @@ static int Open(vlc_object_t *p_this)
     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;
@@ -1956,7 +1956,7 @@ static void Close(vlc_object_t *p_this)
 
     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++)
index 92cc6af30f98725b7e7645a3651a7c8f2d73dce1..cca9738f924f181ff9378dff6d4cec49853502b4 100644 (file)
@@ -128,13 +128,13 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
     /* 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;
 };
 
index 3631929ece3596074b37c0a7a2e6f3347681fddd..8d0dceb579ae0339839853ff41db4f84bc652210 100644 (file)
@@ -83,7 +83,7 @@ static int Open( vlc_object_t *p_this )
 
     // 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;
@@ -152,7 +152,7 @@ static void Close( vlc_object_t *p_this )
 
     // 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
index 0fe5459a0cf6871cc02099eaf2a3ca126950475c..14357645a1e51711e301942c4a0da80a262bfdc5 100644 (file)
@@ -322,7 +322,7 @@ static int Open( vlc_object_t *p_this )
 #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;
 }
@@ -337,7 +337,7 @@ static void Close( vlc_object_t *p_this )
 
     /* 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 )
     {
index 1caf9d05926c5fa8024aa2fec1c36090564cd233..dc81a35934ccb4f7d4710954af53ae383c62fd82 100644 (file)
@@ -100,7 +100,7 @@ libvlc_log_t *libvlc_log_open( libvlc_instance_t *p_instance )
     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 )
     {
@@ -119,7 +119,7 @@ void libvlc_log_close( libvlc_log_t *p_log )
         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 );
index 42c002d274091ef4056fd119d610b5600303d646..74c8e140877c96abb159c9b568294cb4386673dc 100644 (file)
@@ -275,10 +275,10 @@ module_provides
 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
index 93fcee503002956b59b03979e54d6e5ebdc691e2..74aeabf6236f3adc6f890f13dc23daf4a178cd42 100644 (file)
@@ -78,8 +78,7 @@ struct msg_subscription_t
  * @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)
@@ -101,7 +100,7 @@ msg_subscription_t *msg_Subscribe (libvlc_int_t *instance, msg_callback_t cb,
  * 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)
@@ -117,36 +116,34 @@ void msg_Unsubscribe (msg_subscription_t *sub)
     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 */
@@ -155,10 +152,10 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type, const char *psz_module,
 
 #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( ;; )
     {
@@ -213,7 +210,7 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type, const char *psz_module,
     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);
@@ -222,21 +219,21 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type, const char *psz_module,
     /* 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)