Commit 19efca33 authored by Rémi Duraffort's avatar Rémi Duraffort

use var_Get(Bool|Integer|...) when possible.

(and fix a memleak)
parent f2730906
...@@ -274,8 +274,7 @@ static void Probe( aout_instance_t * p_aout, ...@@ -274,8 +274,7 @@ static void Probe( aout_instance_t * p_aout,
/* Add final settings to the variable */ /* Add final settings to the variable */
var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
val.b_bool = true; var_SetBool( p_aout, "intf-change", true );
var_Set( p_aout, "intf-change", val );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -285,11 +285,7 @@ static int OpenAudio( vlc_object_t *p_this ) ...@@ -285,11 +285,7 @@ static int OpenAudio( vlc_object_t *p_this )
/* Retrieve config values */ /* Retrieve config values */
var_Create( p_aout, "directx-audio-float32", var_Create( p_aout, "directx-audio-float32",
VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
psz_speaker = var_CreateGetString( p_aout, "directx-audio-speaker" );
var_Create( p_aout, "directx-audio-speaker",
VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Get( p_this, "directx-audio-speaker", &val );
psz_speaker = val.psz_string;
while ( *ppsz_compare != NULL ) while ( *ppsz_compare != NULL )
{ {
...@@ -307,12 +303,11 @@ static int OpenAudio( vlc_object_t *p_this ) ...@@ -307,12 +303,11 @@ static int OpenAudio( vlc_object_t *p_this )
msg_Err( p_aout, "Defaulting to Windows default speaker config"); msg_Err( p_aout, "Defaulting to Windows default speaker config");
i = 0; i = 0;
} }
free( psz_speaker );
p_aout->output.p_sys->i_speaker_setup = i; p_aout->output.p_sys->i_speaker_setup = i;
var_Create( p_aout, "directx-audio-device", p_aout->output.p_sys->i_device_id = var_CreateGetInteger( p_aout,
VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); "directx-audio-device" );
var_Get( p_aout, "directx-audio-device", &val );
p_aout->output.p_sys->i_device_id = val.i_int;
p_aout->output.p_sys->p_device_guid = 0; p_aout->output.p_sys->p_device_guid = 0;
/* Initialise DirectSound */ /* Initialise DirectSound */
...@@ -678,9 +673,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -678,9 +673,7 @@ static void Probe( aout_instance_t * p_aout )
} }
var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
var_SetBool( p_aout, "intf-change", true );
val.b_bool = true;
var_Set( p_aout, "intf-change", val );
} }
/***************************************************************************** /*****************************************************************************
...@@ -995,13 +988,9 @@ static int CreateDSBufferPCM( aout_instance_t *p_aout, int *i_format, ...@@ -995,13 +988,9 @@ static int CreateDSBufferPCM( aout_instance_t *p_aout, int *i_format,
int i_channels, int i_nb_channels, int i_rate, int i_channels, int i_nb_channels, int i_rate,
bool b_probe ) bool b_probe )
{ {
vlc_value_t val;
var_Get( p_aout, "directx-audio-float32", &val );
/* Float32 audio samples are not supported for 5.1 output on the emu101k */ /* Float32 audio samples are not supported for 5.1 output on the emu101k */
if( !var_GetBool( p_aout, "directx-audio-float32" ) ||
if( !val.b_bool || i_nb_channels > 2 || i_nb_channels > 2 ||
CreateDSBuffer( p_aout, VLC_FOURCC('f','l','3','2'), CreateDSBuffer( p_aout, VLC_FOURCC('f','l','3','2'),
i_channels, i_nb_channels, i_rate, i_channels, i_nb_channels, i_rate,
FRAME_SIZE * 4 * i_nb_channels, b_probe ) FRAME_SIZE * 4 * i_nb_channels, b_probe )
......
...@@ -138,12 +138,9 @@ static int Open( vlc_object_t * p_this ) ...@@ -138,12 +138,9 @@ static int Open( vlc_object_t * p_this )
aout_instance_t * p_aout = (aout_instance_t *)p_this; aout_instance_t * p_aout = (aout_instance_t *)p_this;
char * psz_name, * psz_format; char * psz_name, * psz_format;
const char * const * ppsz_compare = format_list; const char * const * ppsz_compare = format_list;
vlc_value_t val;
int i_channels, i = 0; int i_channels, i = 0;
var_Create( p_this, "audiofile-file", VLC_VAR_STRING|VLC_VAR_DOINHERIT ); psz_name = var_CreateGetString( p_this, "audiofile-file" );
var_Get( p_this, "audiofile-file", &val );
psz_name = val.psz_string;
if( !psz_name || !*psz_name ) if( !psz_name || !*psz_name )
{ {
msg_Err( p_aout, "you need to specify an output file name" ); msg_Err( p_aout, "you need to specify an output file name" );
...@@ -171,9 +168,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -171,9 +168,7 @@ static int Open( vlc_object_t * p_this )
p_aout->output.pf_play = Play; p_aout->output.pf_play = Play;
/* Audio format */ /* Audio format */
var_Create( p_this, "audiofile-format", VLC_VAR_STRING|VLC_VAR_DOINHERIT ); psz_format = var_CreateGetString( p_this, "audiofile-format" );
var_Get( p_this, "audiofile-format", &val );
psz_format = val.psz_string;
while ( *ppsz_compare != NULL ) while ( *ppsz_compare != NULL )
{ {
...@@ -211,10 +206,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -211,10 +206,7 @@ static int Open( vlc_object_t * p_this )
} }
/* Channels number */ /* Channels number */
var_Create( p_this, "audiofile-channels", i_channels = var_CreateGetInteger( p_this, "audiofile-channels" );
VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Get( p_this, "audiofile-channels", &val );
i_channels = val.i_int;
if( i_channels > 0 && i_channels <= CHANNELS_MAX ) if( i_channels > 0 && i_channels <= CHANNELS_MAX )
{ {
...@@ -223,9 +215,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -223,9 +215,8 @@ static int Open( vlc_object_t * p_this )
} }
/* WAV header */ /* WAV header */
var_Create( p_this, "audiofile-wav", VLC_VAR_BOOL|VLC_VAR_DOINHERIT ); p_aout->output.p_sys->b_add_wav_header = var_CreateGetBool( p_this,
var_Get( p_this, "audiofile-wav", &val ); "audiofile-wav" );
p_aout->output.p_sys->b_add_wav_header = val.b_bool;
if( p_aout->output.p_sys->b_add_wav_header ) if( p_aout->output.p_sys->b_add_wav_header )
{ {
......
...@@ -169,13 +169,12 @@ static int Open( vlc_object_t * p_this ) ...@@ -169,13 +169,12 @@ static int Open( vlc_object_t * p_this )
{ {
aout_instance_t *p_aout = (aout_instance_t *)p_this; aout_instance_t *p_aout = (aout_instance_t *)p_this;
struct aout_sys_t * p_sys; struct aout_sys_t * p_sys;
vlc_value_t val;
int i_err; int i_err;
msg_Dbg( p_aout, "entering Open()"); msg_Dbg( p_aout, "entering Open()");
/* Allocate p_sys structure */ /* Allocate p_sys structure */
p_sys = (aout_sys_t *)malloc( sizeof(aout_sys_t) ); p_sys = malloc( sizeof(aout_sys_t) );
if( p_sys == NULL ) if( p_sys == NULL )
return VLC_ENOMEM; return VLC_ENOMEM;
p_sys->p_aout = p_aout; p_sys->p_aout = p_aout;
...@@ -184,9 +183,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -184,9 +183,7 @@ static int Open( vlc_object_t * p_this )
p_aout->output.pf_play = Play; p_aout->output.pf_play = Play;
/* Retrieve output device id from config */ /* Retrieve output device id from config */
var_Create( p_aout, "portaudio-audio-device", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT); p_sys->i_device_id = var_CreateGetInteger( p_aout, "portaudio-audio-device" );
var_Get( p_aout, "portaudio-audio-device", &val );
p_sys->i_device_id = val.i_int;
#ifdef PORTAUDIO_IS_SERIOUSLY_BROKEN #ifdef PORTAUDIO_IS_SERIOUSLY_BROKEN
if( !b_init ) if( !b_init )
...@@ -434,9 +431,7 @@ static int PAOpenDevice( aout_instance_t *p_aout ) ...@@ -434,9 +431,7 @@ static int PAOpenDevice( aout_instance_t *p_aout )
} }
var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
var_SetBool( p_aout, "intf-change", true );
val.b_bool = true;
var_Set( p_aout, "intf-change", val );
} }
/* Audio format is paFloat32 (always supported by portaudio v19) */ /* Audio format is paFloat32 (always supported by portaudio v19) */
......
...@@ -215,8 +215,7 @@ static int Open ( vlc_object_t *p_this ) ...@@ -215,8 +215,7 @@ static int Open ( vlc_object_t *p_this )
var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
} }
val.b_bool = true; var_SetBool( p_aout, "intf-change", true );
var_Set( p_aout, "intf-change", val );
p_aout->output.output.i_rate = obtained.freq; p_aout->output.output.i_rate = obtained.freq;
p_aout->output.i_nb_samples = obtained.samples; p_aout->output.i_nb_samples = obtained.samples;
......
...@@ -341,25 +341,23 @@ static int Open( vlc_object_t *p_this ) ...@@ -341,25 +341,23 @@ static int Open( vlc_object_t *p_this )
{ {
WAVEOUTCAPS wocaps; WAVEOUTCAPS wocaps;
if( val.i_int == AOUT_VAR_5_1 ) switch( val.i_int )
{ {
case AOUT_VAR_5_1:
p_aout->output.output.i_physical_channels p_aout->output.output.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
| AOUT_CHAN_LFE; | AOUT_CHAN_LFE;
} break;
else if( val.i_int == AOUT_VAR_2F2R ) case AOUT_VAR_2F2R:
{
p_aout->output.output.i_physical_channels p_aout->output.output.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
} break;
else if( val.i_int == AOUT_VAR_MONO ) case AOUT_VAR_MONO:
{
p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER;
} break;
else default:
{
p_aout->output.output.i_physical_channels p_aout->output.output.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
} }
...@@ -410,7 +408,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -410,7 +408,7 @@ static int Open( vlc_object_t *p_this )
if( p_aout->output.p_sys->p_silence_buffer == NULL ) if( p_aout->output.p_sys->p_silence_buffer == NULL )
{ {
free( p_aout->output.p_sys ); free( p_aout->output.p_sys );
return 1; return VLC_ENOMEM;
} }
p_aout->output.p_sys->i_repeat_counter = 0; p_aout->output.p_sys->i_repeat_counter = 0;
...@@ -448,7 +446,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -448,7 +446,7 @@ static int Open( vlc_object_t *p_this )
p_aout->output.p_sys->waveheader[i].dwUser = 0; p_aout->output.p_sys->waveheader[i].dwUser = 0;
} }
return 0; return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -566,9 +564,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -566,9 +564,7 @@ static void Probe( aout_instance_t * p_aout )
} }
var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
var_SetBool( p_aout, "intf-change", true );
val.b_bool = true;
var_Set( p_aout, "intf-change", val );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -98,14 +98,11 @@ int __aout_VolumeGet( vlc_object_t * p_object, audio_volume_t * pi_volume ) ...@@ -98,14 +98,11 @@ int __aout_VolumeGet( vlc_object_t * p_object, audio_volume_t * pi_volume )
*****************************************************************************/ *****************************************************************************/
int __aout_VolumeSet( vlc_object_t * p_object, audio_volume_t i_volume ) int __aout_VolumeSet( vlc_object_t * p_object, audio_volume_t i_volume )
{ {
vlc_value_t val;
aout_instance_t *p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT, FIND_ANYWHERE ); aout_instance_t *p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT, FIND_ANYWHERE );
int i_result = 0; int i_result = 0;
config_PutInt( p_object, "volume", i_volume ); config_PutInt( p_object, "volume", i_volume );
var_SetBool( p_object->p_libvlc, "volume-change", true );
val.b_bool = true;
var_Set( p_object->p_libvlc, "volume-change", val );
if ( p_aout == NULL ) return 0; if ( p_aout == NULL ) return 0;
...@@ -116,7 +113,7 @@ int __aout_VolumeSet( vlc_object_t * p_object, audio_volume_t i_volume ) ...@@ -116,7 +113,7 @@ int __aout_VolumeSet( vlc_object_t * p_object, audio_volume_t i_volume )
} }
aout_unlock_mixer( p_aout ); aout_unlock_mixer( p_aout );
var_Set( p_aout, "intf-change", val ); var_SetBool( p_aout, "intf-change", true );
vlc_object_release( p_aout ); vlc_object_release( p_aout );
return i_result; return i_result;
} }
...@@ -157,7 +154,6 @@ int __aout_VolumeInfos( vlc_object_t * p_object, audio_volume_t * pi_soft ) ...@@ -157,7 +154,6 @@ int __aout_VolumeInfos( vlc_object_t * p_object, audio_volume_t * pi_soft )
int __aout_VolumeUp( vlc_object_t * p_object, int i_nb_steps, int __aout_VolumeUp( vlc_object_t * p_object, int i_nb_steps,
audio_volume_t * pi_volume ) audio_volume_t * pi_volume )
{ {
vlc_value_t val;
aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT, aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
FIND_ANYWHERE ); FIND_ANYWHERE );
int i_result = 0, i_volume = 0, i_volume_step = 0; int i_result = 0, i_volume = 0, i_volume_step = 0;
...@@ -175,8 +171,7 @@ int __aout_VolumeUp( vlc_object_t * p_object, int i_nb_steps, ...@@ -175,8 +171,7 @@ int __aout_VolumeUp( vlc_object_t * p_object, int i_nb_steps,
(audio_volume_t) i_volume ); (audio_volume_t) i_volume );
if ( pi_volume != NULL ) *pi_volume = (audio_volume_t) i_volume; if ( pi_volume != NULL ) *pi_volume = (audio_volume_t) i_volume;
val.b_bool = true; var_SetBool( p_object->p_libvlc, "volume-change", true );
var_Set( p_object->p_libvlc, "volume-change", val );
if ( p_aout == NULL ) return 0; if ( p_aout == NULL ) return 0;
...@@ -201,7 +196,6 @@ int __aout_VolumeUp( vlc_object_t * p_object, int i_nb_steps, ...@@ -201,7 +196,6 @@ int __aout_VolumeUp( vlc_object_t * p_object, int i_nb_steps,
int __aout_VolumeDown( vlc_object_t * p_object, int i_nb_steps, int __aout_VolumeDown( vlc_object_t * p_object, int i_nb_steps,
audio_volume_t * pi_volume ) audio_volume_t * pi_volume )
{ {
vlc_value_t val;
aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT, aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
FIND_ANYWHERE ); FIND_ANYWHERE );
int i_result = 0, i_volume = 0, i_volume_step = 0; int i_result = 0, i_volume = 0, i_volume_step = 0;
...@@ -218,8 +212,7 @@ int __aout_VolumeDown( vlc_object_t * p_object, int i_nb_steps, ...@@ -218,8 +212,7 @@ int __aout_VolumeDown( vlc_object_t * p_object, int i_nb_steps,
var_SetInteger( p_object->p_libvlc, "saved-volume", (audio_volume_t) i_volume ); var_SetInteger( p_object->p_libvlc, "saved-volume", (audio_volume_t) i_volume );
if ( pi_volume != NULL ) *pi_volume = (audio_volume_t) i_volume; if ( pi_volume != NULL ) *pi_volume = (audio_volume_t) i_volume;
val.b_bool = true; var_SetBool( p_object->p_libvlc, "volume-change", true );
var_Set( p_object->p_libvlc, "volume-change", val );
if ( p_aout == NULL ) return 0; if ( p_aout == NULL ) return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment