Commit 30336bba authored by Gildas Bazin's avatar Gildas Bazin

* 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.
parent baa735b3
......@@ -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 <massiot@via.ecp.fr>
*
......@@ -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
......
......@@ -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 <sam@zoy.org>
*
......@@ -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 )
......
......@@ -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: Stphane Borel <stef@via.ecp.fr>
*
......@@ -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;
}
......
......@@ -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: Stphane Borel <stef@via.ecp.fr>
*
......@@ -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;
}
......
......@@ -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: Stphane Borel <stef@via.ecp.fr>
*
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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 <jobi@via.ecp.fr>
*
......@@ -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;
}
......
......@@ -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 <henri@videolan.org> - Original Author
* Jeffrey Baker <jwbaker@acm.org> - 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 );
......
......@@ -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 <colin@zoy.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -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 );
}
......
......@@ -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 <gbazin@netcourrier.com>
*
......@@ -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 );
}
......
......@@ -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 <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -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" ) )