[vlc-devel] commit: Store the object type name rather than object type ID within log messages. ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue Mar 25 22:16:32 CET 2008


vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Tue Mar 25 23:14:57 2008 +0200| [6c52c72bfbfb9c63fd1fb6e2b7e762fbabf49591]

Store the object type name rather than object type ID within log messages.

This remove the triplicated id to name conversion and saves many lookups.
It also removes the obnoxious "private" messages.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6c52c72bfbfb9c63fd1fb6e2b7e762fbabf49591
---

 include/vlc_messages.h              |    4 +---
 modules/gui/beos/MessagesWindow.cpp |   17 ++---------------
 src/control/log.c                   |    2 +-
 src/libvlc.sym                      |    1 -
 src/misc/messages.c                 |   35 +++--------------------------------
 5 files changed, 7 insertions(+), 52 deletions(-)

diff --git a/include/vlc_messages.h b/include/vlc_messages.h
index 4eee1dc..54085ba 100644
--- a/include/vlc_messages.h
+++ b/include/vlc_messages.h
@@ -59,7 +59,7 @@ typedef struct
 {
     int     i_type;                             /**< message type, see below */
     int     i_object_id;
-    int     i_object_type;
+    const char *psz_object_type;
     char *  psz_module;
     char *  psz_msg;                            /**< the message itself */
     char *  psz_header;                         /**< Additional header */
@@ -161,8 +161,6 @@ void __msg_Destroy ( vlc_object_t * );
 VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t *, int ) );
 VLC_EXPORT( void, __msg_Unsubscribe, ( vlc_object_t *, msg_subscription_t * ) );
 
-VLC_EXPORT(const char *, msg_GetObjectTypeName, (int i_object_type ));
-
 /**
  * @}
  */
diff --git a/modules/gui/beos/MessagesWindow.cpp b/modules/gui/beos/MessagesWindow.cpp
index b105867..22ebedb 100644
--- a/modules/gui/beos/MessagesWindow.cpp
+++ b/modules/gui/beos/MessagesWindow.cpp
@@ -54,7 +54,7 @@ void MessagesView::Pulse()
     }
 
     int i_start, oldLength;
-    char * psz_module_type = NULL;
+    const char * psz_module_type = NULL;
     rgb_color red = { 200, 0, 0 };
     rgb_color gray = { 150, 150, 150 };
     rgb_color green = { 0, 150, 0 };
@@ -80,20 +80,7 @@ void MessagesView::Pulse()
                 case VLC_MSG_DBG: color = gray; break;
             }
 
-            switch( p_sub->p_msg[i_start].i_object_type )
-            {
-                case VLC_OBJECT_ROOT: psz_module_type = "root"; break;
-                case VLC_OBJECT_VLC: psz_module_type = "vlc"; break;
-                case VLC_OBJECT_MODULE: psz_module_type = "module"; break;
-                case VLC_OBJECT_INTF: psz_module_type = "interface"; break;
-                case VLC_OBJECT_PLAYLIST: psz_module_type = "playlist"; break;
-                case VLC_OBJECT_ITEM: psz_module_type = "item"; break;
-                case VLC_OBJECT_INPUT: psz_module_type = "input"; break;
-                case VLC_OBJECT_DECODER: psz_module_type = "decoder"; break;
-                case VLC_OBJECT_VOUT: psz_module_type = "video output"; break;
-                case VLC_OBJECT_AOUT: psz_module_type = "audio output"; break;
-                case VLC_OBJECT_SOUT: psz_module_type = "stream output"; break;
-            }
+            psz_module_type = p_sub->p_msg[i_start].psz_object_type;
 
             if( LockLooper() )
             {
diff --git a/src/control/log.c b/src/control/log.c
index 2fcdbf0..8cfb3c8 100644
--- a/src/control/log.c
+++ b/src/control/log.c
@@ -172,7 +172,7 @@ libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
                 vlc_mutex_lock(p_iter->p_messages->p_lock);
                 msg = p_iter->p_messages->p_msg+i_pos;
                 buffer->i_severity  = msg->i_type;
-                buffer->psz_type    = msg_GetObjectTypeName(msg->i_object_type);
+                buffer->psz_type    = msg->psz_object_type;
                 buffer->psz_name    = msg->psz_module;
                 buffer->psz_header  = msg->psz_header;
                 buffer->psz_message = msg->psz_msg;
diff --git a/src/libvlc.sym b/src/libvlc.sym
index afb2104..a6e28fc 100644
--- a/src/libvlc.sym
+++ b/src/libvlc.sym
@@ -173,7 +173,6 @@ __msg_Dbg
 __msg_Err
 __msg_Generic
 __msg_GenericVa
-msg_GetObjectTypeName
 __msg_Info
 __msg_Subscribe
 __msg_Unsubscribe
diff --git a/src/misc/messages.c b/src/misc/messages.c
index 3fc0f03..7721fc4 100644
--- a/src/misc/messages.c
+++ b/src/misc/messages.c
@@ -197,35 +197,6 @@ void __msg_Unsubscribe( vlc_object_t *p_this, msg_subscription_t *p_sub )
     UNLOCK_BANK;
 }
 
-const char *msg_GetObjectTypeName(int i_object_type )
-{
-    switch( i_object_type )
-    {
-        case VLC_OBJECT_GLOBAL: return "global";
-        case VLC_OBJECT_LIBVLC: return "libvlc";
-        case VLC_OBJECT_MODULE: return "module";
-        case VLC_OBJECT_INTF: return "interface";
-        case VLC_OBJECT_PLAYLIST: return "playlist";
-        case VLC_OBJECT_ITEM: return "item";
-        case VLC_OBJECT_INPUT: return "input";
-        case VLC_OBJECT_DECODER: return "decoder";
-        case VLC_OBJECT_PACKETIZER: return "packetizer";
-        case VLC_OBJECT_ENCODER: return "encoder";
-        case VLC_OBJECT_VOUT: return "video output";
-        case VLC_OBJECT_AOUT: return "audio output";
-        case VLC_OBJECT_SOUT: return "stream output";
-        case VLC_OBJECT_HTTPD: return "http server";
-        case VLC_OBJECT_HTTPD_HOST: return "http server";
-        case VLC_OBJECT_DIALOGS: return "dialogs provider";
-        case VLC_OBJECT_VLM: return "vlm";
-        case VLC_OBJECT_ANNOUNCE: return "announce handler";
-        case VLC_OBJECT_DEMUX: return "demuxer";
-        case VLC_OBJECT_ACCESS: return "access";
-        case VLC_OBJECT_META_ENGINE: return "meta engine";
-        default: return "private";
-    }
-}
-
 /*****************************************************************************
  * __msg_*: print a message
  *****************************************************************************
@@ -479,7 +450,7 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue, int i_type,
 
                 p_item->i_type =        VLC_MSG_WARN;
                 p_item->i_object_id =   p_this->i_object_id;
-                p_item->i_object_type = p_this->i_object_type;
+                p_item->psz_object_type = p_this->psz_object_type;
                 p_item->psz_module =    strdup( "message" );
                 p_item->psz_msg =       strdup( "message queue overflowed" );
                 p_item->psz_header =    NULL;
@@ -501,7 +472,7 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue, int i_type,
     /* Fill message information fields */
     p_item->i_type =        i_type;
     p_item->i_object_id =   p_this->i_object_id;
-    p_item->i_object_type = p_this->i_object_type;
+    p_item->psz_object_type = p_this->psz_object_type;
     p_item->psz_module =    strdup( psz_module );
     p_item->psz_msg =       psz_str;
     p_item->psz_header =    psz_header;
@@ -603,7 +574,7 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
             break;
     }
 
-    psz_object = msg_GetObjectTypeName(p_item->i_object_type);
+    psz_object = p_item->psz_object_type;
 
 #ifdef UNDER_CE
 #   define CE_WRITE(str) WriteFile( QUEUE(MSG_QUEUE_NORMAL).logfile, \




More information about the vlc-devel mailing list