[vlc-commits] aout: propagate volume and mute to input manager (fix #6760)

Rémi Denis-Courmont git at videolan.org
Thu Jul 19 20:25:03 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jul 19 21:18:48 2012 +0300| [94d7df181f3ca554db270358c079dd0bcba9f672] | committer: Rémi Denis-Courmont

aout: propagate volume and mute to input manager (fix #6760)

Several of UI & control plugins follow the volume and mute status
through the playlist instead of the aout. This patch works around
that limitation.

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

 src/audio_output/common.c |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/audio_output/common.c b/src/audio_output/common.c
index 06b205c..803a449 100644
--- a/src/audio_output/common.c
+++ b/src/audio_output/common.c
@@ -30,9 +30,11 @@
 
 #include <limits.h>
 #include <assert.h>
+#include <math.h>
 
 #include <vlc_common.h>
 #include <vlc_aout.h>
+#include <vlc_aout_intf.h>
 #include <vlc_modules.h>
 #include "aout_internal.h"
 #include "libvlc.h"
@@ -44,6 +46,25 @@
 /* Local functions */
 static void aout_Destructor( vlc_object_t * p_this );
 
+static int var_Copy (vlc_object_t *src, const char *name, vlc_value_t prev,
+                     vlc_value_t value, void *data)
+{
+    vlc_object_t *dst = data;
+
+    (void) src; (void) prev;
+    return var_Set (dst, name, value);
+}
+
+static int var_CopyVolume (vlc_object_t *src, const char *name,
+                           vlc_value_t prev, vlc_value_t value, void *data)
+{
+    vlc_object_t *dst = data;
+    long volume = lroundf (value.f_float * (float)AOUT_VOLUME_DEFAULT);
+
+    (void) src; (void) prev;
+    return var_SetInteger (dst, name, volume);
+}
+
 #undef aout_New
 /*****************************************************************************
  * aout_New: initialize aout structure
@@ -74,7 +95,9 @@ audio_output_t *aout_New( vlc_object_t * p_parent )
     char *str;
 
     var_Create (aout, "volume", VLC_VAR_FLOAT);
+    var_AddCallback (aout, "volume", var_CopyVolume, p_parent);
     var_Create (aout, "mute", VLC_VAR_BOOL | VLC_VAR_DOINHERIT);
+    var_AddCallback (aout, "mute", var_Copy, p_parent);
 
     /* Visualizations */
     var_Create (aout, "visual", VLC_VAR_STRING | VLC_VAR_HASCHOICE);
@@ -181,6 +204,9 @@ void aout_Destroy (audio_output_t *aout)
 
     if (owner->module != NULL)
         aout_Shutdown (aout);
+
+    var_DelCallback (aout, "mute", var_Copy, aout->p_parent);
+    var_DelCallback (aout, "volume", var_CopyVolume, aout->p_parent);
     vlc_object_release (aout);
 }
 



More information about the vlc-commits mailing list