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,
/* Add final settings to the variable */
var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
val.b_bool = true;
var_Set( p_aout, "intf-change", val );
var_SetBool( p_aout, "intf-change", true );
}
/*****************************************************************************
......
......@@ -285,11 +285,7 @@ static int OpenAudio( vlc_object_t *p_this )
/* Retrieve config values */
var_Create( p_aout, "directx-audio-float32",
VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
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;
psz_speaker = var_CreateGetString( p_aout, "directx-audio-speaker" );
while ( *ppsz_compare != NULL )
{
......@@ -307,12 +303,11 @@ static int OpenAudio( vlc_object_t *p_this )
msg_Err( p_aout, "Defaulting to Windows default speaker config");
i = 0;
}
free( psz_speaker );
p_aout->output.p_sys->i_speaker_setup = i;
var_Create( p_aout, "directx-audio-device",
VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Get( p_aout, "directx-audio-device", &val );
p_aout->output.p_sys->i_device_id = val.i_int;
p_aout->output.p_sys->i_device_id = var_CreateGetInteger( p_aout,
"directx-audio-device" );
p_aout->output.p_sys->p_device_guid = 0;
/* Initialise DirectSound */
......@@ -678,9 +673,7 @@ static void Probe( aout_instance_t * p_aout )
}
var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
val.b_bool = true;
var_Set( p_aout, "intf-change", val );
var_SetBool( p_aout, "intf-change", true );
}
/*****************************************************************************
......@@ -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,
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 */
if( !val.b_bool || i_nb_channels > 2 ||
if( !var_GetBool( p_aout, "directx-audio-float32" ) ||
i_nb_channels > 2 ||
CreateDSBuffer( p_aout, VLC_FOURCC('f','l','3','2'),
i_channels, i_nb_channels, i_rate,
FRAME_SIZE * 4 * i_nb_channels, b_probe )
......
......@@ -138,12 +138,9 @@ static int Open( vlc_object_t * p_this )
aout_instance_t * p_aout = (aout_instance_t *)p_this;
char * psz_name, * psz_format;
const char * const * ppsz_compare = format_list;
vlc_value_t val;
int i_channels, i = 0;
var_Create( p_this, "audiofile-file", VLC_VAR_STRING|VLC_VAR_DOINHERIT );
var_Get( p_this, "audiofile-file", &val );
psz_name = val.psz_string;
psz_name = var_CreateGetString( p_this, "audiofile-file" );
if( !psz_name || !*psz_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 )
p_aout->output.pf_play = Play;
/* Audio format */
var_Create( p_this, "audiofile-format", VLC_VAR_STRING|VLC_VAR_DOINHERIT );
var_Get( p_this, "audiofile-format", &val );
psz_format = val.psz_string;
psz_format = var_CreateGetString( p_this, "audiofile-format" );
while ( *ppsz_compare != NULL )
{
......@@ -211,10 +206,7 @@ static int Open( vlc_object_t * p_this )
}
/* Channels number */
var_Create( p_this, "audiofile-channels",
VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Get( p_this, "audiofile-channels", &val );
i_channels = val.i_int;
i_channels = var_CreateGetInteger( p_this, "audiofile-channels" );
if( i_channels > 0 && i_channels <= CHANNELS_MAX )
{
......@@ -223,9 +215,8 @@ static int Open( vlc_object_t * p_this )
}
/* WAV header */
var_Create( p_this, "audiofile-wav", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
var_Get( p_this, "audiofile-wav", &val );
p_aout->output.p_sys->b_add_wav_header = val.b_bool;
p_aout->output.p_sys->b_add_wav_header = var_CreateGetBool( p_this,
"audiofile-wav" );
if( p_aout->output.p_sys->b_add_wav_header )
{
......
......@@ -169,13 +169,12 @@ static int Open( vlc_object_t * p_this )
{
aout_instance_t *p_aout = (aout_instance_t *)p_this;
struct aout_sys_t * p_sys;
vlc_value_t val;
int i_err;
msg_Dbg( p_aout, "entering Open()");
/* 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 )
return VLC_ENOMEM;
p_sys->p_aout = p_aout;
......@@ -184,9 +183,7 @@ static int Open( vlc_object_t * p_this )
p_aout->output.pf_play = Play;
/* Retrieve output device id from config */
var_Create( p_aout, "portaudio-audio-device", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT);
var_Get( p_aout, "portaudio-audio-device", &val );
p_sys->i_device_id = val.i_int;
p_sys->i_device_id = var_CreateGetInteger( p_aout, "portaudio-audio-device" );
#ifdef PORTAUDIO_IS_SERIOUSLY_BROKEN
if( !b_init )
......@@ -434,9 +431,7 @@ static int PAOpenDevice( aout_instance_t *p_aout )
}
var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
val.b_bool = true;
var_Set( p_aout, "intf-change", val );
var_SetBool( p_aout, "intf-change", true );
}
/* Audio format is paFloat32 (always supported by portaudio v19) */
......
......@@ -215,8 +215,7 @@ static int Open ( vlc_object_t *p_this )
var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
}
val.b_bool = true;
var_Set( p_aout, "intf-change", val );
var_SetBool( p_aout, "intf-change", true );
p_aout->output.output.i_rate = obtained.freq;
p_aout->output.i_nb_samples = obtained.samples;
......
......@@ -341,27 +341,25 @@ static int Open( vlc_object_t *p_this )
{
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
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
| AOUT_CHAN_LFE;
}
else if( val.i_int == AOUT_VAR_2F2R )
{
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
| AOUT_CHAN_LFE;
break;
case AOUT_VAR_2F2R:
p_aout->output.output.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
}
else if( val.i_int == AOUT_VAR_MONO )
{
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
| AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
break;
case AOUT_VAR_MONO:
p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER;
}
else
{
break;
default:
p_aout->output.output.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
}
if( OpenWaveOutPCM( p_aout,
......@@ -410,7 +408,7 @@ static int Open( vlc_object_t *p_this )
if( p_aout->output.p_sys->p_silence_buffer == NULL )
{
free( p_aout->output.p_sys );
return 1;
return VLC_ENOMEM;
}
p_aout->output.p_sys->i_repeat_counter = 0;
......@@ -448,7 +446,7 @@ static int Open( vlc_object_t *p_this )
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 )
}
var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
val.b_bool = true;
var_Set( p_aout, "intf-change", val );
var_SetBool( p_aout, "intf-change", true );
}
/*****************************************************************************
......
......@@ -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 )
{
vlc_value_t val;
aout_instance_t *p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT, FIND_ANYWHERE );
int i_result = 0;
config_PutInt( p_object, "volume", i_volume );
val.b_bool = true;
var_Set( p_object->p_libvlc, "volume-change", val );
var_SetBool( p_object->p_libvlc, "volume-change", true );
if ( p_aout == NULL ) return 0;
......@@ -116,7 +113,7 @@ int __aout_VolumeSet( vlc_object_t * p_object, audio_volume_t i_volume )
}
aout_unlock_mixer( p_aout );
var_Set( p_aout, "intf-change", val );
var_SetBool( p_aout, "intf-change", true );
vlc_object_release( p_aout );
return i_result;
}
......@@ -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,
audio_volume_t * pi_volume )
{
vlc_value_t val;
aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
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,
(audio_volume_t) i_volume );
if ( pi_volume != NULL ) *pi_volume = (audio_volume_t) i_volume;
val.b_bool = true;
var_Set( p_object->p_libvlc, "volume-change", val );
var_SetBool( p_object->p_libvlc, "volume-change", true );
if ( p_aout == NULL ) return 0;
......@@ -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,
audio_volume_t * pi_volume )
{
vlc_value_t val;
aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
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,
var_SetInteger( p_object->p_libvlc, "saved-volume", (audio_volume_t) i_volume );
if ( pi_volume != NULL ) *pi_volume = (audio_volume_t) i_volume;
val.b_bool = true;
var_Set( p_object->p_libvlc, "volume-change", val );
var_SetBool( p_object->p_libvlc, "volume-change", true );
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