From: Gildas Bazin Date: Sun, 4 May 2003 22:42:18 +0000 (+0000) Subject: * src/misc/variables.c, ALL: improvements to the object variables api. X-Git-Tag: 0.6.0~392 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=30336bba3f772a1b20a1c5a0663635b1bffc6c68;p=vlc * src/misc/variables.c, ALL: improvements to the object variables api. - added another argument to var_Change(). - added a VLC_VAR_SETTEXT and VLC_VAR_GETTEXT method to var_Change() that are used to set/get a friendly name to an object variable. - added VLC_VAR_CHOICESCOUNT to var_Change() to be able to retrieve the number of availabel choices without having to get their value as well. - VLC_VAR_ADDCHOICE uses the extra var_Change() argument to assign a friendly name to the choice value. - VLC_VAR_GETCHOICES retrieves the choices values and their friendly names. * modules/gui/wxwindows/*: first step in implementing menu auto-generation in the wxWindows interface. --- diff --git a/include/audio_output.h b/include/audio_output.h index 88b3f787c5..317a5febf9 100644 --- a/include/audio_output.h +++ b/include/audio_output.h @@ -2,7 +2,7 @@ * audio_output.h : audio output interface ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: audio_output.h,v 1.79 2003/02/11 11:16:04 massiot Exp $ + * $Id: audio_output.h,v 1.80 2003/05/04 22:42:14 gbazin Exp $ * * Authors: Christophe Massiot * @@ -122,6 +122,20 @@ typedef int32_t vlc_fixed_t; #define AOUT_CHAN_PHYSMASK 0xFFFF +/* Values used for the audio-device and audio-channels object variables */ +#define AOUT_VAR_MONO 1 +#define AOUT_VAR_STEREO 2 +#define AOUT_VAR_2F2R 3 +#define AOUT_VAR_5_1 4 +#define AOUT_VAR_6_1 5 +#define AOUT_VAR_7_1 6 +#define AOUT_VAR_SPDIF 7 + +#define AOUT_VAR_CHAN_STEREO 1 +#define AOUT_VAR_CHAN_RSTEREO 2 +#define AOUT_VAR_CHAN_LEFT 3 +#define AOUT_VAR_CHAN_RIGHT 4 +#define AOUT_VAR_CHAN_DOLBYS 5 /***************************************************************************** * aout_buffer_t : audio output buffer diff --git a/include/variables.h b/include/variables.h index a34267ea20..45e166ad7f 100644 --- a/include/variables.h +++ b/include/variables.h @@ -2,7 +2,7 @@ * variables.h: variables handling ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: variables.h,v 1.12 2003/03/11 23:56:53 gbazin Exp $ + * $Id: variables.h,v 1.13 2003/05/04 22:42:14 gbazin Exp $ * * Authors: Samuel Hocevar * @@ -37,6 +37,9 @@ struct variable_t uint32_t i_hash; int i_type; + /* The variable display name, mainly for use by the interfaces */ + char * psz_text; + /* A pointer to a comparison function, a duplication function, and * a deallocation function */ int ( * pf_cmp ) ( vlc_value_t, vlc_value_t ); @@ -52,6 +55,7 @@ struct variable_t /* If the variable is to be chosen in a list */ int i_default; vlc_list_t choices; + vlc_list_t choices_text; /* Set to TRUE if the variable is in a callback */ vlc_bool_t b_incallback; @@ -80,6 +84,7 @@ struct variable_t #define VLC_VAR_TIME 0x0060 #define VLC_VAR_ADDRESS 0x0070 #define VLC_VAR_MUTEX 0x0080 +#define VLC_VAR_LIST 0x0090 /* Additive flags */ #define VLC_VAR_HASCHOICE 0x0100 @@ -100,12 +105,18 @@ struct variable_t #define VLC_VAR_SETVALUE 0x0013 +#define VLC_VAR_SETTEXT 0x0014 +#define VLC_VAR_GETTEXT 0x0015 + #define VLC_VAR_ADDCHOICE 0x0020 #define VLC_VAR_DELCHOICE 0x0021 #define VLC_VAR_CLEARCHOICES 0x0022 #define VLC_VAR_SETDEFAULT 0x0023 -#define VLC_VAR_GETLIST 0x0024 -#define VLC_VAR_FREELIST 0x0025 +#define VLC_VAR_GETCHOICES 0x0024 +#define VLC_VAR_FREECHOICES 0x0025 +#define VLC_VAR_GETLIST 0x0026 +#define VLC_VAR_FREELIST 0x0027 +#define VLC_VAR_CHOICESCOUNT 0x0028 /***************************************************************************** * Prototypes @@ -113,7 +124,7 @@ struct variable_t VLC_EXPORT( int, __var_Create, ( vlc_object_t *, const char *, int ) ); VLC_EXPORT( int, __var_Destroy, ( vlc_object_t *, const char * ) ); -VLC_EXPORT( int, __var_Change, ( vlc_object_t *, const char *, int, vlc_value_t * ) ); +VLC_EXPORT( int, __var_Change, ( vlc_object_t *, const char *, int, vlc_value_t *, vlc_value_t * ) ); VLC_EXPORT( int, __var_Type, ( vlc_object_t *, const char * ) ); VLC_EXPORT( int, __var_Set, ( vlc_object_t *, const char *, vlc_value_t ) ); @@ -122,7 +133,7 @@ VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) ); #define var_Create(a,b,c) __var_Create( VLC_OBJECT(a), b, c ) #define var_Destroy(a,b) __var_Destroy( VLC_OBJECT(a), b ) -#define var_Change(a,b,c,d) __var_Change( VLC_OBJECT(a), b, c, d ) +#define var_Change(a,b,c,d,e) __var_Change( VLC_OBJECT(a), b, c, d, e ) #define var_Type(a,b) __var_Type( VLC_OBJECT(a), b ) #define var_Set(a,b,c) __var_Set( VLC_OBJECT(a), b, c ) diff --git a/modules/access/dvd/access.c b/modules/access/dvd/access.c index ffeba628d8..0bf8dc147f 100644 --- a/modules/access/dvd/access.c +++ b/modules/access/dvd/access.c @@ -8,7 +8,7 @@ * -udf.* to find files ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: access.c,v 1.12 2003/03/24 17:15:29 gbazin Exp $ + * $Id: access.c,v 1.13 2003/05/04 22:42:14 gbazin Exp $ * * Author: Stéphane Borel * @@ -325,7 +325,7 @@ static int DVDSetProgram( input_thread_t * p_input, /* Update the navigation variables without triggering a callback */ val.i_int = p_program->i_number; - var_Change( p_input, "program", VLC_VAR_SETVALUE, &val ); + var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL ); } return 0; @@ -500,12 +500,12 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area ) /* Update the navigation variables without triggering a callback */ val.i_int = p_area->i_id; - var_Change( p_input, "title", VLC_VAR_SETVALUE, &val ); - var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL ); + var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL ); + var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL ); for( i = 1; i <= p_area->i_part_nb; i++ ) { val.i_int = i; - var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val ); + var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val, NULL ); } } /* i_title >= 0 */ @@ -525,7 +525,7 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area ) /* Update the navigation variables without triggering a callback */ val.i_int = p_area->i_part; - var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val ); + var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL ); return 0; } diff --git a/modules/access/dvdplay/access.c b/modules/access/dvdplay/access.c index 99b4fd8ec5..ed41aebc62 100644 --- a/modules/access/dvdplay/access.c +++ b/modules/access/dvdplay/access.c @@ -2,7 +2,7 @@ * access.c: access capabilities for dvdplay plugin. ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: access.c,v 1.16 2003/04/05 12:32:19 gbazin Exp $ + * $Id: access.c,v 1.17 2003/05/04 22:42:14 gbazin Exp $ * * Author: Stéphane Borel * @@ -251,7 +251,7 @@ static int dvdplay_SetProgram( input_thread_t * p_input, /* Update the navigation variables without triggering a callback */ val.i_int = p_program->i_number; - var_Change( p_input, "program", VLC_VAR_SETVALUE, &val ); + var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL ); } return 0; @@ -320,7 +320,7 @@ static int dvdplay_SetArea( input_thread_t * p_input, input_area_t * p_area ) /* Update the navigation variables without triggering a callback */ val.i_int = p_area->i_part; - var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val ); + var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL ); return 0; } @@ -430,7 +430,7 @@ static void pf_vmg_callback( void* p_args, dvdplay_event_t event ) /* Update the navigation variables without triggering a callback */ val.i_int = p_input->stream.p_selected_area->i_part; - var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val ); + var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL ); break; case NEW_CELL: p_dvd->b_end_of_cell = 0; @@ -536,17 +536,17 @@ static int dvdNewArea( input_thread_t * p_input, input_area_t * p_area ) /* Update the navigation variables without triggering a callback */ val.i_int = p_area->i_id; - var_Change( p_input, "title", VLC_VAR_SETVALUE, &val ); - var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL ); + var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL ); + var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL ); for( i = 1; (unsigned int)i <= p_area->i_part_nb; i++ ) { val.i_int = i; - var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val ); + var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val, NULL ); } /* Update the navigation variables without triggering a callback */ val.i_int = p_area->i_part; - var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val ); + var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL ); return 0; } diff --git a/modules/access/dvdread/input.c b/modules/access/dvdread/input.c index eb52382314..f5724f4c13 100644 --- a/modules/access/dvdread/input.c +++ b/modules/access/dvdread/input.c @@ -6,7 +6,7 @@ * It depends on: libdvdread for ifo files and block reading. ***************************************************************************** * Copyright (C) 2001, 2003 VideoLAN - * $Id: input.c,v 1.19 2003/03/24 17:15:29 gbazin Exp $ + * $Id: input.c,v 1.20 2003/05/04 22:42:14 gbazin Exp $ * * Author: Stéphane Borel * @@ -475,7 +475,7 @@ static int DvdReadSetProgram( input_thread_t * p_input, /* Update the navigation variables without triggering a callback */ val.i_int = p_program->i_number; - var_Change( p_input, "program", VLC_VAR_SETVALUE, &val ); + var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL ); } return VLC_SUCCESS; @@ -798,12 +798,12 @@ static int DvdReadSetArea( input_thread_t * p_input, input_area_t * p_area ) /* Update the navigation variables without triggering a callback */ val.i_int = p_area->i_id; - var_Change( p_input, "title", VLC_VAR_SETVALUE, &val ); - var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL ); + var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL ); + var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL ); for( i = 1; i <= p_area->i_part_nb; i++ ) { val.i_int = i; - var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val ); + var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val, NULL ); } } /* i_title >= 0 */ @@ -852,7 +852,7 @@ static int DvdReadSetArea( input_thread_t * p_input, input_area_t * p_area ) /* Update the navigation variables without triggering a callback */ val.i_int = p_area->i_part; - var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val ); + var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL ); return VLC_SUCCESS; } diff --git a/modules/access/satellite/access.c b/modules/access/satellite/access.c index e4a9269ddd..ff3b3ed3da 100644 --- a/modules/access/satellite/access.c +++ b/modules/access/satellite/access.c @@ -437,7 +437,7 @@ int SatelliteSetProgram( input_thread_t * p_input, /* Update the navigation variables without triggering a callback */ val.i_int = p_new_prg->i_number; - var_Change( p_input, "program", VLC_VAR_SETVALUE, &val ); + var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL ); return 0; } diff --git a/modules/access/vcd/vcd.c b/modules/access/vcd/vcd.c index e092ddb5c4..c5fc6cadce 100644 --- a/modules/access/vcd/vcd.c +++ b/modules/access/vcd/vcd.c @@ -2,7 +2,7 @@ * vcd.c : VCD input module for vlc ***************************************************************************** * Copyright (C) 2000 VideoLAN - * $Id: vcd.c,v 1.18 2003/03/30 18:14:36 gbazin Exp $ + * $Id: vcd.c,v 1.19 2003/05/04 22:42:15 gbazin Exp $ * * Author: Johan Bilien * @@ -409,12 +409,12 @@ static int VCDSetArea( input_thread_t * p_input, input_area_t * p_area ) /* Update the navigation variables without triggering a callback */ val.i_int = p_area->i_id; - var_Change( p_input, "title", VLC_VAR_SETVALUE, &val ); - var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL ); + var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL ); + var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL ); for( i = 1; i <= p_area->i_part_nb; i++ ) { val.i_int = i; - var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val ); + var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val, NULL ); } } @@ -438,7 +438,7 @@ static int VCDSetArea( input_thread_t * p_input, input_area_t * p_area ) /* Update the navigation variables without triggering a callback */ val.i_int = p_area->i_part; - var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val ); + var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL ); return 0; } diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c index 18af114502..2eefccef30 100644 --- a/modules/audio_output/alsa.c +++ b/modules/audio_output/alsa.c @@ -2,7 +2,7 @@ * alsa.c : alsa plugin for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: alsa.c,v 1.25 2003/03/30 18:14:36 gbazin Exp $ + * $Id: alsa.c,v 1.26 2003/05/04 22:42:15 gbazin Exp $ * * Authors: Henri Fallon - Original Author * Jeffrey Baker - Port to ALSA 1.0 API @@ -104,9 +104,11 @@ static void Probe( aout_instance_t * p_aout, int i_snd_pcm_format ) { struct aout_sys_t * p_sys = p_aout->output.p_sys; - vlc_value_t val; + vlc_value_t val, text; - var_Create ( p_aout, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); + var_Create ( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); + text.psz_string = _("Audio device"); + var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL ); /* Now test linear PCM capabilities */ if ( !snd_pcm_open( &p_sys->p_snd_pcm, psz_device, @@ -153,25 +155,29 @@ static void Probe( aout_instance_t * p_aout, switch ( i_channels ) { case 1: - val.psz_string = N_("Mono"); + val.i_int = AOUT_VAR_MONO; + text.psz_string = N_("Mono"); var_Change( p_aout, "audio-device", - VLC_VAR_ADDCHOICE, &val ); + VLC_VAR_ADDCHOICE, &val, &text ); break; case 2: - val.psz_string = N_("Stereo"); + val.i_int = AOUT_VAR_STEREO; + text.psz_string = N_("Stereo"); var_Change( p_aout, "audio-device", - VLC_VAR_ADDCHOICE, &val ); + VLC_VAR_ADDCHOICE, &val, &text ); break; /* case 4: - val.psz_string = N_("2 Front 2 Rear"); + val.i_int = AOUT_VAR_2F2R; + text.psz_string = N_("2 Front 2 Rear"); var_Change( p_aout, "audio-device", - VLC_VAR_ADDCHOICE, &val ); + VLC_VAR_ADDCHOICE, &val, &text ); break; case 6: - val.psz_string = N_("5.1"); + val.i_int = AOUT_VAR_5_1; + text.psz_string = N_("5.1"); var_Change( p_aout, "audio-device", - VLC_VAR_ADDCHOICE, &val ); + VLC_VAR_ADDCHOICE, &val, &text ); break; */ } @@ -191,11 +197,14 @@ static void Probe( aout_instance_t * p_aout, if ( !snd_pcm_open( &p_sys->p_snd_pcm, psz_iec_device, SND_PCM_STREAM_PLAYBACK, 0 ) ) { - val.psz_string = N_("A/52 over S/PDIF"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); - snd_pcm_close( p_sys->p_snd_pcm ); + val.i_int = AOUT_VAR_SPDIF; + text.psz_string = N_("A/52 over S/PDIF"); + var_Change( p_aout, "audio-device", + VLC_VAR_ADDCHOICE, &val, &text ); if( config_GetInt( p_aout, "spdif" ) ) var_Set( p_aout, "audio-device", val ); + + snd_pcm_close( p_sys->p_snd_pcm ); } } @@ -305,11 +314,11 @@ static int Open( vlc_object_t *p_this ) return VLC_EGENERIC; } - if ( !strcmp( val.psz_string, N_("A/52 over S/PDIF") ) ) + if ( val.i_int, AOUT_VAR_SPDIF ) { p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i'); } - else if ( !strcmp( val.psz_string, N_("5.1") ) ) + else if ( val.i_int == AOUT_VAR_5_1 ) { p_aout->output.output.i_format = i_vlc_pcm_format; p_aout->output.output.i_physical_channels @@ -317,20 +326,20 @@ static int Open( vlc_object_t *p_this ) | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE; } - else if ( !strcmp( val.psz_string, N_("2 Front 2 Rear") ) ) + else if ( val.i_int == AOUT_VAR_2F2R ) { p_aout->output.output.i_format = i_vlc_pcm_format; p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; } - else if ( !strcmp( val.psz_string, N_("Stereo") ) ) + else if ( val.i_int == AOUT_VAR_STEREO ) { p_aout->output.output.i_format = i_vlc_pcm_format; p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; } - else if ( !strcmp( val.psz_string, N_("Mono") ) ) + else if ( val.i_int == AOUT_VAR_MONO ) { p_aout->output.output.i_format = i_vlc_pcm_format; p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; @@ -339,13 +348,10 @@ static int Open( vlc_object_t *p_this ) else { /* This should not happen ! */ - msg_Err( p_aout, "internal: can't find audio-device (%s)", - val.psz_string ); + msg_Err( p_aout, "internal: can't find audio-device (%i)", val.i_int ); free( p_sys ); - free( val.psz_string ); return VLC_EGENERIC; } - free( val.psz_string ); #ifdef DEBUG snd_output_stdio_attach( &p_sys->p_snd_stderr, stderr, 0 ); diff --git a/modules/audio_output/coreaudio.c b/modules/audio_output/coreaudio.c index 8a79d001ad..a1abfafe26 100644 --- a/modules/audio_output/coreaudio.c +++ b/modules/audio_output/coreaudio.c @@ -2,7 +2,7 @@ * coreaudio.c: CoreAudio output plugin ***************************************************************************** * Copyright (C) 2002-2003 VideoLAN - * $Id: coreaudio.c,v 1.2 2003/05/04 15:02:42 massiot Exp $ + * $Id: coreaudio.c,v 1.3 2003/05/04 22:42:15 gbazin Exp $ * * Authors: Colin Delacroix * Jon Lech Johansen @@ -1119,14 +1119,7 @@ static int InitDevice( aout_instance_t * p_aout ) return( VLC_ENOVAR ); } - if( !sscanf( val.psz_string, "%d:", &i_option ) || - p_sys->i_options <= i_option ) - { - i_option = 0; - } - - free( (void *)val.psz_string ); - + i_option = val.i_int; p_option = &p_sys->p_options[i_option]; p_dev = &p_sys->p_devices[p_option->i_dev]; @@ -1450,7 +1443,7 @@ static void InitDeviceVar( aout_instance_t * p_aout, int i_option, vlc_bool_t b_change ) { UInt32 i; - vlc_value_t val; + vlc_value_t val, text; struct aout_sys_t * p_sys = p_aout->output.p_sys; @@ -1466,13 +1459,15 @@ static void InitDeviceVar( aout_instance_t * p_aout, int i_option, } } - var_Create( p_aout, "audio-device", VLC_VAR_STRING | - VLC_VAR_HASCHOICE ); + var_Create( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); + text.psz_string = _("Audio device"); + var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL ); for( i = 0; i < p_sys->i_options; i++ ) { - val.psz_string = p_sys->p_options[i].sz_option; - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + text.psz_string = p_sys->p_options[i].sz_option; + val.i_int = i; + var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); if( !b_change && i == (UInt32)i_option ) { @@ -1487,7 +1482,7 @@ static void InitDeviceVar( aout_instance_t * p_aout, int i_option, if( b_change ) { - val.psz_string = p_sys->p_options[i_option].sz_option; + val.i_int = i_option; var_Set( p_aout, "audio-device", val ); } diff --git a/modules/audio_output/directx.c b/modules/audio_output/directx.c index 578e393d78..023dce93c7 100644 --- a/modules/audio_output/directx.c +++ b/modules/audio_output/directx.c @@ -2,7 +2,7 @@ * directx.c: Windows DirectX audio output method ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: directx.c,v 1.18 2003/04/29 16:03:14 gbazin Exp $ + * $Id: directx.c,v 1.19 2003/05/04 22:42:15 gbazin Exp $ * * Authors: Gildas Bazin * @@ -273,9 +273,8 @@ static int OpenAudio( vlc_object_t *p_this ) CreateEvent( NULL, FALSE, FALSE, NULL ); /* Open the device */ - if( !strcmp( val.psz_string, N_("A/52 over S/PDIF") ) ) + if( val.i_int == AOUT_VAR_SPDIF ) { - free( val.psz_string ); p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i'); /* Calculate the frame size in bytes */ @@ -301,20 +300,20 @@ static int OpenAudio( vlc_object_t *p_this ) } else { - if( !strcmp( val.psz_string, N_("5.1") ) ) + if( val.i_int == AOUT_VAR_5_1 ) { p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE; } - else if( !strcmp( val.psz_string, N_("2 Front 2 Rear") ) ) + else if( val.i_int == AOUT_VAR_2F2R ) { p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; } - else if( !strcmp( val.psz_string, "Mono" ) ) + else if( val.i_int == AOUT_VAR_MONO ) { p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; } @@ -323,7 +322,6 @@ static int OpenAudio( vlc_object_t *p_this ) p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; } - free( val.psz_string ); if( CreateDSBufferPCM( p_aout, &p_aout->output.output.i_format, p_aout->output.output.i_physical_channels, @@ -370,12 +368,14 @@ static int OpenAudio( vlc_object_t *p_this ) *****************************************************************************/ static void Probe( aout_instance_t * p_aout ) { - vlc_value_t val; + vlc_value_t val, text; int i_format; unsigned int i_physical_channels; DWORD ui_speaker_config; - var_Create( p_aout, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); + var_Create( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); + text.psz_string = _("Audio device"); + var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL ); /* Test for 5.1 support */ i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | @@ -387,8 +387,10 @@ static void Probe( aout_instance_t * p_aout ) p_aout->output.output.i_rate, VLC_TRUE ) == VLC_SUCCESS ) { - val.psz_string = N_("5.1"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + val.i_int = AOUT_VAR_5_1; + text.psz_string = N_("5.1"); + var_Change( p_aout, "audio-device", + VLC_VAR_ADDCHOICE, &val, &text ); msg_Dbg( p_aout, "device supports 5.1 channels" ); } } @@ -403,8 +405,10 @@ static void Probe( aout_instance_t * p_aout ) p_aout->output.output.i_rate, VLC_TRUE ) == VLC_SUCCESS ) { - val.psz_string = N_("2 Front 2 Rear"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + val.i_int = AOUT_VAR_2F2R; + text.psz_string = N_("2 Front 2 Rear"); + var_Change( p_aout, "audio-device", + VLC_VAR_ADDCHOICE, &val, &text ); msg_Dbg( p_aout, "device supports 4 channels" ); } } @@ -415,8 +419,9 @@ static void Probe( aout_instance_t * p_aout ) p_aout->output.output.i_rate, VLC_TRUE ) == VLC_SUCCESS ) { - val.psz_string = N_("Stereo"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + val.i_int = AOUT_VAR_STEREO; + text.psz_string = N_("Stereo"); + var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); msg_Dbg( p_aout, "device supports 2 channels" ); } @@ -426,8 +431,9 @@ static void Probe( aout_instance_t * p_aout ) p_aout->output.output.i_rate, VLC_TRUE ) == VLC_SUCCESS ) { - val.psz_string = N_("Mono"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + val.i_int = AOUT_VAR_MONO; + text.psz_string = N_("Mono"); + var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); msg_Dbg( p_aout, "device supports 1 channel" ); } @@ -441,18 +447,18 @@ static void Probe( aout_instance_t * p_aout ) switch( DSSPEAKER_CONFIG(ui_speaker_config) ) { case DSSPEAKER_5POINT1: - val.psz_string = N_("5.1"); + val.i_int = AOUT_VAR_5_1; break; case DSSPEAKER_QUAD: - val.psz_string = N_("2 Front 2 Rear"); + val.i_int = AOUT_VAR_2F2R; break; case DSSPEAKER_MONO: - val.psz_string = N_("Mono"); + val.i_int = AOUT_VAR_MONO; break; case DSSPEAKER_SURROUND: case DSSPEAKER_STEREO: default: - val.psz_string = N_("Stereo"); + val.i_int = AOUT_VAR_STEREO; break; } var_Set( p_aout, "audio-device", val ); @@ -468,8 +474,10 @@ static void Probe( aout_instance_t * p_aout ) == VLC_SUCCESS ) { msg_Dbg( p_aout, "device supports A/52 over S/PDIF" ); - val.psz_string = N_("A/52 over S/PDIF"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + val.i_int = AOUT_VAR_SPDIF; + text.psz_string = N_("A/52 over S/PDIF"); + var_Change( p_aout, "audio-device", + VLC_VAR_ADDCHOICE, &val, &text ); if( config_GetInt( p_aout, "spdif" ) ) var_Set( p_aout, "audio-device", val ); } diff --git a/modules/audio_output/oss.c b/modules/audio_output/oss.c index e10ce091f9..9818d46e45 100644 --- a/modules/audio_output/oss.c +++ b/modules/audio_output/oss.c @@ -2,7 +2,7 @@ * oss.c : OSS /dev/dsp module for vlc ***************************************************************************** * Copyright (C) 2000-2002 VideoLAN - * $Id: oss.c,v 1.57 2003/04/20 21:19:41 sam Exp $ + * $Id: oss.c,v 1.58 2003/05/04 22:42:15 gbazin Exp $ * * Authors: Michel Kaempf * Samuel Hocevar @@ -66,7 +66,6 @@ # endif #endif - /***************************************************************************** * aout_sys_t: OSS audio output method descriptor ***************************************************************************** @@ -112,6 +111,7 @@ vlc_module_begin(); add_bool( "oss-buggy", 0, NULL, BUGGY_TEXT, BUGGY_LONGTEXT, VLC_TRUE ); set_description( _("Linux OSS audio output") ); set_capability( "audio output", 100 ); + add_shortcut( "oss" ); set_callbacks( Open, Close ); vlc_module_end(); @@ -122,10 +122,12 @@ vlc_module_end(); static void Probe( aout_instance_t * p_aout ) { struct aout_sys_t * p_sys = p_aout->output.p_sys; - vlc_value_t val; + vlc_value_t val, text; int i_format, i_nb_channels; - var_Create( p_aout, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); + var_Create( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); + text.psz_string = _("Audio device"); + var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL ); /* Test for multi-channel. */ #ifdef SNDCTL_DSP_GETCHANNELMASK @@ -161,8 +163,10 @@ static void Probe( aout_instance_t * p_aout ) | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE)) ) { - val.psz_string = N_("5.1"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + val.i_int = AOUT_VAR_5_1; + text.psz_string = N_("5.1"); + var_Change( p_aout, "audio-device", + VLC_VAR_ADDCHOICE, &val, &text ); } if ( (i_chanmask & DSP_BIND_SURR) @@ -170,8 +174,10 @@ static void Probe( aout_instance_t * p_aout ) (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT)) ) { - val.psz_string = N_("2 Front 2 Rear"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + val.i_int = AOUT_VAR_2F2R; + text.psz_string = N_("2 Front 2 Rear"); + var_Change( p_aout, "audio-device", + VLC_VAR_ADDCHOICE, &val, &text ); } } } @@ -192,8 +198,9 @@ static void Probe( aout_instance_t * p_aout ) if( ioctl( p_sys->i_fd, SNDCTL_DSP_CHANNELS, &i_nb_channels ) >= 0 && i_nb_channels == 2 ) { - val.psz_string = N_("Stereo"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + val.i_int = AOUT_VAR_STEREO; + text.psz_string = N_("Stereo"); + var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); } /* Reset all. */ @@ -211,8 +218,9 @@ static void Probe( aout_instance_t * p_aout ) if( ioctl( p_sys->i_fd, SNDCTL_DSP_CHANNELS, &i_nb_channels ) >= 0 && i_nb_channels == 1 ) { - val.psz_string = N_("Mono"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + val.i_int = AOUT_VAR_MONO; + text.psz_string = N_("Mono"); + var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); if ( p_aout->output.output.i_physical_channels == AOUT_CHAN_CENTER ) { var_Set( p_aout, "audio-device", val ); @@ -234,8 +242,10 @@ static void Probe( aout_instance_t * p_aout ) if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) >= 0 && i_format == AFMT_AC3 ) { - val.psz_string = N_("A/52 over S/PDIF"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + val.i_int = AOUT_VAR_SPDIF; + text.psz_string = N_("A/52 over S/PDIF"); + var_Change( p_aout, "audio-device", + VLC_VAR_ADDCHOICE, &val, &text ); if( config_GetInt( p_aout, "spdif" ) ) var_Set( p_aout, "audio-device", val ); } @@ -307,11 +317,11 @@ static int Open( vlc_object_t *p_this ) return VLC_EGENERIC; } - if ( !strcmp( val.psz_string, N_("A/52 over S/PDIF") ) ) + if ( val.i_int == AOUT_VAR_SPDIF ) { p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i'); } - else if ( !strcmp( val.psz_string, N_("5.1") ) ) + else if ( val.i_int == AOUT_VAR_5_1 ) { p_aout->output.output.i_format = AOUT_FMT_S16_NE; p_aout->output.output.i_physical_channels @@ -319,20 +329,20 @@ static int Open( vlc_object_t *p_this ) | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE; } - else if ( !strcmp( val.psz_string, N_("2 Front 2 Rear") ) ) + else if ( val.i_int == AOUT_VAR_2F2R ) { p_aout->output.output.i_format = AOUT_FMT_S16_NE; p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; } - else if ( !strcmp( val.psz_string, N_("Stereo") ) ) + else if ( val.i_int == AOUT_VAR_STEREO ) { p_aout->output.output.i_format = AOUT_FMT_S16_NE; p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; } - else if ( !strcmp( val.psz_string, N_("Mono") ) ) + else if ( val.i_int == AOUT_VAR_MONO ) { p_aout->output.output.i_format = AOUT_FMT_S16_NE; p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; @@ -340,13 +350,10 @@ static int Open( vlc_object_t *p_this ) else { /* This should not happen ! */ - msg_Err( p_aout, "internal: can't find audio-device (%s)", - val.psz_string ); + msg_Err( p_aout, "internal: can't find audio-device (%i)", val.i_int ); free( p_sys ); - free( val.psz_string ); return VLC_EGENERIC; } - free( val.psz_string ); val.b_bool = VLC_TRUE; var_Set( p_aout, "intf-change", val ); diff --git a/modules/audio_output/sdl.c b/modules/audio_output/sdl.c index 6e70aefee4..0958063d27 100644 --- a/modules/audio_output/sdl.c +++ b/modules/audio_output/sdl.c @@ -2,7 +2,7 @@ * sdl.c : SDL audio output plugin for vlc ***************************************************************************** * Copyright (C) 2000-2002 VideoLAN - * $Id: sdl.c,v 1.21 2003/03/30 18:14:36 gbazin Exp $ + * $Id: sdl.c,v 1.22 2003/05/04 22:42:15 gbazin Exp $ * * Authors: Michel Kaempf * Samuel Hocevar @@ -79,7 +79,7 @@ static int Open ( vlc_object_t *p_this ) aout_instance_t *p_aout = (aout_instance_t *)p_this; SDL_AudioSpec desired, obtained; int i_nb_channels; - vlc_value_t val; + vlc_value_t val, text; /* Check that no one uses the DSP. */ Uint32 i_flags = SDL_INIT_AUDIO; @@ -105,22 +105,20 @@ static int Open ( vlc_object_t *p_this ) return VLC_EGENERIC; } - if ( var_Type( p_aout, "audio-device" ) == - (VLC_VAR_STRING | VLC_VAR_HASCHOICE) ) + if ( var_Type( p_aout, "audio-device" ) != 0 ) { /* The user has selected an audio device. */ vlc_value_t val; var_Get( p_aout, "audio-device", &val ); - if ( !strcmp( val.psz_string, N_("Stereo") ) ) + if ( val.i_int == AOUT_VAR_STEREO ) { p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; } - else if ( !strcmp( val.psz_string, N_("Mono") ) ) + else if ( val.i_int == AOUT_VAR_MONO ) { p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; } - free( val.psz_string ); } i_nb_channels = aout_FormatNbChannels( &p_aout->output.output ); @@ -173,10 +171,17 @@ static int Open ( vlc_object_t *p_this ) if ( var_Type( p_aout, "audio-device" ) == 0 ) { - var_Create( p_aout, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); - val.psz_string = (obtained.channels == 2) ? N_("Stereo") : + var_Create( p_aout, "audio-device", + VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); + text.psz_string = _("Audio device"); + var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL ); + + val.i_int = (obtained.channels == 2) ? AOUT_VAR_STEREO : + AOUT_VAR_MONO; + text.psz_string = (obtained.channels == 2) ? N_("Stereo") : N_("Mono"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + var_Change( p_aout, "audio-device", + VLC_VAR_ADDCHOICE, &val, &text ); var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); } @@ -184,22 +189,27 @@ static int Open ( vlc_object_t *p_this ) else if ( var_Type( p_aout, "audio-device" ) == 0 ) { /* First launch. */ - var_Create( p_aout, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); - val.psz_string = N_("Stereo"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); - val.psz_string = N_("Mono"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + var_Create( p_aout, "audio-device", + VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); + text.psz_string = _("Audio device"); + var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL ); + + val.i_int = AOUT_VAR_STEREO; + text.psz_string = N_("Stereo"); + var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); + val.i_int = AOUT_VAR_MONO; + text.psz_string = N_("Mono"); + var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); if ( i_nb_channels == 2 ) { - val.psz_string = N_("Stereo"); + val.i_int = AOUT_VAR_STEREO; } else { - val.psz_string = N_("Mono"); + val.i_int = AOUT_VAR_MONO; } - var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val ); - var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, - NULL ); + var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val, NULL ); + var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); } val.b_bool = VLC_TRUE; diff --git a/modules/audio_output/waveout.c b/modules/audio_output/waveout.c index 5f8666bc59..4899859e7c 100644 --- a/modules/audio_output/waveout.c +++ b/modules/audio_output/waveout.c @@ -2,7 +2,7 @@ * waveout.c : Windows waveOut plugin for vlc ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: waveout.c,v 1.23 2003/04/08 21:26:22 gbazin Exp $ + * $Id: waveout.c,v 1.24 2003/05/04 22:42:15 gbazin Exp $ * * Authors: Gildas Bazin * @@ -198,10 +198,9 @@ static int Open( vlc_object_t *p_this ) } /* Open the device */ - if( !strcmp( val.psz_string, N_("A/52 over S/PDIF") ) ) + if( val.i_int == AOUT_VAR_SPDIF ) { p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i'); - free( val.psz_string ); if( OpenWaveOut( p_aout, VLC_FOURCC('s','p','d','i'), p_aout->output.output.i_physical_channels, @@ -225,20 +224,20 @@ static int Open( vlc_object_t *p_this ) } else { - if( !strcmp( val.psz_string, N_("5.1") ) ) + if( val.i_int == AOUT_VAR_5_1 ) { p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE; } - else if( !strcmp( val.psz_string, N_("2 Front 2 Rear") ) ) + else if( val.i_int == AOUT_VAR_2F2R ) { p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; } - else if( !strcmp( val.psz_string, "Mono" ) ) + else if( val.i_int == AOUT_VAR_MONO ) { p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; } @@ -247,7 +246,6 @@ static int Open( vlc_object_t *p_this ) p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; } - free( val.psz_string ); if( OpenWaveOutPCM( p_aout, &p_aout->output.output.i_format, p_aout->output.output.i_physical_channels, @@ -303,11 +301,13 @@ static int Open( vlc_object_t *p_this ) *****************************************************************************/ static void Probe( aout_instance_t * p_aout ) { - vlc_value_t val; + vlc_value_t val, text; int i_format; unsigned int i_physical_channels; - var_Create( p_aout, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); + var_Create( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); + text.psz_string = _("Audio device"); + var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL ); /* Test for 5.1 support */ i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | @@ -320,8 +320,10 @@ static void Probe( aout_instance_t * p_aout ) p_aout->output.output.i_rate, VLC_TRUE ) == VLC_SUCCESS ) { - val.psz_string = N_("5.1"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + val.i_int = AOUT_VAR_5_1; + text.psz_string = N_("5.1"); + var_Change( p_aout, "audio-device", + VLC_VAR_ADDCHOICE, &val, &text ); msg_Dbg( p_aout, "device supports 5.1 channels" ); } } @@ -337,8 +339,10 @@ static void Probe( aout_instance_t * p_aout ) p_aout->output.output.i_rate, VLC_TRUE ) == VLC_SUCCESS ) { - val.psz_string = N_("2 Front 2 Rear"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + val.i_int = AOUT_VAR_2F2R; + text.psz_string = N_("2 Front 2 Rear"); + var_Change( p_aout, "audio-device", + VLC_VAR_ADDCHOICE, &val, &text ); msg_Dbg( p_aout, "device supports 4 channels" ); } } @@ -350,9 +354,9 @@ static void Probe( aout_instance_t * p_aout ) p_aout->output.output.i_rate, VLC_TRUE ) == VLC_SUCCESS ) { - val.psz_string = N_("Stereo"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); - var_Set( p_aout, "audio-device", val ); + val.i_int = AOUT_VAR_STEREO; + text.psz_string = N_("Stereo"); + var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); msg_Dbg( p_aout, "device supports 2 channels" ); } @@ -363,8 +367,9 @@ static void Probe( aout_instance_t * p_aout ) p_aout->output.output.i_rate, VLC_TRUE ) == VLC_SUCCESS ) { - val.psz_string = N_("Mono"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + val.i_int = AOUT_VAR_MONO; + text.psz_string = N_("Mono"); + var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text ); msg_Dbg( p_aout, "device supports 1 channel" ); } @@ -378,8 +383,10 @@ static void Probe( aout_instance_t * p_aout ) == VLC_SUCCESS ) { msg_Dbg( p_aout, "device supports A/52 over S/PDIF" ); - val.psz_string = N_("A/52 over S/PDIF"); - var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val ); + val.i_int = AOUT_VAR_SPDIF; + text.psz_string = N_("A/52 over S/PDIF"); + var_Change( p_aout, "audio-device", + VLC_VAR_ADDCHOICE, &val, &text ); if( config_GetInt( p_aout, "spdif" ) ) var_Set( p_aout, "audio-device", val ); } diff --git a/modules/control/rc/rc.c b/modules/control/rc/rc.c index 5b6bf8cbb4..6650e31375 100644 --- a/modules/control/rc/rc.c +++ b/modules/control/rc/rc.c @@ -2,7 +2,7 @@ * rc.c : remote control stdin/stdout plugin for vlc ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: rc.c,v 1.30 2003/03/30 18:14:37 gbazin Exp $ + * $Id: rc.c,v 1.31 2003/05/04 22:42:15 gbazin Exp $ * * Authors: Peter Surda * @@ -794,7 +794,7 @@ static int AudioConfig( vlc_object_t *p_this, char const *psz_cmd, { aout_instance_t * p_aout; const char * psz_variable; - const char * psz_name; + vlc_value_t val_name; int i_error; p_aout = vlc_object_find( p_this, VLC_OBJECT_AOUT, FIND_ANYWHERE ); @@ -803,55 +803,58 @@ static int AudioConfig( vlc_object_t *p_this, char const *psz_cmd, if ( !strcmp( psz_cmd, "adev" ) ) { psz_variable = "audio-device"; - psz_name = "audio devices"; } else { psz_variable = "audio-channels"; - psz_name = "audio channels"; } + /* Get the descriptive name of the variable */ + var_Change( (vlc_object_t *)p_aout, psz_variable, VLC_VAR_GETTEXT, + &val_name, NULL ); + if( !val_name.psz_string ) val_name.psz_string = strdup(psz_variable); + if ( !*newval.psz_string ) { /* Retrieve all registered ***. */ - vlc_value_t val; - int i; - char * psz_value; + vlc_value_t val, text; + int i, i_value; if ( var_Get( (vlc_object_t *)p_aout, psz_variable, &val ) < 0 ) { vlc_object_release( (vlc_object_t *)p_aout ); return VLC_EGENERIC; } - psz_value = val.psz_string; + i_value = val.i_int; if ( var_Change( (vlc_object_t *)p_aout, psz_variable, - VLC_VAR_GETLIST, &val ) < 0 ) + VLC_VAR_GETLIST, &val, &text ) < 0 ) { - free( psz_value ); vlc_object_release( (vlc_object_t *)p_aout ); return VLC_EGENERIC; } - printf( "+----[ %s ]\n", psz_name ); + printf( "+----[ %s ]\n", val_name.psz_string ); for ( i = 0; i < val.p_list->i_count; i++ ) { - if ( !strcmp( psz_value, val.p_list->p_values[i].psz_string ) ) - printf( "| %s *\n", val.p_list->p_values[i].psz_string ); + if ( i_value == val.p_list->p_values[i].i_int ) + printf( "| %i - %s *\n", val.p_list->p_values[i].i_int, + text.p_list->p_values[i].psz_string ); else - printf( "| %s\n", val.p_list->p_values[i].psz_string ); + printf( "| %i - %s\n", val.p_list->p_values[i].i_int, + text.p_list->p_values[i].psz_string ); } var_Change( (vlc_object_t *)p_aout, psz_variable, VLC_VAR_FREELIST, - &val ); - printf( "+----[ end of %s ]\n", psz_name ); + &val, NULL ); + printf( "+----[ end of %s ]\n", val_name.psz_string ); - free( psz_value ); + if( val_name.psz_string ) free( val_name.psz_string ); i_error = VLC_SUCCESS; } else { vlc_value_t val; - val.psz_string = newval.psz_string; + val.i_int = atoi( newval.psz_string ); i_error = var_Set( (vlc_object_t *)p_aout, psz_variable, val ); } diff --git a/modules/gui/gtk/menu.c b/modules/gui/gtk/menu.c index 479d1a2c93..06cb3d03fa 100644 --- a/modules/gui/gtk/menu.c +++ b/modules/gui/gtk/menu.c @@ -2,7 +2,7 @@ * menu.c : functions to handle menu items. ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: menu.c,v 1.8 2003/02/05 22:11:52 sam Exp $ + * $Id: menu.c,v 1.9 2003/05/04 22:42:15 gbazin Exp $ * * Authors: Samuel Hocevar * Stéphane Borel @@ -293,15 +293,16 @@ void GtkMenubarChapterToggle( GtkCheckMenuItem * menuitem, gpointer user_data ) } -static void GtkPopupObjectToggle( GtkCheckMenuItem * menuitem, gpointer user_data, - int i_object_type, char *psz_variable ) +static void GtkPopupObjectToggle( GtkCheckMenuItem * menuitem, + gpointer user_data, int i_object_type, char *psz_variable ) { intf_thread_t *p_intf = GtkGetIntf( menuitem ); GtkLabel *p_label; p_label = GTK_LABEL( ( GTK_BIN( menuitem )->child ) ); - if( menuitem->active && !p_intf->p_sys->b_aout_update && !p_intf->p_sys->b_vout_update ) + if( menuitem->active && !p_intf->p_sys->b_aout_update && + !p_intf->p_sys->b_vout_update ) { vlc_object_t * p_obj; @@ -311,7 +312,14 @@ static void GtkPopupObjectToggle( GtkCheckMenuItem * menuitem, gpointer user_dat { vlc_value_t val; - gtk_label_get( p_label, &val.psz_string ); + if( user_data ) + { + val = (vlc_value_t)user_data; + } + else + { + gtk_label_get( p_label, &val.psz_string ); + } if( var_Set( p_obj, psz_variable, val ) < 0 ) { @@ -1067,14 +1075,13 @@ static gint GtkSetupVarMenu( intf_thread_t * p_intf, char * psz_variable, void(*pf_toggle )( GtkCheckMenuItem *, gpointer ) ) { - vlc_value_t val; - char * psz_value; + vlc_value_t val, text, val_list, text_list; GtkWidget * p_menu; GSList * p_group = NULL; GtkWidget * p_item; GtkWidget * p_item_active = NULL; - int i_item; + int i_item, i_type; /* temporary hack to avoid blank menu when an open menu is removed */ if( GTK_MENU_ITEM(p_root)->submenu != NULL ) @@ -1085,16 +1092,29 @@ static gint GtkSetupVarMenu( intf_thread_t * p_intf, gtk_menu_item_remove_submenu( GTK_MENU_ITEM( p_root ) ); gtk_widget_set_sensitive( p_root, FALSE ); + /* Check the type of the object variable */ + i_type = var_Type( p_object, psz_variable ); + + /* Make sure we want to display the variable */ + if( i_type & VLC_VAR_HASCHOICE ) + { + var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL ); + if( val.i_int == 0 ) return FALSE; + } + + /* Get the descriptive name of the variable */ + var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL ); + /* get the current value */ if( var_Get( p_object, psz_variable, &val ) < 0 ) { return FALSE; } - psz_value = val.psz_string; - if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST, &val ) < 0 ) + if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST, + &val_list, &text_list ) < 0 ) { - free( psz_value ); + if( i_type == VLC_VAR_STRING ) free( val.psz_string ); return FALSE; } @@ -1102,41 +1122,74 @@ static gint GtkSetupVarMenu( intf_thread_t * p_intf, p_menu = gtk_menu_new(); gtk_object_set_data( GTK_OBJECT( p_menu ), "p_intf", p_intf ); - for( i_item = 0; i_item < val.p_list->i_count; i_item++ ) + for( i_item = 0; i_item < val_list.p_list->i_count; i_item++ ) { - p_item = gtk_radio_menu_item_new_with_label( p_group, - val.p_list->p_values[i_item].psz_string ); - p_group = gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) ); - - if( !strcmp( psz_value, val.p_list->p_values[i_item].psz_string ) ) + switch( i_type & VLC_VAR_TYPE ) { - p_item_active = p_item; + case VLC_VAR_STRING: + p_item = gtk_radio_menu_item_new_with_label( p_group, + text_list.p_list->p_values[i_item].psz_string ? + text_list.p_list->p_values[i_item].psz_string : + val_list.p_list->p_values[i_item].psz_string ); + + /* signal hanling for off */ + gtk_signal_connect( GTK_OBJECT( p_item ), "toggled", + GTK_SIGNAL_FUNC ( pf_toggle ), + /* FIXME memory leak */ + strdup(val_list.p_list->p_values[i_item].psz_string) ); + + if( !strcmp( val.psz_string, + val_list.p_list->p_values[i_item].psz_string ) ) + { + p_item_active = p_item; + } + break; + case VLC_VAR_INTEGER: + p_item = gtk_radio_menu_item_new_with_label( p_group, + text_list.p_list->p_values[i_item].psz_string ? + text_list.p_list->p_values[i_item].psz_string : + NULL /* FIXME */ ); + + /* signal hanling for off */ + gtk_signal_connect( GTK_OBJECT( p_item ), "toggled", + GTK_SIGNAL_FUNC ( pf_toggle ), + (gpointer)val_list.p_list->p_values[i_item].i_int ); + + if( val.i_int == val_list.p_list->p_values[i_item].i_int ) + { + p_item_active = p_item; + } + break; + default: + /* FIXME */ + return FALSE; } - gtk_widget_show( p_item ); + p_group = gtk_radio_menu_item_group( GTK_RADIO_MENU_ITEM( p_item ) ); - /* signal hanling for off */ - gtk_signal_connect( GTK_OBJECT( p_item ), "toggled", - GTK_SIGNAL_FUNC ( pf_toggle ), NULL ); + gtk_widget_show( p_item ); gtk_menu_append( GTK_MENU( p_menu ), p_item ); - } + /* link the new menu to the menubar item */ gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu ); if( p_item_active ) { - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (p_item_active), TRUE); + gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(p_item_active), + TRUE ); } - if( val.p_list->i_count > 0 ) + if( val_list.p_list->i_count > 0 ) { gtk_widget_set_sensitive( p_root, TRUE ); } /* clean up everything */ - var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val ); + if( i_type == VLC_VAR_STRING ) free( val.psz_string ); + var_Change( p_object, psz_variable, VLC_VAR_FREELIST, + &val_list, &text_list ); return TRUE; } diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index 4f5a21ca2c..f379842318 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -2,7 +2,7 @@ * intf.m: MacOS X interface plugin ***************************************************************************** * Copyright (C) 2002-2003 VideoLAN - * $Id: intf.m,v 1.71 2003/05/01 01:11:17 hartman Exp $ + * $Id: intf.m,v 1.72 2003/05/04 22:42:16 gbazin Exp $ * * Authors: Jon Lech Johansen * Christophe Massiot @@ -1186,6 +1186,7 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) var_Set( (vlc_object_t *)p_aout, "intf-change", val ); +#error fixme! look at rc.c line 823 [self setupVarMenu: o_mi_channels target: (vlc_object_t *)p_aout var: "audio-channels" selector: @selector(toggleVar:)]; @@ -1327,7 +1328,7 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) psz_value = val.psz_string; if ( var_Change( p_object, psz_variable, - VLC_VAR_GETLIST, &val ) < 0 ) + VLC_VAR_GETLIST, &val, NULL ) < 0 ) { free( psz_value ); return; @@ -1355,7 +1356,7 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) } var_Change( p_object, psz_variable, VLC_VAR_FREELIST, - &val ); + &val, NULL ); free( psz_value ); } diff --git a/modules/gui/macosx/vout.m b/modules/gui/macosx/vout.m index 518482a4e0..7e5ca767f2 100644 --- a/modules/gui/macosx/vout.m +++ b/modules/gui/macosx/vout.m @@ -2,7 +2,7 @@ * vout.m: MacOS X video output plugin ***************************************************************************** * Copyright (C) 2001-2003 VideoLAN - * $Id: vout.m,v 1.45 2003/05/01 01:11:17 hartman Exp $ + * $Id: vout.m,v 1.46 2003/05/04 22:42:16 gbazin Exp $ * * Authors: Colin Delacroix * Florian G. Pflug @@ -201,7 +201,8 @@ int E_(OpenVideo) ( vlc_object_t *p_this ) (int)s_rect.size.width, (int)s_rect.size.height ); val.psz_string = psz_temp; - var_Change( p_vout, "video-device", VLC_VAR_ADDCHOICE, &val ); + var_Change( p_vout, "video-device", + VLC_VAR_ADDCHOICE, &val, NULL ); if( ( i - 1 ) == i_option ) { diff --git a/modules/gui/win32/menu.cpp b/modules/gui/win32/menu.cpp index ec132b963a..08c741bdd8 100644 --- a/modules/gui/win32/menu.cpp +++ b/modules/gui/win32/menu.cpp @@ -2,7 +2,7 @@ * menu.cpp: functions to handle menu items ***************************************************************************** * Copyright (C) 2002-2003 VideoLAN - * $Id: menu.cpp,v 1.14 2003/02/12 02:11:58 ipkiss Exp $ + * $Id: menu.cpp,v 1.15 2003/05/04 22:42:16 gbazin Exp $ * * Authors: Olivier Teuliere * @@ -51,6 +51,7 @@ void __fastcall TMenusGen::AoutVarClick( TObject *Sender ) return; } +#error fixme! look at rc.c line 823 if( Item->Parent == MenuADevice || Item->Parent == PopupADevice ) { VarChange( p_aout, "audio-device", MenuADevice, PopupADevice, Item ); @@ -414,6 +415,7 @@ void __fastcall TMenusGen::SetupMenus() var_Set( (vlc_object_t *)p_aout, "intf-change", val ); +#error fixme! look at rc.c line 823 SetupVarMenu( (vlc_object_t *)p_aout, "audio-channels", MenuChannel, AoutVarClick ); SetupVarMenu( (vlc_object_t *)p_aout, "audio-channels", @@ -632,7 +634,7 @@ void __fastcall TMenusGen::SetupVarMenu( vlc_object_t *p_object, } psz_value = val.psz_string; - if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST, &val ) < 0 ) + if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST, &val, NULL ) < 0 ) { free( psz_value ); return; @@ -657,7 +659,7 @@ void __fastcall TMenusGen::SetupVarMenu( vlc_object_t *p_object, Root->Enabled = ( val.p_list->i_count > 0 ); /* clean up everything */ - var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val ); + var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val, NULL ); // free( psz_value ); } diff --git a/modules/gui/wxwindows/Modules.am b/modules/gui/wxwindows/Modules.am index 137abed34e..2a4b17b51a 100644 --- a/modules/gui/wxwindows/Modules.am +++ b/modules/gui/wxwindows/Modules.am @@ -6,7 +6,7 @@ SOURCES_wxwindows = \ modules/gui/wxwindows/streamout.cpp \ modules/gui/wxwindows/messages.cpp \ modules/gui/wxwindows/playlist.cpp \ - modules/gui/wxwindows/popup.cpp \ + modules/gui/wxwindows/menus.cpp \ modules/gui/wxwindows/preferences.cpp \ modules/gui/wxwindows/timer.cpp \ modules/gui/wxwindows/fileinfo.cpp \ diff --git a/modules/gui/wxwindows/interface.cpp b/modules/gui/wxwindows/interface.cpp index 0162eb6227..79aeac9315 100644 --- a/modules/gui/wxwindows/interface.cpp +++ b/modules/gui/wxwindows/interface.cpp @@ -2,7 +2,7 @@ * interface.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: interface.cpp,v 1.21 2003/04/17 14:18:47 anil Exp $ + * $Id: interface.cpp,v 1.22 2003/05/04 22:42:16 gbazin Exp $ * * Authors: Gildas Bazin * @@ -69,6 +69,25 @@ /***************************************************************************** * Local class declarations. *****************************************************************************/ +class wxMenuExt: public wxMenu +{ +public: + /* Constructor */ + wxMenuExt( wxMenu* parentMenu, int id, const wxString& text, + const wxString& helpString, wxItemKind kind, + char *_psz_var, int _i_object_id, vlc_value_t _val, + int _i_val_type ); + + virtual ~wxMenuExt() {}; + + char *psz_var; + int i_val_type; + int i_object_id; + vlc_value_t val; + +private: + +}; /***************************************************************************** * Event Table. @@ -114,6 +133,10 @@ BEGIN_EVENT_TABLE(Interface, wxFrame) EVT_MENU(FileInfo_Event, Interface::OnFileInfo) EVT_MENU(Prefs_Event, Interface::OnPreferences) + EVT_MENU_OPEN(Interface::OnMenuOpen) + EVT_MENU_CLOSE(Interface::OnMenuClose) + + /* Toolbar events */ EVT_MENU(OpenFile_Event, Interface::OnOpenFile) EVT_MENU(OpenDisc_Event, Interface::OnOpenDisc) @@ -228,11 +251,18 @@ void Interface::CreateOurMenuBar() /* Create the "Settings" menu */ wxMenu *settings_menu = new wxMenu; - settings_menu->Append( Audio_Event, _("&Audio"), HELP_AUDIO ); settings_menu->Append( Subtitles_Event, _("&Subtitles"), HELP_SUBS ); settings_menu->AppendSeparator(); settings_menu->Append( Prefs_Event, _("&Preferences..."), HELP_PREFS ); + /* Create the "Audio" menu */ + p_audio_menu = new wxMenu; + b_audio_menu = 1; + + /* Create the "Video" menu */ + p_video_menu = new wxMenu; + b_video_menu = 1; + /* Create the "Help" menu */ wxMenu *help_menu = new wxMenu; help_menu->Append( About_Event, _("&About..."), HELP_ABOUT ); @@ -242,11 +272,16 @@ void Interface::CreateOurMenuBar() menubar->Append( file_menu, _("&File") ); menubar->Append( view_menu, _("&View") ); menubar->Append( settings_menu, _("&Settings") ); + menubar->Append( p_audio_menu, _("&Audio") ); + menubar->Append( p_video_menu, _("&Video") ); menubar->Append( help_menu, _("&Help") ); /* Attach the menu bar to the frame */ SetMenuBar( menubar ); + /* Intercept all menu events in our custom event handler */ + PushEventHandler( new MenuEvtHandler( p_intf, this ) ); + #if !defined(__WXX11__) /* Associate drop targets with the menubar */ menubar->SetDropTarget( new DragAndDrop( p_intf ) ); @@ -371,6 +406,40 @@ void Interface::Open( int i_access_method ) /***************************************************************************** * Event Handlers. *****************************************************************************/ +void Interface::OnMenuOpen(wxMenuEvent& event) +{ + if( event.GetEventObject() == p_audio_menu ) + { + if( b_audio_menu ) + { + p_audio_menu = AudioMenu( p_intf, this ); + wxMenu *menu = + GetMenuBar()->Replace( 3, p_audio_menu, _("&Audio") ); + if( menu ) delete menu; + + b_audio_menu = 0; + } + else b_audio_menu = 1; + } + else if( event.GetEventObject() == p_video_menu ) + { + if( b_video_menu ) + { + p_video_menu = VideoMenu( p_intf, this ); + wxMenu *menu = + GetMenuBar()->Replace( 4, p_video_menu, _("&Video") ); + if( menu ) delete menu; + + b_video_menu = 0; + } + else b_video_menu = 1; + } +} + +void Interface::OnMenuClose(wxMenuEvent& event) +{ +} + void Interface::OnExit( wxCommandEvent& WXUNUSED(event) ) { /* TRUE is to force the frame to close. */ @@ -531,17 +600,17 @@ void Interface::OnSliderUpdate( wxScrollEvent& event ) #ifdef WIN32 if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE - || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL ) + || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL ) { #endif - if( p_intf->p_sys->i_slider_pos != event.GetPosition() - && p_intf->p_sys->p_input ) - { + if( p_intf->p_sys->i_slider_pos != event.GetPosition() + && p_intf->p_sys->p_input ) + { p_intf->p_sys->i_slider_pos = event.GetPosition(); - input_Seek( p_intf->p_sys->p_input, p_intf->p_sys->i_slider_pos * - 100 / SLIDER_MAX_POS, - INPUT_SEEK_PERCENT | INPUT_SEEK_SET ); - } + input_Seek( p_intf->p_sys->p_input, p_intf->p_sys->i_slider_pos * + 100 / SLIDER_MAX_POS, + INPUT_SEEK_PERCENT | INPUT_SEEK_SET ); + } #ifdef WIN32 p_intf->p_sys->b_slider_free = VLC_TRUE; @@ -550,19 +619,19 @@ void Interface::OnSliderUpdate( wxScrollEvent& event ) { p_intf->p_sys->b_slider_free = VLC_FALSE; - if( p_intf->p_sys->p_input ) - { - /* Update stream date */ + if( p_intf->p_sys->p_input ) + { + /* Update stream date */ #define p_area p_intf->p_sys->p_input->stream.p_selected_area - char psz_time[ OFFSETTOTIME_MAX_SIZE ]; + char psz_time[ OFFSETTOTIME_MAX_SIZE ]; - slider_box->SetLabel( - input_OffsetToTime( p_intf->p_sys->p_input, - psz_time, - p_area->i_size * event.GetPosition() - / SLIDER_MAX_POS ) ); + slider_box->SetLabel( + input_OffsetToTime( p_intf->p_sys->p_input, + psz_time, + p_area->i_size * event.GetPosition() + / SLIDER_MAX_POS ) ); #undef p_area - } + } } #endif diff --git a/modules/gui/wxwindows/menus.cpp b/modules/gui/wxwindows/menus.cpp new file mode 100644 index 0000000000..b12017f3e6 --- /dev/null +++ b/modules/gui/wxwindows/menus.cpp @@ -0,0 +1,530 @@ +/***************************************************************************** + * menus.cpp : wxWindows plugin for vlc + ***************************************************************************** + * Copyright (C) 2000-2001 VideoLAN + * $Id: menus.cpp,v 1.1 2003/05/04 22:42:16 gbazin Exp $ + * + * Authors: Gildas Bazin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +/***************************************************************************** + * Preamble + *****************************************************************************/ +#include /* malloc(), free() */ +#include /* ENOMEM */ +#include /* strerror() */ +#include + +#include + +#ifdef WIN32 /* mingw32 hack */ +#undef Yield +#undef CreateDialog +#endif + +/* Let vlc take care of the i18n stuff */ +#define WXINTL_NO_GETTEXT_MACRO + +#include +#include +#include + +#include + +#include "wxwindows.h" + +class wxMenuItemExt: public wxMenuItem +{ +public: + /* Constructor */ + wxMenuItemExt( wxMenu* parentMenu, int id, const wxString& text, + const wxString& helpString, wxItemKind kind, + char *_psz_var, int _i_object_id, vlc_value_t _val, + int _i_val_type ); + + virtual ~wxMenuItemExt(); + + char *psz_var; + int i_val_type; + int i_object_id; + vlc_value_t val; + +private: + +}; + +/***************************************************************************** + * Event Table. + *****************************************************************************/ + +/* IDs for the controls and the menu commands */ +enum +{ + /* menu items */ + FirstAutoGenerated_Event = wxID_HIGHEST + 1000, + MenuDummy_Event, + MenuLast_Event, +}; + +BEGIN_EVENT_TABLE(Menu, wxMenu) + /* Menu events */ + EVT_MENU(MenuDummy_Event, Menu::OnEntrySelected) +END_EVENT_TABLE() + +BEGIN_EVENT_TABLE(MenuEvtHandler, wxEvtHandler) + EVT_MENU(-1, MenuEvtHandler::OnMenuEvent) +END_EVENT_TABLE() + +void PopupMenu( intf_thread_t *_p_intf, Interface *_p_main_interface ) +{ + vlc_object_t *p_object; + char *ppsz_varnames[16]; + int pi_objects[16]; + int i = 0; + + /* Initializations */ + memset( pi_objects, 0, 16 * sizeof(int) ); + + /* Audio menu */ + ppsz_varnames[i++] = _("Audio menu"); + ppsz_varnames[i++] = NULL; /* Separator */ + + p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_AOUT, + FIND_ANYWHERE ); + if( p_object != NULL ) + { + ppsz_varnames[i] = "audio-device"; + pi_objects[i++] = p_object->i_object_id; + ppsz_varnames[i] = "audio-channels"; + pi_objects[i++] = p_object->i_object_id; + vlc_object_release( p_object ); + } + + /* Video menu */ + ppsz_varnames[i++] = NULL; /* Separator */ + ppsz_varnames[i++] = _("Video menu"); + ppsz_varnames[i++] = NULL; /* Separator */ + + p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_VOUT, + FIND_ANYWHERE ); + if( p_object != NULL ) + { + ppsz_varnames[i] = "fullscreen"; + pi_objects[i++] = p_object->i_object_id; + vlc_object_release( p_object ); + } + + /* Input menu */ + ppsz_varnames[i++] = NULL; /* Separator */ + ppsz_varnames[i++] = _("Input menu"); + ppsz_varnames[i++] = NULL; /* Separator */ + + p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT, + FIND_ANYWHERE ); + if( p_object != NULL ) + { + ppsz_varnames[i] = "title"; + pi_objects[i++] = p_object->i_object_id; + ppsz_varnames[i] = "chapter"; + pi_objects[i++] = p_object->i_object_id; + ppsz_varnames[i] = "navigation"; + pi_objects[i++] = p_object->i_object_id; + vlc_object_release( p_object ); + } + + /* Misc stuff */ + ppsz_varnames[i++] = NULL; /* Separator */ + ppsz_varnames[i++] = _("Close"); + + /* Build menu */ + wxMenu *popupmenu = new Menu( _p_intf, _p_main_interface, i, + ppsz_varnames, pi_objects ); + + _p_main_interface->p_popup_menu = popupmenu; + wxPoint mousepos = wxGetMousePosition(); + _p_main_interface->PopupMenu( popupmenu, + _p_main_interface->ScreenToClient(mousepos).x, + _p_main_interface->ScreenToClient(mousepos).y + ); +} + +wxMenu *AudioMenu( intf_thread_t *_p_intf, Interface *_p_main_interface ) +{ + vlc_object_t *p_object; + char *ppsz_varnames[4]; + int pi_objects[4]; + int i = 0; + + /* Initializations */ + memset( pi_objects, 0, 4 * sizeof(int) ); + + /* Audio menu */ + ppsz_varnames[i++] = NULL; /* Separator */ + + /* Audio menu */ + p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_AOUT, + FIND_ANYWHERE ); + if( p_object != NULL ) + { + ppsz_varnames[i] = "audio-device"; + pi_objects[i++] = p_object->i_object_id; + ppsz_varnames[i] = "audio-channels"; + pi_objects[i++] = p_object->i_object_id; + vlc_object_release( p_object ); + } + + /* Build menu */ + return new Menu( _p_intf, _p_main_interface, i, + ppsz_varnames, pi_objects ); +} + +wxMenu *VideoMenu( intf_thread_t *_p_intf, Interface *_p_main_interface ) +{ + vlc_object_t *p_object; + char *ppsz_varnames[4]; + int pi_objects[4]; + int i = 0; + + /* Initializations */ + memset( pi_objects, 0, 4 * sizeof(int) ); + + ppsz_varnames[i++] = NULL; /* Separator */ + + p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_VOUT, + FIND_ANYWHERE ); + if( p_object != NULL ) + { + ppsz_varnames[i] = "fullscreen"; + pi_objects[i++] = p_object->i_object_id; + vlc_object_release( p_object ); + } + + /* Build menu */ + return new Menu( _p_intf, _p_main_interface, i, + ppsz_varnames, pi_objects ); +} + +/***************************************************************************** + * Constructor. + *****************************************************************************/ +Menu::Menu( intf_thread_t *_p_intf, Interface *_p_main_interface, + int i_count, char **ppsz_varnames, int *pi_objects ): + wxMenu( ) +{ + vlc_object_t *p_object; + int i; + + /* Initializations */ + p_intf = _p_intf; + p_main_interface = _p_main_interface; + + i_item_id = MenuLast_Event; + + for( i = 0; i < i_count; i++ ) + { + if( !ppsz_varnames[i] ) + { + AppendSeparator(); + continue; + } + + if( !pi_objects[i] ) + { + Append( MenuDummy_Event, ppsz_varnames[i] ); + continue; + } + + p_object = (vlc_object_t *)vlc_object_get( p_intf, pi_objects[i] ); + if( p_object == NULL ) continue; + + CreateMenuItem( this, ppsz_varnames[i], p_object ); + vlc_object_release( p_object ); + } + +} + +Menu::~Menu() +{ +} + +/***************************************************************************** + * Private methods. + *****************************************************************************/ +void Menu::OnEntrySelected( wxCommandEvent& WXUNUSED(event) ) +{ +} + +void Menu::CreateMenuItem( wxMenu *menu, char *psz_var, + vlc_object_t *p_object ) +{ + wxMenuItemExt *menuitem; + vlc_value_t val, text; + int i_type; + + /* Check the type of the object variable */ + i_type = var_Type( p_object, psz_var ); + + switch( i_type & VLC_VAR_TYPE ) + { + case VLC_VAR_VOID: + case VLC_VAR_BOOL: + case VLC_VAR_VARIABLE: + case VLC_VAR_STRING: + case VLC_VAR_INTEGER: + break; + default: + /* Variable doesn't exist or isn't handled */ + return; + } + + /* Make sure we want to display the variable */ + if( i_type & VLC_VAR_HASCHOICE ) + { + var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL ); + if( val.i_int == 0 ) return; + } + + /* Get the descriptive name of the variable */ + var_Change( p_object, psz_var, VLC_VAR_GETTEXT, &text, NULL ); + + if( i_type & VLC_VAR_HASCHOICE ) + { + menu->Append( MenuDummy_Event, + text.psz_string ? text.psz_string : psz_var, + CreateChoicesMenu( psz_var, p_object ), + "" /* Nothing for now (maybe use a GETLONGTEXT) */ ); + + if( text.psz_string ) free( text.psz_string ); + return; + } + + + switch( i_type & VLC_VAR_TYPE ) + { + case VLC_VAR_VOID: + menuitem = new wxMenuItemExt( menu, ++i_item_id, + text.psz_string ? + text.psz_string : psz_var, + "", wxITEM_NORMAL, strdup(psz_var), + p_object->i_object_id, val, i_type ); + menu->Append( menuitem ); + break; + + case VLC_VAR_BOOL: + menuitem = new wxMenuItemExt( menu, ++i_item_id, + text.psz_string ? + text.psz_string : psz_var, + "", wxITEM_CHECK, strdup(psz_var), + p_object->i_object_id, val, i_type ); + menu->Append( menuitem ); + Check( i_item_id -1, val.b_bool ? FALSE : TRUE ); + break; + + default: + if( text.psz_string ) free( text.psz_string ); + return; + } + + if( text.psz_string ) free( text.psz_string ); +} + +wxMenu *Menu::CreateChoicesMenu( char *psz_var, vlc_object_t *p_object ) +{ + vlc_value_t val, val_list, text_list; + int i_type, i; + + /* Check the type of the object variable */ + i_type = var_Type( p_object, psz_var ); + + /* Make sure we want to display the variable */ + if( i_type & VLC_VAR_HASCHOICE ) + { + var_Change( p_object, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL ); + if( val.i_int == 0 ) return NULL; + } + else + { + return NULL; + } + + switch( i_type & VLC_VAR_TYPE ) + { + case VLC_VAR_VOID: + case VLC_VAR_BOOL: + case VLC_VAR_VARIABLE: + case VLC_VAR_STRING: + case VLC_VAR_INTEGER: + break; + default: + /* Variable doesn't exist or isn't handled */ + return NULL; + } + + if( var_Get( p_object, psz_var, &val ) < 0 ) + { + return NULL; + } + + if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, + &val_list, &text_list ) < 0 ) + { + if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string ); + return NULL; + } + + wxMenu *menu = new wxMenu; + for( i = 0; i < val_list.p_list->i_count; i++ ) + { + vlc_value_t another_val; + wxMenuItemExt *menuitem; + + switch( i_type & VLC_VAR_TYPE ) + { + case VLC_VAR_VARIABLE: + menu->Append( MenuDummy_Event, + text_list.p_list->p_values[i].psz_string ? + text_list.p_list->p_values[i].psz_string : + val_list.p_list->p_values[i].psz_string, + CreateChoicesMenu( + val_list.p_list->p_values[i].psz_string, + p_object ), "" ); + break; + + case VLC_VAR_STRING: + another_val.psz_string = + strdup(val_list.p_list->p_values[i].psz_string); + menuitem = + new wxMenuItemExt( this, ++i_item_id, + text_list.p_list->p_values[i].psz_string ? + text_list.p_list->p_values[i].psz_string : + another_val.psz_string, + "", wxITEM_RADIO, strdup(psz_var), + p_object->i_object_id, another_val, i_type ); + + menu->Append( menuitem ); + + if( !strcmp( val.psz_string, + val_list.p_list->p_values[i].psz_string ) ) + menu->Check( i_item_id, TRUE ); + break; + + case VLC_VAR_INTEGER: + menuitem = + new wxMenuItemExt( this, ++i_item_id, + text_list.p_list->p_values[i].psz_string ? + text_list.p_list->p_values[i].psz_string : + wxString::Format("%d", + val_list.p_list->p_values[i].i_int), + "", wxITEM_RADIO, strdup(psz_var), + p_object->i_object_id, + val_list.p_list->p_values[i], i_type ); + + menu->Append( menuitem ); + + if( !((i_type & VLC_VAR_FLAGS) & VLC_VAR_ISCOMMAND) && + val_list.p_list->p_values[i].i_int == val.i_int ) + menu->Check( i_item_id, TRUE ); + break; + + default: + break; + } + + } + + /* clean up everything */ + if( i_type == VLC_VAR_STRING ) free( val.psz_string ); + var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, &text_list ); + + return menu; +} + +/***************************************************************************** + * A small helper class which intercepts all popup menu events + *****************************************************************************/ +MenuEvtHandler::MenuEvtHandler( intf_thread_t *_p_intf, + Interface *_p_main_interface ) +{ + /* Initializations */ + p_intf = _p_intf; + p_main_interface = _p_main_interface; +} + +MenuEvtHandler::~MenuEvtHandler() +{ +} + +void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event ) +{ + wxMenuItem *p_menuitem; + + /* Check if this is an auto generated menu item */ + if( event.GetId() < FirstAutoGenerated_Event ) + { + event.Skip(); + return; + } + + if( (p_menuitem = p_main_interface->GetMenuBar()->FindItem(event.GetId())) + == NULL ) + { + if( p_main_interface->p_popup_menu ) + { + p_menuitem = + p_main_interface->p_popup_menu->FindItem( event.GetId() ); + } + } + + if( p_menuitem ) + { + wxMenuItemExt *p_menuitemext = (wxMenuItemExt *)p_menuitem; + vlc_object_t *p_object; + + p_object = (vlc_object_t *)vlc_object_get( p_intf, + p_menuitemext->i_object_id ); + if( p_object == NULL ) return; + + var_Set( p_object, p_menuitemext->psz_var, p_menuitemext->val ); + + vlc_object_release( p_object ); + } + else + event.Skip(); +} + +/***************************************************************************** + * A small helper class which encapsulate wxMenuitem with some other useful + * things. + *****************************************************************************/ +wxMenuItemExt::wxMenuItemExt( wxMenu* parentMenu, int id, const wxString& text, + const wxString& helpString, wxItemKind kind, + char *_psz_var, int _i_object_id, vlc_value_t _val, int _i_val_type ): + wxMenuItem( parentMenu, id, text, helpString, kind ) +{ + /* Initializations */ + psz_var = _psz_var; + i_val_type = _i_val_type; + i_object_id = _i_object_id; + val = _val; +}; + +wxMenuItemExt::~wxMenuItemExt() +{ + if( psz_var ) free( psz_var ); + if( ((i_val_type & VLC_VAR_TYPE) == VLC_VAR_STRING) + && val.psz_string ) free( val.psz_string ); +}; diff --git a/modules/gui/wxwindows/popup.cpp b/modules/gui/wxwindows/popup.cpp deleted file mode 100644 index 17fe2a3742..0000000000 --- a/modules/gui/wxwindows/popup.cpp +++ /dev/null @@ -1,318 +0,0 @@ -/***************************************************************************** - * popup.cpp : wxWindows plugin for vlc - ***************************************************************************** - * Copyright (C) 2000-2001 VideoLAN - * $Id: popup.cpp,v 1.5 2003/04/01 00:18:29 gbazin Exp $ - * - * Authors: Gildas Bazin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -/***************************************************************************** - * Preamble - *****************************************************************************/ -#include /* malloc(), free() */ -#include /* ENOMEM */ -#include /* strerror() */ -#include - -#include - -#ifdef WIN32 /* mingw32 hack */ -#undef Yield -#undef CreateDialog -#endif - -/* Let vlc take care of the i18n stuff */ -#define WXINTL_NO_GETTEXT_MACRO - -#include -#include -#include - -#include - -#include "wxwindows.h" - -/***************************************************************************** - * Event Table. - *****************************************************************************/ - -/* IDs for the controls and the menu commands */ -enum -{ - /* menu items */ - Close_Event = wxID_HIGHEST + 1000, - MenuDummy_Event, - MenuLast_Event, -}; - -BEGIN_EVENT_TABLE(PopupMenu, wxMenu) - /* Menu events */ - EVT_MENU(Close_Event, PopupMenu::OnClose) - EVT_MENU(MenuDummy_Event, PopupMenu::OnEntrySelected) - -END_EVENT_TABLE() - -BEGIN_EVENT_TABLE(PopupEvtHandler, wxEvtHandler) - EVT_MENU(-1, PopupEvtHandler::OnMenuEvent) -END_EVENT_TABLE() - -/***************************************************************************** - * Constructor. - *****************************************************************************/ -PopupMenu::PopupMenu( intf_thread_t *_p_intf, Interface *_p_main_interface ): - wxMenu( ) -{ - vlc_object_t *p_object; - - /* Initializations */ - p_intf = _p_intf; - p_main_interface = _p_main_interface; - i_item_id = MenuLast_Event; - - /* Audio menu */ - Append( MenuDummy_Event, _("Audio menu") ); - AppendSeparator(); - p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT, - FIND_ANYWHERE ); - if( p_object == NULL ) return; - - CreateMenuEntry( "audio-device", p_object ); - CreateMenuEntry( "audio-channels", p_object ); - - vlc_object_release( p_object ); - - /* Video menu */ - AppendSeparator(); - Append( MenuDummy_Event, _("Video menu") ); - AppendSeparator(); - p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT, - FIND_ANYWHERE ); - if( p_object == NULL ) return; - - CreateMenuEntry( "fullscreen", p_object ); - - vlc_object_release( p_object ); - - /* Input menu */ - AppendSeparator(); - Append( MenuDummy_Event, _("Input menu") ); - AppendSeparator(); - p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT, - FIND_ANYWHERE ); - if( p_object == NULL ) return; - - CreateMenuEntry( "title", p_object ); - CreateMenuEntry( "chapter", p_object ); - CreateMenuEntry( "navigation", p_object ); - - vlc_object_release( p_object ); - - /* Misc stuff */ - AppendSeparator(); - Append( Close_Event, _("&Close") ); - - /* Intercept all menu events in our custom event handler */ - p_main_interface->p_popup_menu = this; - p_main_interface->PushEventHandler( - new PopupEvtHandler( p_intf, p_main_interface ) ); - - wxPoint mousepos = wxGetMousePosition(); - p_main_interface->PopupMenu( this, - p_main_interface->ScreenToClient(mousepos).x, - p_main_interface->ScreenToClient(mousepos).y - ); -} - -PopupMenu::~PopupMenu() -{ -} - -/***************************************************************************** - * Private methods. - *****************************************************************************/ -void PopupMenu::OnClose( wxCommandEvent& WXUNUSED(event) ) -{ - p_intf->b_die = VLC_TRUE; -} - -void PopupMenu::OnEntrySelected( wxCommandEvent& WXUNUSED(event) ) -{ -} - -void PopupMenu::CreateMenuEntry( char *psz_var, vlc_object_t *p_object ) -{ - vlc_value_t val, val1; - int i_type; - - /* Check the type of the object variable */ - i_type = var_Type( p_object, psz_var ); - - if( i_type & VLC_VAR_HASCHOICE ) - { - Append( MenuDummy_Event, psz_var, - CreateSubMenu( psz_var, p_object ), - "YEAAAARRRGGGHHH HEEELLPPPPPP" ); - return; - } - - if( var_Get( p_object, psz_var, &val ) < 0 ) - { - return; - } - - wxMenuItemExt *menuitem; - - switch( i_type ) - { - case VLC_VAR_VOID: - menuitem = new wxMenuItemExt( this, i_item_id++, psz_var, - "", wxITEM_NORMAL, strdup(psz_var), - p_object->i_object_id, val ); - Append( menuitem ); - break; - - case VLC_VAR_BOOL: - val1.b_bool = !val.b_bool; - menuitem = new wxMenuItemExt( this, i_item_id++, psz_var, - "", wxITEM_CHECK, strdup(psz_var), - p_object->i_object_id, val1 ); - Append( menuitem ); - Check( i_item_id - 1, val.b_bool ? TRUE : FALSE ); - break; - - case VLC_VAR_STRING: - break; - - default: - break; - } - -} - -wxMenu *PopupMenu::CreateSubMenu( char *psz_var, vlc_object_t *p_object ) -{ - wxMenu *menu = new wxMenu; - vlc_value_t val; - vlc_value_t val_list; - int i_type, i; - - /* Check the type of the object variable */ - i_type = var_Type( p_object, psz_var ); - - if( var_Get( p_object, psz_var, &val ) < 0 ) - { - return NULL; - } - - if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val_list ) < 0 ) - { - return NULL; - } - - for( i = 0; i < val_list.p_list->i_count; i++ ) - { - vlc_value_t another_val; - wxMenuItemExt *menuitem; - - switch( i_type & VLC_VAR_TYPE ) - { - case VLC_VAR_VARIABLE: - menu->Append( MenuDummy_Event, - val_list.p_list->p_values[i].psz_string, - CreateSubMenu( val_list.p_list->p_values[i].psz_string, - p_object ), - "YEAAAARRRGGGHHH HEEELLPPPPPP" ); - break; - - case VLC_VAR_STRING: - another_val.psz_string = - strdup(val_list.p_list->p_values[i].psz_string); - menuitem = - new wxMenuItemExt( this, i_item_id++, another_val.psz_string, - "", wxITEM_RADIO, strdup(psz_var), - p_object->i_object_id, - another_val ); - - menu->Append( menuitem ); - - if( !strcmp( val.psz_string, - val_list.p_list->p_values[i].psz_string ) ) - menu->Check( i_item_id - 1, TRUE ); - break; - - case VLC_VAR_INTEGER: - menuitem = - new wxMenuItemExt( this, i_item_id++, - wxString::Format("%d", - val_list.p_list->p_values[i].i_int), - "", wxITEM_RADIO, strdup(psz_var), - p_object->i_object_id, - val_list.p_list->p_values[i] ); - - menu->Append( menuitem ); - - if( !((i_type & VLC_VAR_FLAGS) & VLC_VAR_ISCOMMAND) && - val_list.p_list->p_values[i].i_int == val.i_int ) - menu->Check( i_item_id - 1, TRUE ); - break; - - default: - break; - } - } - - var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list ); - - return menu; -} - -/***************************************************************************** - * A small helper class which intercepts all popup menu events - *****************************************************************************/ -PopupEvtHandler::PopupEvtHandler( intf_thread_t *_p_intf, - Interface *_p_main_interface ) -{ - /* Initializations */ - p_intf = _p_intf; - p_main_interface = _p_main_interface; -} - -PopupEvtHandler::~PopupEvtHandler() -{ -} - -void PopupEvtHandler::OnMenuEvent( wxCommandEvent& event ) -{ - wxMenuItemExt *p_menuitem = (wxMenuItemExt *) - p_main_interface->p_popup_menu->FindItem( event.GetId() ); - - if( p_menuitem ) - { - vlc_object_t *p_object; - - p_object = (vlc_object_t *)vlc_object_get( p_intf, - p_menuitem->i_object_id ); - if( p_object == NULL ) return; - - var_Set( p_object, p_menuitem->psz_var, p_menuitem->val ); - - vlc_object_release( p_object ); - } - else - event.Skip(); -} diff --git a/modules/gui/wxwindows/timer.cpp b/modules/gui/wxwindows/timer.cpp index 934e9298e9..7321913abc 100644 --- a/modules/gui/wxwindows/timer.cpp +++ b/modules/gui/wxwindows/timer.cpp @@ -2,7 +2,7 @@ * timer.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: timer.cpp,v 1.13 2003/04/17 14:00:44 anil Exp $ + * $Id: timer.cpp,v 1.14 2003/05/04 22:42:16 gbazin Exp $ * * Authors: Gildas Bazin * @@ -105,8 +105,7 @@ void Timer::Notify() /* If the "display popup" flag has changed */ if( p_intf->b_menu_change ) { - p_main_interface->p_popup_menu = - new PopupMenu( p_intf, p_main_interface ); + PopupMenu( p_intf, p_main_interface ); p_intf->b_menu_change = 0; } diff --git a/modules/gui/wxwindows/wxwindows.h b/modules/gui/wxwindows/wxwindows.h index 2e77c201da..46637316a7 100644 --- a/modules/gui/wxwindows/wxwindows.h +++ b/modules/gui/wxwindows/wxwindows.h @@ -2,7 +2,7 @@ * wxwindows.h: private wxWindows interface description ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: wxwindows.h,v 1.18 2003/04/21 16:55:53 anil Exp $ + * $Id: wxwindows.h,v 1.19 2003/05/04 22:42:16 gbazin Exp $ * * Authors: Gildas Bazin * @@ -154,6 +154,9 @@ private: void OnPrevStream( wxCommandEvent& event ); void OnNextStream( wxCommandEvent& event ); + void OnMenuOpen( wxMenuEvent& event ); + void OnMenuClose( wxMenuEvent& event ); + DECLARE_EVENT_TABLE(); Timer *timer; @@ -162,6 +165,12 @@ private: wxFrame *p_prefs_dialog; int i_old_playing_status; + + /* For auto-generated menus */ + wxMenu *p_audio_menu; + vlc_bool_t b_audio_menu; + wxMenu *p_video_menu; + vlc_bool_t b_video_menu; }; /* Open Dialog */ @@ -432,38 +441,18 @@ private: }; #endif -/* Popup contextual menu */ -class PopupMenu: public wxMenu -{ -public: - /* Constructor */ - PopupMenu( intf_thread_t *p_intf, Interface *p_main_interface ); - virtual ~PopupMenu(); +/* Menus */ +void PopupMenu( intf_thread_t *_p_intf, Interface *_p_main_interface ); +wxMenu *AudioMenu( intf_thread_t *_p_intf, Interface *_p_main_interface ); +wxMenu *VideoMenu( intf_thread_t *_p_intf, Interface *_p_main_interface ); -private: - /* Event handlers (these functions should _not_ be virtual) */ - void OnClose( wxCommandEvent& event ); - void OnEntrySelected( wxCommandEvent& event ); - - wxMenu *PopupMenu::CreateDummyMenu(); - void PopupMenu::CreateMenuEntry( char *, vlc_object_t * ); - wxMenu *PopupMenu::CreateSubMenu( char *, vlc_object_t * ); - - DECLARE_EVENT_TABLE(); - - intf_thread_t *p_intf; - Interface *p_main_interface; - - int i_item_id; -}; - -class PopupEvtHandler : public wxEvtHandler +class MenuEvtHandler : public wxEvtHandler { public: - PopupEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface ); - virtual ~PopupEvtHandler(); + MenuEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface ); + virtual ~MenuEvtHandler(); - void PopupEvtHandler::OnMenuEvent( wxCommandEvent& event ); + void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event ); private: @@ -473,29 +462,27 @@ private: Interface *p_main_interface; }; -class wxMenuItemExt: public wxMenuItem +class Menu: public wxMenu { public: /* Constructor */ - wxMenuItemExt( wxMenu* parentMenu, int id, - const wxString& text, - const wxString& helpString, - wxItemKind kind, - char *_psz_var, int _i_object_id, vlc_value_t _val ): - wxMenuItem( parentMenu, id, text, helpString, kind ) - { - /* Initializations */ - psz_var = _psz_var; - i_object_id = _i_object_id; - val = _val; - }; - - virtual ~wxMenuItemExt() { if( psz_var ) free( psz_var ); }; - - char *psz_var; - int i_object_id; - vlc_value_t val; + Menu( intf_thread_t *p_intf, Interface *p_main_interface, int i_count, + char **ppsz_names, int *pi_objects ); + virtual ~Menu(); private: + /* Event handlers (these functions should _not_ be virtual) */ + void OnClose( wxCommandEvent& event ); + void OnEntrySelected( wxCommandEvent& event ); + wxMenu *Menu::CreateDummyMenu(); + void Menu::CreateMenuItem( wxMenu *, char *, vlc_object_t * ); + wxMenu *Menu::CreateChoicesMenu( char *, vlc_object_t * ); + + DECLARE_EVENT_TABLE(); + + intf_thread_t *p_intf; + Interface *p_main_interface; + + int i_item_id; }; diff --git a/modules/misc/dummy/dummy.c b/modules/misc/dummy/dummy.c index bdb37db27b..e9e701417a 100644 --- a/modules/misc/dummy/dummy.c +++ b/modules/misc/dummy/dummy.c @@ -2,7 +2,7 @@ * dummy.c : dummy plugin for vlc ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: dummy.c,v 1.5 2003/03/30 18:14:38 gbazin Exp $ + * $Id: dummy.c,v 1.6 2003/05/04 22:42:17 gbazin Exp $ * * Authors: Samuel Hocevar * @@ -53,6 +53,7 @@ vlc_module_begin(); set_description( _("dummy functions") ); add_shortcut( "vlc" ); add_submodule(); + set_description( _("dummy interface function") ); set_capability( "interface", 0 ); set_callbacks( E_(OpenIntf), NULL ); #ifdef WIN32 @@ -60,18 +61,23 @@ vlc_module_begin(); add_bool( "dummy-quiet", 0, NULL, QUIET_TEXT, QUIET_LONGTEXT, VLC_FALSE ); #endif add_submodule(); + set_description( _("dummy access function") ); set_capability( "access", 0 ); set_callbacks( E_(OpenAccess), NULL ); add_submodule(); + set_description( _("dummy demux function") ); set_capability( "demux", 0 ); set_callbacks( E_(OpenDemux), E_(CloseDemux) ); add_submodule(); + set_description( _("dummy decoder function") ); set_capability( "decoder", 0 ); set_callbacks( E_(OpenDecoder), NULL ); add_submodule(); + set_description( _("dummy audio output function") ); set_capability( "audio output", 1 ); set_callbacks( E_(OpenAudio), NULL ); add_submodule(); + set_description( _("dummy video output function") ); set_capability( "video output", 1 ); set_callbacks( E_(OpenVideo), NULL ); add_category_hint( N_("Video"), NULL, VLC_FALSE ); diff --git a/modules/misc/testsuite/test4.c b/modules/misc/testsuite/test4.c index 8063d16d2b..85ac61f749 100644 --- a/modules/misc/testsuite/test4.c +++ b/modules/misc/testsuite/test4.c @@ -2,7 +2,7 @@ * test4.c : Miscellaneous stress tests module for vlc ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: test4.c,v 1.6 2002/12/14 19:34:06 gbazin Exp $ + * $Id: test4.c,v 1.7 2003/05/04 22:42:17 gbazin Exp $ * * Authors: Samuel Hocevar * @@ -87,12 +87,12 @@ static int Foo( vlc_object_t *p_this, char const *psz_cmd, var_Create( p_this, "honk", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); val.psz_string = "foo"; - var_Change( p_this, "honk", VLC_VAR_ADDCHOICE, &val ); + var_Change( p_this, "honk", VLC_VAR_ADDCHOICE, &val, NULL ); val.psz_string = "bar"; - var_Change( p_this, "honk", VLC_VAR_ADDCHOICE, &val ); + var_Change( p_this, "honk", VLC_VAR_ADDCHOICE, &val, NULL ); val.psz_string = "baz"; - var_Change( p_this, "honk", VLC_VAR_ADDCHOICE, &val ); - var_Change( p_this, "honk", VLC_VAR_SETDEFAULT, &val ); + var_Change( p_this, "honk", VLC_VAR_ADDCHOICE, &val, NULL ); + var_Change( p_this, "honk", VLC_VAR_SETDEFAULT, &val, NULL ); var_Get( p_this, "honk", &val ); printf( "value: %s\n", val.psz_string ); @@ -107,16 +107,16 @@ static int Foo( vlc_object_t *p_this, char const *psz_cmd, var_Get( p_this, "honk", &val ); printf( "value: %s\n", val.psz_string ); val.psz_string = "baz"; - var_Change( p_this, "honk", VLC_VAR_DELCHOICE, &val ); + var_Change( p_this, "honk", VLC_VAR_DELCHOICE, &val, NULL ); var_Get( p_this, "honk", &val ); printf( "value: %s\n", val.psz_string ); - var_Change( p_this, "honk", VLC_VAR_GETLIST, &val ); + var_Change( p_this, "honk", VLC_VAR_GETLIST, &val, NULL ); for( i = 0 ; i < val.p_list->i_count ; i++ ) { printf( "value %i: %s\n", i, val.p_list->p_values[i].psz_string ); } - var_Change( p_this, "honk", VLC_VAR_FREELIST, &val ); + var_Change( p_this, "honk", VLC_VAR_FREELIST, &val, NULL ); var_Destroy( p_this, "honk" ); diff --git a/src/audio_output/output.c b/src/audio_output/output.c index 62a6f421b4..246e61e94a 100644 --- a/src/audio_output/output.c +++ b/src/audio_output/output.c @@ -2,7 +2,7 @@ * output.c : internal management of output streams for the audio output ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: output.c,v 1.37 2003/04/22 19:26:02 asmax Exp $ + * $Id: output.c,v 1.38 2003/05/04 22:42:17 gbazin Exp $ * * Authors: Christophe Massiot * @@ -43,7 +43,7 @@ int aout_OutputNew( aout_instance_t * p_aout, /* Retrieve user defaults. */ char * psz_name = config_GetPsz( p_aout, "aout" ); int i_rate = config_GetInt( p_aout, "aout-rate" ); - vlc_value_t val; + vlc_value_t val, text; /* kludge to avoid a fpu error when rate is 0... */ if( i_rate == 0 ) i_rate = -1; @@ -55,8 +55,7 @@ int aout_OutputNew( aout_instance_t * p_aout, vlc_mutex_lock( &p_aout->output_fifo_lock ); /* Find the best output plug-in. */ - p_aout->output.p_module = module_Need( p_aout, "audio output", - psz_name ); + p_aout->output.p_module = module_Need( p_aout, "audio output", psz_name ); if ( psz_name != NULL ) free( psz_name ); if ( p_aout->output.p_module == NULL ) { @@ -66,53 +65,56 @@ int aout_OutputNew( aout_instance_t * p_aout, } if ( var_Type( p_aout, "audio-channels" ) == - (VLC_VAR_STRING | VLC_VAR_HASCHOICE) ) + (VLC_VAR_INTEGER | VLC_VAR_HASCHOICE) ) { /* The user may have selected a different channels configuration. */ var_Get( p_aout, "audio-channels", &val ); - if ( !strcmp( val.psz_string, _("Reverse stereo") ) ) + if ( val.i_int == AOUT_VAR_CHAN_RSTEREO ) { p_aout->output.output.i_original_channels |= AOUT_CHAN_REVERSESTEREO; } - else if ( !strcmp( val.psz_string, _("Stereo") ) ) + else if ( val.i_int == AOUT_VAR_CHAN_STEREO ) { p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; } - else if ( !strcmp( val.psz_string, _("Left") ) ) + else if ( val.i_int == AOUT_VAR_CHAN_LEFT ) { p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT; } - else if ( !strcmp( val.psz_string, _("Right") ) ) + else if ( val.i_int == AOUT_VAR_CHAN_RIGHT ) { p_aout->output.output.i_original_channels = AOUT_CHAN_RIGHT; } - else if ( !strcmp( val.psz_string, _("Dolby Surround") ) ) + else if ( val.i_int == AOUT_VAR_CHAN_DOLBYS ) { p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_DOLBYSTEREO; } - free( val.psz_string ); } else if ( p_aout->output.output.i_physical_channels == AOUT_CHAN_CENTER && (p_aout->output.output.i_original_channels & AOUT_CHAN_PHYSMASK) == (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) ) { /* Mono - create the audio-channels variable. */ - var_Create( p_aout, "audio-channels", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); - val.psz_string = _("Stereo"); - var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val ); - val.psz_string = _("Left"); - var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val ); - val.psz_string = _("Right"); - var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val ); + var_Create( p_aout, "audio-channels", + VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); + text.psz_string = _("Audio channels"); + var_Change( p_aout, "audio-channels", VLC_VAR_SETTEXT, &text, NULL ); + + val.i_int = AOUT_VAR_CHAN_STEREO; text.psz_string = _("Stereo"); + var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); + val.i_int = AOUT_VAR_CHAN_LEFT; text.psz_string = _("Left"); + var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); + val.i_int = AOUT_VAR_CHAN_RIGHT; text.psz_string = _("Right"); + var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); if ( p_aout->output.output.i_original_channels & AOUT_CHAN_DUALMONO ) { /* Go directly to the left channel. */ p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT; - val.psz_string = _("Left"); + val.i_int = AOUT_VAR_CHAN_LEFT; var_Set( p_aout, "audio-channels", val ); } var_AddCallback( p_aout, "audio-channels", aout_ChannelsRestart, @@ -124,27 +126,33 @@ int aout_OutputNew( aout_instance_t * p_aout, (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT)) ) { /* Stereo - create the audio-channels variable. */ - var_Create( p_aout, "audio-channels", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); + var_Create( p_aout, "audio-channels", + VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); + text.psz_string = _("Audio channels"); + var_Change( p_aout, "audio-channels", VLC_VAR_SETTEXT, &text, NULL ); + if ( p_aout->output.output.i_original_channels & AOUT_CHAN_DOLBYSTEREO ) { - val.psz_string = _("Dolby Surround"); + val.i_int = AOUT_VAR_CHAN_DOLBYS; + text.psz_string = _("Dolby Surround"); } else { - val.psz_string = _("Stereo"); + val.i_int = AOUT_VAR_CHAN_STEREO; + text.psz_string = _("Stereo"); } - var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val ); - val.psz_string = _("Left"); - var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val ); - val.psz_string = _("Right"); - var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val ); - val.psz_string = _("Reverse stereo"); - var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val ); + var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); + val.i_int = AOUT_VAR_CHAN_LEFT; text.i_int = _("Left"); + var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); + val.i_int = AOUT_VAR_CHAN_RIGHT; text.psz_string = _("Right"); + var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); + val.i_int = AOUT_VAR_CHAN_RSTEREO; text.psz_string=_("Reverse stereo"); + var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); if ( p_aout->output.output.i_original_channels & AOUT_CHAN_DUALMONO ) { /* Go directly to the left channel. */ p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT; - val.psz_string = _("Left"); + val.i_int = AOUT_VAR_CHAN_LEFT; var_Set( p_aout, "audio-channels", val ); } var_AddCallback( p_aout, "audio-channels", aout_ChannelsRestart, diff --git a/src/input/input_ext-intf.c b/src/input/input_ext-intf.c index 72a94a8bf8..c1f89a8ae7 100644 --- a/src/input/input_ext-intf.c +++ b/src/input/input_ext-intf.c @@ -2,7 +2,7 @@ * input_ext-intf.c: services to the interface ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: input_ext-intf.c,v 1.48 2003/03/11 23:56:54 gbazin Exp $ + * $Id: input_ext-intf.c,v 1.49 2003/05/04 22:42:17 gbazin Exp $ * * Authors: Christophe Massiot * @@ -384,7 +384,7 @@ int input_ChangeProgram( input_thread_t * p_input, uint16_t i_program_number ) /* Update the navigation variables without triggering a callback */ val.i_int = i_program_number; - var_Change( p_input, "program", VLC_VAR_SETVALUE, &val ); + var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL ); return 0; } diff --git a/src/input/input_programs.c b/src/input/input_programs.c index cc66a62692..44787ab8f0 100644 --- a/src/input/input_programs.c +++ b/src/input/input_programs.c @@ -2,7 +2,7 @@ * input_programs.c: es_descriptor_t, pgrm_descriptor_t management ***************************************************************************** * Copyright (C) 1999-2002 VideoLAN - * $Id: input_programs.c,v 1.104 2003/04/13 20:00:21 fenrir Exp $ + * $Id: input_programs.c,v 1.105 2003/05/04 22:42:17 gbazin Exp $ * * Authors: Christophe Massiot * @@ -205,7 +205,7 @@ pgrm_descriptor_t * input_AddProgram( input_thread_t * p_input, p_pgrm ); val.i_int = i_pgrm_id; - var_Change( p_input, "program", VLC_VAR_ADDCHOICE, &val ); + var_Change( p_input, "program", VLC_VAR_ADDCHOICE, &val, NULL ); return p_pgrm; } @@ -236,7 +236,7 @@ void input_DelProgram( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm ) } val.i_int = i_pgrm_index; - var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val ); + var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL ); /* Free the structures that describe the es that belongs to that program */ while( p_pgrm->i_es_number ) @@ -299,7 +299,7 @@ input_area_t * input_AddArea( input_thread_t * p_input, /* Take care of the navigation variables */ val.i_int = i_area_id; - var_Change( p_input, "title", VLC_VAR_ADDCHOICE, &val ); + var_Change( p_input, "title", VLC_VAR_ADDCHOICE, &val, NULL ); val.psz_string = malloc( sizeof("title ") + 5 ); if( val.psz_string ) @@ -313,12 +313,13 @@ input_area_t * input_AddArea( input_thread_t * p_input, var_AddCallback( p_input, val.psz_string, NavigationCallback, (void *)(int)i_area_id ); - var_Change( p_input, "navigation", VLC_VAR_ADDCHOICE, &val ); + var_Change( p_input, "navigation", VLC_VAR_ADDCHOICE, &val, NULL ); for( i = 1; i <= i_part_nb; i++ ) { val2.i_int = i; - var_Change( p_input, val.psz_string, VLC_VAR_ADDCHOICE, &val2 ); + var_Change( p_input, val.psz_string, + VLC_VAR_ADDCHOICE, &val2, NULL ); } } @@ -423,7 +424,7 @@ int input_SetProgram( input_thread_t * p_input, pgrm_descriptor_t * p_new_prg ) /* Update the navigation variables without triggering a callback */ val.i_int = p_new_prg->i_number; - var_Change( p_input, "program", VLC_VAR_SETVALUE, &val ); + var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL ); return( 0 ); } @@ -458,7 +459,7 @@ void input_DelArea( input_thread_t * p_input, input_area_t * p_area ) if( val.psz_string ) { sprintf( val.psz_string, "title %i", p_area->i_id ); - var_Change( p_input, "navigation", VLC_VAR_DELCHOICE, &val ); + var_Change( p_input, "navigation", VLC_VAR_DELCHOICE, &val, NULL ); var_Destroy( p_input, val.psz_string ); } diff --git a/src/misc/variables.c b/src/misc/variables.c index 72a59ca094..91e6964a6c 100644 --- a/src/misc/variables.c +++ b/src/misc/variables.c @@ -2,7 +2,7 @@ * variables.c: routines for object variables handling ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: variables.c,v 1.21 2003/03/11 23:56:54 gbazin Exp $ + * $Id: variables.c,v 1.22 2003/05/04 22:42:18 gbazin Exp $ * * Authors: Samuel Hocevar * @@ -54,10 +54,65 @@ static int CmpAddress( vlc_value_t v, vlc_value_t w ) { return v.p_address == w. static void DupDummy( vlc_value_t *p_val ) { (void)p_val; /* unused */ } static void DupString( vlc_value_t *p_val ) { p_val->psz_string = strdup( p_val->psz_string ); } +static void DupList( vlc_value_t *p_val ) +{ + int i; + vlc_list_t *p_list = malloc( sizeof(vlc_list_t) ); + + if( p_val->p_list->i_count ) + { + p_list->i_count = p_val->p_list->i_count; + p_list->p_values = malloc( p_list->i_count * sizeof(vlc_value_t) ); + p_list->pi_types = malloc( p_list->i_count * sizeof(int) ); + } + + for( i = 0; i < p_list->i_count; i++ ) + { + p_list->p_values[i] = p_val->p_list->p_values[i]; + switch( p_val->p_list->pi_types[i] & VLC_VAR_TYPE ) + { + case VLC_VAR_STRING: + + DupString( &p_list->p_values[i] ); + break; + default: + break; + } + } + + p_val->p_list = p_list; +} + static void FreeDummy( vlc_value_t *p_val ) { (void)p_val; /* unused */ } static void FreeString( vlc_value_t *p_val ) { free( p_val->psz_string ); } static void FreeMutex( vlc_value_t *p_val ) { vlc_mutex_destroy( (vlc_mutex_t*)p_val->p_address ); free( p_val->p_address ); } +static void FreeList( vlc_value_t *p_val ) +{ + int i; + for( i = 0; i < p_val->p_list->i_count; i++ ) + { + switch( p_val->p_list->pi_types[i] & VLC_VAR_TYPE ) + { + case VLC_VAR_STRING: + FreeString( &p_val->p_list->p_values[i] ); + break; + case VLC_VAR_MUTEX: + FreeMutex( &p_val->p_list->p_values[i] ); + break; + default: + break; + } + } + + if( p_val->p_list->i_count ) + { + free( p_val->p_list->p_values ); + free( p_val->p_list->pi_types ); + } + free( p_val->p_list ); +} + /***************************************************************************** * Local prototypes *****************************************************************************/ @@ -81,6 +136,7 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type ) { int i_new; variable_t *p_var; + static vlc_list_t dummy_null_list = {0, NULL, NULL}; vlc_mutex_lock( &p_this->var_lock ); @@ -122,6 +178,7 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type ) p_var->i_hash = HashString( psz_name ); p_var->psz_name = strdup( psz_name ); + p_var->psz_text = NULL; p_var->i_type = i_type; memset( &p_var->val, 0, sizeof(vlc_value_t) ); @@ -134,6 +191,8 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type ) p_var->i_default = -1; p_var->choices.i_count = 0; p_var->choices.p_values = NULL; + p_var->choices_text.i_count = 0; + p_var->choices_text.p_values = NULL; p_var->b_incallback = VLC_FALSE; p_var->i_entries = 0; @@ -179,6 +238,12 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type ) p_var->val.p_address = malloc( sizeof(vlc_mutex_t) ); vlc_mutex_init( p_this, (vlc_mutex_t*)p_var->val.p_address ); break; + case VLC_VAR_LIST: + p_var->pf_cmp = CmpAddress; + p_var->pf_dup = DupList; + p_var->pf_free = FreeList; + p_var->val.p_list = &dummy_null_list; + break; } /* Duplicate the default data we stored. */ @@ -238,6 +303,7 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name ) } free( p_var->psz_name ); + if( p_var->psz_text ) free( p_var->psz_text ); memmove( p_this->p_vars + i_var, p_this->p_vars + i_var + 1, @@ -262,7 +328,7 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name ) * *****************************************************************************/ int __var_Change( vlc_object_t *p_this, const char *psz_name, - int i_action, vlc_value_t *p_val ) + int i_action, vlc_value_t *p_val, vlc_value_t *p_val2 ) { int i_var, i; variable_t *p_var; @@ -332,7 +398,12 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name, INSERT_ELEM( p_var->choices.p_values, p_var->choices.i_count, i, *p_val ); + INSERT_ELEM( p_var->choices_text.p_values, + p_var->choices_text.i_count, i, (vlc_value_t)0 ); p_var->pf_dup( &p_var->choices.p_values[i] ); + p_var->choices_text.p_values[i].psz_string = + ( p_val2 && p_val2->psz_string ) ? + strdup( p_val2->psz_string ) : NULL; CheckValue( p_var, &p_var->val ); break; @@ -363,10 +434,17 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name, } p_var->pf_free( &p_var->choices.p_values[i] ); + if( p_var->choices_text.p_values[i].psz_string ) + free( p_var->choices_text.p_values[i].psz_string ); REMOVE_ELEM( p_var->choices.p_values, p_var->choices.i_count, i ); + REMOVE_ELEM( p_var->choices_text.p_values, + p_var->choices_text.i_count, i ); CheckValue( p_var, &p_var->val ); break; + case VLC_VAR_CHOICESCOUNT: + p_val->i_int = p_var->choices.i_count; + break; case VLC_VAR_CLEARCHOICES: for( i = 0 ; i < p_var->choices.i_count ; i++ ) { @@ -410,26 +488,54 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name, /* Free data if needed */ p_var->pf_free( &oldval ); break; + case VLC_VAR_GETCHOICES: case VLC_VAR_GETLIST: p_val->p_list = malloc( sizeof(vlc_list_t) ); + if( p_val2 ) p_val2->p_list = malloc( sizeof(vlc_list_t) ); if( p_var->choices.i_count ) + { p_val->p_list->p_values = malloc( p_var->choices.i_count * sizeof(vlc_value_t) ); + p_val->p_list->pi_types = malloc( p_var->choices.i_count + * sizeof(int) ); + if( p_val2 ) + { + p_val2->p_list->p_values = + malloc( p_var->choices.i_count * sizeof(vlc_value_t) ); + p_val2->p_list->pi_types = + malloc( p_var->choices.i_count * sizeof(int) ); + } + } p_val->p_list->i_count = p_var->choices.i_count; + if( p_val2 ) p_val2->p_list->i_count = p_var->choices.i_count; for( i = 0 ; i < p_var->choices.i_count ; i++ ) { p_val->p_list->p_values[i] = p_var->choices.p_values[i]; + p_val->p_list->pi_types[i] = p_var->i_type; p_var->pf_dup( &p_val->p_list->p_values[i] ); + if( p_val2 ) + { + p_val2->p_list->p_values[i].psz_string = + p_var->choices_text.p_values[i].psz_string ? + strdup(p_var->choices_text.p_values[i].psz_string) : NULL; + p_val2->p_list->pi_types[i] = VLC_VAR_STRING; + } } break; case VLC_VAR_FREELIST: - for( i = p_val->p_list->i_count ; i-- ; ) + FreeList( p_val ); + break; + case VLC_VAR_SETTEXT: + if( p_var->psz_text ) free( p_var->psz_text ); + if( p_val && p_val->psz_string ) + p_var->psz_text = strdup( p_val->psz_string ); + break; + case VLC_VAR_GETTEXT: + p_val->psz_string = NULL; + if( p_var->psz_text ) { - p_var->pf_free( &p_val->p_list->p_values[i] ); + p_val->psz_string = strdup( p_var->psz_text ); } - if( p_val->p_list->i_count ) - free( p_val->p_list->p_values ); - free( p_val->p_list ); break; default: