[vlc-commits] Pass mixer multiplier as argument

Rémi Denis-Courmont git at videolan.org
Tue May 31 17:36:02 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue May 31 18:15:39 2011 +0300| [a822a430136503c41d65834df8394a7fcbab4079] | committer: Rémi Denis-Courmont

Pass mixer multiplier as argument

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a822a430136503c41d65834df8394a7fcbab4079
---

 include/vlc_aout_mixer.h         |    7 +------
 modules/audio_mixer/float32.c    |    8 +++++---
 modules/audio_mixer/spdif.c      |    7 ++++---
 modules/audio_mixer/trivial.c    |    6 ++++--
 src/audio_output/aout_internal.h |    3 +--
 src/audio_output/dec.c           |    4 +---
 src/audio_output/intf.c          |    2 +-
 src/audio_output/mixer.c         |   22 ++++------------------
 8 files changed, 21 insertions(+), 38 deletions(-)

diff --git a/include/vlc_aout_mixer.h b/include/vlc_aout_mixer.h
index 002a712..9e3f421 100644
--- a/include/vlc_aout_mixer.h
+++ b/include/vlc_aout_mixer.h
@@ -72,16 +72,11 @@ struct aout_mixer_t {
      */
     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)
      *
diff --git a/modules/audio_mixer/float32.c b/modules/audio_mixer/float32.c
index d2f3174..7ede585 100644
--- a/modules/audio_mixer/float32.c
+++ b/modules/audio_mixer/float32.c
@@ -39,7 +39,7 @@
  * 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
@@ -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.
  * 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;
 
@@ -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_in = (float *)p_input->begin;
 
+    f_multiplier *= p_input->multiplier;
+
     for( ; ; )
     {
         ptrdiff_t i_available_words = (
diff --git a/modules/audio_mixer/spdif.c b/modules/audio_mixer/spdif.c
index cd1906a..22f3782 100644
--- a/modules/audio_mixer/spdif.c
+++ b/modules/audio_mixer/spdif.c
@@ -41,7 +41,7 @@
  *****************************************************************************/
 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
@@ -71,11 +71,12 @@ static int Create( vlc_object_t *p_this )
 /*****************************************************************************
  * 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;
 }
diff --git a/modules/audio_mixer/trivial.c b/modules/audio_mixer/trivial.c
index 01581ac..1a770fa 100644
--- a/modules/audio_mixer/trivial.c
+++ b/modules/audio_mixer/trivial.c
@@ -40,7 +40,7 @@
  *****************************************************************************/
 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
@@ -71,7 +71,8 @@ static int Create( vlc_object_t *p_this )
 /*****************************************************************************
  * 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 );
@@ -118,5 +119,6 @@ static aout_buffer_t *DoWork( aout_mixer_t *p_mixer, unsigned samples )
             break;
         }
     }
+    (void) multiplier;
     return p_buffer;
 }
diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index 57d542d..74578ea 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -111,8 +111,7 @@ void aout_FiltersPlay( filter_t *const *, unsigned, aout_buffer_t ** );
 /* 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,
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index ecf81b8..cdd1844 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -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. */
     aout_lock_mixer( p_aout );
-
-    aout_MixerRun( p_aout );
-
+    aout_MixerRun( p_aout, p_aout->mixer_multiplier );
     aout_unlock_mixer( p_aout );
 
     return 0;
diff --git a/src/audio_output/intf.c b/src/audio_output/intf.c
index d21c1e1..29a6c49 100644
--- a/src/audio_output/intf.c
+++ b/src/audio_output/intf.c
@@ -245,7 +245,7 @@ static int aout_VolumeSoftSet (aout_instance_t *aout, audio_volume_t volume,
                                bool mute)
 {
     float f = mute ? 0. : (volume / (float)AOUT_VOLUME_DEFAULT);
-    aout_MixerMultiplierSet (aout, f);
+    aout->mixer_multiplier = f;
     return 0;
 }
 
diff --git a/src/audio_output/mixer.c b/src/audio_output/mixer.c
index cda7b58..fd354cd 100644
--- a/src/audio_output/mixer.c
+++ b/src/audio_output/mixer.c
@@ -51,7 +51,6 @@ int aout_MixerNew( aout_instance_t * p_aout )
         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;
@@ -92,7 +91,7 @@ void aout_MixerDelete( aout_instance_t * p_aout )
  *****************************************************************************
  * 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;
@@ -322,7 +321,7 @@ static int MixBuffer( aout_instance_t * p_aout )
     /* 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) )
@@ -339,20 +338,7 @@ static int MixBuffer( aout_instance_t * p_aout )
  *****************************************************************************
  * 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 );
 }



More information about the vlc-commits mailing list