]> git.sesse.net Git - vlc/blobdiff - src/misc/objects.c
* src/playlist/item.c: fixed memory leak.
[vlc] / src / misc / objects.c
index 239fcc0787e2d85684f161da1b8bf668c146073e..0f42de7ae945589be4907316cc0e1d998ffb5b67 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * objects.c: vlc_object_t handling
  *****************************************************************************
- * Copyright (C) 2002 VideoLAN
- * $Id: objects.c,v 1.39 2003/09/18 17:54:02 zorglub Exp $
+ * Copyright (C) 2004 VideoLAN
+ * $Id$
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
 
 #include "vlc_playlist.h"
 #include "vlc_interface.h"
+#include "vlc_codec.h"
 
-#include "httpd.h"
+#include "vlc_httpd.h"
+#include "vlc_vlm.h"
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
@@ -83,7 +85,7 @@ static vlc_mutex_t    structure_lock;
  * 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
@@ -114,6 +116,10 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
             i_size = sizeof(intf_thread_t);
             psz_type = "interface";
             break;
+        case VLC_OBJECT_DIALOGS:
+            i_size = sizeof(intf_thread_t);
+            psz_type = "dialogs provider";
+            break;
         case VLC_OBJECT_PLAYLIST:
             i_size = sizeof(playlist_t);
             psz_type = "playlist";
@@ -126,9 +132,13 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
             i_size = sizeof(decoder_t);
             psz_type = "decoder";
             break;
-        case VLC_OBJECT_DECODER_FIFO: /* tmp for backward compat */
-            i_size = sizeof(decoder_fifo_t);
-            psz_type = "decoder";
+        case VLC_OBJECT_PACKETIZER:
+            i_size = sizeof(decoder_t);
+            psz_type = "packetizer";
+            break;
+        case VLC_OBJECT_ENCODER:
+            i_size = sizeof(encoder_t);
+            psz_type = "encoder";
             break;
         case VLC_OBJECT_VOUT:
             i_size = sizeof(vout_thread_t);
@@ -146,6 +156,14 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
             i_size = sizeof( httpd_t );
             psz_type = "http daemon";
             break;
+        case VLC_OBJECT_VLM:
+            i_size = sizeof( vlm_t );
+            psz_type = "vlm dameon";
+            break;
+        case VLC_OBJECT_ANNOUNCE:
+            i_size = sizeof( announce_handler_t );
+            psz_type = "announce handler";
+            break;
         default:
             i_size = i_type > 0
                       ? i_type > (int)sizeof(vlc_object_t)
@@ -254,7 +272,7 @@ void * __vlc_object_create( vlc_object_t *p_this, int i_type )
 /**
  ****************************************************************************
  * Destroy a vlc object
- * 
+ *
  * This function destroys an object that has been previously allocated with
  * vlc_object_create. The object's refcount must be zero and it must not be
  * attached to other objects in any way.
@@ -265,13 +283,15 @@ void __vlc_object_destroy( vlc_object_t *p_this )
 
     if( p_this->i_children )
     {
-        msg_Err( p_this, "cannot delete object with children" );
+        msg_Err( p_this, "cannot delete object (%i, %s) with children" ,
+                 p_this->i_object_id, p_this->psz_object_name );
         return;
     }
 
     if( p_this->p_parent )
     {
-        msg_Err( p_this, "cannot delete object with a parent" );
+        msg_Err( p_this, "cannot delete object (%i, %s) with a parent",
+                 p_this->i_object_id, p_this->psz_object_name );
         return;
     }
 
@@ -426,8 +446,21 @@ void * __vlc_object_find( vlc_object_t *p_this, int i_type, int i_mode )
     /* Otherwise, recursively look for the object */
     if( (i_mode & 0x000f) == FIND_ANYWHERE )
     {
-        p_found = FindObject( VLC_OBJECT(p_this->p_vlc), i_type,
-                              (i_mode & ~0x000f) | FIND_CHILD );
+        vlc_object_t *p_root = p_this;
+
+        /* Find the root */
+        while( p_root->p_parent != NULL &&
+               p_root != VLC_OBJECT( p_this->p_vlc ) )
+        {
+            p_root = p_root->p_parent;
+        }
+
+        p_found = FindObject( p_root, i_type, (i_mode & ~0x000f)|FIND_CHILD );
+        if( p_found == NULL && p_root != VLC_OBJECT( p_this->p_vlc ) )
+        {
+            p_found = FindObject( VLC_OBJECT( p_this->p_vlc ),
+                                  i_type, (i_mode & ~0x000f)|FIND_CHILD );
+        }
     }
     else
     {