diff --git a/Common/GPU/Vulkan/VulkanLoader.cpp b/Common/GPU/Vulkan/VulkanLoader.cpp index 95c1bfa1d7..24e128aada 100644 --- a/Common/GPU/Vulkan/VulkanLoader.cpp +++ b/Common/GPU/Vulkan/VulkanLoader.cpp @@ -382,7 +382,7 @@ bool VulkanMayBeAvailable() { #if PPSSPP_PLATFORM(IOS) g_vulkanAvailabilityChecked = true; g_vulkanMayBeAvailable = System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 13; - INFO_LOG(SYSTEM, "VulkanMayBeAvailable: Detected version: %d", System_GetPropertyInt(SYSPROP_SYSTEMVERSION)); + INFO_LOG(SYSTEM, "VulkanMayBeAvailable: Detected version: %d", (int)System_GetPropertyInt(SYSPROP_SYSTEMVERSION)); return g_vulkanMayBeAvailable; #else // Unsupported in VR at the moment diff --git a/Common/System/System.h b/Common/System/System.h index 7c7b3c4c1b..3668d8074e 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -230,6 +230,7 @@ enum class SystemNotification { KEEP_SCREEN_AWAKE, ACTIVITY, UI_STATE_CHANGED, + AUDIO_MODE_CHANGED, }; // I guess it's not super great architecturally to centralize this, since it's not general - but same with a lot of diff --git a/Core/Config.cpp b/Core/Config.cpp index 83a76ac3ce..ee757a61e1 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -700,6 +700,8 @@ static const ConfigSetting soundSettings[] = { ConfigSetting("AchievementSoundVolume", &g_Config.iAchievementSoundVolume, 6, CfgFlag::PER_GAME), ConfigSetting("AudioDevice", &g_Config.sAudioDevice, "", CfgFlag::DEFAULT), ConfigSetting("AutoAudioDevice", &g_Config.bAutoAudioDevice, true, CfgFlag::DEFAULT), + ConfigSetting("AudioMixWithOthers", &g_Config.bAudioMixWithOthers, true, CfgFlag::DEFAULT), + ConfigSetting("AudioRespectSilentMode", &g_Config.bAudioRespectSilentMode, false, CfgFlag::DEFAULT), ConfigSetting("UseNewAtrac", &g_Config.bUseNewAtrac, false, CfgFlag::DEFAULT), }; diff --git a/Core/Config.h b/Core/Config.h index 7f545a3b57..e414309cf3 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -280,6 +280,10 @@ public: bool bAutoAudioDevice; bool bUseNewAtrac; + // iOS only for now + bool bAudioMixWithOthers; + bool bAudioRespectSilentMode; + // UI bool bShowDebuggerOnLoad; int iShowStatusFlags; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 283775dc57..0719664aab 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -617,7 +617,23 @@ void GameSettingsScreen::CreateAudioSettings(UI::ViewGroup *audioSettings) { auto ms = GetI18NCategory(I18NCat::MAINSETTINGS); audioSettings->Add(new ItemHeader(ms->T("Audio"))); - CheckBox *enableSound = audioSettings->Add(new CheckBox(&g_Config.bEnableSound,a->T("Enable Sound"))); + CheckBox *enableSound = audioSettings->Add(new CheckBox(&g_Config.bEnableSound,a->T("Enable Sound"))); + +#if PPSSPP_PLATFORM(IOS) + CheckBox *respectSilentMode = audioSettings->Add(new CheckBox(&g_Config.bAudioRespectSilentMode, a->T("Respect silent mode"))); + respectSilentMode->OnClick.Add([=](EventParams &e) { + System_Notify(SystemNotification::AUDIO_MODE_CHANGED); + return UI::EVENT_DONE; + }); + respectSilentMode->SetEnabledPtr(&g_Config.bEnableSound); + CheckBox *mixWithOthers = audioSettings->Add(new CheckBox(&g_Config.bAudioMixWithOthers, a->T("Mix audio with other apps"))); + mixWithOthers->OnClick.Add([=](EventParams &e) { + System_Notify(SystemNotification::AUDIO_MODE_CHANGED); + return UI::EVENT_DONE; + }); + mixWithOthers->SetEnabledPtr(&g_Config.bEnableSound); +#endif + PopupSliderChoice *volume = audioSettings->Add(new PopupSliderChoice(&g_Config.iGlobalVolume, VOLUME_OFF, VOLUME_FULL, VOLUME_FULL, a->T("Global volume"), screenManager())); volume->SetEnabledPtr(&g_Config.bEnableSound); volume->SetZeroLabel(a->T("Mute")); diff --git a/ios/DisplayManager.mm b/ios/DisplayManager.mm index 36c6115e75..782332ee28 100644 --- a/ios/DisplayManager.mm +++ b/ios/DisplayManager.mm @@ -6,6 +6,7 @@ // #import "DisplayManager.h" +#import "iOSCoreAudio.h" #import "ViewController.h" #import "AppDelegate.h" #include "Common/System/Display.h" diff --git a/ios/iOSCoreAudio.mm b/ios/iOSCoreAudio.mm index 3e1aa0cf29..8fd426ba71 100644 --- a/ios/iOSCoreAudio.mm +++ b/ios/iOSCoreAudio.mm @@ -21,6 +21,7 @@ #include "iOSCoreAudio.h" #include "Common/Log.h" +#include "Core/Config.h" #include #import @@ -38,6 +39,8 @@ void iOSCoreAudioUpdateSession() { } else { [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error]; } + + INFO_LOG(AUDIO, "RespectSilentMode: %d MixWithOthers: %d", g_Config.bAudioRespectSilentMode, g_Config.bAudioMixWithOthers); } void iOSCoreAudioSetDisplayConnected(bool connected) { @@ -80,6 +83,8 @@ OSStatus iOSCoreAudioCallback(void *inRefCon, void iOSCoreAudioInit() { + iOSCoreAudioUpdateSession(); + NSError *error = nil; AVAudioSession *session = [AVAudioSession sharedInstance]; if (![session setActive:YES error:&error]) { diff --git a/ios/main.mm b/ios/main.mm index 9f1dcded49..dc6a83834e 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -24,6 +24,7 @@ #import "AppDelegate.h" #import "PPSSPPUIApplication.h" #import "ViewController.h" +#import "iOSCoreAudio.h" #include "Common/MemoryUtil.h" #include "Common/System/NativeApp.h" @@ -393,6 +394,11 @@ void System_Notify(SystemNotification notification) { } }); break; + case SystemNotification::AUDIO_MODE_CHANGED: + dispatch_async(dispatch_get_main_queue(), ^{ + iOSCoreAudioUpdateSession(); + }); + break; default: break; }