mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
iOS: Implement the two new audio flags (respect silent mode, mix with other apps)
This commit is contained in:
1 parent
35c40196d4
commit
5e9878cfda
1 file changed
+29
-3
+29
-3
@@ -33,14 +33,40 @@ static bool g_displayConnected = false;
|
||||
|
||||
void iOSCoreAudioUpdateSession() {
|
||||
NSError *error = nil;
|
||||
// Default mode
|
||||
if (g_displayConnected) {
|
||||
INFO_LOG(AUDIO, "Display connected, setting Playback mode");
|
||||
// Special handling when a display is connected. Always exclusive.
|
||||
// Let's revisit this later.
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error];
|
||||
} else {
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error];
|
||||
return;
|
||||
}
|
||||
|
||||
INFO_LOG(AUDIO, "RespectSilentMode: %d MixWithOthers: %d", g_Config.bAudioRespectSilentMode, g_Config.bAudioMixWithOthers);
|
||||
|
||||
// Hacky hack to force iOS to re-evaluate.
|
||||
// Switching from CatogoryPlayback to CategoryPlayback with an option otherwise does nothing.
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAudioProcessing error:&error];
|
||||
|
||||
// Here, we apply the settings.
|
||||
const bool mixWithOthers = g_Config.bAudioMixWithOthers;
|
||||
if (g_Config.bAudioMixWithOthers) {
|
||||
if (g_Config.bAudioRespectSilentMode) {
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error];
|
||||
} else {
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:&error];
|
||||
}
|
||||
} else {
|
||||
if (g_Config.bAudioRespectSilentMode) {
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategorySoloAmbient error:&error];
|
||||
} else {
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:0 error:&error];
|
||||
}
|
||||
// Can't achieve exclusive + respect silent mode
|
||||
}
|
||||
|
||||
if (error) {
|
||||
NSLog(@"%@", error);
|
||||
}
|
||||
}
|
||||
|
||||
void iOSCoreAudioSetDisplayConnected(bool connected) {
|
||||
|
||||
Reference in new issue
Block a user