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_DEMUX:
132 i_size = sizeof(demux_t);
135 case VLC_OBJECT_DECODER:
136 i_size = sizeof(decoder_t);
137 psz_type = "decoder";
139 case VLC_OBJECT_PACKETIZER:
140 i_size = sizeof(decoder_t);
141 psz_type = "packetizer";
143 case VLC_OBJECT_ENCODER:
144 i_size = sizeof(encoder_t);
145 psz_type = "encoder";
147 case VLC_OBJECT_VOUT:
148 i_size = sizeof(vout_thread_t);
149 psz_type = "video output";
151 case VLC_OBJECT_AOUT:
152 i_size = sizeof(aout_instance_t);
153 psz_type = "audio output";
155 case VLC_OBJECT_SOUT:
156 i_size = sizeof(sout_instance_t);
157 psz_type = "stream output";
159 case VLC_OBJECT_HTTPD:
160 i_size = sizeof( httpd_t );
161 psz_type = "http daemon";
164 i_size = sizeof( vlm_t );
165 psz_type = "vlm dameon";
167 case VLC_OBJECT_ANNOUNCE:
168 i_size = sizeof( announce_handler_t );
169 psz_type = "announce handler";
173 ? i_type > (int)sizeof(vlc_object_t)
174 ? i_type : (int)sizeof(vlc_object_t)
175 : (int)sizeof(vlc_object_t);
176 i_type = VLC_OBJECT_GENERIC;
177 psz_type = "generic";
181 if( i_type == VLC_OBJECT_ROOT )
187 p_new = malloc( i_size );
194 memset( p_new, 0, i_size );
197 p_new->i_object_type = i_type;
198 p_new->psz_object_type = psz_type;
200 p_new->psz_object_name = NULL;
202 p_new->b_die = VLC_FALSE;
203 p_new->b_error = VLC_FALSE;
204 p_new->b_dead = VLC_FALSE;
205 p_new->b_attached = VLC_FALSE;
208 p_new->p_vars = (variable_t *)malloc( 16 * sizeof( variable_t ) );
216 if( i_type == VLC_OBJECT_ROOT )
218 /* If i_type is root, then p_new is actually p_libvlc */
219 p_new->p_libvlc = (libvlc_t*)p_new;
222 p_new->p_libvlc->i_counter = 0;
223 p_new->i_object_id = 0;
225 p_new->p_libvlc->i_objects = 1;
226 p_new->p_libvlc->pp_objects = malloc( sizeof(vlc_object_t *) );
227 p_new->p_libvlc->pp_objects[0] = p_new;
228 p_new->b_attached = VLC_TRUE;
232 p_new->p_libvlc = p_this->p_libvlc;
233 p_new->p_vlc = ( i_type == VLC_OBJECT_VLC ) ? (vlc_t*)p_new
236 vlc_mutex_lock( &structure_lock );
238 p_new->p_libvlc->i_counter++;
239 p_new->i_object_id = p_new->p_libvlc->i_counter;
241 /* Wooohaa! If *this* fails, we're in serious trouble! Anyway it's
242 * useless to try and recover anything if pp_objects gets smashed. */
243 INSERT_ELEM( p_new->p_libvlc->pp_objects,
244 p_new->p_libvlc->i_objects,
245 p_new->p_libvlc->i_objects,
248 vlc_mutex_unlock( &structure_lock );
251 p_new->i_refcount = 0;
252 p_new->p_parent = NULL;
253 p_new->pp_children = NULL;
254 p_new->i_children = 0;
256 p_new->p_private = NULL;
258 /* Initialize mutexes and condvars */
259 vlc_mutex_init( p_new, &p_new->object_lock );
260 vlc_cond_init( p_new, &p_new->object_wait );
261 vlc_mutex_init( p_new, &p_new->var_lock );
263 if( i_type == VLC_OBJECT_ROOT )
265 vlc_mutex_init( p_new, &structure_lock );
267 var_Create( p_new, "list", VLC_VAR_STRING | VLC_VAR_ISCOMMAND );
268 var_AddCallback( p_new, "list", DumpCommand, NULL );
269 var_Create( p_new, "tree", VLC_VAR_STRING | VLC_VAR_ISCOMMAND );
270 var_AddCallback( p_new, "tree", DumpCommand, NULL );
277 ****************************************************************************
278 * Destroy a vlc object
280 * This function destroys an object that has been previously allocated with
281 * vlc_object_create. The object's refcount must be zero and it must not be
282 * attached to other objects in any way.
283 *****************************************************************************/
284 void __vlc_object_destroy( vlc_object_t *p_this )
288 if( p_this->i_children )
290 msg_Err( p_this, "cannot delete object (%i, %s) with children" ,
291 p_this->i_object_id, p_this->psz_object_name );
295 if( p_this->p_parent )
297 msg_Err( p_this, "cannot delete object (%i, %s) with a parent",
298 p_this->i_object_id, p_this->psz_object_name );
302 while( p_this->i_refcount )
306 /* Don't warn immediately ... 100ms seems OK */
309 msg_Warn( p_this, "refcount is %i, delaying before deletion",
310 p_this->i_refcount );
312 else if( i_delay == 12 )
314 msg_Err( p_this, "refcount is %i, I have a bad feeling about this",
315 p_this->i_refcount );
317 else if( i_delay == 42 )
319 msg_Err( p_this, "we waited too long, cancelling destruction" );
326 /* Destroy the associated variables, starting from the end so that
327 * no memmove calls have to be done. */
328 while( p_this->i_vars )
330 var_Destroy( p_this, p_this->p_vars[p_this->i_vars - 1].psz_name );
333 free( p_this->p_vars );
334 vlc_mutex_destroy( &p_this->var_lock );
336 if( p_this->i_object_type == VLC_OBJECT_ROOT )
338 /* We are the root object ... no need to lock. */
339 free( p_this->p_libvlc->pp_objects );
340 p_this->p_libvlc->pp_objects = NULL;
341 p_this->p_libvlc->i_objects--;
343 vlc_mutex_destroy( &structure_lock );
349 vlc_mutex_lock( &structure_lock );
351 /* Wooohaa! If *this* fails, we're in serious trouble! Anyway it's
352 * useless to try and recover anything if pp_objects gets smashed. */
353 i_index = FindIndex( p_this, p_this->p_libvlc->pp_objects,
354 p_this->p_libvlc->i_objects );
355 REMOVE_ELEM( p_this->p_libvlc->pp_objects,
356 p_this->p_libvlc->i_objects, i_index );
358 vlc_mutex_unlock( &structure_lock );
361 vlc_mutex_destroy( &p_this->object_lock );
362 vlc_cond_destroy( &p_this->object_wait );
368 * find an object given its ID
370 * This function looks for the object whose i_object_id field is i_id. We
371 * use a dichotomy so that lookups are in log2(n).
372 *****************************************************************************/
373 void * __vlc_object_get( vlc_object_t *p_this, int i_id )
376 vlc_object_t **pp_objects;
378 vlc_mutex_lock( &structure_lock );
380 pp_objects = p_this->p_libvlc->pp_objects;
382 /* Perform our dichotomy */
383 for( i_max = p_this->p_libvlc->i_objects - 1 ; ; )
385 i_middle = i_max / 2;
387 if( pp_objects[i_middle]->i_object_id > i_id )
391 else if( pp_objects[i_middle]->i_object_id < i_id )
395 pp_objects += i_middle;
400 /* This happens when there are only two remaining objects */
401 if( pp_objects[i_middle+1]->i_object_id == i_id )
403 vlc_mutex_unlock( &structure_lock );
404 pp_objects[i_middle+1]->i_refcount++;
405 return pp_objects[i_middle+1];
412 vlc_mutex_unlock( &structure_lock );
413 pp_objects[i_middle]->i_refcount++;
414 return pp_objects[i_middle];
419 /* this means that i_max == i_middle, and since we have already
420 * tested pp_objects[i_middle]), p_found is properly set. */
425 vlc_mutex_unlock( &structure_lock );
430 ****************************************************************************
431 * find a typed object and increment its refcount
432 *****************************************************************************
433 * This function recursively looks for a given object type. i_mode can be one
434 * of FIND_PARENT, FIND_CHILD or FIND_ANYWHERE.
435 *****************************************************************************/
436 void * __vlc_object_find( vlc_object_t *p_this, int i_type, int i_mode )
438 vlc_object_t *p_found;
440 vlc_mutex_lock( &structure_lock );
442 /* If we are of the requested type ourselves, don't look further */
443 if( !(i_mode & FIND_STRICT) && p_this->i_object_type == i_type )
445 p_this->i_refcount++;
446 vlc_mutex_unlock( &structure_lock );
450 /* Otherwise, recursively look for the object */
451 if( (i_mode & 0x000f) == FIND_ANYWHERE )
453 vlc_object_t *p_root = p_this;
456 while( p_root->p_parent != NULL &&
457 p_root != VLC_OBJECT( p_this->p_vlc ) )
459 p_root = p_root->p_parent;
462 p_found = FindObject( p_root, i_type, (i_mode & ~0x000f)|FIND_CHILD );
463 if( p_found == NULL && p_root != VLC_OBJECT( p_this->p_vlc ) )
465 p_found = FindObject( VLC_OBJECT( p_this->p_vlc ),
466 i_type, (i_mode & ~0x000f)|FIND_CHILD );
471 p_found = FindObject( p_this, i_type, i_mode );
474 vlc_mutex_unlock( &structure_lock );
480 ****************************************************************************
481 * increment an object refcount
482 *****************************************************************************/
483 void __vlc_object_yield( vlc_object_t *p_this )
485 vlc_mutex_lock( &structure_lock );
486 p_this->i_refcount++;
487 vlc_mutex_unlock( &structure_lock );
491 ****************************************************************************
492 * decrement an object refcount
493 *****************************************************************************/
494 void __vlc_object_release( vlc_object_t *p_this )
496 vlc_mutex_lock( &structure_lock );
497 p_this->i_refcount--;
498 vlc_mutex_unlock( &structure_lock );
502 ****************************************************************************
503 * attach object to a parent object
504 *****************************************************************************
505 * This function sets p_this as a child of p_parent, and p_parent as a parent
506 * of p_this. This link can be undone using vlc_object_detach.
507 *****************************************************************************/
508 void __vlc_object_attach( vlc_object_t *p_this, vlc_object_t *p_parent )
510 vlc_mutex_lock( &structure_lock );
512 /* Attach the parent to its child */
513 p_this->p_parent = p_parent;
515 /* Attach the child to its parent */
516 INSERT_ELEM( p_parent->pp_children, p_parent->i_children,
517 p_parent->i_children, p_this );
519 /* Climb up the tree to see whether we are connected with the root */
520 if( p_parent->b_attached )
522 SetAttachment( p_this, VLC_TRUE );
525 vlc_mutex_unlock( &structure_lock );
529 ****************************************************************************
530 * detach object from its parent
531 *****************************************************************************
532 * This function removes all links between an object and its parent.
533 *****************************************************************************/
534 void __vlc_object_detach( vlc_object_t *p_this )
536 vlc_mutex_lock( &structure_lock );
537 if( !p_this->p_parent )
539 msg_Err( p_this, "object is not attached" );
540 vlc_mutex_unlock( &structure_lock );
544 /* Climb up the tree to see whether we are connected with the root */
545 if( p_this->p_parent->b_attached )
547 SetAttachment( p_this, VLC_FALSE );
550 DetachObject( p_this );
551 vlc_mutex_unlock( &structure_lock );
555 ****************************************************************************
556 * find a list typed objects and increment their refcount
557 *****************************************************************************
558 * This function recursively looks for a given object type. i_mode can be one
559 * of FIND_PARENT, FIND_CHILD or FIND_ANYWHERE.
560 *****************************************************************************/
561 vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
564 vlc_object_t **pp_current, **pp_end;
565 int i_count = 0, i_index = 0;
567 vlc_mutex_lock( &structure_lock );
569 /* Look for the objects */
570 switch( i_mode & 0x000f )
573 pp_current = p_this->p_libvlc->pp_objects;
574 pp_end = pp_current + p_this->p_libvlc->i_objects;
576 for( ; pp_current < pp_end ; pp_current++ )
578 if( (*pp_current)->b_attached
579 && (*pp_current)->i_object_type == i_type )
585 p_list = NewList( i_count );
586 pp_current = p_this->p_libvlc->pp_objects;
588 for( ; pp_current < pp_end ; pp_current++ )
590 if( (*pp_current)->b_attached
591 && (*pp_current)->i_object_type == i_type )
593 ListReplace( p_list, *pp_current, i_index );
594 if( i_index < i_count ) i_index++;
600 i_count = CountChildren( p_this, i_type );
601 p_list = NewList( i_count );
603 /* Check allocation was successful */
604 if( p_list->i_count != i_count )
606 msg_Err( p_this, "list allocation failed!" );
612 ListChildren( p_list, p_this, i_type );
616 msg_Err( p_this, "unimplemented!" );
617 p_list = NewList( 0 );
621 vlc_mutex_unlock( &structure_lock );
626 /*****************************************************************************
627 * DumpCommand: print the current vlc structure
628 *****************************************************************************
629 * This function prints either an ASCII tree showing the connections between
630 * vlc objects, and additional information such as their refcount, thread ID,
631 * etc. (command "tree"), or the same data as a simple list (command "list").
632 *****************************************************************************/
633 static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd,
634 vlc_value_t oldval, vlc_value_t newval, void *p_data )
636 if( *psz_cmd == 't' )
638 char psz_foo[2 * MAX_DUMPSTRUCTURE_DEPTH + 1];
639 vlc_object_t *p_object;
641 if( *newval.psz_string )
643 p_object = vlc_object_get( p_this, atoi(newval.psz_string) );
652 p_object = p_this->p_vlc ? VLC_OBJECT(p_this->p_vlc) : p_this;
655 vlc_mutex_lock( &structure_lock );
658 DumpStructure( p_object, 0, psz_foo );
660 vlc_mutex_unlock( &structure_lock );
662 if( *newval.psz_string )
664 vlc_object_release( p_this );
667 else if( *psz_cmd == 'l' )
669 vlc_object_t **pp_current, **pp_end;
671 vlc_mutex_lock( &structure_lock );
673 pp_current = p_this->p_libvlc->pp_objects;
674 pp_end = pp_current + p_this->p_libvlc->i_objects;
676 for( ; pp_current < pp_end ; pp_current++ )
678 if( (*pp_current)->b_attached )
680 PrintObject( *pp_current, "" );
684 printf( " o %.8i %s (not attached)\n",
685 (*pp_current)->i_object_id,
686 (*pp_current)->psz_object_type );
690 vlc_mutex_unlock( &structure_lock );
696 /*****************************************************************************
697 * vlc_list_release: free a list previously allocated by vlc_list_find
698 *****************************************************************************
699 * This function decreases the refcount of all objects in the list and
701 *****************************************************************************/
702 void vlc_list_release( vlc_list_t *p_list )
706 for( i_index = 0; i_index < p_list->i_count; i_index++ )
708 vlc_mutex_lock( &structure_lock );
710 p_list->p_values[i_index].p_object->i_refcount--;
712 vlc_mutex_unlock( &structure_lock );
715 free( p_list->p_values );
719 /* Following functions are local */
721 /*****************************************************************************
722 * FindIndex: find the index of an object in an array of objects
723 *****************************************************************************
724 * This function assumes that p_this can be found in pp_objects. It will not
725 * crash if p_this cannot be found, but will return a wrong value. It is your
726 * duty to check the return value if you are not certain that the object could
728 *****************************************************************************/
729 static int FindIndex( vlc_object_t *p_this,
730 vlc_object_t **pp_objects, int i_count )
732 int i_middle = i_count / 2;
739 if( pp_objects[i_middle] == p_this )
749 /* We take advantage of the sorted array */
750 if( pp_objects[i_middle]->i_object_id < p_this->i_object_id )
752 return i_middle + FindIndex( p_this, pp_objects + i_middle,
753 i_count - i_middle );
757 return FindIndex( p_this, pp_objects, i_middle );
761 static vlc_object_t * FindObject( vlc_object_t *p_this, int i_type, int i_mode )
766 switch( i_mode & 0x000f )
769 p_tmp = p_this->p_parent;
772 if( p_tmp->i_object_type == i_type )
779 return FindObject( p_tmp, i_type, i_mode );
785 for( i = p_this->i_children; i--; )
787 p_tmp = p_this->pp_children[i];
788 if( p_tmp->i_object_type == i_type )
793 else if( p_tmp->i_children )
795 p_tmp = FindObject( p_tmp, i_type, i_mode );
805 /* Handled in vlc_object_find */
812 static void DetachObject( vlc_object_t *p_this )
814 vlc_object_t *p_parent = p_this->p_parent;
817 /* Remove p_this's parent */
818 p_this->p_parent = NULL;
820 /* Remove all of p_parent's children which are p_this */
821 for( i_index = p_parent->i_children ; i_index-- ; )
823 if( p_parent->pp_children[i_index] == p_this )
825 p_parent->i_children--;
826 for( i = i_index ; i < p_parent->i_children ; i++ )
828 p_parent->pp_children[i] = p_parent->pp_children[i+1];
833 if( p_parent->i_children )
835 p_parent->pp_children = (vlc_object_t **)realloc( p_parent->pp_children,
836 p_parent->i_children * sizeof(vlc_object_t *) );
840 free( p_parent->pp_children );
841 p_parent->pp_children = NULL;
845 /*****************************************************************************
846 * SetAttachment: recursively set the b_attached flag of a subtree.
847 *****************************************************************************
848 * This function is used by the attach and detach functions to propagate
849 * the b_attached flag in a subtree.
850 *****************************************************************************/
851 static void SetAttachment( vlc_object_t *p_this, vlc_bool_t b_attached )
855 for( i_index = p_this->i_children ; i_index-- ; )
857 SetAttachment( p_this->pp_children[i_index], b_attached );
860 p_this->b_attached = b_attached;
863 static void PrintObject( vlc_object_t *p_this, const char *psz_prefix )
865 char psz_children[20], psz_refcount[20], psz_thread[20], psz_name[50];
868 if( p_this->psz_object_name )
870 snprintf( psz_name, 50, " \"%s\"", p_this->psz_object_name );
875 psz_children[0] = '\0';
876 switch( p_this->i_children )
881 strcpy( psz_children, ", 1 child" );
884 snprintf( psz_children, 20,
885 ", %i children", p_this->i_children );
886 psz_children[19] = '\0';
890 psz_refcount[0] = '\0';
891 if( p_this->i_refcount )
893 snprintf( psz_refcount, 20, ", refcount %i", p_this->i_refcount );
894 psz_refcount[19] = '\0';
897 psz_thread[0] = '\0';
898 if( p_this->b_thread )
900 snprintf( psz_thread, 20, " (thread %d)", (int)p_this->thread_id );
901 psz_thread[19] = '\0';
904 printf( " %so %.8i %s%s%s%s%s\n", psz_prefix,
905 p_this->i_object_id, p_this->psz_object_type,
906 psz_name, psz_thread, psz_refcount, psz_children );
909 static void DumpStructure( vlc_object_t *p_this, int i_level, char *psz_foo )
912 char i_back = psz_foo[i_level];
913 psz_foo[i_level] = '\0';
915 PrintObject( p_this, psz_foo );
917 psz_foo[i_level] = i_back;
919 if( i_level / 2 >= MAX_DUMPSTRUCTURE_DEPTH )
921 msg_Warn( p_this, "structure tree is too deep" );
925 for( i = 0 ; i < p_this->i_children ; i++ )
929 psz_foo[i_level-1] = ' ';
931 if( psz_foo[i_level-2] == '`' )
933 psz_foo[i_level-2] = ' ';
937 if( i == p_this->i_children - 1 )
939 psz_foo[i_level] = '`';
943 psz_foo[i_level] = '|';
946 psz_foo[i_level+1] = '-';
947 psz_foo[i_level+2] = '\0';
949 DumpStructure( p_this->pp_children[i], i_level + 2, psz_foo );
953 static vlc_list_t * NewList( int i_count )
955 vlc_list_t * p_list = (vlc_list_t *)malloc( sizeof( vlc_list_t ) );
961 p_list->i_count = i_count;
965 p_list->p_values = NULL;
969 p_list->p_values = malloc( i_count * sizeof( vlc_value_t ) );
970 if( p_list->p_values == NULL )
979 static void ListReplace( vlc_list_t *p_list, vlc_object_t *p_object,
982 if( p_list == NULL || i_index >= p_list->i_count )
987 p_object->i_refcount++;
989 p_list->p_values[i_index].p_object = p_object;
994 static void ListAppend( vlc_list_t *p_list, vlc_object_t *p_object )
1001 p_list->p_values = realloc( p_list->p_values, (p_list->i_count + 1)
1002 * sizeof( vlc_value_t ) );
1003 if( p_list->p_values == NULL )
1005 p_list->i_count = 0;
1009 p_object->i_refcount++;
1011 p_list->p_values[p_list->i_count].p_object = p_object;
1017 static int CountChildren( vlc_object_t *p_this, int i_type )
1019 vlc_object_t *p_tmp;
1022 for( i = 0; i < p_this->i_children; i++ )
1024 p_tmp = p_this->pp_children[i];
1026 if( p_tmp->i_object_type == i_type )
1031 if( p_tmp->i_children )
1033 i_count += CountChildren( p_tmp, i_type );
1040 static void ListChildren( vlc_list_t *p_list, vlc_object_t *p_this, int i_type )
1042 vlc_object_t *p_tmp;
1045 for( i = 0; i < p_this->i_children; i++ )
1047 p_tmp = p_this->pp_children[i];
1049 if( p_tmp->i_object_type == i_type )
1051 ListReplace( p_list, p_tmp, p_list->i_count++ );
1054 if( p_tmp->i_children )
1056 ListChildren( p_list, p_tmp, i_type );