[vlc-commits] audiounit_ios: fix mute state

Thomas Guillem git at videolan.org
Fri Feb 24 11:41:12 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Feb 24 10:47:43 2017 +0100| [c2f42208614ccbcb6504c070711f16b0fa50e7bb] | committer: Thomas Guillem

audiounit_ios: fix mute state

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

 modules/audio_output/audiounit_ios.m | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m
index 8468fb0..7c261cf 100644
--- a/modules/audio_output/audiounit_ios.m
+++ b/modules/audio_output/audiounit_ios.m
@@ -65,6 +65,7 @@ struct aout_sys_t
 
     /* The AudioUnit we use */
     AudioUnit au_unit;
+    bool      b_muted;
 };
 
 #pragma mark -
@@ -135,14 +136,27 @@ static int MuteSet(audio_output_t *p_aout, bool mute)
 {
     struct aout_sys_t * p_sys = p_aout->sys;
 
-    if (p_sys != NULL && p_sys->au_unit != NULL) {
-        msg_Dbg(p_aout, "audio output mute set to %d", mute?1:0);
-        Pause(p_aout, mute, 0);
+    p_sys->b_muted = mute;
+    if (p_sys->au_unit != NULL)
+    {
+        SetPlayback(p_aout, !mute);
+        if (mute)
+            ca_Flush(p_aout, false);
     }
 
     return VLC_SUCCESS;
 }
 
+static void Play(audio_output_t * p_aout, block_t * p_block)
+{
+    struct aout_sys_t * p_sys = p_aout->sys;
+
+    if (p_sys->b_muted)
+        block_Release(p_block);
+    else
+        ca_Play(p_aout, p_block);
+}
+
 /*****************************************************************************
  * RenderCallback: This function is called everytime the AudioUnit wants
  * us to provide some more audio data.
@@ -277,6 +291,7 @@ static int StartAnalog(audio_output_t *p_aout, audio_sample_format_t *fmt)
         AudioUnitUninitialize(p_sys->au_unit);
         goto error;
     }
+    p_aout->play = Play;
 
     /* start the unit */
     if (SetPlayback(p_aout, true) != VLC_SUCCESS)
@@ -286,6 +301,13 @@ static int StartAnalog(audio_output_t *p_aout, audio_sample_format_t *fmt)
         goto error;
     }
 
+    if (p_sys->b_muted)
+    {
+        /* Stop playback after Starting it, this is not optimized, but this
+         * allow more error checking from the Start function */
+        SetPlayback(p_aout, false);
+    }
+
     return VLC_SUCCESS;
 
 error:
@@ -358,6 +380,7 @@ static int Open(vlc_object_t *obj)
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;
 
+    sys->b_muted = false;
     aout->sys = sys;
     aout->start = Start;
     aout->stop = Stop;



More information about the vlc-commits mailing list