[vlc-commits] audiounit: run an AudioSession when outputting media content, so the user is able to listen to the audio when the silent switch is on

Felix Paul Kühne git at videolan.org
Thu Apr 4 19:36:50 CEST 2013


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sat Mar  9 18:48:05 2013 +0100| [55428b8a80787e414e460e263e6042eb584c0626] | committer: Felix Paul Kühne

audiounit: run an AudioSession when outputting media content, so the user is able to listen to the audio when the silent switch is on

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

 modules/audio_output/audiounit_ios.c |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/modules/audio_output/audiounit_ios.c b/modules/audio_output/audiounit_ios.c
index e0f9693..4763cb7 100644
--- a/modules/audio_output/audiounit_ios.c
+++ b/modules/audio_output/audiounit_ios.c
@@ -258,6 +258,17 @@ static int StartAnalog(audio_output_t *p_aout, audio_sample_format_t *fmt)
         return false;
     }
 
+    /* start audio session so playback continues if mute switch is on */
+    AudioSessionInitialize (NULL,
+                            kCFRunLoopCommonModes,
+                            NULL,
+                            NULL);
+
+	/* Set audio session to mediaplayback */
+	UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
+	AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory),&sessionCategory);
+	AudioSessionSetActive(true);
+
     /* setup circular buffer */
     TPCircularBufferInit(&p_sys->circular_buffer, kBufferLength);
 
@@ -274,6 +285,8 @@ static void Stop(audio_output_t *p_aout)
     struct aout_sys_t   *p_sys = p_aout->sys;
     OSStatus status;
 
+    AudioSessionSetActive(false);
+
     if (p_sys->au_unit) {
         status = AudioOutputUnitStop(p_sys->au_unit);
         if (status != noErr)
@@ -331,10 +344,13 @@ static void Pause (audio_output_t *p_aout, bool pause, mtime_t date)
     struct aout_sys_t * p_sys = p_aout->sys;
     VLC_UNUSED(date);
 
-    if (pause)
+    if (pause) {
         AudioOutputUnitStop(p_sys->au_unit);
-    else
+        AudioSessionSetActive(false);
+    } else {
         AudioOutputUnitStart(p_sys->au_unit);
+        AudioSessionSetActive(true);
+    }
 }
 
 static void Flush(audio_output_t *p_aout, bool wait)



More information about the vlc-commits mailing list