*/
audio_sample_format_t fmt;
- /* Multiplier used to raise or lower the volume of the sound in
- * software.
- */
- float multiplier;
-
/* Array of mixer inputs */
aout_mixer_input_t *input;
/* 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)
*
* Local prototypes
*****************************************************************************/
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
* Terminology : in this function a word designates a single float32, eg.
* 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;
- float f_multiplier = p_mixer->multiplier * p_input->multiplier;
const int i_nb_channels = aout_FormatNbChannels( &p_mixer->fmt );
int i_nb_words = samples * i_nb_channels;
float * p_out = (float *)p_buffer->p_buffer;
float * p_in = (float *)p_input->begin;
+ f_multiplier *= p_input->multiplier;
+
for( ; ; )
{
ptrdiff_t i_available_words = (
*****************************************************************************/
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
/*****************************************************************************
* 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_buffer_t * p_old_buffer = aout_FifoPop( NULL, &p_input->fifo );
- (void) samples;
+ (void) samples; (void) multiplier;
return p_old_buffer;
}
*****************************************************************************/
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
/*****************************************************************************
* 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;
int i_nb_channels = aout_FormatNbChannels( &p_mixer->fmt );
break;
}
}
+ (void) multiplier;
return p_buffer;
}
/* From mixer.c : */
int aout_MixerNew( aout_instance_t * p_aout );
void aout_MixerDelete( aout_instance_t * p_aout );
-void aout_MixerRun( aout_instance_t * p_aout );
-void aout_MixerMultiplierSet( aout_instance_t * p_aout, float f_multiplier );
+void aout_MixerRun( aout_instance_t * p_aout, float );
/* From output.c : */
int aout_OutputNew( aout_instance_t * p_aout,
/* Run the mixer if it is able to run. */
aout_lock_mixer( p_aout );
-
- aout_MixerRun( p_aout );
-
+ aout_MixerRun( p_aout, p_aout->mixer_multiplier );
aout_unlock_mixer( p_aout );
return 0;
bool mute)
{
float f = mute ? 0. : (volume / (float)AOUT_VOLUME_DEFAULT);
- aout_MixerMultiplierSet (aout, f);
+ aout->mixer_multiplier = f;
return 0;
}
return VLC_EGENERIC;
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->mix = NULL;
p_mixer->sys = NULL;
*****************************************************************************
* 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;
mtime_t start_date, end_date;
/* Run the mixer. */
aout_buffer_t * p_outbuf;
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 );
if( unlikely(p_outbuf == NULL) )
*****************************************************************************
* 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 );
-}
-
-/*****************************************************************************
- * 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;
+ while( MixBuffer( p_aout, volume ) != -1 );
}