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

Allocate global object as the others - not statically anymore

parent c07b1d0c
...@@ -115,13 +115,8 @@ void *vlc_custom_create( vlc_object_t *p_this, size_t i_size, ...@@ -115,13 +115,8 @@ void *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
if( p_priv == NULL ) if( p_priv == NULL )
return NULL; return NULL;
if( i_type == VLC_OBJECT_GLOBAL ) assert (i_size >= sizeof (vlc_object_t));
p_new = p_this; p_new = (vlc_object_t *)(p_priv + 1);
else
{
assert (i_size >= sizeof (vlc_object_t));
p_new = (vlc_object_t *)(p_priv + 1);
}
p_new->p_internals = p_priv; p_new->p_internals = p_priv;
p_new->i_object_type = i_type; p_new->i_object_type = i_type;
...@@ -137,8 +132,9 @@ void *vlc_custom_create( vlc_object_t *p_this, size_t i_size, ...@@ -137,8 +132,9 @@ void *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
p_new->psz_header = NULL; p_new->psz_header = NULL;
p_new->i_flags |= p_this->i_flags if (p_this)
& (OBJECT_FLAGS_NODBG|OBJECT_FLAGS_QUIET|OBJECT_FLAGS_NOINTERACT); p_new->i_flags = p_this->i_flags
& (OBJECT_FLAGS_NODBG|OBJECT_FLAGS_QUIET|OBJECT_FLAGS_NOINTERACT);
p_priv->p_vars = calloc( sizeof( variable_t ), 16 ); p_priv->p_vars = calloc( sizeof( variable_t ), 16 );
......
...@@ -57,13 +57,12 @@ static pthread_mutex_t once_mutex = PTHREAD_MUTEX_INITIALIZER; ...@@ -57,13 +57,12 @@ static pthread_mutex_t once_mutex = PTHREAD_MUTEX_INITIALIZER;
* Global process-wide VLC object. * Global process-wide VLC object.
* Contains inter-instance data, such as the module cache and global mutexes. * Contains inter-instance data, such as the module cache and global mutexes.
*/ */
static vlc_object_t *p_root; static libvlc_global_data_t *p_root;
static libvlc_global_data_t libvlc_global;
libvlc_global_data_t *vlc_global( void ) libvlc_global_data_t *vlc_global( void )
{ {
assert( i_initializations > 0 ); assert( i_initializations > 0 );
return &libvlc_global; return p_root;
} }
...@@ -143,16 +142,16 @@ int vlc_threads_init( void ) ...@@ -143,16 +142,16 @@ int vlc_threads_init( void )
if( i_initializations == 0 ) if( i_initializations == 0 )
{ {
/* We should be safe now. Do all the initialization stuff we want. */ p_root = vlc_custom_create( NULL, sizeof( *p_root ),
libvlc_global.b_ready = false;
p_root = vlc_custom_create( VLC_OBJECT(&libvlc_global), 0,
VLC_OBJECT_GLOBAL, "global" ); VLC_OBJECT_GLOBAL, "global" );
if( p_root == NULL ) if( p_root == NULL )
{ {
i_ret = VLC_ENOMEM; i_ret = VLC_ENOMEM;
goto out; goto out;
} }
/* We should be safe now. Do all the initialization stuff we want. */
p_root->b_ready = false;
vlc_threadvar_create( p_root, &msg_context_global_key ); vlc_threadvar_create( p_root, &msg_context_global_key );
} }
i_initializations++; i_initializations++;
...@@ -185,8 +184,9 @@ void vlc_threads_end( void ) ...@@ -185,8 +184,9 @@ void vlc_threads_end( void )
#endif #endif
assert( i_initializations > 0 ); assert( i_initializations > 0 );
if( --i_initializations == 0 ) if( i_initializations == 0 )
vlc_object_release( p_root ); vlc_object_release( p_root );
i_initializations--;
#if defined( UNDER_CE ) #if defined( UNDER_CE )
#elif defined( WIN32 ) #elif defined( WIN32 )
......
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