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 @@
#error You are not libvlc or one of its plugins. You cannot include this file
#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
*****************************************************************************
......
......@@ -566,7 +566,7 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */
variable_t * p_vars; \
\
/* 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 */ \
\
volatile int i_refcount; /**< usage count */ \
......
......@@ -234,8 +234,7 @@ vlc_module_begin();
add_shortcut( "ffmpeg-deinterlace" );
#endif
var_Create( (vlc_object_t *)p_module->p_libvlc_global, "avcodec",
VLC_VAR_MUTEX );
var_Create( p_module->p_libvlc_global, "avcodec", VLC_VAR_MUTEX );
vlc_module_end();
......@@ -339,7 +338,7 @@ static void CloseDecoder( vlc_object_t *p_this )
decoder_sys_t *p_sys = p_dec->p_sys;
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 )
{
......@@ -428,7 +427,7 @@ void E_(InitLibavcodec)( vlc_object_t *p_object )
static int b_ffmpeginit = 0;
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 );
/* *** init ffmpeg library (libavcodec) *** */
......
......@@ -125,8 +125,8 @@ static int Open( vlc_object_t *p_this )
int i_port = 0;
char *psz_src;
var_Create(p_intf->p_libvlc_global, "http-host", VLC_VAR_STRING );
psz_address=var_GetString(p_intf->p_libvlc_global, "http-host");
var_Create(p_intf->p_libvlc, "http-host", VLC_VAR_STRING );
psz_address = var_GetString(p_intf->p_libvlc, "http-host");
if( !psz_address || !*psz_address )
{
psz_address = config_GetPsz( p_intf, "http-host" );
......@@ -281,7 +281,7 @@ static int Open( vlc_object_t *p_this )
/* Ugly hack to run several HTTP servers on different ports */
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;
......
......@@ -127,11 +127,10 @@ typedef struct bridge_t
#define GetBridge(a) __GetBridge( VLC_OBJECT(a) )
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;
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;
}
......@@ -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 );
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;
p_bridge = malloc( sizeof( bridge_t ) );
......@@ -519,7 +518,7 @@ static int SendIn( sout_stream_t *p_stream, sout_stream_id_t *id,
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++ )
free( p_bridge->pp_es[i] );
free( p_bridge->pp_es );
......
......@@ -177,7 +177,7 @@ static int Open( vlc_object_t *p_this )
{
sout_stream_t *p_stream = (sout_stream_t *)p_this;
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;
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 )
p_bridge = GetBridge( p_stream );
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;
p_bridge = malloc( sizeof( bridge_t ) );
......@@ -498,7 +498,7 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
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++ )
free( p_bridge->pp_es[i] );
free( p_bridge->pp_es );
......
......@@ -286,7 +286,7 @@ static int CreateFilter( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
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_offsets;
int i_index;
......
......@@ -40,7 +40,7 @@ typedef struct bridge_t
#define GetBridge(a) __GetBridge( VLC_OBJECT(a) )
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;
vlc_value_t val;
......
......@@ -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" );
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 */
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[] )
close( STDOUT_FILENO );
close( STDERR_FILENO );
p_libvlc->p_libvlc_global->b_daemon = VLC_TRUE;
libvlc_global.b_daemon = VLC_TRUE;
}
#endif
}
......@@ -1039,7 +1039,7 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, vlc_bool_t b_release )
#ifndef WIN32
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" ) )
{
psz_pidfile = config_GetPsz( p_libvlc, "pidfile" );
......@@ -1117,7 +1117,7 @@ int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc,
return VLC_EGENERIC;
#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.
* We prefer the dummy interface if none is specified. */
......
......@@ -34,7 +34,6 @@ extern vlc_object_t *
vlc_custom_create (vlc_object_t *p_this, size_t i_size, int i_type,
const char *psz_type);
#if 0
/*****************************************************************************
* libvlc_global_data_t (global variable)
*****************************************************************************
......@@ -71,8 +70,11 @@ struct libvlc_global_data_t
char * psz_vlcpath;
#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;
......
......@@ -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 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_global->i_counter = 0;
p_libvlc_global->i_counter = 0;
p_new->i_object_id = 0;
p_new->p_libvlc_global->i_objects = 1;
p_new->p_libvlc_global->pp_objects = malloc( sizeof(vlc_object_t *) );
p_new->p_libvlc_global->pp_objects[0] = p_new;
p_libvlc_global->i_objects = 1;
p_libvlc_global->pp_objects = malloc( sizeof(vlc_object_t *) );
p_libvlc_global->pp_objects[0] = p_new;
p_new->b_attached = VLC_TRUE;
}
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_this->p_libvlc;
vlc_mutex_lock( &structure_lock );
p_new->p_libvlc_global->i_counter++;
p_new->i_object_id = p_new->p_libvlc_global->i_counter;
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
* useless to try and recover anything if pp_objects gets smashed. */
TAB_APPEND( p_new->p_libvlc_global->i_objects,
p_new->p_libvlc_global->pp_objects,
TAB_APPEND( p_libvlc_global->i_objects, p_libvlc_global->pp_objects,
p_new );
vlc_mutex_unlock( &structure_lock );
......@@ -395,25 +396,27 @@ void __vlc_object_destroy( vlc_object_t *p_this )
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. */
free( p_this->p_libvlc_global->pp_objects );
p_this->p_libvlc_global->pp_objects = NULL;
p_this->p_libvlc_global->i_objects--;
free( p_global->pp_objects );
p_global->pp_objects = NULL;
p_global->i_objects--;
vlc_mutex_destroy( &structure_lock );
}
else
{
libvlc_global_data_t *p_libvlc_global = vlc_global( p_this );
int i_index;
vlc_mutex_lock( &structure_lock );
/* Wooohaa! If *this* fails, we're in serious trouble! Anyway it's
* useless to try and recover anything if pp_objects gets smashed. */
i_index = FindIndex( p_this, p_this->p_libvlc_global->pp_objects,
p_this->p_libvlc_global->i_objects );
REMOVE_ELEM( p_this->p_libvlc_global->pp_objects,
p_this->p_libvlc_global->i_objects, i_index );
i_index = FindIndex( p_this, p_libvlc_global->pp_objects,
p_libvlc_global->i_objects );
REMOVE_ELEM( p_libvlc_global->pp_objects,
p_libvlc_global->i_objects, i_index );
vlc_mutex_unlock( &structure_lock );
}
......@@ -465,13 +468,14 @@ void * __vlc_object_get( vlc_object_t *p_this, int i_id )
{
int i_max, i_middle;
vlc_object_t **pp_objects;
libvlc_global_data_t *p_libvlc_global = vlc_global( p_this );
vlc_mutex_lock( &structure_lock );
pp_objects = p_this->p_libvlc_global->pp_objects;
pp_objects = p_libvlc_global->pp_objects;
/* 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;
......@@ -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_object_t **pp_current, **pp_end;
int i_count = 0, i_index = 0;
libvlc_global_data_t *p_libvlc_global = vlc_global( p_this );
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 )
switch( i_mode & 0x000f )
{
case FIND_ANYWHERE:
pp_current = p_this->p_libvlc_global->pp_objects;
pp_end = pp_current + p_this->p_libvlc_global->i_objects;
pp_current = p_libvlc_global->pp_objects;
pp_end = pp_current + p_libvlc_global->i_objects;
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 )
}
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++ )
{
......@@ -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,
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;
if( *psz_cmd == 'l' )
{
......@@ -790,8 +797,8 @@ static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd,
vlc_object_t **pp_current, **pp_end;
pp_current = p_this->p_libvlc_global->pp_objects;
pp_end = pp_current + p_this->p_libvlc_global->i_objects;
pp_current = p_libvlc_global->pp_objects;
pp_end = pp_current + p_libvlc_global->i_objects;
for( ; pp_current < pp_end ; pp_current++ )
{
......
......@@ -155,7 +155,6 @@ static char * GetWindowsError ( void );
static void module_LoadMain( vlc_object_t *p_this );
/* Sub-version number
* (only used to avoid breakage in dev version when cache structure changes) */
#define CACHE_SUBVERSION_NUM 3
......@@ -170,19 +169,20 @@ void __module_InitBank( vlc_object_t *p_this )
{
module_bank_t *p_bank = NULL;
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_Get( p_this->p_libvlc_global, "libvlc", &lockval );
var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
var_Get( p_libvlc_global, "libvlc", &lockval );
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 );
var_Destroy( p_this->p_libvlc_global, "libvlc" );
var_Destroy( p_libvlc_global, "libvlc" );
return;
}
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) );
if( !p_bank )
......@@ -202,23 +202,12 @@ void __module_InitBank( vlc_object_t *p_this )
#endif
/* Everything worked, attach the object */
p_this->p_libvlc_global->p_module_bank = p_bank;
vlc_object_attach( p_bank, p_this->p_libvlc_global );
p_libvlc_global->p_module_bank = p_bank;
vlc_object_attach( p_bank, p_libvlc_global );
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.
......@@ -230,35 +219,37 @@ void __module_EndBank( vlc_object_t *p_this )
{
module_t * p_next = NULL;
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_Get( p_this->p_libvlc_global, "libvlc", &lockval );
var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
var_Get( p_libvlc_global, "libvlc", &lockval );
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 );
var_Destroy( p_this->p_libvlc_global, "libvlc" );
var_Destroy( p_libvlc_global, "libvlc" );
return;
}
if( --p_this->p_libvlc_global->p_module_bank->i_usage )
if( --p_libvlc_global->p_module_bank->i_usage )
{
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc_global, "libvlc" );
var_Destroy( p_libvlc_global, "libvlc" );
return;
}
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc_global, "libvlc" );
var_Destroy( p_libvlc_global, "libvlc" );
config_AutoSaveConfigFile( p_this );
#ifdef HAVE_DYNAMIC_PLUGINS
#define p_bank p_this->p_libvlc_global->p_module_bank
# define p_bank p_libvlc_global->p_module_bank
if( p_bank->b_cache ) CacheSave( p_this );
while( p_bank->i_loaded_cache-- )
{
if( p_bank->pp_loaded_cache[p_bank->i_loaded_cache] )
{
DeleteModule( p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->p_module, p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->b_used );
DeleteModule( p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->p_module,
p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->b_used );
free( p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->psz_file );
free( p_bank->pp_loaded_cache[p_bank->i_loaded_cache] );
p_bank->pp_loaded_cache[p_bank->i_loaded_cache] = NULL;
......@@ -280,14 +271,14 @@ void __module_EndBank( vlc_object_t *p_this )
free( p_bank->pp_cache );
p_bank->pp_cache = NULL;
}
#undef p_bank
# undef p_bank
#endif
vlc_object_detach( p_this->p_libvlc_global->p_module_bank );
vlc_object_detach( p_libvlc_global->p_module_bank );
while( p_this->p_libvlc_global->p_module_bank->i_children )
while( p_libvlc_global->p_module_bank->i_children )
{
p_next = (module_t *)p_this->p_libvlc_global->p_module_bank->pp_children[0];
p_next = (module_t *)p_libvlc_global->p_module_bank->pp_children[0];
if( DeleteModule( p_next, VLC_TRUE ) )
{
......@@ -301,10 +292,8 @@ void __module_EndBank( vlc_object_t *p_this )
}
}
vlc_object_destroy( p_this->p_libvlc_global->p_module_bank );
p_this->p_libvlc_global->p_module_bank = NULL;
return;
vlc_object_destroy( p_libvlc_global->p_module_bank );
p_libvlc_global->p_module_bank = NULL;
}
/*****************************************************************************
......@@ -318,19 +307,20 @@ void __module_EndBank( vlc_object_t *p_this )
static void module_LoadMain( vlc_object_t *p_this )
{
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_Get( p_this->p_libvlc_global, "libvlc", &lockval );
var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
var_Get( p_libvlc_global, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address );
if( p_this->p_libvlc_global->p_module_bank->b_main )
if( p_libvlc_global->p_module_bank->b_main )
{
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc_global, "libvlc" );
var_Destroy( p_libvlc_global, "libvlc" );
return;
}
p_this->p_libvlc_global->p_module_bank->b_main = VLC_TRUE;
p_libvlc_global->p_module_bank->b_main = VLC_TRUE;
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc_global, "libvlc" );
var_Destroy( p_libvlc_global, "libvlc" );
AllocateBuiltinModule( p_this, vlc_entry__main );
}
......@@ -343,19 +333,20 @@ static void module_LoadMain( vlc_object_t *p_this )
void __module_LoadBuiltins( vlc_object_t * p_this )
{
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_Get( p_this->p_libvlc_global, "libvlc", &lockval );
var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
var_Get( p_libvlc_global, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address );
if( p_this->p_libvlc_global->p_module_bank->b_builtins )
if( p_libvlc_global->p_module_bank->b_builtins )
{
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc_global, "libvlc" );
var_Destroy( p_libvlc_global, "libvlc" );
return;
}
p_this->p_libvlc_global->p_module_bank->b_builtins = VLC_TRUE;
p_libvlc_global->p_module_bank->b_builtins = VLC_TRUE;
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc_global, "libvlc" );
var_Destroy( p_libvlc_global, "libvlc" );
msg_Dbg( p_this, "checking builtin modules" );
ALLOCATE_ALL_BUILTINS();
......@@ -370,27 +361,28 @@ void __module_LoadPlugins( vlc_object_t * p_this )
{
#ifdef HAVE_DYNAMIC_PLUGINS
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_Get( p_this->p_libvlc_global, "libvlc", &lockval );
var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
var_Get( p_libvlc_global, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address );
if( p_this->p_libvlc_global->p_module_bank->b_plugins )
if( p_libvlc_global->p_module_bank->b_plugins )
{
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc_global, "libvlc" );
var_Destroy( p_libvlc_global, "libvlc" );
return;
}
p_this->p_libvlc_global->p_module_bank->b_plugins = VLC_TRUE;
p_libvlc_global->p_module_bank->b_plugins = VLC_TRUE;
vlc_mutex_unlock( lockval.p_address );
var_Destroy( p_this->p_libvlc_global, "libvlc" );
var_Destroy( p_libvlc_global, "libvlc" );
msg_Dbg( p_this, "checking plugin modules" );
if( config_GetInt( p_this, "plugins-cache" ) )
p_this->p_libvlc_global->p_module_bank->b_cache = VLC_TRUE;
p_libvlc_global->p_module_bank->b_cache = VLC_TRUE;
if( p_this->p_libvlc_global->p_module_bank->b_cache ||
p_this->p_libvlc_global->p_module_bank->b_cache_delete ) CacheLoad( p_this );
if( p_libvlc_global->p_module_bank->b_cache ||
p_libvlc_global->p_module_bank->b_cache_delete ) CacheLoad( p_this );
AllocateAllPlugins( p_this );
#endif
......@@ -1073,6 +1065,8 @@ static int AllocatePluginFile( vlc_object_t * p_this, char * psz_file,
if( p_module )
{
libvlc_global_data_t *p_libvlc_global = vlc_global( p_this );
/* Everything worked fine !
* The module is ready to be added to the list. */
p_module->b_builtin = VLC_FALSE;
......@@ -1080,13 +1074,13 @@ static int AllocatePluginFile( vlc_object_t * p_this, char * psz_file,
/* msg_Dbg( p_this, "plugin \"%s\", %s",
p_module->psz_object_name, p_module->psz_longname ); */
vlc_object_attach( p_module, p_this->p_libvlc_global->p_module_bank );
vlc_object_attach( p_module, p_libvlc_global->p_module_bank );
if( !p_this->p_libvlc_global->p_module_bank->b_cache )
if( !p_libvlc_global->p_module_bank->b_cache )
return 0;
#define p_bank p_libvlc_global->p_module_bank
/* Add entry to cache */
#define p_bank p_this->p_libvlc_global->p_module_bank
p_bank->pp_cache =
realloc( p_bank->pp_cache, (p_bank->i_cache + 1) * sizeof(void *) );
p_bank->pp_cache[p_bank->i_cache] = malloc( sizeof(module_cache_t) );
......@@ -1256,7 +1250,7 @@ static int AllocateBuiltinModule( vlc_object_t * p_this,
/* msg_Dbg( p_this, "builtin \"%s\", %s",
p_module->psz_object_name, p_module->psz_longname ); */
vlc_object_attach( p_module, p_this->p_libvlc_global->p_module_bank );
vlc_object_attach( p_module, vlc_global( p_this )->p_module_bank );
return 0;
}
......@@ -1632,6 +1626,7 @@ static void CacheLoad( vlc_object_t *p_this )
int i_cache;