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

Hide libvlc_global_data_t from plugins

parent c262bd27
...@@ -26,49 +26,6 @@ ...@@ -26,49 +26,6 @@
#error You are not libvlc or one of its plugins. You cannot include this file #error You are not libvlc or one of its plugins. You cannot include this file
#endif #endif
/*****************************************************************************
* libvlc_global_data_t (global variable)
*****************************************************************************
* This structure has an unique instance, statically allocated in main and
* never accessed from the outside. It stores once-initialized data such as
* the CPU capabilities or the global lock.
*****************************************************************************/
struct libvlc_global_data_t
{
VLC_COMMON_MEMBERS
vlc_bool_t b_ready; ///< Initialization boolean
uint32_t i_cpu; ///< CPU extensions
/* Object structure data */
int i_counter; ///< object counter
int i_objects; ///< Attached objects count
vlc_object_t ** pp_objects; ///< Array of all objects
module_bank_t * p_module_bank; ///< The module bank
intf_thread_t *p_probe; ///< Devices prober
/* Arch-specific variables */
#if !defined( WIN32 )
vlc_bool_t b_daemon;
#endif
#if defined( SYS_BEOS )
vlc_object_t * p_appthread;
char * psz_vlcpath;
#elif defined( __APPLE__ )
char * psz_vlcpath;
vlc_iconv_t iconv_macosx; /* for HFS+ file names */
vlc_mutex_t iconv_lock;
#elif defined( WIN32 ) && !defined( UNDER_CE )
SIGNALOBJECTANDWAIT SignalObjectAndWait;
vlc_bool_t b_fast_mutex;
int i_win9x_cv;
char * psz_vlcpath;
#elif defined( UNDER_CE )
char * psz_vlcpath;
#endif
};
/***************************************************************************** /*****************************************************************************
* libvlc_internal_instance_t * libvlc_internal_instance_t
***************************************************************************** *****************************************************************************
......
...@@ -566,7 +566,7 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */ ...@@ -566,7 +566,7 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */
variable_t * p_vars; \ variable_t * p_vars; \
\ \
/* Stuff related to the libvlc structure */ \ /* Stuff related to the libvlc structure */ \
libvlc_global_data_t *p_libvlc_global; /**< root of all evil */ \ vlc_object_t *p_libvlc_global; /**< root of all evil */ \
libvlc_int_t *p_libvlc; /**< (root of all evil) - 1 */ \ libvlc_int_t *p_libvlc; /**< (root of all evil) - 1 */ \
\ \
volatile int i_refcount; /**< usage count */ \ volatile int i_refcount; /**< usage count */ \
......
...@@ -234,8 +234,7 @@ vlc_module_begin(); ...@@ -234,8 +234,7 @@ vlc_module_begin();
add_shortcut( "ffmpeg-deinterlace" ); add_shortcut( "ffmpeg-deinterlace" );
#endif #endif
var_Create( (vlc_object_t *)p_module->p_libvlc_global, "avcodec", var_Create( p_module->p_libvlc_global, "avcodec", VLC_VAR_MUTEX );
VLC_VAR_MUTEX );
vlc_module_end(); vlc_module_end();
...@@ -339,7 +338,7 @@ static void CloseDecoder( vlc_object_t *p_this ) ...@@ -339,7 +338,7 @@ static void CloseDecoder( vlc_object_t *p_this )
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
vlc_value_t lockval; vlc_value_t lockval;
var_Get( (vlc_object_t *)p_dec->p_libvlc_global, "avcodec", &lockval ); var_Get( p_dec->p_libvlc_global, "avcodec", &lockval );
switch( p_sys->i_cat ) switch( p_sys->i_cat )
{ {
...@@ -428,7 +427,7 @@ void E_(InitLibavcodec)( vlc_object_t *p_object ) ...@@ -428,7 +427,7 @@ void E_(InitLibavcodec)( vlc_object_t *p_object )
static int b_ffmpeginit = 0; static int b_ffmpeginit = 0;
vlc_value_t lockval; vlc_value_t lockval;
var_Get( (vlc_object_t *)p_object->p_libvlc_global, "avcodec", &lockval ); var_Get( p_object->p_libvlc_global, "avcodec", &lockval );
vlc_mutex_lock( lockval.p_address ); vlc_mutex_lock( lockval.p_address );
/* *** init ffmpeg library (libavcodec) *** */ /* *** init ffmpeg library (libavcodec) *** */
......
...@@ -125,8 +125,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -125,8 +125,8 @@ static int Open( vlc_object_t *p_this )
int i_port = 0; int i_port = 0;
char *psz_src; char *psz_src;
var_Create(p_intf->p_libvlc_global, "http-host", VLC_VAR_STRING ); var_Create(p_intf->p_libvlc, "http-host", VLC_VAR_STRING );
psz_address=var_GetString(p_intf->p_libvlc_global, "http-host"); psz_address = var_GetString(p_intf->p_libvlc, "http-host");
if( !psz_address || !*psz_address ) if( !psz_address || !*psz_address )
{ {
psz_address = config_GetPsz( p_intf, "http-host" ); psz_address = config_GetPsz( p_intf, "http-host" );
...@@ -281,7 +281,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -281,7 +281,7 @@ static int Open( vlc_object_t *p_this )
/* Ugly hack to run several HTTP servers on different ports */ /* Ugly hack to run several HTTP servers on different ports */
snprintf( psz_tmp, sizeof (psz_tmp), "%s:%d", psz_address, i_port + 1 ); snprintf( psz_tmp, sizeof (psz_tmp), "%s:%d", psz_address, i_port + 1 );
var_SetString( p_intf->p_libvlc_global, "http-host", psz_tmp ); var_SetString( p_intf->p_libvlc, "http-host", psz_tmp );
} }
p_sys->i_files = 0; p_sys->i_files = 0;
......
...@@ -127,11 +127,10 @@ typedef struct bridge_t ...@@ -127,11 +127,10 @@ typedef struct bridge_t
#define GetBridge(a) __GetBridge( VLC_OBJECT(a) ) #define GetBridge(a) __GetBridge( VLC_OBJECT(a) )
static bridge_t *__GetBridge( vlc_object_t *p_object ) static bridge_t *__GetBridge( vlc_object_t *p_object )
{ {
libvlc_global_data_t *p_libvlc_global = p_object->p_libvlc_global;
bridge_t *p_bridge; bridge_t *p_bridge;
vlc_value_t val; vlc_value_t val;
if( var_Get( p_libvlc_global, "bridge-struct", &val ) != VLC_SUCCESS ) if( var_Get( p_object->p_libvlc_global, "bridge-struct", &val ) )
{ {
p_bridge = NULL; p_bridge = NULL;
} }
...@@ -219,7 +218,7 @@ static sout_stream_id_t * AddOut( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -219,7 +218,7 @@ static sout_stream_id_t * AddOut( sout_stream_t *p_stream, es_format_t *p_fmt )
p_bridge = GetBridge( p_stream ); p_bridge = GetBridge( p_stream );
if ( p_bridge == NULL ) if ( p_bridge == NULL )
{ {
libvlc_global_data_t *p_libvlc_global = p_stream->p_libvlc_global; vlc_object_t *p_libvlc_global = p_stream->p_libvlc_global;
vlc_value_t val; vlc_value_t val;
p_bridge = malloc( sizeof( bridge_t ) ); p_bridge = malloc( sizeof( bridge_t ) );
...@@ -519,7 +518,7 @@ static int SendIn( sout_stream_t *p_stream, sout_stream_id_t *id, ...@@ -519,7 +518,7 @@ static int SendIn( sout_stream_t *p_stream, sout_stream_id_t *id,
if( b_no_es ) if( b_no_es )
{ {
libvlc_global_data_t *p_libvlc_global = p_stream->p_libvlc_global; vlc_object_t *p_libvlc_global = p_stream->p_libvlc_global;
for ( i = 0; i < p_bridge->i_es_num; i++ ) for ( i = 0; i < p_bridge->i_es_num; i++ )
free( p_bridge->pp_es[i] ); free( p_bridge->pp_es[i] );
free( p_bridge->pp_es ); free( p_bridge->pp_es );
......
...@@ -177,7 +177,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -177,7 +177,7 @@ static int Open( vlc_object_t *p_this )
{ {
sout_stream_t *p_stream = (sout_stream_t *)p_this; sout_stream_t *p_stream = (sout_stream_t *)p_this;
sout_stream_sys_t *p_sys; sout_stream_sys_t *p_sys;
libvlc_global_data_t *p_libvlc_global = p_this->p_libvlc_global; vlc_object_t *p_libvlc_global = p_this->p_libvlc_global;
vlc_value_t val; vlc_value_t val;
config_ChainParse( p_stream, CFG_PREFIX, ppsz_sout_options, config_ChainParse( p_stream, CFG_PREFIX, ppsz_sout_options,
...@@ -317,7 +317,7 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -317,7 +317,7 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt )
p_bridge = GetBridge( p_stream ); p_bridge = GetBridge( p_stream );
if ( p_bridge == NULL ) if ( p_bridge == NULL )
{ {
libvlc_global_data_t *p_libvlc_global = p_stream->p_libvlc_global; vlc_object_t *p_libvlc_global = p_stream->p_libvlc_global;
vlc_value_t val; vlc_value_t val;
p_bridge = malloc( sizeof( bridge_t ) ); p_bridge = malloc( sizeof( bridge_t ) );
...@@ -498,7 +498,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -498,7 +498,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
if ( b_last_es ) if ( b_last_es )
{ {
libvlc_global_data_t *p_libvlc_global = p_stream->p_libvlc_global; vlc_object_t *p_libvlc_global = p_stream->p_libvlc_global;
for ( i = 0; i < p_bridge->i_es_num; i++ ) for ( i = 0; i < p_bridge->i_es_num; i++ )
free( p_bridge->pp_es[i] ); free( p_bridge->pp_es[i] );
free( p_bridge->pp_es ); free( p_bridge->pp_es );
......
...@@ -286,7 +286,7 @@ static int CreateFilter( vlc_object_t *p_this ) ...@@ -286,7 +286,7 @@ static int CreateFilter( vlc_object_t *p_this )
{ {
filter_t *p_filter = (filter_t *)p_this; filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys; filter_sys_t *p_sys;
libvlc_global_data_t *p_libvlc_global = p_filter->p_libvlc_global; vlc_object_t *p_libvlc_global = p_filter->p_libvlc_global;
char *psz_order; char *psz_order;
char *psz_offsets; char *psz_offsets;
int i_index; int i_index;
......
...@@ -40,7 +40,7 @@ typedef struct bridge_t ...@@ -40,7 +40,7 @@ typedef struct bridge_t
#define GetBridge(a) __GetBridge( VLC_OBJECT(a) ) #define GetBridge(a) __GetBridge( VLC_OBJECT(a) )
static bridge_t *__GetBridge( vlc_object_t *p_object ) static bridge_t *__GetBridge( vlc_object_t *p_object )
{ {
libvlc_global_data_t *p_libvlc_global = p_object->p_libvlc_global; vlc_object_t *p_libvlc_global = p_object->p_libvlc_global;
bridge_t *p_bridge; bridge_t *p_bridge;
vlc_value_t val; vlc_value_t val;
......
...@@ -369,7 +369,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] ) ...@@ -369,7 +369,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
msg_Err( p_libvlc, "Unable to fork vlc to daemon mode" ); msg_Err( p_libvlc, "Unable to fork vlc to daemon mode" );
b_exit = VLC_TRUE; b_exit = VLC_TRUE;
} }
p_libvlc->p_libvlc_global->b_daemon = VLC_TRUE; libvlc_global.b_daemon = VLC_TRUE;
/* lets check if we need to write the pidfile */ /* lets check if we need to write the pidfile */
psz_pidfile = config_GetPsz( p_libvlc, "pidfile" ); psz_pidfile = config_GetPsz( p_libvlc, "pidfile" );
...@@ -416,7 +416,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] ) ...@@ -416,7 +416,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
close( STDOUT_FILENO ); close( STDOUT_FILENO );
close( STDERR_FILENO ); close( STDERR_FILENO );
p_libvlc->p_libvlc_global->b_daemon = VLC_TRUE; libvlc_global.b_daemon = VLC_TRUE;
} }
#endif #endif
} }
...@@ -1039,7 +1039,7 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, vlc_bool_t b_release ) ...@@ -1039,7 +1039,7 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, vlc_bool_t b_release )
#ifndef WIN32 #ifndef WIN32
char* psz_pidfile = NULL; char* psz_pidfile = NULL;
if( p_libvlc->p_libvlc_global->p_module_bank ) if( libvlc_global.p_module_bank )
if( config_GetInt( p_libvlc, "daemon" ) ) if( config_GetInt( p_libvlc, "daemon" ) )
{ {
psz_pidfile = config_GetPsz( p_libvlc, "pidfile" ); psz_pidfile = config_GetPsz( p_libvlc, "pidfile" );
...@@ -1117,7 +1117,7 @@ int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc, ...@@ -1117,7 +1117,7 @@ int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc,
return VLC_EGENERIC; return VLC_EGENERIC;
#ifndef WIN32 #ifndef WIN32
if( p_libvlc->p_libvlc_global->b_daemon && b_block && !psz_module ) if( libvlc_global.b_daemon && b_block && !psz_module )
{ {
/* Daemon mode hack. /* Daemon mode hack.
* We prefer the dummy interface if none is specified. */ * We prefer the dummy interface if none is specified. */
......
...@@ -34,7 +34,6 @@ extern vlc_object_t * ...@@ -34,7 +34,6 @@ extern vlc_object_t *
vlc_custom_create (vlc_object_t *p_this, size_t i_size, int i_type, vlc_custom_create (vlc_object_t *p_this, size_t i_size, int i_type,
const char *psz_type); const char *psz_type);
#if 0
/***************************************************************************** /*****************************************************************************
* libvlc_global_data_t (global variable) * libvlc_global_data_t (global variable)
***************************************************************************** *****************************************************************************
...@@ -71,8 +70,11 @@ struct libvlc_global_data_t ...@@ -71,8 +70,11 @@ struct libvlc_global_data_t
char * psz_vlcpath; char * psz_vlcpath;
#endif #endif
}; };
#endif
static inline libvlc_global_data_t *vlc_global( vlc_object_t *p_this )
{
return (libvlc_global_data_t *)p_this->p_libvlc_global;
}
extern uint32_t cpu_flags; extern uint32_t cpu_flags;
......
...@@ -139,32 +139,33 @@ vlc_object_t *vlc_custom_create( vlc_object_t *p_this, size_t i_size, ...@@ -139,32 +139,33 @@ vlc_object_t *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
if( i_type == VLC_OBJECT_GLOBAL ) if( i_type == VLC_OBJECT_GLOBAL )
{ {
/* If i_type is global, then p_new is actually p_libvlc_global */ /* If i_type is global, then p_new is actually p_libvlc_global */
p_new->p_libvlc_global = (libvlc_global_data_t*)p_new; libvlc_global_data_t *p_libvlc_global = (libvlc_global_data_t *)p_new;
p_new->p_libvlc_global = p_new;
p_new->p_libvlc = NULL; p_new->p_libvlc = NULL;
p_new->p_libvlc_global->i_counter = 0; p_libvlc_global->i_counter = 0;
p_new->i_object_id = 0; p_new->i_object_id = 0;
p_new->p_libvlc_global->i_objects = 1; p_libvlc_global->i_objects = 1;
p_new->p_libvlc_global->pp_objects = malloc( sizeof(vlc_object_t *) ); p_libvlc_global->pp_objects = malloc( sizeof(vlc_object_t *) );
p_new->p_libvlc_global->pp_objects[0] = p_new; p_libvlc_global->pp_objects[0] = p_new;
p_new->b_attached = VLC_TRUE; p_new->b_attached = VLC_TRUE;
} }
else else
{ {
p_new->p_libvlc_global = p_this->p_libvlc_global; libvlc_global_data_t *p_libvlc_global = vlc_global( p_this );
p_new->p_libvlc_global = VLC_OBJECT (p_libvlc_global);
p_new->p_libvlc = ( i_type == VLC_OBJECT_LIBVLC ) ? (libvlc_int_t*)p_new p_new->p_libvlc = ( i_type == VLC_OBJECT_LIBVLC ) ? (libvlc_int_t*)p_new
: p_this->p_libvlc; : p_this->p_libvlc;
vlc_mutex_lock( &structure_lock ); vlc_mutex_lock( &structure_lock );
p_new->p_libvlc_global->i_counter++; p_libvlc_global->i_counter++;
p_new->i_object_id = p_new->p_libvlc_global->i_counter; p_new->i_object_id = p_libvlc_global->i_counter;
/* Wooohaa! If *this* fails, we're in serious trouble! Anyway it's /* Wooohaa! If *this* fails, we're in serious trouble! Anyway it's
* useless to try and recover anything if pp_objects gets smashed. */ * useless to try and recover anything if pp_objects gets smashed. */
TAB_APPEND( p_new->p_libvlc_global->i_objects, TAB_APPEND( p_libvlc_global->i_objects, p_libvlc_global->pp_objects,
p_new->p_libvlc_global->pp_objects,
p_new ); p_new );
vlc_mutex_unlock( &structure_lock ); vlc_mutex_unlock( &structure_lock );
...@@ -395,25 +396,27 @@ void __vlc_object_destroy( vlc_object_t *p_this ) ...@@ -395,25 +396,27 @@ void __vlc_object_destroy( vlc_object_t *p_this )
if( p_this->i_object_type == VLC_OBJECT_GLOBAL ) if( p_this->i_object_type == VLC_OBJECT_GLOBAL )
{ {
libvlc_global_data_t *p_global = (libvlc_global_data_t *)p_this;
/* We are the global object ... no need to lock. */ /* We are the global object ... no need to lock. */
free( p_this->p_libvlc_global->pp_objects ); free( p_global->pp_objects );
p_this->p_libvlc_global->pp_objects = NULL; p_global->pp_objects = NULL;
p_this->p_libvlc_global->i_objects--; p_global->i_objects--;
vlc_mutex_destroy( &structure_lock ); vlc_mutex_destroy( &structure_lock );
} }
else else
{ {
libvlc_global_data_t *p_libvlc_global = vlc_global( p_this );
int i_index; int i_index;
vlc_mutex_lock( &structure_lock ); vlc_mutex_lock( &structure_lock );
/* Wooohaa! If *this* fails, we're in serious trouble! Anyway it's /* Wooohaa! If *this* fails, we're in serious trouble! Anyway it's
* useless to try and recover anything if pp_objects gets smashed. */ * useless to try and recover anything if pp_objects gets smashed. */
i_index = FindIndex( p_this, p_this->p_libvlc_global->pp_objects, i_index = FindIndex( p_this, p_libvlc_global->pp_objects,
p_this->p_libvlc_global->i_objects ); p_libvlc_global->i_objects );
REMOVE_ELEM( p_this->p_libvlc_global->pp_objects, REMOVE_ELEM( p_libvlc_global->pp_objects,
p_this->p_libvlc_global->i_objects, i_index ); p_libvlc_global->i_objects, i_index );
vlc_mutex_unlock( &structure_lock ); vlc_mutex_unlock( &structure_lock );
} }
...@@ -465,13 +468,14 @@ void * __vlc_object_get( vlc_object_t *p_this, int i_id ) ...@@ -465,13 +468,14 @@ void * __vlc_object_get( vlc_object_t *p_this, int i_id )
{ {
int i_max, i_middle; int i_max, i_middle;
vlc_object_t **pp_objects; vlc_object_t **pp_objects;
libvlc_global_data_t *p_libvlc_global = vlc_global( p_this );
vlc_mutex_lock( &structure_lock ); vlc_mutex_lock( &structure_lock );
pp_objects = p_this->p_libvlc_global->pp_objects; pp_objects = p_libvlc_global->pp_objects;
/* Perform our dichotomy */ /* Perform our dichotomy */
for( i_max = p_this->p_libvlc_global->i_objects - 1 ; ; ) for( i_max = p_libvlc_global->i_objects - 1 ; ; )
{ {
i_middle = i_max / 2; i_middle = i_max / 2;
...@@ -713,6 +717,7 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode ) ...@@ -713,6 +717,7 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
vlc_list_t *p_list; vlc_list_t *p_list;
vlc_object_t **pp_current, **pp_end; vlc_object_t **pp_current, **pp_end;
int i_count = 0, i_index = 0; int i_count = 0, i_index = 0;
libvlc_global_data_t *p_libvlc_global = vlc_global( p_this );
vlc_mutex_lock( &structure_lock ); vlc_mutex_lock( &structure_lock );
...@@ -720,8 +725,8 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode ) ...@@ -720,8 +725,8 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
switch( i_mode & 0x000f ) switch( i_mode & 0x000f )
{ {
case FIND_ANYWHERE: case FIND_ANYWHERE:
pp_current = p_this->p_libvlc_global->pp_objects; pp_current = p_libvlc_global->pp_objects;
pp_end = pp_current + p_this->p_libvlc_global->i_objects; pp_end = pp_current + p_libvlc_global->i_objects;
for( ; pp_current < pp_end ; pp_current++ ) for( ; pp_current < pp_end ; pp_current++ )
{ {
...@@ -733,7 +738,7 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode ) ...@@ -733,7 +738,7 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
} }
p_list = NewList( i_count ); p_list = NewList( i_count );
pp_current = p_this->p_libvlc_global->pp_objects; pp_current = p_libvlc_global->pp_objects;
for( ; pp_current < pp_end ; pp_current++ ) for( ; pp_current < pp_end ; pp_current++ )
{ {
...@@ -783,6 +788,8 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode ) ...@@ -783,6 +788,8 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd, static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval, void *p_data )
{ {
libvlc_global_data_t *p_libvlc_global = vlc_global( p_this );
(void)oldval; (void)p_data; (void)oldval; (void)p_data;
if( *psz_cmd == 'l' ) if( *psz_cmd == 'l' )
{ {
...@@ -790,8 +797,8 @@ static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd, ...@@ -790,8 +797,8 @@ static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd,
vlc_object_t **pp_current, **pp_end; vlc_object_t **pp_current, **pp_end;
pp_current = p_this->p_libvlc_global->pp_objects; pp_current = p_libvlc_global->pp_objects;
pp_end = pp_current + p_this->p_libvlc_global->i_objects; pp_end = pp_current + p_libvlc_global->i_objects;
for( ; pp_current < pp_end ; pp_current++ ) for( ; pp_current < pp_end ; pp_current++ )
{ {
......
...@@ -155,7 +155,6 @@ static char * GetWindowsError ( void ); ...@@ -155,7 +155,6 @@ static char * GetWindowsError ( void );
static void module_LoadMain( vlc_object_t *p_this ); static void module_LoadMain( vlc_object_t *p_this );
/* Sub-version number /* Sub-version number
* (only used to avoid breakage in dev version when cache structure changes) */ * (only used to avoid breakage in dev version when cache structure changes) */
#define CACHE_SUBVERSION_NUM 3 #define CACHE_SUBVERSION_NUM 3
...@@ -170,19 +169,20 @@ void __module_InitBank( vlc_object_t *p_this ) ...@@ -170,19 +169,20 @@ void __module_InitBank( vlc_object_t *p_this )
{ {
module_bank_t *p_bank = NULL; module_bank_t *p_bank = NULL;
vlc_value_t lockval; vlc_value_t lockval;
libvlc_global_data_t *p_libvlc_global = vlc_global( p_this );
var_Create( p_this->p_libvlc_global, "libvlc", VLC_VAR_MUTEX ); var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
var_Get( p_this->p_libvlc_global, "libvlc", &lockval ); var_Get( p_libvlc_global, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address ); vlc_mutex_lock( lockval.p_address );
if( p_this->p_libvlc_global->p_module_bank ) if( p_libvlc_global->p_module_bank )
{ {
p_this->p_libvlc_global->p_module_bank->i_usage++; p_libvlc_global->p_module_bank->i_usage++;
vlc_mutex_unlock( lockval.p_address ); vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc_global, "libvlc" ); var_Destroy( p_libvlc_global, "libvlc" );
return; return;
} }
vlc_mutex_unlock( lockval.p_address ); vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc_global, "libvlc" ); var_Destroy( p_libvlc_global, "libvlc" );
p_bank = vlc_object_create( p_this, sizeof(module_bank_t) ); p_bank = vlc_object_create( p_this, sizeof(module_bank_t) );
if( !p_bank ) if( !p_bank )
...@@ -202,23 +202,12 @@ void __module_InitBank( vlc_object_t *p_this ) ...@@ -202,23 +202,12 @@ void __module_InitBank( vlc_object_t *p_this )
#endif #endif
/* Everything worked, attach the object */ /* Everything worked, attach the object */
p_this->p_libvlc_global->p_module_bank = p_bank; p_libvlc_global->p_module_bank = p_bank;
vlc_object_attach( p_bank, p_this->p_libvlc_global ); vlc_object_attach( p_bank, p_libvlc_global );
module_LoadMain( p_this ); module_LoadMain( p_this );
} }
/*****************************************************************************
* module_ResetBank: reset the module bank.
*****************************************************************************
* This function resets the module bank by unloading all unused plugin
* modules.
*****************************************************************************/
void __module_ResetBank( vlc_object_t *p_this )
{
msg_Err( p_this, "FIXME: module_ResetBank unimplemented" );
return;
}
/***************************************************************************** /*****************************************************************************
* module_EndBank: empty the module bank. * module_EndBank: empty the module bank.
...@@ -230,35 +219,37 @@ void __module_EndBank( vlc_object_t *p_this ) ...@@ -230,35 +219,37 @@ void __module_EndBank( vlc_object_t *p_this )
{ {
module_t * p_next = NULL; module_t * p_next = NULL;
vlc_value_t lockval; vlc_value_t lockval;
libvlc_global_data_t *p_libvlc_global = vlc_global( p_this );
var_Create( p_this->p_libvlc_global, "libvlc", VLC_VAR_MUTEX ); var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
var_Get( p_this->p_libvlc_global, "libvlc", &lockval ); var_Get( p_libvlc_global, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address ); vlc_mutex_lock( lockval.p_address );
if( !p_this->p_libvlc_global->p_module_bank ) if( !p_libvlc_global->p_module_bank )
{ {
vlc_mutex_unlock( lockval.p_address );