Commit 30066f7b authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Recurse through the object tree instead of using the objects table

parent ef626a5d
...@@ -78,7 +78,7 @@ static void SetAttachment ( vlc_object_t *, bool ); ...@@ -78,7 +78,7 @@ static void SetAttachment ( vlc_object_t *, bool );
static vlc_list_t * NewList ( int ); static vlc_list_t * NewList ( int );
static void ListReplace ( vlc_list_t *, vlc_object_t *, int ); static void ListReplace ( vlc_list_t *, vlc_object_t *, int );
/*static void ListAppend ( vlc_list_t *, vlc_object_t * );*/ static void ListAppend ( vlc_list_t *, vlc_object_t * );
static int CountChildren ( vlc_object_t *, int ); static int CountChildren ( vlc_object_t *, int );
static void ListChildren ( vlc_list_t *, vlc_object_t *, int ); static void ListChildren ( vlc_list_t *, vlc_object_t *, int );
...@@ -959,6 +959,19 @@ void __vlc_object_detach( vlc_object_t *p_this ) ...@@ -959,6 +959,19 @@ void __vlc_object_detach( vlc_object_t *p_this )
vlc_mutex_unlock( &structure_lock ); vlc_mutex_unlock( &structure_lock );
} }
static void vlc_tree_find (vlc_object_t *node, int type, vlc_list_t *list)
{
assert (node);
vlc_assert_locked (&structure_lock);
if (node->i_object_type == type)
ListAppend (list, node);
for (int i = 0; i < node->i_children; i++)
vlc_tree_find (node->pp_children[i], type, list);
}
/** /**
**************************************************************************** ****************************************************************************
* find a list typed objects and increment their refcount * find a list typed objects and increment their refcount
...@@ -969,7 +982,6 @@ void __vlc_object_detach( vlc_object_t *p_this ) ...@@ -969,7 +982,6 @@ void __vlc_object_detach( vlc_object_t *p_this )
vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode ) vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
{ {
vlc_list_t *p_list; vlc_list_t *p_list;
vlc_object_t **pp_current, **pp_end;
int i_count = 0, i_index = 0; int i_count = 0, i_index = 0;
libvlc_global_data_t *p_libvlc_global = vlc_global(); libvlc_global_data_t *p_libvlc_global = vlc_global();
...@@ -979,31 +991,10 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode ) ...@@ -979,31 +991,10 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
switch( i_mode & 0x000f ) switch( i_mode & 0x000f )
{ {
case FIND_ANYWHERE: case FIND_ANYWHERE:
pp_current = p_libvlc_global->pp_objects; p_list = NewList (0);
pp_end = pp_current + p_libvlc_global->i_objects; if (p_list != NULL)
vlc_tree_find (VLC_OBJECT (p_libvlc_global), i_type, p_list);
for( ; pp_current < pp_end ; pp_current++ ) break;
{
if( vlc_internals(*pp_current)->b_attached
&& (*pp_current)->i_object_type == i_type )
{
i_count++;
}
}
p_list = NewList( i_count );
pp_current = p_libvlc_global->pp_objects;
for( ; pp_current < pp_end ; pp_current++ )
{
if( vlc_internals(*pp_current)->b_attached
&& (*pp_current)->i_object_type == i_type )
{
ListReplace( p_list, *pp_current, i_index );
if( i_index < i_count ) i_index++;
}
}
break;
case FIND_CHILD: case FIND_CHILD:
i_count = CountChildren( p_this, i_type ); i_count = CountChildren( p_this, i_type );
...@@ -1570,7 +1561,7 @@ static void ListReplace( vlc_list_t *p_list, vlc_object_t *p_object, ...@@ -1570,7 +1561,7 @@ static void ListReplace( vlc_list_t *p_list, vlc_object_t *p_object,
return; return;
} }
/*static void ListAppend( vlc_list_t *p_list, vlc_object_t *p_object ) static void ListAppend( vlc_list_t *p_list, vlc_object_t *p_object )
{ {
if( p_list == NULL ) if( p_list == NULL )
{ {
...@@ -1591,7 +1582,7 @@ static void ListReplace( vlc_list_t *p_list, vlc_object_t *p_object, ...@@ -1591,7 +1582,7 @@ static void ListReplace( vlc_list_t *p_list, vlc_object_t *p_object,
p_list->i_count++; p_list->i_count++;
return; return;
}*/ }
static int CountChildren( vlc_object_t *p_this, int i_type ) static int CountChildren( vlc_object_t *p_this, int i_type )
{ {
......
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