Commit 1d0ffadb authored by Felix Paul Kühne's avatar Felix Paul Kühne

audioqueue: use the AudioSession API to overwrite the mute switch during media playback (iOS only)

parent b620bade
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment