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

Move object lock and condition into the internals

parent 838cee47
......@@ -513,10 +513,6 @@ typedef struct vlc_object_internals_t vlc_object_internals_t;
char *psz_header; \
int i_flags; \
\
/* Object access lock */ \
vlc_mutex_t object_lock; \
vlc_cond_t object_wait; \
\
/* Object properties */ \
volatile bool b_error; /**< set by the object */ \
volatile bool b_die; /**< set by the outside */ \
......
......@@ -34,8 +34,8 @@
/**
* Current plugin ABI version
*/
# define MODULE_SYMBOL 0_9_0k
# define MODULE_SUFFIX "__0_9_0k"
# define MODULE_SYMBOL 0_9_0l
# define MODULE_SUFFIX "__0_9_0l"
/*****************************************************************************
* Add a few defines. You do not want to read this section. Really.
......
......@@ -142,16 +142,6 @@ extern void *
vlc_custom_create (vlc_object_t *p_this, size_t i_size, int i_type,
const char *psz_type);
/* Signal an object without checking for locking consistency. This is wrong. */
#ifdef __GNUC__
__attribute__((deprecated))
#endif
static inline void
vlc_object_signal_maybe (vlc_object_t *p_this)
{
vlc_cond_signal (&p_this->object_wait);
}
/**
* libvlc_global_data_t (global variable)
*
......@@ -189,6 +179,8 @@ struct vlc_object_internals_t
bool b_thread;
/* Objects thread synchronization */
vlc_mutex_t lock;
vlc_cond_t wait;
int pipes[2];
vlc_spinlock_t spin;
......@@ -214,6 +206,16 @@ struct vlc_object_internals_t
#define vlc_internals( obj ) (((vlc_object_internals_t*)(VLC_OBJECT(obj)))-1)
/* Signal an object without checking for locking consistency. This is wrong. */
#ifdef __GNUC__
__attribute__((deprecated))
#endif
static inline void
vlc_object_signal_maybe (vlc_object_t *p_this)
{
vlc_cond_signal (&(vlc_internals(p_this)->wait));
}
/**
* Private LibVLC instance data.
*/
......
......@@ -176,8 +176,8 @@ void *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
p_new->p_private = NULL;
/* Initialize mutexes and condvars */
vlc_mutex_init( &p_new->object_lock );
vlc_cond_init( p_new, &p_new->object_wait );
vlc_mutex_init( &p_priv->lock );
vlc_cond_init( p_new, &p_priv->wait );
vlc_mutex_init( &p_priv->var_lock );
vlc_spin_init( &p_priv->spin );
p_priv->pipes[0] = p_priv->pipes[1] = -1;
......@@ -387,8 +387,8 @@ static void vlc_object_destroy( vlc_object_t *p_this )
#endif
vlc_spin_destroy( &p_priv->ref_spin );
vlc_mutex_destroy( &p_this->object_lock );
vlc_cond_destroy( &p_this->object_wait );
vlc_mutex_destroy( &p_priv->lock );
vlc_cond_destroy( &p_priv->wait );
vlc_spin_destroy( &p_priv->spin );
if( p_priv->pipes[1] != -1 )
close( p_priv->pipes[1] );
......@@ -403,13 +403,13 @@ static void vlc_object_destroy( vlc_object_t *p_this )
void __vlc_object_lock( vlc_object_t *obj )
{
vlc_mutex_lock( &obj->object_lock );
vlc_mutex_lock( &(vlc_internals(obj)->lock) );
}
void __vlc_object_unlock( vlc_object_t *obj )
{
vlc_assert_locked( &obj->object_lock );
vlc_mutex_unlock( &obj->object_lock );
vlc_assert_locked( &(vlc_internals(obj)->lock) );
vlc_mutex_unlock( &(vlc_internals(obj)->lock) );
}
#ifdef WIN32
......@@ -540,8 +540,9 @@ int __vlc_object_waitpipe( vlc_object_t *obj )
*/
void __vlc_object_wait( vlc_object_t *obj )
{
vlc_assert_locked( &obj->object_lock );
vlc_cond_wait( &obj->object_wait, &obj->object_lock );
vlc_object_internals_t *priv = vlc_internals( obj );
vlc_assert_locked( &priv->lock);
vlc_cond_wait( &priv->wait, &priv->lock );
}
......@@ -554,8 +555,9 @@ void __vlc_object_wait( vlc_object_t *obj )
*/
int __vlc_object_timedwait( vlc_object_t *obj, mtime_t deadline )
{
vlc_assert_locked( &obj->object_lock );
return vlc_cond_timedwait( &obj->object_wait, &obj->object_lock, deadline );
vlc_object_internals_t *priv = vlc_internals( obj );
vlc_assert_locked( &priv->lock);
return vlc_cond_timedwait( &priv->wait, &priv->lock, deadline );
}
......@@ -583,7 +585,7 @@ int __vlc_object_timedwait( vlc_object_t *obj, mtime_t deadline )
*/
bool __vlc_object_alive( vlc_object_t *obj )
{
vlc_assert_locked( &obj->object_lock );
vlc_assert_locked( &(vlc_internals(obj)->lock) );
return !obj->b_die;
}
......@@ -597,8 +599,8 @@ bool __vlc_object_alive( vlc_object_t *obj )
*/
void __vlc_object_signal_unlocked( vlc_object_t *obj )
{
vlc_assert_locked (&obj->object_lock);
vlc_cond_signal( &obj->object_wait );
vlc_assert_locked (&(vlc_internals(obj)->lock));
vlc_cond_signal( &(vlc_internals(obj)->wait) );
}
......
......@@ -379,7 +379,7 @@ static int CacheLoadConfig( module_t *p_module, FILE *file )
p_module->p_config[i].b_dirty = false;
p_module->p_config[i].p_lock = &p_module->object_lock;
p_module->p_config[i].p_lock = &(vlc_internals(p_module)->lock);
if( p_module->p_config[i].i_list )
{
......
......@@ -220,7 +220,7 @@ module_config_t *vlc_config_create (module_t *module, int type)
memset (tab + confsize, 0, sizeof (tab[confsize]));
tab[confsize].i_type = type;
tab[confsize].p_lock = &module->object_lock;
tab[confsize].p_lock = &(vlc_internals(module)->lock);
if (type & CONFIG_ITEM)
{
......
......@@ -225,7 +225,7 @@ static void input_selected_stream_changed( const vlc_event_t * event, void * dat
/* Internals */
void playlist_release_current_input( playlist_t * p_playlist )
{
vlc_assert_locked( &p_playlist->object_lock );
vlc_assert_locked( &(vlc_internals(p_playlist)->lock) );
if( !p_playlist->p_input ) return;
......@@ -248,7 +248,7 @@ void playlist_release_current_input( playlist_t * p_playlist )
void playlist_set_current_input(
playlist_t * p_playlist, input_thread_t * p_input )
{
vlc_assert_locked( &p_playlist->object_lock );
vlc_assert_locked( &(vlc_internals(p_playlist)->lock) );
playlist_release_current_input( p_playlist );
......
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