[vlc-commits] commit: add msg_SubscriptionSetVerbosity call, so core filter message-level for subscribers (Ilkka Ollakka )
git at videolan.org
git at videolan.org
Wed Jul 14 20:40:48 CEST 2010
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Tue Jul 13 16:22:48 2010 +0300| [14d8d88c6c045e5241fa6237eb65f95124c9deda] | committer: Ilkka Ollakka
add msg_SubscriptionSetVerbosity call, so core filter message-level for subscribers
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=14d8d88c6c045e5241fa6237eb65f95124c9deda
---
include/vlc_messages.h | 1 +
src/libvlccore.sym | 1 +
src/misc/messages.c | 28 ++++++++++++++++++++++++++++
3 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/include/vlc_messages.h b/include/vlc_messages.h
index 80fc1b3..15ce936 100644
--- a/include/vlc_messages.h
+++ b/include/vlc_messages.h
@@ -114,6 +114,7 @@ typedef void (*msg_callback_t) (msg_cb_data_t *, msg_item_t *, unsigned);
VLC_EXPORT( msg_subscription_t*, msg_Subscribe, ( libvlc_int_t *, msg_callback_t, msg_cb_data_t * ) );
VLC_EXPORT( void, msg_Unsubscribe, ( msg_subscription_t * ) );
+VLC_EXPORT( void, msg_SubscriptionSetVerbosity, ( msg_subscription_t *, const int) );
/* Enable or disable a certain object debug messages */
VLC_EXPORT( void, msg_EnableObjectPrinting, ( vlc_object_t *, const char * psz_object ) );
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 8fe0452..5e4ad0c 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -276,6 +276,7 @@ msg_Generic
msg_GenericVa
msg_Subscribe
msg_Unsubscribe
+msg_SubscriptionSetVerbosity
msleep
mstrtime
mwait
diff --git a/src/misc/messages.c b/src/misc/messages.c
index 8df893f..063ae60 100644
--- a/src/misc/messages.c
+++ b/src/misc/messages.c
@@ -142,6 +142,7 @@ msg_bank_t *msg_Create (void)
static void const * kObjectPrintingEnabled = &kObjectPrintingEnabled;
static void const * kObjectPrintingDisabled = &kObjectPrintingDisabled;
+
#undef msg_EnableObjectPrinting
void msg_EnableObjectPrinting (vlc_object_t *obj, const char * psz_object)
{
@@ -202,6 +203,7 @@ struct msg_subscription_t
libvlc_int_t *instance;
msg_callback_t func;
msg_cb_data_t *opaque;
+ int verbosity;
};
/**
@@ -224,6 +226,7 @@ msg_subscription_t *msg_Subscribe (libvlc_int_t *instance, msg_callback_t cb,
sub->instance = instance;
sub->func = cb;
sub->opaque = opaque;
+ sub->verbosity = 2; /* by default, give all the messages */
msg_bank_t *bank = libvlc_bank (instance);
vlc_rwlock_wrlock (&bank->lock);
@@ -247,6 +250,18 @@ void msg_Unsubscribe (msg_subscription_t *sub)
free (sub);
}
+void msg_SubscriptionSetVerbosity( msg_subscription_t *sub, const int i_verbosity )
+{
+ if( i_verbosity < 0 || i_verbosity > 2 ) return;
+
+ msg_bank_t *bank = libvlc_bank ( sub->instance );
+
+ vlc_rwlock_wrlock (&bank->lock);
+
+ sub->verbosity = i_verbosity;
+
+ vlc_rwlock_unlock (&bank->lock);
+}
/*****************************************************************************
* msg_*: print a message
*****************************************************************************
@@ -455,6 +470,19 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type,
if( val == kObjectPrintingEnabled ); /* Allowed */
else if( !bank->all_objects_enabled ) continue;
}
+ switch( p_item->i_type )
+ {
+ case VLC_MSG_INFO:
+ case VLC_MSG_ERR:
+ if( sub->verbosity < 0 ) continue;
+ break;
+ case VLC_MSG_WARN:
+ if( sub->verbosity < 1 ) continue;
+ break;
+ case VLC_MSG_DBG:
+ if( sub->verbosity < 2 ) continue;
+ break;
+ }
sub->func (sub->opaque, p_item, 0);
}
More information about the vlc-commits
mailing list