Changeset 215c1a851ceb2a32c721381954ffa0b68c547432
- Timestamp:
- 14/12/02 20:34:07
(6 years ago)
- Author:
- Gildas Bazin <gbazin@videolan.org>
- git-committer:
- Gildas Bazin <gbazin@videolan.org> 1039894447 +0000
- git-parent:
[c4fde1e51a66497c0019872f19b786a7554dae5f]
- git-author:
- Gildas Bazin <gbazin@videolan.org> 1039894447 +0000
- Message:
* src/misc/objects.c: implemented the FIND_CHILD mode for vlc_list_find().
vlc_object_get() now increments the refcount of the object so you'll need to release
the object at some point.
* src/misc/variables.c, ALL: var_Change() with VLC_VAR_GETLIST now returns a vlc_value_t
which points to a vlc_list_t.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| ra71b1c8 |
r215c1a8 |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2002 VideoLAN |
|---|
| 5 | | * $Id: variables.h,v 1.10 2002/12/13 01:56:29 gbazin Exp $ |
|---|
| | 5 | * $Id: variables.h,v 1.11 2002/12/14 19:34:07 gbazin Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Samuel Hocevar <sam@zoy.org> |
|---|
| … | … | |
| 52 | 52 | /* If the variable is to be chosen in a list */ |
|---|
| 53 | 53 | int i_default; |
|---|
| 54 | | int i_choices; |
|---|
| 55 | | vlc_value_t *pp_choices; |
|---|
| | 54 | vlc_list_t choices; |
|---|
| 56 | 55 | |
|---|
| 57 | 56 | /* Set to TRUE if the variable is in a callback */ |
|---|
| ra71b1c8 |
r215c1a8 |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 1998, 1999, 2000 VideoLAN |
|---|
| 5 | | * $Id: vlc.h,v 1.19 2002/12/13 01:56:29 gbazin Exp $ |
|---|
| | 5 | * $Id: vlc.h,v 1.20 2002/12/14 19:34:07 gbazin Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * This program is free software; you can redistribute it and/or modify |
|---|
| … | … | |
| 42 | 42 | void * p_address; |
|---|
| 43 | 43 | vlc_object_t * p_object; |
|---|
| | 44 | vlc_list_t * p_list; |
|---|
| 44 | 45 | |
|---|
| 45 | 46 | /* Make sure the structure is at least 64bits */ |
|---|
| rec51872 |
r215c1a8 |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2001 VideoLAN |
|---|
| 5 | | * $Id: rc.c,v 1.16 2002/12/07 23:50:30 massiot Exp $ |
|---|
| | 5 | * $Id: rc.c,v 1.17 2002/12/14 19:34:06 gbazin Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Peter Surda <shurdeek@panorama.sth.ac.at> |
|---|
| … | … | |
| 736 | 736 | /* Retrieve all registered ***. */ |
|---|
| 737 | 737 | vlc_value_t val; |
|---|
| 738 | | int i, i_vals; |
|---|
| 739 | | vlc_value_t * p_vals; |
|---|
| 740 | | const char * psz_value; |
|---|
| | 738 | int i; |
|---|
| | 739 | char * psz_value; |
|---|
| 741 | 740 | |
|---|
| 742 | 741 | if ( var_Get( (vlc_object_t *)p_aout, psz_variable, &val ) < 0 ) |
|---|
| … | … | |
| 756 | 755 | |
|---|
| 757 | 756 | printf( "+----[ %s ]\n", psz_name ); |
|---|
| 758 | | i_vals = ((vlc_value_t *)val.p_address)[0].i_int; |
|---|
| 759 | | p_vals = &((vlc_value_t *)val.p_address)[1]; /* Starts at index 1 */ |
|---|
| 760 | | for ( i = 0; i < i_vals; i++ ) |
|---|
| 761 | | { |
|---|
| 762 | | if ( !strcmp( psz_value, p_vals[i].psz_string ) ) |
|---|
| 763 | | printf( "| %s *\n", p_vals[i].psz_string ); |
|---|
| | 757 | for ( i = 0; i < val.p_list->i_count; i++ ) |
|---|
| | 758 | { |
|---|
| | 759 | if ( !strcmp( psz_value, val.p_list->p_values[i].psz_string ) ) |
|---|
| | 760 | printf( "| %s *\n", val.p_list->p_values[i].psz_string ); |
|---|
| 764 | 761 | else |
|---|
| 765 | | printf( "| %s\n", p_vals[i].psz_string ); |
|---|
| | 762 | printf( "| %s\n", val.p_list->p_values[i].psz_string ); |
|---|
| 766 | 763 | } |
|---|
| 767 | 764 | var_Change( (vlc_object_t *)p_aout, psz_variable, VLC_VAR_FREELIST, |
|---|
| r2397666 |
r215c1a8 |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2002 VideoLAN |
|---|
| 5 | | * $Id: intf.m,v 1.9 2002/12/08 23:38:02 massiot Exp $ |
|---|
| | 5 | * $Id: intf.m,v 1.10 2002/12/14 19:34:06 gbazin Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Jon Lech Johansen <jon-vl@nanocrew.net> |
|---|
| … | … | |
| 840 | 840 | NSMenu * o_menu = [o_mi submenu]; |
|---|
| 841 | 841 | vlc_value_t val; |
|---|
| 842 | | int i_vals; |
|---|
| 843 | | vlc_value_t * p_vals; |
|---|
| 844 | 842 | char * psz_value; |
|---|
| 845 | 843 | |
|---|
| … | … | |
| 864 | 862 | } |
|---|
| 865 | 863 | |
|---|
| 866 | | i_vals = ((vlc_value_t *)val.p_address)[0].i_int; |
|---|
| 867 | | p_vals = &((vlc_value_t *)val.p_address)[1]; /* Starts at index 1 */ |
|---|
| 868 | | |
|---|
| 869 | 864 | /* make (un)sensitive */ |
|---|
| 870 | | [o_mi setEnabled: (i_vals > 0)]; |
|---|
| 871 | | |
|---|
| 872 | | for ( i = 0; i < i_vals; i++ ) |
|---|
| | 865 | [o_mi setEnabled: (val.p_list->i_count > 0)]; |
|---|
| | 866 | |
|---|
| | 867 | for ( i = 0; i < val.p_list->i_count; i++ ) |
|---|
| 873 | 868 | { |
|---|
| 874 | 869 | NSMenuItem * o_lmi; |
|---|
| 875 | 870 | NSString * o_title; |
|---|
| 876 | 871 | |
|---|
| 877 | | o_title = [NSString stringWithCString: p_vals[i].psz_string]; |
|---|
| | 872 | o_title = [NSString stringWithCString: val.p_list->p_values[i].psz_string]; |
|---|
| 878 | 873 | o_lmi = [o_menu addItemWithTitle: o_title |
|---|
| 879 | 874 | action: pf_callback keyEquivalent: @""]; |
|---|
| … | … | |
| 884 | 879 | [o_lmi setTarget: o_controls]; |
|---|
| 885 | 880 | |
|---|
| 886 | | if ( !strcmp( psz_value, p_vals[i].psz_string ) ) |
|---|
| | 881 | if ( !strcmp( psz_value, val.p_list->p_values[i].psz_string ) ) |
|---|
| 887 | 882 | [o_lmi setState: NSOnState]; |
|---|
| 888 | 883 | } |
|---|
| r0d62cd7 |
r215c1a8 |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2002 VideoLAN |
|---|
| 5 | | * $Id: test4.c,v 1.5 2002/12/07 15:25:26 gbazin Exp $ |
|---|
| | 5 | * $Id: test4.c,v 1.6 2002/12/14 19:34:06 gbazin Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Samuel Hocevar <sam@zoy.org> |
|---|
| … | … | |
| 83 | 83 | { |
|---|
| 84 | 84 | vlc_value_t val; |
|---|
| 85 | | int i, i_vals; |
|---|
| 86 | | vlc_value_t *p_vals; |
|---|
| | 85 | int i; |
|---|
| 87 | 86 | |
|---|
| 88 | 87 | var_Create( p_this, "honk", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); |
|---|
| … | … | |
| 114 | 113 | |
|---|
| 115 | 114 | var_Change( p_this, "honk", VLC_VAR_GETLIST, &val ); |
|---|
| 116 | | i_vals = ((vlc_value_t*)val.p_address)[0].i_int; |
|---|
| 117 | | p_vals = &((vlc_value_t*)val.p_address)[1]; |
|---|
| 118 | | for( i = 0 ; i < i_vals ; i++ ) |
|---|
| 119 | | { |
|---|
| 120 | | printf( "value %i: %s\n", i, p_vals[i].psz_string ); |
|---|
| | 115 | for( i = 0 ; i < val.p_list->i_count ; i++ ) |
|---|
| | 116 | { |
|---|
| | 117 | printf( "value %i: %s\n", i, val.p_list->p_values[i].psz_string ); |
|---|
| 121 | 118 | } |
|---|
| 122 | 119 | var_Change( p_this, "honk", VLC_VAR_FREELIST, &val ); |
|---|
| … | … | |
| 308 | 305 | int id = (int) (MAXOBJ * i_level * 1.0 * rand() / (RAND_MAX)); |
|---|
| 309 | 306 | vlc_object_get( p_this, pp_objects[id]->i_object_id ); |
|---|
| | 307 | vlc_object_release( p_this ); |
|---|
| 310 | 308 | } |
|---|
| 311 | 309 | |
|---|
| ra71b1c8 |
r215c1a8 |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 1998-2002 VideoLAN |
|---|
| 5 | | * $Id: libvlc.c,v 1.51 2002/12/13 01:56:30 gbazin Exp $ |
|---|
| | 5 | * $Id: libvlc.c,v 1.52 2002/12/14 19:34:06 gbazin Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Vincent Seguin <seguin@via.ecp.fr> |
|---|
| … | … | |
| 256 | 256 | { |
|---|
| 257 | 257 | //module_EndBank( p_vlc ); |
|---|
| | 258 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 258 | 259 | return VLC_EGENERIC; |
|---|
| 259 | 260 | } |
|---|
| … | … | |
| 269 | 270 | vlc_object_destroy( p_help_module ); |
|---|
| 270 | 271 | //module_EndBank( p_vlc ); |
|---|
| | 272 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 271 | 273 | return VLC_EGENERIC; |
|---|
| 272 | 274 | } |
|---|
| … | … | |
| 299 | 301 | vlc_object_destroy( p_help_module ); |
|---|
| 300 | 302 | //module_EndBank( p_vlc ); |
|---|
| | 303 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 301 | 304 | return VLC_EEXIT; |
|---|
| 302 | 305 | } |
|---|
| … | … | |
| 346 | 349 | { |
|---|
| 347 | 350 | //module_EndBank( p_vlc ); |
|---|
| | 351 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 348 | 352 | return VLC_EEXIT; |
|---|
| 349 | 353 | } |
|---|
| … | … | |
| 368 | 372 | #endif |
|---|
| 369 | 373 | //module_EndBank( p_vlc ); |
|---|
| | 374 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 370 | 375 | return VLC_EGENERIC; |
|---|
| 371 | 376 | } |
|---|
| … | … | |
| 463 | 468 | } |
|---|
| 464 | 469 | |
|---|
| | 470 | msg_Err( p_vlc, "SIZEOF: %i", sizeof(vlc_list_t) ); |
|---|
| | 471 | msg_Err( p_vlc, "SIZEOF: %i", sizeof(vlc_value_t) ); |
|---|
| | 472 | |
|---|
| 465 | 473 | /* |
|---|
| 466 | 474 | * Initialize playlist and get commandline files |
|---|
| … | … | |
| 475 | 483 | } |
|---|
| 476 | 484 | //module_EndBank( p_vlc ); |
|---|
| | 485 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 477 | 486 | return VLC_EGENERIC; |
|---|
| 478 | 487 | } |
|---|
| … | … | |
| 483 | 492 | GetFilenames( p_vlc, i_argc, ppsz_argv ); |
|---|
| 484 | 493 | |
|---|
| | 494 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 485 | 495 | return VLC_SUCCESS; |
|---|
| 486 | 496 | } |
|---|
| … | … | |
| 529 | 539 | { |
|---|
| 530 | 540 | msg_Err( p_vlc, "interface initialization failed" ); |
|---|
| | 541 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 531 | 542 | return VLC_EGENERIC; |
|---|
| 532 | 543 | } |
|---|
| … | … | |
| 539 | 550 | vlc_object_detach( p_intf ); |
|---|
| 540 | 551 | intf_Destroy( p_intf ); |
|---|
| | 552 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 541 | 553 | return i_err; |
|---|
| 542 | 554 | } |
|---|
| 543 | 555 | |
|---|
| | 556 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 544 | 557 | return VLC_SUCCESS; |
|---|
| 545 | 558 | } |
|---|
| … | … | |
| 605 | 618 | vlc_threads_end( &libvlc ); |
|---|
| 606 | 619 | |
|---|
| | 620 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 607 | 621 | return VLC_SUCCESS; |
|---|
| 608 | 622 | } |
|---|
| … | … | |
| 627 | 641 | p_vlc->b_die = VLC_TRUE; |
|---|
| 628 | 642 | |
|---|
| | 643 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 629 | 644 | return VLC_SUCCESS; |
|---|
| 630 | 645 | } |
|---|
| … | … | |
| 658 | 673 | if( p_playlist == NULL ) |
|---|
| 659 | 674 | { |
|---|
| | 675 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 660 | 676 | return VLC_EGENERIC; |
|---|
| 661 | 677 | } |
|---|
| … | … | |
| 668 | 684 | vlc_object_release( p_playlist ); |
|---|
| 669 | 685 | |
|---|
| | 686 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 670 | 687 | return i_err; |
|---|
| 671 | 688 | } |
|---|
| … | … | |
| 679 | 696 | { |
|---|
| 680 | 697 | vlc_t *p_vlc; |
|---|
| | 698 | int i_ret; |
|---|
| 681 | 699 | |
|---|
| 682 | 700 | p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; |
|---|
| … | … | |
| 713 | 731 | break; |
|---|
| 714 | 732 | } |
|---|
| | 733 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 715 | 734 | return VLC_SUCCESS; |
|---|
| 716 | 735 | } |
|---|
| 717 | 736 | } |
|---|
| 718 | 737 | |
|---|
| 719 | | return var_Set( p_vlc, psz_var, value ); |
|---|
| | 738 | i_ret = var_Set( p_vlc, psz_var, value ); |
|---|
| | 739 | |
|---|
| | 740 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| | 741 | return i_ret; |
|---|
| 720 | 742 | } |
|---|
| 721 | 743 | |
|---|
| … | … | |
| 728 | 750 | { |
|---|
| 729 | 751 | vlc_t *p_vlc; |
|---|
| | 752 | int i_ret; |
|---|
| 730 | 753 | |
|---|
| 731 | 754 | p_vlc = i_object ? vlc_object_get( &libvlc, i_object ) : p_static_vlc; |
|---|
| … | … | |
| 736 | 759 | } |
|---|
| 737 | 760 | |
|---|
| 738 | | return var_Get( p_vlc, psz_var, p_value ); |
|---|
| | 761 | i_ret = var_Get( p_vlc, psz_var, p_value ); |
|---|
| | 762 | |
|---|
| | 763 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| | 764 | return i_ret; |
|---|
| 739 | 765 | } |
|---|
| 740 | 766 | |
|---|
| … | … | |
| 770 | 796 | if( !p_playlist ) |
|---|
| 771 | 797 | { |
|---|
| | 798 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 772 | 799 | return VLC_ENOOBJ; |
|---|
| 773 | 800 | } |
|---|
| … | … | |
| 786 | 813 | vlc_object_release( p_playlist ); |
|---|
| 787 | 814 | |
|---|
| | 815 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 788 | 816 | return VLC_SUCCESS; |
|---|
| 789 | 817 | } |
|---|
| … | … | |
| 854 | 882 | } |
|---|
| 855 | 883 | |
|---|
| | 884 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 856 | 885 | return VLC_SUCCESS; |
|---|
| 857 | 886 | } |
|---|
| … | … | |
| 876 | 905 | if( !p_input ) |
|---|
| 877 | 906 | { |
|---|
| | 907 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 878 | 908 | return VLC_ENOOBJ; |
|---|
| 879 | 909 | } |
|---|
| … | … | |
| 882 | 912 | vlc_object_release( p_input ); |
|---|
| 883 | 913 | |
|---|
| | 914 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 884 | 915 | return VLC_SUCCESS; |
|---|
| 885 | 916 | } |
|---|
| … | … | |
| 904 | 935 | if( !p_vout ) |
|---|
| 905 | 936 | { |
|---|
| | 937 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 906 | 938 | return VLC_ENOOBJ; |
|---|
| 907 | 939 | } |
|---|
| … | … | |
| 910 | 942 | vlc_object_release( p_vout ); |
|---|
| 911 | 943 | |
|---|
| | 944 | if( i_object ) vlc_object_release( p_vlc ); |
|---|
| 912 | 945 | return VLC_SUCCESS; |
|---|
| 913 | 946 | } |
|---|
| ra71b1c8 |
r215c1a8 |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2002 VideoLAN |
|---|
| 5 | | * $Id: objects.c,v 1.32 2002/12/13 01:56:30 gbazin Exp $ |
|---|
| | 5 | * $Id: objects.c,v 1.33 2002/12/14 19:34:06 gbazin Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Samuel Hocevar <sam@zoy.org> |
|---|
| … | … | |
| 61 | 61 | static void ListReplace ( vlc_list_t *, vlc_object_t *, int ); |
|---|
| 62 | 62 | static void ListAppend ( vlc_list_t *, vlc_object_t * ); |
|---|
| | 63 | static int CountChildren ( vlc_object_t *, int ); |
|---|
| | 64 | static void ListChildren ( vlc_list_t *, vlc_object_t *, int ); |
|---|
| 63 | 65 | |
|---|
| 64 | 66 | /***************************************************************************** |
|---|
| … | … | |
| 352 | 354 | { |
|---|
| 353 | 355 | vlc_mutex_unlock( &structure_lock ); |
|---|
| | 356 | pp_objects[i_middle+1]->i_refcount++; |
|---|
| 354 | 357 | return pp_objects[i_middle+1]; |
|---|
| 355 | 358 | } |
|---|
| … | … | |
| 360 | 363 | { |
|---|
| 361 | 364 | vlc_mutex_unlock( &structure_lock ); |
|---|
| | 365 | pp_objects[i_middle]->i_refcount++; |
|---|
| 362 | 366 | return pp_objects[i_middle]; |
|---|
| 363 | 367 | } |
|---|
| … | … | |
| 491 | 495 | { |
|---|
| 492 | 496 | vlc_list_t list; |
|---|
| | 497 | vlc_object_t **pp_current, **pp_end; |
|---|
| | 498 | int i_count = 0, i_index = 0; |
|---|
| 493 | 499 | |
|---|
| 494 | 500 | vlc_mutex_lock( &structure_lock ); |
|---|
| 495 | 501 | |
|---|
| 496 | 502 | /* Look for the objects */ |
|---|
| 497 | | if( (i_mode & 0x000f) == FIND_ANYWHERE ) |
|---|
| 498 | | { |
|---|
| 499 | | vlc_object_t **pp_current, **pp_end; |
|---|
| 500 | | int i_count = 0, i_index = 0; |
|---|
| 501 | | |
|---|
| | 503 | switch( i_mode & 0x000f ) |
|---|
| | 504 | { |
|---|
| | 505 | case FIND_ANYWHERE: |
|---|
| 502 | 506 | pp_current = p_this->p_libvlc->pp_objects; |
|---|
| 503 | 507 | pp_end = pp_current + p_this->p_libvlc->i_objects; |
|---|
| … | … | |
| 524 | 528 | } |
|---|
| 525 | 529 | } |
|---|
| 526 | | } |
|---|
| 527 | | else |
|---|
| 528 | | { |
|---|
| | 530 | break; |
|---|
| | 531 | |
|---|
| | 532 | case FIND_CHILD: |
|---|
| | 533 | i_count = CountChildren( p_this, i_type ); |
|---|
| | 534 | list = NewList( i_count ); |
|---|
| | 535 | |
|---|
| | 536 | /* Check allocation was successful */ |
|---|
| | 537 | if( list.i_count != i_count ) |
|---|
| | 538 | { |
|---|
| | 539 | msg_Err( p_this, "list allocation failed!" ); |
|---|
| | 540 | list.i_count = 0; |
|---|
| | 541 | break; |
|---|
| | 542 | } |
|---|
| | 543 | |
|---|
| | 544 | list.i_count = 0; |
|---|
| | 545 | ListChildren( &list, p_this, i_type ); |
|---|
| | 546 | break; |
|---|
| | 547 | |
|---|
| | 548 | default: |
|---|
| 529 | 549 | msg_Err( p_this, "unimplemented!" ); |
|---|
| 530 | 550 | list = NewList( 0 ); |
|---|
| | 551 | break; |
|---|
| 531 | 552 | } |
|---|
| 532 | 553 | |
|---|
| … | … | |
| 571 | 592 | |
|---|
| 572 | 593 | vlc_mutex_unlock( &structure_lock ); |
|---|
| | 594 | |
|---|
| | 595 | if( *newval.psz_string ) |
|---|
| | 596 | { |
|---|
| | 597 | vlc_object_release( p_this ); |
|---|
| | 598 | } |
|---|
| 573 | 599 | } |
|---|
| 574 | 600 | else if( *psz_cmd == 'l' ) |
|---|
| … | … | |
| 916 | 942 | return; |
|---|
| 917 | 943 | } |
|---|
| | 944 | |
|---|
| | 945 | static int CountChildren( vlc_object_t *p_this, int i_type ) |
|---|
| | 946 | { |
|---|
| | 947 | vlc_object_t *p_tmp; |
|---|
| | 948 | int i, i_count = 0; |
|---|
| | 949 | |
|---|
| | 950 | for( i = 0; i < p_this->i_children; i++ ) |
|---|
| | 951 | { |
|---|
| | 952 | p_tmp = p_this->pp_children[i]; |
|---|
| | 953 | |
|---|
| | 954 | if( p_tmp->i_object_type == i_type ) |
|---|
| | 955 | { |
|---|
| | 956 | i_count++; |
|---|
| | 957 | } |
|---|
| | 958 | |
|---|
| | 959 | if( p_tmp->i_children ) |
|---|
| | 960 | { |
|---|
| | 961 | i_count += CountChildren( p_tmp, i_type ); |
|---|
| | 962 | } |
|---|
| | 963 | } |
|---|
| | 964 | |
|---|
| | 965 | return i_count; |
|---|
| | 966 | } |
|---|
| | 967 | |
|---|
| | 968 | static void ListChildren( vlc_list_t *p_list, vlc_object_t *p_this, int i_type ) |
|---|
| | 969 | { |
|---|
| | 970 | vlc_object_t *p_tmp; |
|---|
| | 971 | int i; |
|---|
| | 972 | |
|---|
| | 973 | for( i = 0; i < p_this->i_children; i++ ) |
|---|
| | 974 | { |
|---|
| | 975 | p_tmp = p_this->pp_children[i]; |
|---|
| | 976 | |
|---|
| | 977 | if( p_tmp->i_object_type == i_type ) |
|---|
| | 978 | { |
|---|
| | 979 | ListReplace( p_list, p_tmp, p_list->i_count++ ); |
|---|
| | 980 | } |
|---|
| | 981 | |
|---|
| | 982 | if( p_tmp->i_children ) |
|---|
| | 983 | { |
|---|
| | 984 | ListChildren( p_list, p_tmp, i_type ); |
|---|
| | 985 | } |
|---|
| | 986 | } |
|---|
| | 987 | } |
|---|
| r05b378d |
r215c1a8 |
|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2002 VideoLAN |
|---|
| 5 | | * $Id: variables.c,v 1.17 2002/12/10 18:22:01 gbazin Exp $ |
|---|
| | 5 | * $Id: variables.c,v 1.18 2002/12/14 19:34:06 gbazin Exp $ |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Authors: Samuel Hocevar <sam@zoy.org> |
|---|
| … | … | |
| 133 | 133 | |
|---|
| 134 | 134 | p_var->i_default = -1; |
|---|
| 135 | | p_var->i_choices = 0; |
|---|
| 136 | | p_var->pp_choices = NULL; |
|---|
| | 135 | p_var->choices.i_count = 0; |
|---|
| | 136 | p_var->choices.p_values = NULL; |
|---|
| 137 | 137 | |
|---|
| 138 | 138 | p_var->b_incallback = VLC_FALSE; |
|---|
| … | … | |
| 221 | 221 | |
|---|
| 222 | 222 | /* Free choice list if needed */ |
|---|
| 223 | | if( p_var->pp_choices ) |
|---|
| 224 | | { |
|---|
| 225 | | for( i = 0 ; i < p_var->i_choices ; i++ ) |
|---|
| 226 | | { |
|---|
| 227 | | p_var->pf_free( &p_var->pp_choices[i] ); |
|---|
| 228 | | } |
|---|
| 229 | | free( p_var->pp_choices ); |
|---|
| | 223 | if( p_var->choices.i_count ) |
|---|
| | 224 | { |
|---|
| | 225 | for( i = 0 ; i < p_var->choices.i_count ; i++ ) |
|---|
| | 226 | { |
|---|
| | 227 | p_var->pf_free( &p_var->choices.p_values[i] ); |
|---|
| | 228 | } |
|---|
| | 229 | free( p_var->choices.p_values ); |
|---|
| 230 | 230 | } |
|---|
| 231 | 231 | |
|---|
| … | … | |
| 310 | 310 | CheckValue( p_var, &p_var->val ); |
|---|
| 311 | 311 | break; |
|---|
| 312 | | |
|---|
| 313 | 312 | case VLC_VAR_ADDCHOICE: |
|---|
| 314 | 313 | /* FIXME: the list is sorted, dude. Use something cleverer. */ |
|---|
| 315 | | for( i = p_var->i_choices ; i-- ; ) |
|---|
| 316 | | { |
|---|
| 317 | | if( p_var->pf_cmp( p_var->pp_choices[i], *p_val ) < 0 ) |
|---|
| | 314 | for( i = p_var->choices.i_count ; i-- ; ) |
|---|
| | 315 | { |
|---|
| | 316 | if( p_var->pf_cmp( p_var->choices.p_values[i], *p_val ) < 0 ) |
|---|
| 318 | 317 | { |
|---|
| 319 | 318 | break; |
|---|
| … | … | |
| 329 | 328 | } |
|---|
| 330 | 329 | |
|---|
| 331 | | INSERT_ELEM( p_var->pp_choices, p_var->i_choices, i, *p_val ); |
|---|
| 332 | | p_var->pf_dup( &p_var->pp_choices[i] ); |
|---|
| | 330 | INSERT_ELEM( p_var->choices.p_values, p_var->choices.i_count, |
|---|
| | 331 | i, *p_val ); |
|---|
| | 332 | p_var->pf_dup( &p_var->choices.p_values[i] ); |
|---|
| 333 | 333 | |
|---|
| 334 | 334 | CheckValue( p_var, &p_var->val ); |
|---|
| … | … | |
| 336 | 336 | case VLC_VAR_DELCHOICE: |
|---|
| 337 | 337 | /* FIXME: the list is sorted, dude. Use something cleverer. */ |
|---|
| 338 | | for( i = 0 ; i < p_var->i_choices ; i++ ) |
|---|
| 339 | | { |
|---|
| 340 | | if( p_var->pf_cmp( p_var->pp_choices[i], *p_val ) == 0 ) |
|---|
| | 338 | for( i = 0 ; i < p_var->choices.i_count ; i++ ) |
|---|
| | 339 | { |
|---|
| | 340 | if( p_var->pf_cmp( p_var->choices.p_values[i], *p_val ) == 0 ) |
|---|
| 341 | 341 | { |
|---|
| 342 | 342 | break; |
|---|
| … | … | |
| 344 | 344 | } |
|---|
| 345 | 345 | |
|---|
| 346 | | if( i == p_var->i_choices ) |
|---|
| | 346 | if( i == p_var->choices.i_count ) |
|---|
| 347 | 347 | { |
|---|
| 348 | 348 | /* Not found */ |
|---|
| … | … | |
| 360 | 360 | } |
|---|
| 361 | 361 | |
|---|
| 362 | | p_var->pf_free( &p_var->pp_choices[i] ); |
|---|
| 363 | | REMOVE_ELEM( p_var->pp_choices, p_var->i_choices, i ); |
|---|
| | 362 | p_var->pf_free( &p_var->choices.p_values[i] ); |
|---|
| | 363 | REMOVE_ELEM( p_var->choices.p_values, p_var->choices.i_count, i ); |
|---|
| 364 | 364 | |
|---|
| 365 | 365 | CheckValue( p_var, &p_var->val ); |
|---|
| … | … | |
| 367 | 367 | case VLC_VAR_SETDEFAULT: |
|---|
| 368 | 368 | /* FIXME: the list is sorted, dude. Use something cleverer. */ |
|---|
| 369 | | for( i = 0 ; i < p_var->i_choices ; i++ ) |
|---|
| 370 | | { |
|---|
| 371 | | if( p_var->pf_cmp( p_var->pp_choices[i], *p_val ) == 0 ) |
|---|
| | 369 | for( i = 0 ; i < p_var->choices.i_count ; i++ ) |
|---|
| | 370 | { |
|---|
| | 371 | if( p_var->pf_cmp( p_var->choices.p_values[i], *p_val ) == 0 ) |
|---|
| 372 | 372 | { |
|---|
| 373 | 373 | break; |
|---|
| … | … | |
| 375 | 375 | } |
|---|
| 376 | 376 | |
|---|
| 377 | | if( i == p_var->i_choices ) |
|---|
| | 377 | if( i == p_var->choices.i_count ) |
|---|
| 378 | 378 | { |
|---|
| 379 | 379 | /* Not found */ |
|---|
| … | … | |
| 386 | 386 | |
|---|
| 387 | 387 | case VLC_VAR_GETLIST: |
|---|
| 388 | | p_val->p_address = malloc( (1 + p_var->i_choices) |
|---|
| 389 | | * sizeof(vlc_value_t) ); |
|---|
| 390 | | ((vlc_value_t*)p_val->p_address)[0].i_int = p_var->i_choices; |
|---|
| 391 | | for( i = 0 ; i < p_var->i_choices ; i++ ) |
|---|
| 392 | | { |
|---|
| 393 | | ((vlc_value_t*)p_val->p_address)[i+1] = p_var->pp_choices[i]; |
|---|
| 394 | | p_var->pf_dup( &((vlc_value_t*)p_val->p_address)[i+1] ); |
|---|
| | 388 | p_val->p_list = malloc( sizeof(vlc_list_t) ); |
|---|
| | 389 | p_val->p_list->p_values = malloc( p_var->choices.i_count |
|---|
| | 390 | * sizeof(vlc_value_t) ); |
|---|
| | 391 | p_val->p_list->i_count = p_var->choices.i_count; |
|---|
| | 392 | for( i = 0 ; i < p_var->choices.i_count ; i++ ) |
|---|
| | 393 | { |
|---|
| | 394 | p_val->p_list->p_values[i] = p_var->choices.p_values[i]; |
|---|
| | 395 | p_var->pf_dup( &p_val->p_list->p_values[i] ); |
|---|
| 395 | 396 | } |
|---|
| 396 | 397 | break; |
|---|
| 397 | 398 | case VLC_VAR_FREELIST: |
|---|
| 398 | | for( i = ((vlc_value_t*)p_val->p_address)[0].i_int ; i-- ; ) |
|---|
| 399 | | { |
|---|
| 400 | | p_var->pf_free( &((vlc_value_t*)p_val->p_address)[i+1] ); |
|---|
| 401 | | } |
|---|
| 402 | | free( p_val->p_address ); |
|---|
| | 399 | for( i = p_val->p_list->i_count ; i-- ; ) |
|---|
| | 400 | { |
|---|
| | 401 | p_var->pf_free( &p_val->p_list->p_values[i] ); |
|---|
| | 402 | } |
|---|
| | 403 | free( p_val->p_list->p_values ); |
|---|
| | 404 | free( p_val->p_list ); |
|---|
| 403 | 405 | break; |
|---|
| 404 | 406 | |
|---|
| … | … | |
| 837 | 839 | { |
|---|
| 838 | 840 | /* Check that our variable is in the list */ |
|---|
| 839 | | if( p_var->i_type & VLC_VAR_HASCHOICE && p_var->i_choices ) |
|---|
| | 841 | if( p_var->i_type & VLC_VAR_HASCHOICE && p_var->choices.i_count ) |
|---|
| 840 | 842 | { |
|---|
| 841 | 843 | int i; |
|---|
| 842 | 844 | |
|---|
| 843 | 845 | /* FIXME: the list is sorted, dude. Use something cleverer. */ |
|---|
| 844 | | for( i = p_var->i_choices ; i-- ; ) |
|---|
| 845 | | { |
|---|
| 846 | | if( p_var->pf_cmp( *p_val, p_var->pp_choices[i] ) == 0 ) |
|---|
| | 846 | for( i = p_var->choices.i_count ; i-- ; ) |
|---|
| | 847 | { |
|---|
| | 848 | if( p_var->pf_cmp( *p_val, p_var->choices.p_values[i] ) == 0 ) |
|---|
| 847 | 849 | { |
|---|
| 848 | 850 | break; |
|---|
| … | … | |
| 855 | 857 | /* Free the old variable, get the new one, dup it */ |
|---|
| 856 | 858 | p_var->pf_free( p_val ); |
|---|
| 857 | | *p_val = p_var->pp_choices[p_var->i_default >= 0 |
|---|
| 858 | | ? p_var->i_default : 0 ]; |
|---|
| | 859 | *p_val = p_var->choices.p_values[p_var->i_default >= 0 |
|---|
| | 860 | ? p_var->i_default : 0 ]; |
|---|
| 859 | 861 | p_var->pf_dup( p_val ); |
|---|
| 860 | 862 | } |
|---|
| … | … | |
| 908 | 910 | } |
|---|
| 909 | 911 | } |
|---|
| 910 | | |
|---|