[vlc-commits] aout: move volume/mute code to output.c

Rémi Denis-Courmont git at videolan.org
Thu Nov 1 18:26:10 CET 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Nov  1 18:09:46 2012 +0200| [e1eb563f9fae3240af1849d0570dedfe59c085b6] | committer: Rémi Denis-Courmont

aout: move volume/mute code to output.c

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

 src/audio_output/aout_internal.h |   12 ++++++---
 src/audio_output/intf.c          |   19 +++++----------
 src/audio_output/output.c        |   50 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 17 deletions(-)

diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index d40d45c..9b24b23 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -136,6 +136,14 @@ void aout_volume_Delete(aout_volume_t *);
 
 
 /* From output.c : */
+audio_output_t *aout_New (vlc_object_t *);
+#define aout_New(a) aout_New(VLC_OBJECT(a))
+void aout_Destroy (audio_output_t *);
+float aout_OutputVolumeGet (audio_output_t *);
+int aout_OutputVolumeSet (audio_output_t *, float);
+int aout_OutputMuteGet (audio_output_t *);
+int aout_OutputMuteSet (audio_output_t *, bool);
+
 int aout_OutputNew( audio_output_t * p_aout,
                     const audio_sample_format_t * p_format );
 void aout_OutputPlay( audio_output_t * p_aout, block_t * p_buffer );
@@ -145,10 +153,6 @@ void aout_OutputDelete( audio_output_t * p_aout );
 
 
 /* From common.c : */
-audio_output_t *aout_New (vlc_object_t *);
-#define aout_New(a) aout_New(VLC_OBJECT(a))
-void aout_Destroy (audio_output_t *);
-
 void aout_FormatsPrint(vlc_object_t *, const char *,
                        const audio_sample_format_t *,
                        const audio_sample_format_t *);
diff --git a/src/audio_output/intf.c b/src/audio_output/intf.c
index 2c987d5..2323052 100644
--- a/src/audio_output/intf.c
+++ b/src/audio_output/intf.c
@@ -72,7 +72,7 @@ float aout_VolumeGet (vlc_object_t *obj)
     if (aout == NULL)
         return -1.f;
 
-    float volume = var_GetFloat (aout, "volume");
+    float volume = aout_OutputVolumeGet (aout);
     vlc_object_release (aout);
     return volume;
 }
@@ -89,10 +89,7 @@ int aout_VolumeSet (vlc_object_t *obj, float vol)
     audio_output_t *aout = findAout (obj);
     if (aout != NULL)
     {
-        aout_lock (aout);
-        if (aout->volume_set != NULL)
-            ret = aout->volume_set (aout, vol);
-        aout_unlock (aout);
+        ret = aout_OutputVolumeSet (aout, vol);
         vlc_object_release (aout);
     }
     return ret;
@@ -134,7 +131,7 @@ int aout_MuteGet (vlc_object_t *obj)
     if (aout == NULL)
         return -1.f;
 
-    bool mute = var_InheritBool (aout, "mute");
+    bool mute = aout_OutputMuteGet (aout);
     vlc_object_release (aout);
     return mute;
 }
@@ -150,15 +147,11 @@ int aout_MuteSet (vlc_object_t *obj, bool mute)
     audio_output_t *aout = findAout (obj);
     if (aout != NULL)
     {
-        aout_lock (aout);
-        if (aout->mute_set != NULL)
-            ret = aout->mute_set (aout, mute);
-        aout_unlock (aout);
+        ret = aout_OutputMuteSet (aout, mute);
         vlc_object_release (aout);
+        if (ret == 0)
+            var_SetBool (obj, "mute", mute);
     }
-
-    if (ret == 0)
-        var_SetBool (obj, "mute", mute);
     return ret;
 }
 
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index 6609bb4..30e236c 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -251,6 +251,56 @@ static void aout_Destructor (vlc_object_t *obj)
 }
 
 /**
+ * Gets the volume of the audio output stream (independent of mute).
+ * \return Current audio volume (0. = silent, 1. = nominal),
+ * or a strictly negative value if undefined.
+ */
+float aout_OutputVolumeGet (audio_output_t *aout)
+{
+    return var_GetFloat (aout, "volume");
+}
+
+/**
+ * Sets the volume of the audio output stream.
+ * \note The mute status is not changed.
+ * \return 0 on success, -1 on failure.
+ */
+int aout_OutputVolumeSet (audio_output_t *aout, float vol)
+{
+    int ret = -1;
+
+    aout_lock (aout);
+    if (aout->volume_set != NULL)
+        ret = aout->volume_set (aout, vol);
+    aout_unlock (aout);
+    return ret;
+}
+
+/**
+ * Gets the audio output stream mute flag.
+ * \return 0 if not muted, 1 if muted, -1 if undefined.
+ */
+int aout_OutputMuteGet (audio_output_t *aout)
+{
+    return var_InheritBool (aout, "mute");
+}
+
+/**
+ * Sets the audio output stream mute flag.
+ * \return 0 on success, -1 on failure.
+ */
+int aout_OutputMuteSet (audio_output_t *aout, bool mute)
+{
+    int ret = -1;
+
+    aout_lock (aout);
+    if (aout->mute_set != NULL)
+        ret = aout->mute_set (aout, mute);
+    aout_unlock (aout);
+    return ret;
+}
+
+/**
  * Starts an audio output stream.
  * \param fmtp audio output stream format [IN/OUT]
  * \warning The caller must hold the audio output lock.



More information about the vlc-commits mailing list