[vlc-commits] audioqueue: use the AudioSession API to overwrite the mute switch during media playback (iOS only)
Felix Paul Kühne
git at videolan.org
Mon Feb 4 23:53:22 CET 2013
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Feb 4 23:50:27 2013 +0100| [1d0ffadb2e17cbc76918e063dd676d33de69b8d4] | committer: Felix Paul Kühne
audioqueue: use the AudioSession API to overwrite the mute switch during media playback (iOS only)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1d0ffadb2e17cbc76918e063dd676d33de69b8d4
---
modules/audio_output/audioqueue.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/modules/audio_output/audioqueue.c b/modules/audio_output/audioqueue.c
index 773cbd6..813c4c5 100644
--- a/modules/audio_output/audioqueue.c
+++ b/modules/audio_output/audioqueue.c
@@ -31,6 +31,9 @@
#import <vlc_plugin.h>
#import <vlc_aout.h>
#import <AudioToolBox/AudioQueue.h>
+#import <AudioToolBox/AudioSession.h>
+#import <TargetConditionals.h>
+
#pragma mark -
#pragma mark private declarations
@@ -62,6 +65,7 @@ set_subcategory(SUBCAT_AUDIO_AOUT)
add_shortcut("audioqueue")
set_callbacks(Open, Close)
vlc_module_end ()
+
#pragma mark -
#pragma mark initialization
@@ -150,6 +154,19 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
if (error != noErr)
return VLC_EGENERIC;
+#ifdef TARGET_OS_IPHONE
+ // 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);
+#endif
+
p_aout->time_get = TimeGet;
p_aout->play = Play;
p_aout->pause = Pause;
@@ -160,6 +177,10 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
static void Stop(audio_output_t *p_aout)
{
+#ifdef TARGET_OS_IPHONE
+ AudioSessionSetActive(false);
+#endif
+
p_aout->sys->i_played_length = 0;
AudioQueueDisposeTimeline(p_aout->sys->audioQueueRef, p_aout->sys->timelineRef);
AudioQueueStop(p_aout->sys->audioQueueRef, true);
@@ -203,10 +224,17 @@ static void Pause(audio_output_t *p_aout, bool pause, mtime_t date)
{
VLC_UNUSED(date);
- if (pause)
+ if (pause) {
AudioQueuePause(p_aout->sys->audioQueueRef);
- else
+#ifdef TARGET_OS_IPHONE
+ AudioSessionSetActive(false);
+#endif
+ } else {
AudioQueueStart(p_aout->sys->audioQueueRef, NULL);
+#ifdef TARGET_OS_IPHONE
+ AudioSessionSetActive(true);
+#endif
+ }
}
static void Flush(audio_output_t *p_aout, bool wait)
More information about the vlc-commits
mailing list