Commit 267cd7f9 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

- Do not attach libvlc to the global data

  to avoid crashes in the messaging system (global data has no libvlc pointer)
- Rename ROOT to GLOBAL to avoid confusion (the root is LIBVLC, not GLOBAL)
parent c6e7cf1b
......@@ -32,7 +32,7 @@
*/
/* Object types */
#define VLC_OBJECT_ROOT (-1)
#define VLC_OBJECT_GLOBAL (-1)
#define VLC_OBJECT_LIBVLC (-2)
#define VLC_OBJECT_MODULE (-3)
#define VLC_OBJECT_INTF (-4)
......
......@@ -208,9 +208,6 @@ libvlc_int_t * libvlc_InternalCreate( void )
vlc_thread_set_priority( p_libvlc, VLC_THREAD_PRIORITY_LOW );
#endif
/* Store our newly allocated structure in the global list */
vlc_object_attach( p_libvlc, p_libvlc_global );
/* Store data for the non-reentrant API */
p_static_vlc = p_libvlc;
......@@ -907,7 +904,6 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, vlc_bool_t b_release )
/* Destroy mutexes */
vlc_mutex_destroy( &p_libvlc->config_lock );
vlc_object_detach( p_libvlc );
if( b_release ) vlc_object_release( p_libvlc );
vlc_object_destroy( p_libvlc );
......
......@@ -198,7 +198,7 @@ const char *msg_GetObjectTypeName(int i_object_type )
{
switch( i_object_type )
{
case VLC_OBJECT_ROOT: return "root";
case VLC_OBJECT_GLOBAL: return "global";
case VLC_OBJECT_LIBVLC: return "libvlc";
case VLC_OBJECT_MODULE: return "module";
case VLC_OBJECT_INTF: return "interface";
......@@ -333,7 +333,6 @@ static void QueueMsg( vlc_object_t *p_this, int i_queue, int i_type,
while( p_obj != NULL )
{
char *psz_old = NULL;
if( p_obj == NULL ) break;
if( p_obj->psz_header )
{
i_header_size += strlen( p_obj->psz_header ) + 4;
......
......@@ -82,19 +82,11 @@ static void ListChildren ( vlc_list_t *, vlc_object_t *, int );
*****************************************************************************/
static vlc_mutex_t structure_lock;
/*****************************************************************************
* vlc_object_create: initialize a vlc object
*****************************************************************************
* This function allocates memory for a vlc object and initializes it. If
* i_type is not a known value such as VLC_OBJECT_ROOT, VLC_OBJECT_VOUT and
* so on, vlc_object_create will use its value for the object size.
*****************************************************************************/
/**
* Initialize a vlc object
*
* This function allocates memory for a vlc object and initializes it. If
* i_type is not a known value such as VLC_OBJECT_ROOT, VLC_OBJECT_VOUT and
* i_type is not a known value such as VLC_OBJECT_LIBVLC, VLC_OBJECT_VOUT and
* so on, vlc_object_create will use its value for the object size.
*/
void * __vlc_object_create( vlc_object_t *p_this, int i_type )
......@@ -105,9 +97,9 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
switch( i_type )
{
case VLC_OBJECT_ROOT:
case VLC_OBJECT_GLOBAL:
i_size = sizeof(libvlc_global_data_t);
psz_type = "root";
psz_type = "global";
break;
case VLC_OBJECT_LIBVLC:
i_size = sizeof(libvlc_int_t);
......@@ -229,7 +221,7 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
break;
}
if( i_type == VLC_OBJECT_ROOT )
if( i_type == VLC_OBJECT_GLOBAL )
{
p_new = p_this;
}
......@@ -266,14 +258,14 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
if( !p_new->p_vars )
{
if( i_type != VLC_OBJECT_ROOT )
if( i_type != VLC_OBJECT_GLOBAL )
free( p_new );
return NULL;
}
if( i_type == VLC_OBJECT_ROOT )
if( i_type == VLC_OBJECT_GLOBAL )
{
/* If i_type is root, 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;
p_new->p_libvlc = NULL;
......@@ -317,7 +309,7 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
vlc_cond_init( p_new, &p_new->object_wait );
vlc_mutex_init( p_new, &p_new->var_lock );
if( i_type == VLC_OBJECT_ROOT )
if( i_type == VLC_OBJECT_GLOBAL )
{
vlc_mutex_init( p_new, &structure_lock );
......@@ -398,9 +390,9 @@ void __vlc_object_destroy( vlc_object_t *p_this )
if( p_this->psz_header ) free( p_this->psz_header );
if( p_this->i_object_type == VLC_OBJECT_ROOT )
if( p_this->i_object_type == VLC_OBJECT_GLOBAL )
{
/* We are the root object ... no need to lock. */
/* 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--;
......@@ -426,8 +418,8 @@ void __vlc_object_destroy( vlc_object_t *p_this )
vlc_mutex_destroy( &p_this->object_lock );
vlc_cond_destroy( &p_this->object_wait );
/* root is not dynamically allocated by vlc_object_create */
if( p_this->i_object_type != VLC_OBJECT_ROOT )
/* global is not dynamically allocated by vlc_object_create */
if( p_this->i_object_type != VLC_OBJECT_GLOBAL )
free( p_this );
}
......
......@@ -117,7 +117,7 @@ int __vlc_threads_init( vlc_object_t *p_this )
#elif defined( HAVE_CTHREADS_H )
#endif
p_root = vlc_object_create( p_libvlc_global, VLC_OBJECT_ROOT );
p_root = vlc_object_create( p_libvlc_global, VLC_OBJECT_GLOBAL );
if( p_root == NULL )
i_ret = VLC_ENOMEM;
......
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