-/*****************************************************************************
- * Local macros
- *****************************************************************************/
-#if defined(HAVE_VA_COPY)
-# define vlc_va_copy(dest,src) va_copy(dest,src)
-#elif defined(HAVE___VA_COPY)
-# define vlc_va_copy(dest,src) __va_copy(dest,src)
-#else
-# define vlc_va_copy(dest,src) (dest)=(src)
-#endif
-
-#define QUEUE priv->msg_bank.queue
-#define LOCK_BANK vlc_mutex_lock( &priv->msg_bank.lock );
-#define UNLOCK_BANK vlc_mutex_unlock( &priv->msg_bank.lock );
-
-/*****************************************************************************
- * Local prototypes
- *****************************************************************************/
-static void QueueMsg ( vlc_object_t *, int, const char *,
- const char *, va_list );
-static void FlushMsg ( msg_queue_t * );
-static void PrintMsg ( vlc_object_t *, msg_item_t * );
-
-/**
- * Initialize messages queues
- * This function initializes all message queues
- */
-void msg_Create (libvlc_int_t *p_libvlc)
-{
- libvlc_priv_t *priv = libvlc_priv (p_libvlc);
- vlc_mutex_init( &priv->msg_bank.lock );
- vlc_mutex_init( &QUEUE.lock );
- QUEUE.b_overflow = false;
- QUEUE.i_start = 0;
- QUEUE.i_stop = 0;
- QUEUE.i_sub = 0;
- QUEUE.pp_sub = 0;
-
-#ifdef UNDER_CE
- QUEUE.logfile =
- CreateFile( L"vlc-log.txt", GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
- CREATE_ALWAYS, 0, NULL );
- SetFilePointer( QUEUE.logfile, 0, NULL, FILE_END );
-#endif
-}
-
-/**
- * Flush all message queues
- */
-void msg_Flush (libvlc_int_t *p_libvlc)
-{
- libvlc_priv_t *priv = libvlc_priv (p_libvlc);
- vlc_mutex_lock( &QUEUE.lock );
- FlushMsg( &QUEUE );
- vlc_mutex_unlock( &QUEUE.lock );
-}
-
-/**
- * Destroy the message queues
- *
- * This functions prints all messages remaining in the queues,
- * then frees all the allocated ressources
- * No other messages interface functions should be called after this one.
- */
-void msg_Destroy (libvlc_int_t *p_libvlc)
-{
- libvlc_priv_t *priv = libvlc_priv (p_libvlc);
-
- if( QUEUE.i_sub )
- msg_Err( p_libvlc, "stale interface subscribers" );
-
- FlushMsg( &QUEUE );
-
-#ifdef UNDER_CE
- CloseHandle( QUEUE.logfile );
-#endif
- /* Destroy lock */
- vlc_mutex_destroy( &QUEUE.lock );
- vlc_mutex_destroy( &priv->msg_bank.lock);
-}
-
-/**
- * Subscribe to a message queue.
- */
-msg_subscription_t *__msg_Subscribe( vlc_object_t *p_this )
-{
- 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;
-
- LOCK_BANK;
- vlc_mutex_lock( &QUEUE.lock );
-
- TAB_APPEND( QUEUE.i_sub, QUEUE.pp_sub, p_sub );
-
- p_sub->i_start = QUEUE.i_start;
- p_sub->pi_stop = &QUEUE.i_stop;
- p_sub->p_msg = QUEUE.msg;
- p_sub->p_lock = &QUEUE.lock;
-
- vlc_mutex_unlock( &QUEUE.lock );
- UNLOCK_BANK;
-
- return p_sub;
-}
-