Commit 88bc3a7e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

msg_Subscribe: expose structure to plugins

This eliminates one error case that nobody dealt with anyway.
parent b549105c
......@@ -107,11 +107,6 @@ VLC_API void libvlc_Quit( libvlc_int_t * );
* @{
*/
/**
* Used by interface plugins which subscribe to the message bank.
*/
typedef struct msg_subscription_t msg_subscription_t;
/**
* Message logging callback signature.
* Accepts one private data pointer, the message, and an overrun counter.
......@@ -119,7 +114,17 @@ typedef struct msg_subscription_t msg_subscription_t;
typedef void (*msg_callback_t) (void *, int, const msg_item_t *,
const char *, va_list);
VLC_API msg_subscription_t *vlc_Subscribe(msg_callback_t, void *) VLC_USED;
/**
* Used by interface plugins which subscribe to the message bank.
*/
typedef struct msg_subscription
{
struct msg_subscription *prev, *next;
msg_callback_t func;
void *opaque;
} msg_subscription_t;
VLC_API void vlc_Subscribe(msg_subscription_t *, msg_callback_t, void *);
VLC_API void vlc_Unsubscribe(msg_subscription_t *);
/*@}*/
......
......@@ -75,7 +75,7 @@ struct intf_sys_t
bool b_vout_update;
/* The messages window */
msg_subscription_t * p_sub;
msg_subscription_t sub;
};
/*****************************************************************************
......
......@@ -106,7 +106,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 = vlc_Subscribe( MsgCallback, NULL );
vlc_Subscribe( &p_intf->p_sys->sub, MsgCallback, NULL );
p_intf->pf_run = Run;
p_intf->b_should_run_on_first_thread = true;
......@@ -775,7 +775,7 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_eyetv release];
/* unsubscribe from libvlc's debug messages */
vlc_Unsubscribe( p_intf->p_sys->p_sub );
vlc_Unsubscribe( &p_intf->p_sys->sub );
[o_msg_arr removeAllObjects];
[o_msg_arr release];
......
......@@ -190,7 +190,7 @@ struct intf_sys_t
int box_start; // first line of box displayed
int box_idx; // selected line
msg_subscription_t *sub; // message bank subscription
msg_subscription_t sub; // message bank subscription
struct
{
int type;
......@@ -1789,7 +1789,7 @@ static int Open(vlc_object_t *p_this)
vlc_mutex_init(&sys->pl_lock);
sys->verbosity = var_InheritInteger(intf, "verbose");
sys->sub = vlc_Subscribe(MsgCallback, sys);
vlc_Subscribe(&sys->sub, MsgCallback, sys);
sys->box_type = BOX_PLAYLIST;
sys->plidx_follow = true;
......@@ -1842,7 +1842,7 @@ static void Close(vlc_object_t *p_this)
endwin(); /* Close the ncurses interface */
vlc_Unsubscribe(sys->sub);
vlc_Unsubscribe(&sys->sub);
vlc_mutex_destroy(&sys->msg_lock);
vlc_mutex_destroy(&sys->pl_lock);
for(unsigned i = 0; i < sizeof sys->msgs / sizeof *sys->msgs; i++) {
......
......@@ -121,13 +121,13 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
readSettings( "Messages", QSize( 600, 450 ) );
/* Hook up to LibVLC messaging */
sub = vlc_Subscribe( MsgCallback, this );
vlc_Subscribe( &sub, MsgCallback, this );
}
MessagesDialog::~MessagesDialog()
{
writeSettings( "Messages" );
vlc_Unsubscribe( sub );
vlc_Unsubscribe( &sub );
};
void MessagesDialog::changeVerbosity( int i_verbosity )
......
......@@ -48,7 +48,7 @@ private:
virtual ~MessagesDialog();
Ui::messagesPanelWidget ui;
msg_subscription_t *sub;
msg_subscription_t sub;
static void sinkMessage( void *, msg_item_t *, unsigned );
void customEvent( QEvent * );
void sinkMessage( const MsgEvent * );
......
......@@ -74,7 +74,7 @@
*****************************************************************************/
struct intf_sys_t
{
msg_subscription_t *p_sub;
msg_subscription_t sub;
FILE *p_file;
const char *footer;
};
......@@ -298,7 +298,7 @@ static int Open( vlc_object_t *p_this )
fputs( header, p_sys->p_file );
}
p_sys->p_sub = vlc_Subscribe( cb, p_intf );
vlc_Subscribe( &p_sys->sub, cb, p_intf );
return VLC_SUCCESS;
}
......@@ -311,7 +311,7 @@ static void Close( vlc_object_t *p_this )
intf_sys_t *p_sys = p_intf->p_sys;
/* Flush the queue and unsubscribe from the message queue */
vlc_Unsubscribe( p_sys->p_sub );
vlc_Unsubscribe( &p_sys->sub );
/* Close the log file */
#ifdef HAVE_SYSLOG_H
......
......@@ -55,13 +55,6 @@
vlc_rwlock_t msg_lock = VLC_STATIC_RWLOCK;
msg_subscription_t *msg_head;
struct msg_subscription_t
{
msg_subscription_t *prev, *next;
msg_callback_t func;
void *opaque;
};
/**
* Subscribe to the message queue.
* Whenever a message is emitted, a callback will be called.
......@@ -69,14 +62,9 @@ struct msg_subscription_t
*
* @param cb callback function
* @param opaque data for the callback function
* @return a subscription pointer, or NULL in case of failure
*/
msg_subscription_t *vlc_Subscribe (msg_callback_t cb, void *opaque)
void vlc_Subscribe (msg_subscription_t *sub, msg_callback_t cb, void *opaque)
{
msg_subscription_t *sub = malloc (sizeof (*sub));
if (sub == NULL)
return NULL;
sub->prev = NULL;
sub->func = cb;
sub->opaque = opaque;
......@@ -85,8 +73,6 @@ msg_subscription_t *vlc_Subscribe (msg_callback_t cb, void *opaque)
sub->next = msg_head;
msg_head = sub;
vlc_rwlock_unlock (&msg_lock);
return sub;
}
/**
......@@ -106,7 +92,6 @@ void vlc_Unsubscribe (msg_subscription_t *sub)
msg_head = sub->next;
}
vlc_rwlock_unlock (&msg_lock);
free (sub);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment