/* Find verbosity from VLC_VERBOSE environment variable */
psz_env = getenv( "VLC_VERBOSE" );
if( psz_env != NULL )
- p_libvlc->i_verbose = atoi( psz_env );
+ priv->i_verbose = atoi( psz_env );
else
- p_libvlc->i_verbose = 3;
+ priv->i_verbose = 3;
#if defined( HAVE_ISATTY ) && !defined( WIN32 )
- p_libvlc->b_color = isatty( 2 ); /* 2 is for stderr */
+ priv->b_color = isatty( 2 ); /* 2 is for stderr */
#else
- p_libvlc->b_color = false;
+ priv->b_color = false;
#endif
/* Announce who we are - Do it only for first instance ? */
}
/* Will be re-done properly later on */
- p_libvlc->i_verbose = config_GetInt( p_libvlc, "verbose" );
+ priv->i_verbose = config_GetInt( p_libvlc, "verbose" );
/* Check for daemon mode */
#ifndef WIN32
var_AddCallback( p_libvlc, "verbose", VerboseCallback, NULL );
var_Change( p_libvlc, "verbose", VLC_VAR_TRIGGER_CALLBACKS, NULL, NULL );
- if( p_libvlc->b_color )
- p_libvlc->b_color = config_GetInt( p_libvlc, "color" ) > 0;
+ if( priv->b_color )
+ priv->b_color = config_GetInt( p_libvlc, "color" ) > 0;
/*
* Output messages that may still be in the queue
if( new_val.i_int >= -1 )
{
- p_libvlc->i_verbose = __MIN( new_val.i_int, 2 );
+ libvlc_priv (p_libvlc)->i_verbose = __MIN( new_val.i_int, 2 );
}
return VLC_SUCCESS;
}
extern uint32_t cpu_flags;
uint32_t CPUCapabilities( void );
+/*
+ * Message/logging stuff
+ */
+
+#define NB_QUEUES 2
+
+typedef struct msg_queue_t
+{
+ int i_id;
+
+ /** Message queue lock */
+ vlc_mutex_t lock;
+ bool b_overflow;
+
+ /* Message queue */
+ msg_item_t msg[VLC_MSG_QSIZE]; /**< message queue */
+ int i_start;
+ int i_stop;
+
+ /* Subscribers */
+ int i_sub;
+ msg_subscription_t **pp_sub;
+
+ /* Logfile for WinCE */
+#ifdef UNDER_CE
+ FILE *logfile;
+#endif
+} msg_queue_t;
+
+/**
+ * Store all data requiered by messages interfaces.
+ */
+typedef struct msg_bank_t
+{
+ vlc_mutex_t lock;
+ msg_queue_t queues[NB_QUEUES];
+} msg_bank_t;
+
/*
* Unicode stuff
*/
{
vlc_mutex_t config_lock; ///< config file lock
+ /* Messages */
+ msg_bank_t msg_bank; ///< The message bank
+ int i_verbose; ///< info messages
+ bool b_color; ///< color messages?
+
+ /* Timer stats */
vlc_mutex_t timer_lock; ///< Lock to protect timers
counter_t **pp_timers; ///< Array of all timers
int i_timers; ///< Number of timers
# define vlc_va_copy(dest,src) (dest)=(src)
#endif
-#define QUEUE(i) p_this->p_libvlc->msg_bank.queues[i]
-#define LOCK_BANK vlc_mutex_lock( &p_this->p_libvlc->msg_bank.lock );
-#define UNLOCK_BANK vlc_mutex_unlock( &p_this->p_libvlc->msg_bank.lock );
+#define QUEUE(i) priv->msg_bank.queues[i]
+#define LOCK_BANK vlc_mutex_lock( &priv->msg_bank.lock );
+#define UNLOCK_BANK vlc_mutex_unlock( &priv->msg_bank.lock );
/*****************************************************************************
* Local prototypes
*/
void __msg_Create( vlc_object_t *p_this )
{
- int i;
- vlc_mutex_init( &(p_this->p_libvlc->msg_bank.lock) );
+ libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
+ vlc_mutex_init( &priv->msg_bank.lock );
- for( i = 0; i < 2; i++ )
+ for( int i = 0; i < 2; i++ )
{
vlc_mutex_init( &QUEUE(i).lock );
QUEUE(i).b_overflow = false;
*/
void __msg_Flush( vlc_object_t *p_this )
{
- int i;
- for( i = 0 ; i < NB_QUEUES ; i++ )
+ libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
+
+ for( int i = 0 ; i < NB_QUEUES ; i++ )
{
vlc_mutex_lock( &QUEUE(i).lock );
FlushMsg( &QUEUE(i) );
*/
void __msg_Destroy( vlc_object_t *p_this )
{
- int i;
- for( i = NB_QUEUES -1 ; i >= 0; i-- )
+ libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
+
+ for( int i = NB_QUEUES -1 ; i >= 0; i-- )
{
if( QUEUE(i).i_sub )
msg_Err( p_this, "stale interface subscribers" );
/* Destroy lock */
vlc_mutex_destroy( &QUEUE(i).lock );
}
- vlc_mutex_destroy( &(p_this->p_libvlc->msg_bank.lock) );
+ vlc_mutex_destroy( &priv->msg_bank.lock);
}
/**
*/
msg_subscription_t *__msg_Subscribe( vlc_object_t *p_this, int i )
{
+ libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
msg_subscription_t *p_sub = malloc( sizeof( msg_subscription_t ) );
+ if (p_sub == NULL)
+ return NULL;
+
assert( i < NB_QUEUES );
LOCK_BANK;
*/
void __msg_Unsubscribe( vlc_object_t *p_this, msg_subscription_t *p_sub )
{
- int i,j;
+ libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
LOCK_BANK;
- for( i = 0 ; i< NB_QUEUES ; i++ )
+ for( int i = 0 ; i< NB_QUEUES ; i++ )
{
vlc_mutex_lock( &QUEUE(i).lock );
- for( j = 0 ; j< QUEUE(i).i_sub ; j++ )
+ for( int j = 0 ; j< QUEUE(i).i_sub ; j++ )
{
if( QUEUE(i).pp_sub[j] == p_sub )
{
const char *psz_module,
const char *psz_format, va_list _args )
{
+ libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
int i_header_size; /* Size of the additionnal header */
vlc_object_t *p_obj;
char * psz_str = NULL; /* formatted message string */
static const char * ppsz_type[4] = { "", " error", " warning", " debug" };
static const char *ppsz_color[4] = { WHITE, RED, YELLOW, GRAY };
const char *psz_object;
+ libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
int i_type = p_item->i_type;
switch( i_type )
{
case VLC_MSG_ERR:
- if( p_this->p_libvlc->i_verbose < 0 ) return;
+ if( priv->i_verbose < 0 ) return;
break;
case VLC_MSG_INFO:
- if( p_this->p_libvlc->i_verbose < 0 ) return;
+ if( priv->i_verbose < 0 ) return;
break;
case VLC_MSG_WARN:
- if( p_this->p_libvlc->i_verbose < 1 ) return;
+ if( priv->i_verbose < 1 ) return;
break;
case VLC_MSG_DBG:
- if( p_this->p_libvlc->i_verbose < 2 ) return;
+ if( priv->i_verbose < 2 ) return;
break;
}
#else
/* Send the message to stderr */
- if( p_this->p_libvlc->b_color )
+ if( priv->b_color )
{
if( p_item->psz_header )
{