[vlc-commits] aout: store software amplification and mute separately

Rémi Denis-Courmont git at videolan.org
Tue Jul 3 17:04:16 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jul  2 22:22:01 2012 +0300| [c45103a6ddb7396f4c069089d2640abd238e42f7] | committer: Rémi Denis-Courmont

aout: store software amplification and mute separately

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

 src/audio_output/aout_internal.h |    3 ++-
 src/audio_output/common.c        |    3 ++-
 src/audio_output/dec.c           |    4 +++-
 src/audio_output/output.c        |   11 ++++-------
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index 7f5f53a..b7994de 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -91,7 +91,8 @@ typedef struct
     struct
     {
         vlc_mutex_t lock;
-        float multiplier; /**< Software volume amplification multiplier */
+        float amp; /**< Software volume amplification */
+        bool mute; /**< Software mute */
         struct audio_mixer *mixer; /**< Software volume plugin */
     } volume;
 
diff --git a/src/audio_output/common.c b/src/audio_output/common.c
index 3e728eb..50c4947 100644
--- a/src/audio_output/common.c
+++ b/src/audio_output/common.c
@@ -62,7 +62,8 @@ audio_output_t *aout_New( vlc_object_t * p_parent )
     owner->module = NULL;
     owner->input = NULL;
     vlc_mutex_init (&owner->volume.lock);
-    owner->volume.multiplier = 1.0;
+    owner->volume.amp = 1.f;
+    owner->volume.mute = false;
     owner->volume.mixer = NULL;
 
     aout->pf_play = aout_DecDeleteBuffer;
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 0e814f4..a4fe78d 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -310,7 +310,9 @@ int aout_DecPlay (audio_output_t *p_aout, block_t *p_buffer, int i_input_rate)
         /* Mixer */
         if (owner->volume.mixer != NULL)
         {
-            float amp = owner->volume.multiplier
+            float amp = 0.f;
+            if (!owner->volume.mute)
+                amp = owner->volume.amp
                       * vlc_atomic_getf (&owner->gain.multiplier);
             aout_MixerRun (owner->volume.mixer, p_buffer, amp);
         }
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index 63793d2..5b6b48c 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -279,7 +279,8 @@ void aout_OutputDelete (audio_output_t *aout)
     aout->pf_flush = NULL;
     aout->pf_volume_set = NULL;
     owner->module = NULL;
-    owner->volume.multiplier = 1.0;
+    owner->volume.amp = 1.f;
+    owner->volume.mute = false;
     aout_FiltersDestroyPipeline (owner->filters, owner->nb_filters);
 }
 
@@ -348,12 +349,8 @@ static int aout_VolumeSoftSet (audio_output_t *aout, float volume, bool mute)
      * This code is only used for the VLC software mixer. If you change this
      * formula, be sure to update the aout_VolumeHardInit()-based plugins also.
      */
-    if (!mute)
-        volume = volume * volume * volume;
-    else
-        volume = 0.;
-
-    owner->volume.multiplier = volume;
+    owner->volume.amp = volume * volume * volume;
+    owner->volume.mute = mute;
     return 0;
 }
 



More information about the vlc-commits mailing list