Commit a822a430 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Pass mixer multiplier as argument

parent 600240e2
...@@ -72,16 +72,11 @@ struct aout_mixer_t { ...@@ -72,16 +72,11 @@ struct aout_mixer_t {
*/ */
audio_sample_format_t fmt; audio_sample_format_t fmt;
/* Multiplier used to raise or lower the volume of the sound in
* software.
*/
float multiplier;
/* Array of mixer inputs */ /* Array of mixer inputs */
aout_mixer_input_t *input; aout_mixer_input_t *input;
/* Mix requested number of samples (mandatory) */ /* Mix requested number of samples (mandatory) */
aout_buffer_t *(*mix)(aout_mixer_t *, unsigned); aout_buffer_t *(*mix)(aout_mixer_t *, unsigned, float);
/* Private place holder for the aout_mixer_t module (optional) /* Private place holder for the aout_mixer_t module (optional)
* *
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
static int Create ( vlc_object_t * ); static int Create ( vlc_object_t * );
static aout_buffer_t *DoWork( aout_mixer_t *, unsigned ); static aout_buffer_t *DoWork( aout_mixer_t *, unsigned, float );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -88,10 +88,10 @@ static void ScaleWords( float * p_out, const float * p_in, size_t i_nb_words, ...@@ -88,10 +88,10 @@ static void ScaleWords( float * p_out, const float * p_in, size_t i_nb_words,
* Terminology : in this function a word designates a single float32, eg. * Terminology : in this function a word designates a single float32, eg.
* a stereo sample is consituted of two words. * a stereo sample is consituted of two words.
*****************************************************************************/ *****************************************************************************/
static aout_buffer_t *DoWork( aout_mixer_t * p_mixer, unsigned samples ) static aout_buffer_t *DoWork( aout_mixer_t * p_mixer, unsigned samples,
float f_multiplier )
{ {
aout_mixer_input_t * p_input = p_mixer->input; aout_mixer_input_t * p_input = p_mixer->input;
float f_multiplier = p_mixer->multiplier * p_input->multiplier;
const int i_nb_channels = aout_FormatNbChannels( &p_mixer->fmt ); const int i_nb_channels = aout_FormatNbChannels( &p_mixer->fmt );
int i_nb_words = samples * i_nb_channels; int i_nb_words = samples * i_nb_channels;
...@@ -103,6 +103,8 @@ static aout_buffer_t *DoWork( aout_mixer_t * p_mixer, unsigned samples ) ...@@ -103,6 +103,8 @@ static aout_buffer_t *DoWork( aout_mixer_t * p_mixer, unsigned samples )
float * p_out = (float *)p_buffer->p_buffer; float * p_out = (float *)p_buffer->p_buffer;
float * p_in = (float *)p_input->begin; float * p_in = (float *)p_input->begin;
f_multiplier *= p_input->multiplier;
for( ; ; ) for( ; ; )
{ {
ptrdiff_t i_available_words = ( ptrdiff_t i_available_words = (
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
*****************************************************************************/ *****************************************************************************/
static int Create ( vlc_object_t * ); static int Create ( vlc_object_t * );
static aout_buffer_t *DoWork( aout_mixer_t *, unsigned ); static aout_buffer_t *DoWork( aout_mixer_t *, unsigned, float );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -71,11 +71,12 @@ static int Create( vlc_object_t *p_this ) ...@@ -71,11 +71,12 @@ static int Create( vlc_object_t *p_this )
/***************************************************************************** /*****************************************************************************
* DoWork: mix a new output buffer - this does nothing, indeed * DoWork: mix a new output buffer - this does nothing, indeed
*****************************************************************************/ *****************************************************************************/
static aout_buffer_t *DoWork( aout_mixer_t * p_mixer, unsigned samples ) static aout_buffer_t *DoWork( aout_mixer_t * p_mixer, unsigned samples,
float multiplier )
{ {
aout_mixer_input_t * p_input = p_mixer->input; aout_mixer_input_t * p_input = p_mixer->input;
aout_buffer_t * p_old_buffer = aout_FifoPop( NULL, &p_input->fifo ); aout_buffer_t * p_old_buffer = aout_FifoPop( NULL, &p_input->fifo );
(void) samples; (void) samples; (void) multiplier;
return p_old_buffer; return p_old_buffer;
} }
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
*****************************************************************************/ *****************************************************************************/
static int Create ( vlc_object_t * ); static int Create ( vlc_object_t * );
static aout_buffer_t *DoWork( aout_mixer_t *, unsigned samples ); static aout_buffer_t *DoWork( aout_mixer_t *, unsigned samples, float );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -71,7 +71,8 @@ static int Create( vlc_object_t *p_this ) ...@@ -71,7 +71,8 @@ static int Create( vlc_object_t *p_this )
/***************************************************************************** /*****************************************************************************
* DoWork: mix a new output buffer * DoWork: mix a new output buffer
*****************************************************************************/ *****************************************************************************/
static aout_buffer_t *DoWork( aout_mixer_t *p_mixer, unsigned samples ) static aout_buffer_t *DoWork( aout_mixer_t *p_mixer, unsigned samples,
float multiplier )
{ {
aout_mixer_input_t *p_input = p_mixer->input; aout_mixer_input_t *p_input = p_mixer->input;
int i_nb_channels = aout_FormatNbChannels( &p_mixer->fmt ); int i_nb_channels = aout_FormatNbChannels( &p_mixer->fmt );
...@@ -118,5 +119,6 @@ static aout_buffer_t *DoWork( aout_mixer_t *p_mixer, unsigned samples ) ...@@ -118,5 +119,6 @@ static aout_buffer_t *DoWork( aout_mixer_t *p_mixer, unsigned samples )
break; break;
} }
} }
(void) multiplier;
return p_buffer; return p_buffer;
} }
...@@ -111,8 +111,7 @@ void aout_FiltersPlay( filter_t *const *, unsigned, aout_buffer_t ** ); ...@@ -111,8 +111,7 @@ void aout_FiltersPlay( filter_t *const *, unsigned, aout_buffer_t ** );
/* From mixer.c : */ /* From mixer.c : */
int aout_MixerNew( aout_instance_t * p_aout ); int aout_MixerNew( aout_instance_t * p_aout );
void aout_MixerDelete( aout_instance_t * p_aout ); void aout_MixerDelete( aout_instance_t * p_aout );
void aout_MixerRun( aout_instance_t * p_aout ); void aout_MixerRun( aout_instance_t * p_aout, float );
void aout_MixerMultiplierSet( aout_instance_t * p_aout, float f_multiplier );
/* From output.c : */ /* From output.c : */
int aout_OutputNew( aout_instance_t * p_aout, int aout_OutputNew( aout_instance_t * p_aout,
......
...@@ -293,9 +293,7 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -293,9 +293,7 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
/* Run the mixer if it is able to run. */ /* Run the mixer if it is able to run. */
aout_lock_mixer( p_aout ); aout_lock_mixer( p_aout );
aout_MixerRun( p_aout, p_aout->mixer_multiplier );
aout_MixerRun( p_aout );
aout_unlock_mixer( p_aout ); aout_unlock_mixer( p_aout );
return 0; return 0;
......
...@@ -245,7 +245,7 @@ static int aout_VolumeSoftSet (aout_instance_t *aout, audio_volume_t volume, ...@@ -245,7 +245,7 @@ static int aout_VolumeSoftSet (aout_instance_t *aout, audio_volume_t volume,
bool mute) bool mute)
{ {
float f = mute ? 0. : (volume / (float)AOUT_VOLUME_DEFAULT); float f = mute ? 0. : (volume / (float)AOUT_VOLUME_DEFAULT);
aout_MixerMultiplierSet (aout, f); aout->mixer_multiplier = f;
return 0; return 0;
} }
......
...@@ -51,7 +51,6 @@ int aout_MixerNew( aout_instance_t * p_aout ) ...@@ -51,7 +51,6 @@ int aout_MixerNew( aout_instance_t * p_aout )
return VLC_EGENERIC; return VLC_EGENERIC;
p_mixer->fmt = p_aout->mixer_format; p_mixer->fmt = p_aout->mixer_format;
p_mixer->multiplier = p_aout->mixer_multiplier;
p_mixer->input = &p_aout->pp_inputs[0]->mixer; p_mixer->input = &p_aout->pp_inputs[0]->mixer;
p_mixer->mix = NULL; p_mixer->mix = NULL;
p_mixer->sys = NULL; p_mixer->sys = NULL;
...@@ -92,7 +91,7 @@ void aout_MixerDelete( aout_instance_t * p_aout ) ...@@ -92,7 +91,7 @@ void aout_MixerDelete( aout_instance_t * p_aout )
***************************************************************************** *****************************************************************************
* Please note that you must hold the mixer lock. * Please note that you must hold the mixer lock.
*****************************************************************************/ *****************************************************************************/
static int MixBuffer( aout_instance_t * p_aout ) static int MixBuffer( aout_instance_t * p_aout, float volume )
{ {
int i, i_first_input = 0; int i, i_first_input = 0;
mtime_t start_date, end_date; mtime_t start_date, end_date;
...@@ -322,7 +321,7 @@ static int MixBuffer( aout_instance_t * p_aout ) ...@@ -322,7 +321,7 @@ static int MixBuffer( aout_instance_t * p_aout )
/* Run the mixer. */ /* Run the mixer. */
aout_buffer_t * p_outbuf; aout_buffer_t * p_outbuf;
p_outbuf = p_aout->p_mixer->mix( p_aout->p_mixer, p_outbuf = p_aout->p_mixer->mix( p_aout->p_mixer,
p_aout->output.i_nb_samples ); p_aout->output.i_nb_samples, volume );
aout_unlock_input_fifos( p_aout ); aout_unlock_input_fifos( p_aout );
if( unlikely(p_outbuf == NULL) ) if( unlikely(p_outbuf == NULL) )
...@@ -339,20 +338,7 @@ static int MixBuffer( aout_instance_t * p_aout ) ...@@ -339,20 +338,7 @@ static int MixBuffer( aout_instance_t * p_aout )
***************************************************************************** *****************************************************************************
* Please note that you must hold the mixer lock. * Please note that you must hold the mixer lock.
*****************************************************************************/ *****************************************************************************/
void aout_MixerRun( aout_instance_t * p_aout ) void aout_MixerRun( aout_instance_t * p_aout, float volume )
{ {
while( MixBuffer( p_aout ) != -1 ); while( MixBuffer( p_aout, volume ) != -1 );
}
/*****************************************************************************
* aout_MixerMultiplierSet: set p_aout->mixer.f_multiplier
*****************************************************************************
* Please note that we assume that you own the mixer lock when entering this
* function. This function returns -1 on error.
*****************************************************************************/
void aout_MixerMultiplierSet( aout_instance_t * p_aout, float f_multiplier )
{
p_aout->mixer_multiplier = f_multiplier;
if( p_aout->p_mixer )
p_aout->p_mixer->multiplier = f_multiplier;
} }
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