if( p_priv == NULL )
return NULL;
- if( i_type == VLC_OBJECT_GLOBAL )
- p_new = p_this;
- else
- {
- assert (i_size >= sizeof (vlc_object_t));
- p_new = (vlc_object_t *)(p_priv + 1);
- }
+ assert (i_size >= sizeof (vlc_object_t));
+ p_new = (vlc_object_t *)(p_priv + 1);
p_new->p_internals = p_priv;
p_new->i_object_type = i_type;
p_new->psz_header = NULL;
- p_new->i_flags |= p_this->i_flags
- & (OBJECT_FLAGS_NODBG|OBJECT_FLAGS_QUIET|OBJECT_FLAGS_NOINTERACT);
+ if (p_this)
+ 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 );
* Global process-wide VLC object.
* Contains inter-instance data, such as the module cache and global mutexes.
*/
-static vlc_object_t *p_root;
-static libvlc_global_data_t libvlc_global;
+static libvlc_global_data_t *p_root;
libvlc_global_data_t *vlc_global( void )
{
assert( i_initializations > 0 );
- return &libvlc_global;
+ return p_root;
}
if( i_initializations == 0 )
{
- /* We should be safe now. Do all the initialization stuff we want. */
- libvlc_global.b_ready = false;
-
- p_root = vlc_custom_create( VLC_OBJECT(&libvlc_global), 0,
+ p_root = vlc_custom_create( NULL, sizeof( *p_root ),
VLC_OBJECT_GLOBAL, "global" );
if( p_root == NULL )
{
i_ret = VLC_ENOMEM;
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 );
}
i_initializations++;
#endif
assert( i_initializations > 0 );
- if( --i_initializations == 0 )
+ if( i_initializations == 0 )
vlc_object_release( p_root );
+ i_initializations--;
#if defined( UNDER_CE )
#elif defined( WIN32 )