]> git.sesse.net Git - vlc/commitdiff
- Do not attach libvlc to the global data
authorRémi Denis-Courmont <rem@videolan.org>
Thu, 9 Nov 2006 17:55:58 +0000 (17:55 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Thu, 9 Nov 2006 17:55:58 +0000 (17:55 +0000)
  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)

include/vlc_objects.h
src/libvlc-common.c
src/misc/messages.c
src/misc/objects.c
src/misc/threads.c

index 71565ab947f5b729d144337d2bcc3a75f4761f82..6440a28dca2f76202d8c320ac040f4ccf9801379 100644 (file)
@@ -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)
index 510f8ca79afabc630d98f82fb79b3321594afc64..020b1bd37caea0344aa6dc95437e47952cb2e10a 100644 (file)
@@ -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 );
 
index 51bc8c34100ecdb1e715d6c150f91373a7df9445..9ccbe4912195b254162935172f73abce5a58879b 100644 (file)
@@ -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;
index e25ac1bb6fa485866b334199d6cb0d8195fa60ad..1fd41031ac09de457c1942df79239c7eef78af01 100644 (file)
@@ -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 );
 }
 
index ccc263c8a4e9e2380e13f922144f34d7941fad49..c2c8ef9788dd95c0f4418e7b878d5e8169a7aa0f 100644 (file)
@@ -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;