1 /*****************************************************************************
2 * objects.c: vlc_object_t handling
3 *****************************************************************************
4 * Copyright (C) 2004 VideoLAN
7 * Authors: Samuel Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
26 * This file contains the functions to handle the vlc_object_t type
30 /*****************************************************************************
32 *****************************************************************************/
36 # include <stdlib.h> /* realloc() */
39 #include "stream_control.h"
40 #include "input_ext-intf.h"
41 #include "input_ext-dec.h"
43 #include "vlc_video.h"
44 #include "video_output.h"
46 #include "audio_output.h"
47 #include "aout_internal.h"
48 #include "stream_output.h"
50 #include "vlc_playlist.h"
51 #include "vlc_interface.h"
52 #include "vlc_codec.h"
54 #include "vlc_httpd.h"
56 /*****************************************************************************
58 *****************************************************************************/
59 static int DumpCommand( vlc_object_t *, char const *,
60 vlc_value_t, vlc_value_t, void * );
62 static vlc_object_t * FindObject ( vlc_object_t *, int, int );
63 static void DetachObject ( vlc_object_t * );
64 static void PrintObject ( vlc_object_t *, const char * );
65 static void DumpStructure ( vlc_object_t *, int, char * );
66 static int FindIndex ( vlc_object_t *, vlc_object_t **, int );
67 static void SetAttachment ( vlc_object_t *, vlc_bool_t );
69 static vlc_list_t * NewList ( int );
70 static void ListReplace ( vlc_list_t *, vlc_object_t *, int );
71 static void ListAppend ( vlc_list_t *, vlc_object_t * );
72 static int CountChildren ( vlc_object_t *, int );
73 static void ListChildren ( vlc_list_t *, vlc_object_t *, int );
75 /*****************************************************************************
76 * Local structure lock
77 *****************************************************************************/
78 static vlc_mutex_t structure_lock;
80 /*****************************************************************************
81 * vlc_object_create: initialize a vlc object
82 *****************************************************************************
83 * This function allocates memory for a vlc object and initializes it. If
84 * i_type is not a known value such as VLC_OBJECT_ROOT, VLC_OBJECT_VOUT and
85 * so on, vlc_object_create will use its value for the object size.
86 *****************************************************************************/
89 * Initialize a vlc object
91 * This function allocates memory for a vlc object and initializes it. If
92 * i_type is not a known value such as VLC_OBJECT_ROOT, VLC_OBJECT_VOUT and
93 * so on, vlc_object_create will use its value for the object size.
95 void * __vlc_object_create( vlc_object_t *p_this, int i_type )
103 case VLC_OBJECT_ROOT:
104 i_size = sizeof(libvlc_t);
108 i_size = sizeof(vlc_t);
111 case VLC_OBJECT_MODULE:
112 i_size = sizeof(module_t);
115 case VLC_OBJECT_INTF:
116 i_size = sizeof(intf_thread_t);
117 psz_type = "interface";
119 case VLC_OBJECT_DIALOGS:
120 i_size = sizeof(intf_thread_t);
121 psz_type = "dialogs provider";
123 case VLC_OBJECT_PLAYLIST:
124 i_size = sizeof(playlist_t);
125 psz_type = "playlist";
127 case VLC_OBJECT_INPUT:
128 i_size = sizeof(input_thread_t);
131 case VLC_OBJECT_DECODER:
132 i_size = sizeof(decoder_t);
133 psz_type = "decoder";
135 case VLC_OBJECT_PACKETIZER:
136 i_size = sizeof(decoder_t);
137 psz_type = "packetizer";
139 case VLC_OBJECT_ENCODER:
140 i_size = sizeof(encoder_t);
141 psz_type = "encoder";
143 case VLC_OBJECT_VOUT:
144 i_size = sizeof(vout_thread_t);
145 psz_type = "video output";
147 case VLC_OBJECT_AOUT:
148 i_size = sizeof(aout_instance_t);
149 psz_type = "audio output";
151 case VLC_OBJECT_SOUT:
152 i_size = sizeof(sout_instance_t);
153 psz_type = "stream output";
155 case VLC_OBJECT_HTTPD:
156 i_size = sizeof( httpd_t );
157 psz_type = "http daemon";
160 i_size = sizeof( vlm_t );
161 psz_type = "vlm dameon";
165 ? i_type > (int)sizeof(vlc_object_t)
166 ? i_type : (int)sizeof(vlc_object_t)
167 : (int)sizeof(vlc_object_t);
168 i_type = VLC_OBJECT_GENERIC;
169 psz_type = "generic";
173 if( i_type == VLC_OBJECT_ROOT )
179 p_new = malloc( i_size );
186 memset( p_new, 0, i_size );
189 p_new->i_object_type = i_type;
190 p_new->psz_object_type = psz_type;
192 p_new->psz_object_name = NULL;
194 p_new->b_die = VLC_FALSE;
195 p_new->b_error = VLC_FALSE;
196 p_new->b_dead = VLC_FALSE;
197 p_new->b_attached = VLC_FALSE;
200 p_new->p_vars = (variable_t *)malloc( 16 * sizeof( variable_t ) );
208 if( i_type == VLC_OBJECT_ROOT )
210 /* If i_type is root, then p_new is actually p_libvlc */
211 p_new->p_libvlc = (libvlc_t*)p_new;
214 p_new->p_libvlc->i_counter = 0;
215 p_new->i_object_id = 0;
217 p_new->p_libvlc->i_objects = 1;
218 p_new->p_libvlc->pp_objects = malloc( sizeof(vlc_object_t *) );
219 p_new->p_libvlc->pp_objects[0] = p_new;
220 p_new->b_attached = VLC_TRUE;
224 p_new->p_libvlc = p_this->p_libvlc;
225 p_new->p_vlc = ( i_type == VLC_OBJECT_VLC ) ? (vlc_t*)p_new
228 vlc_mutex_lock( &structure_lock );
230 p_new->p_libvlc->i_counter++;
231 p_new->i_object_id = p_new->p_libvlc->i_counter;
233 /* Wooohaa! If *this* fails, we're in serious trouble! Anyway it's
234 * useless to try and recover anything if pp_objects gets smashed. */
235 INSERT_ELEM( p_new->p_libvlc->pp_objects,
236 p_new->p_libvlc->i_objects,
237 p_new->p_libvlc->i_objects,
240 vlc_mutex_unlock( &structure_lock );
243 p_new->i_refcount = 0;
244 p_new->p_parent = NULL;
245 p_new->pp_children = NULL;
246 p_new->i_children = 0;
248 p_new->p_private = NULL;
250 /* Initialize mutexes and condvars */
251 vlc_mutex_init( p_new, &p_new->object_lock );
252 vlc_cond_init( p_new, &p_new->object_wait );
253 vlc_mutex_init( p_new, &p_new->var_lock );
255 if( i_type == VLC_OBJECT_ROOT )
257 vlc_mutex_init( p_new, &structure_lock );
259 var_Create( p_new, "list", VLC_VAR_STRING | VLC_VAR_ISCOMMAND );
260 var_AddCallback( p_new, "list", DumpCommand, NULL );
261 var_Create( p_new, "tree", VLC_VAR_STRING | VLC_VAR_ISCOMMAND );
262 var_AddCallback( p_new, "tree", DumpCommand, NULL );
269 ****************************************************************************
270 * Destroy a vlc object
272 * This function destroys an object that has been previously allocated with
273 * vlc_object_create. The object's refcount must be zero and it must not be
274 * attached to other objects in any way.
275 *****************************************************************************/
276 void __vlc_object_destroy( vlc_object_t *p_this )
280 if( p_this->i_children )
282 msg_Err( p_this, "cannot delete object (%i, %s) with children" ,
283 p_this->i_object_id, p_this->psz_object_name );
287 if( p_this->p_parent )
289 msg_Err( p_this, "cannot delete object (%i, %s) with a parent",
290 p_this->i_object_id, p_this->psz_object_name );
294 while( p_this->i_refcount )
298 /* Don't warn immediately ... 100ms seems OK */
301 msg_Warn( p_this, "refcount is %i, delaying before deletion",
302 p_this->i_refcount );
304 else if( i_delay == 12 )
306 msg_Err( p_this, "refcount is %i, I have a bad feeling about this",
307 p_this->i_refcount );
309 else if( i_delay == 42 )
311 msg_Err( p_this, "we waited too long, cancelling destruction" );
318 /* Destroy the associated variables, starting from the end so that
319 * no memmove calls have to be done. */
320 while( p_this->i_vars )
322 var_Destroy( p_this, p_this->p_vars[p_this->i_vars - 1].psz_name );
325 free( p_this->p_vars );
326 vlc_mutex_destroy( &p_this->var_lock );
328 if( p_this->i_object_type == VLC_OBJECT_ROOT )
330 /* We are the root object ... no need to lock. */
331 free( p_this->p_libvlc->pp_objects );
332 p_this->p_libvlc->pp_objects = NULL;
333 p_this->p_libvlc->i_objects--;
335 vlc_mutex_destroy( &structure_lock );
341 vlc_mutex_lock( &structure_lock );
343 /* Wooohaa! If *this* fails, we're in serious trouble! Anyway it's
344 * useless to try and recover anything if pp_objects gets smashed. */
345 i_index = FindIndex( p_this, p_this->p_libvlc->pp_objects,
346 p_this->p_libvlc->i_objects );
347 REMOVE_ELEM( p_this->p_libvlc->pp_objects,
348 p_this->p_libvlc->i_objects, i_index );
350 vlc_mutex_unlock( &structure_lock );
353 vlc_mutex_destroy( &p_this->object_lock );
354 vlc_cond_destroy( &p_this->object_wait );
360 * find an object given its ID
362 * This function looks for the object whose i_object_id field is i_id. We
363 * use a dichotomy so that lookups are in log2(n).
364 *****************************************************************************/
365 void * __vlc_object_get( vlc_object_t *p_this, int i_id )
368 vlc_object_t **pp_objects;
370 vlc_mutex_lock( &structure_lock );
372 pp_objects = p_this->p_libvlc->pp_objects;
374 /* Perform our dichotomy */
375 for( i_max = p_this->p_libvlc->i_objects - 1 ; ; )
377 i_middle = i_max / 2;
379 if( pp_objects[i_middle]->i_object_id > i_id )
383 else if( pp_objects[i_middle]->i_object_id < i_id )
387 pp_objects += i_middle;
392 /* This happens when there are only two remaining objects */
393 if( pp_objects[i_middle+1]->i_object_id == i_id )
395 vlc_mutex_unlock( &structure_lock );
396 pp_objects[i_middle+1]->i_refcount++;
397 return pp_objects[i_middle+1];
404 vlc_mutex_unlock( &structure_lock );
405 pp_objects[i_middle]->i_refcount++;
406 return pp_objects[i_middle];
411 /* this means that i_max == i_middle, and since we have already
412 * tested pp_objects[i_middle]), p_found is properly set. */
417 vlc_mutex_unlock( &structure_lock );
422 ****************************************************************************
423 * find a typed object and increment its refcount
424 *****************************************************************************
425 * This function recursively looks for a given object type. i_mode can be one
426 * of FIND_PARENT, FIND_CHILD or FIND_ANYWHERE.
427 *****************************************************************************/
428 void * __vlc_object_find( vlc_object_t *p_this, int i_type, int i_mode )
430 vlc_object_t *p_found;
432 vlc_mutex_lock( &structure_lock );
434 /* If we are of the requested type ourselves, don't look further */
435 if( !(i_mode & FIND_STRICT) && p_this->i_object_type == i_type )
437 p_this->i_refcount++;
438 vlc_mutex_unlock( &structure_lock );
442 /* Otherwise, recursively look for the object */
443 if( (i_mode & 0x000f) == FIND_ANYWHERE )
445 vlc_object_t *p_root = p_this;
448 while( p_root->p_parent != NULL &&
449 p_root != VLC_OBJECT( p_this->p_vlc ) )
451 p_root = p_root->p_parent;
454 p_found = FindObject( p_root, i_type, (i_mode & ~0x000f)|FIND_CHILD );
455 if( p_found == NULL && p_root != VLC_OBJECT( p_this->p_vlc ) )
457 p_found = FindObject( VLC_OBJECT( p_this->p_vlc ),
458 i_type, (i_mode & ~0x000f)|FIND_CHILD );
463 p_found = FindObject( p_this, i_type, i_mode );
466 vlc_mutex_unlock( &structure_lock );
472 ****************************************************************************
473 * increment an object refcount
474 *****************************************************************************/
475 void __vlc_object_yield( vlc_object_t *p_this )
477 vlc_mutex_lock( &structure_lock );
478 p_this->i_refcount++;
479 vlc_mutex_unlock( &structure_lock );
483 ****************************************************************************
484 * decrement an object refcount
485 *****************************************************************************/
486 void __vlc_object_release( vlc_object_t *p_this )
488 vlc_mutex_lock( &structure_lock );
489 p_this->i_refcount--;
490 vlc_mutex_unlock( &structure_lock );
494 ****************************************************************************
495 * attach object to a parent object
496 *****************************************************************************
497 * This function sets p_this as a child of p_parent, and p_parent as a parent
498 * of p_this. This link can be undone using vlc_object_detach.
499 *****************************************************************************/
500 void __vlc_object_attach( vlc_object_t *p_this, vlc_object_t *p_parent )
502 vlc_mutex_lock( &structure_lock );
504 /* Attach the parent to its child */
505 p_this->p_parent = p_parent;
507 /* Attach the child to its parent */
508 INSERT_ELEM( p_parent->pp_children, p_parent->i_children,
509 p_parent->i_children, p_this );
511 /* Climb up the tree to see whether we are connected with the root */
512 if( p_parent->b_attached )
514 SetAttachment( p_this, VLC_TRUE );
517 vlc_mutex_unlock( &structure_lock );
521 ****************************************************************************
522 * detach object from its parent
523 *****************************************************************************
524 * This function removes all links between an object and its parent.
525 *****************************************************************************/
526 void __vlc_object_detach( vlc_object_t *p_this )
528 vlc_mutex_lock( &structure_lock );
529 if( !p_this->p_parent )
531 msg_Err( p_this, "object is not attached" );
532 vlc_mutex_unlock( &structure_lock );
536 /* Climb up the tree to see whether we are connected with the root */
537 if( p_this->p_parent->b_attached )
539 SetAttachment( p_this, VLC_FALSE );
542 DetachObject( p_this );
543 vlc_mutex_unlock( &structure_lock );
547 ****************************************************************************
548 * find a list typed objects and increment their refcount
549 *****************************************************************************
550 * This function recursively looks for a given object type. i_mode can be one
551 * of FIND_PARENT, FIND_CHILD or FIND_ANYWHERE.
552 *****************************************************************************/
553 vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
556 vlc_object_t **pp_current, **pp_end;
557 int i_count = 0, i_index = 0;
559 vlc_mutex_lock( &structure_lock );
561 /* Look for the objects */
562 switch( i_mode & 0x000f )
565 pp_current = p_this->p_libvlc->pp_objects;
566 pp_end = pp_current + p_this->p_libvlc->i_objects;
568 for( ; pp_current < pp_end ; pp_current++ )
570 if( (*pp_current)->b_attached
571 && (*pp_current)->i_object_type == i_type )
577 p_list = NewList( i_count );
578 pp_current = p_this->p_libvlc->pp_objects;
580 for( ; pp_current < pp_end ; pp_current++ )
582 if( (*pp_current)->b_attached
583 && (*pp_current)->i_object_type == i_type )
585 ListReplace( p_list, *pp_current, i_index );
586 if( i_index < i_count ) i_index++;
592 i_count = CountChildren( p_this, i_type );
593 p_list = NewList( i_count );
595 /* Check allocation was successful */
596 if( p_list->i_count != i_count )
598 msg_Err( p_this, "list allocation failed!" );
604 ListChildren( p_list, p_this, i_type );
608 msg_Err( p_this, "unimplemented!" );
609 p_list = NewList( 0 );
613 vlc_mutex_unlock( &structure_lock );
618 /*****************************************************************************
619 * DumpCommand: print the current vlc structure
620 *****************************************************************************
621 * This function prints either an ASCII tree showing the connections between
622 * vlc objects, and additional information such as their refcount, thread ID,
623 * etc. (command "tree"), or the same data as a simple list (command "list").
624 *****************************************************************************/
625 static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd,
626 vlc_value_t oldval, vlc_value_t newval, void *p_data )
628 if( *psz_cmd == 't' )
630 char psz_foo[2 * MAX_DUMPSTRUCTURE_DEPTH + 1];
631 vlc_object_t *p_object;
633 if( *newval.psz_string )
635 p_object = vlc_object_get( p_this, atoi(newval.psz_string) );
644 p_object = p_this->p_vlc ? VLC_OBJECT(p_this->p_vlc) : p_this;
647 vlc_mutex_lock( &structure_lock );
650 DumpStructure( p_object, 0, psz_foo );
652 vlc_mutex_unlock( &structure_lock );
654 if( *newval.psz_string )
656 vlc_object_release( p_this );
659 else if( *psz_cmd == 'l' )
661 vlc_object_t **pp_current, **pp_end;
663 vlc_mutex_lock( &structure_lock );
665 pp_current = p_this->p_libvlc->pp_objects;
666 pp_end = pp_current + p_this->p_libvlc->i_objects;
668 for( ; pp_current < pp_end ; pp_current++ )
670 if( (*pp_current)->b_attached )
672 PrintObject( *pp_current, "" );
676 printf( " o %.8i %s (not attached)\n",
677 (*pp_current)->i_object_id,
678 (*pp_current)->psz_object_type );
682 vlc_mutex_unlock( &structure_lock );
688 /*****************************************************************************
689 * vlc_list_release: free a list previously allocated by vlc_list_find
690 *****************************************************************************
691 * This function decreases the refcount of all objects in the list and
693 *****************************************************************************/
694 void vlc_list_release( vlc_list_t *p_list )
698 for( i_index = 0; i_index < p_list->i_count; i_index++ )
700 vlc_mutex_lock( &structure_lock );
702 p_list->p_values[i_index].p_object->i_refcount--;
704 vlc_mutex_unlock( &structure_lock );
707 free( p_list->p_values );
711 /* Following functions are local */
713 /*****************************************************************************
714 * FindIndex: find the index of an object in an array of objects
715 *****************************************************************************
716 * This function assumes that p_this can be found in pp_objects. It will not
717 * crash if p_this cannot be found, but will return a wrong value. It is your
718 * duty to check the return value if you are not certain that the object could
720 *****************************************************************************/
721 static int FindIndex( vlc_object_t *p_this,
722 vlc_object_t **pp_objects, int i_count )
724 int i_middle = i_count / 2;
731 if( pp_objects[i_middle] == p_this )
741 /* We take advantage of the sorted array */
742 if( pp_objects[i_middle]->i_object_id < p_this->i_object_id )
744 return i_middle + FindIndex( p_this, pp_objects + i_middle,
745 i_count - i_middle );
749 return FindIndex( p_this, pp_objects, i_middle );
753 static vlc_object_t * FindObject( vlc_object_t *p_this, int i_type, int i_mode )
758 switch( i_mode & 0x000f )
761 p_tmp = p_this->p_parent;
764 if( p_tmp->i_object_type == i_type )
771 return FindObject( p_tmp, i_type, i_mode );
777 for( i = p_this->i_children; i--; )
779 p_tmp = p_this->pp_children[i];
780 if( p_tmp->i_object_type == i_type )
785 else if( p_tmp->i_children )
787 p_tmp = FindObject( p_tmp, i_type, i_mode );
797 /* Handled in vlc_object_find */
804 static void DetachObject( vlc_object_t *p_this )
806 vlc_object_t *p_parent = p_this->p_parent;
809 /* Remove p_this's parent */
810 p_this->p_parent = NULL;
812 /* Remove all of p_parent's children which are p_this */
813 for( i_index = p_parent->i_children ; i_index-- ; )
815 if( p_parent->pp_children[i_index] == p_this )
817 p_parent->i_children--;
818 for( i = i_index ; i < p_parent->i_children ; i++ )
820 p_parent->pp_children[i] = p_parent->pp_children[i+1];
825 if( p_parent->i_children )
827 p_parent->pp_children = (vlc_object_t **)realloc( p_parent->pp_children,
828 p_parent->i_children * sizeof(vlc_object_t *) );
832 free( p_parent->pp_children );
833 p_parent->pp_children = NULL;
837 /*****************************************************************************
838 * SetAttachment: recursively set the b_attached flag of a subtree.
839 *****************************************************************************
840 * This function is used by the attach and detach functions to propagate
841 * the b_attached flag in a subtree.
842 *****************************************************************************/
843 static void SetAttachment( vlc_object_t *p_this, vlc_bool_t b_attached )
847 for( i_index = p_this->i_children ; i_index-- ; )
849 SetAttachment( p_this->pp_children[i_index], b_attached );
852 p_this->b_attached = b_attached;
855 static void PrintObject( vlc_object_t *p_this, const char *psz_prefix )
857 char psz_children[20], psz_refcount[20], psz_thread[20], psz_name[50];
860 if( p_this->psz_object_name )
862 snprintf( psz_name, 50, " \"%s\"", p_this->psz_object_name );
867 psz_children[0] = '\0';
868 switch( p_this->i_children )
873 strcpy( psz_children, ", 1 child" );
876 snprintf( psz_children, 20,
877 ", %i children", p_this->i_children );
878 psz_children[19] = '\0';
882 psz_refcount[0] = '\0';
883 if( p_this->i_refcount )
885 snprintf( psz_refcount, 20, ", refcount %i", p_this->i_refcount );
886 psz_refcount[19] = '\0';
889 psz_thread[0] = '\0';
890 if( p_this->b_thread )
892 snprintf( psz_thread, 20, " (thread %d)", (int)p_this->thread_id );
893 psz_thread[19] = '\0';
896 printf( " %so %.8i %s%s%s%s%s\n", psz_prefix,
897 p_this->i_object_id, p_this->psz_object_type,
898 psz_name, psz_thread, psz_refcount, psz_children );
901 static void DumpStructure( vlc_object_t *p_this, int i_level, char *psz_foo )
904 char i_back = psz_foo[i_level];
905 psz_foo[i_level] = '\0';
907 PrintObject( p_this, psz_foo );
909 psz_foo[i_level] = i_back;
911 if( i_level / 2 >= MAX_DUMPSTRUCTURE_DEPTH )
913 msg_Warn( p_this, "structure tree is too deep" );
917 for( i = 0 ; i < p_this->i_children ; i++ )
921 psz_foo[i_level-1] = ' ';
923 if( psz_foo[i_level-2] == '`' )
925 psz_foo[i_level-2] = ' ';
929 if( i == p_this->i_children - 1 )
931 psz_foo[i_level] = '`';
935 psz_foo[i_level] = '|';
938 psz_foo[i_level+1] = '-';
939 psz_foo[i_level+2] = '\0';
941 DumpStructure( p_this->pp_children[i], i_level + 2, psz_foo );
945 static vlc_list_t * NewList( int i_count )
947 vlc_list_t * p_list = (vlc_list_t *)malloc( sizeof( vlc_list_t ) );
953 p_list->i_count = i_count;
957 p_list->p_values = NULL;
961 p_list->p_values = malloc( i_count * sizeof( vlc_value_t ) );
962 if( p_list->p_values == NULL )
971 static void ListReplace( vlc_list_t *p_list, vlc_object_t *p_object,
974 if( p_list == NULL || i_index >= p_list->i_count )
979 p_object->i_refcount++;
981 p_list->p_values[i_index].p_object = p_object;
986 static void ListAppend( vlc_list_t *p_list, vlc_object_t *p_object )
993 p_list->p_values = realloc( p_list->p_values, (p_list->i_count + 1)
994 * sizeof( vlc_value_t ) );
995 if( p_list->p_values == NULL )
1001 p_object->i_refcount++;
1003 p_list->p_values[p_list->i_count].p_object = p_object;
1009 static int CountChildren( vlc_object_t *p_this, int i_type )
1011 vlc_object_t *p_tmp;
1014 for( i = 0; i < p_this->i_children; i++ )
1016 p_tmp = p_this->pp_children[i];
1018 if( p_tmp->i_object_type == i_type )
1023 if( p_tmp->i_children )
1025 i_count += CountChildren( p_tmp, i_type );
1032 static void ListChildren( vlc_list_t *p_list, vlc_object_t *p_this, int i_type )
1034 vlc_object_t *p_tmp;
1037 for( i = 0; i < p_this->i_children; i++ )
1039 p_tmp = p_this->pp_children[i];
1041 if( p_tmp->i_object_type == i_type )
1043 ListReplace( p_list, p_tmp, p_list->i_count++ );
1046 if( p_tmp->i_children )
1048 ListChildren( p_list, p_tmp, i_type );