diff --git a/UI/BackgroundAudio.cpp b/UI/BackgroundAudio.cpp index e9f13a4837..705d4976c4 100644 --- a/UI/BackgroundAudio.cpp +++ b/UI/BackgroundAudio.cpp @@ -12,6 +12,7 @@ #include "Common/Data/Collections/FixedSizeQueue.h" #include "Core/HW/SimpleAudioDec.h" #include "Core/HLE/__sceAudio.h" +#include "Core/System.h" #include "GameInfoCache.h" #include "Core/Config.h" #include "UI/BackgroundAudio.h" @@ -333,14 +334,18 @@ void BackgroundAudio::SetGame(const Path &path) { bgGamePath_ = path; } -int BackgroundAudio::Play() { +bool BackgroundAudio::Play() { + if (GetUIState() == UISTATE_INGAME) { + return false; + } + std::lock_guard lock(mutex_); // Immediately stop the sound if it is turned off while playing. if (!g_Config.bEnableSound) { Clear(true); __PushExternalAudio(0, 0); - return 0; + return true; } double now = time_now_d(); @@ -398,7 +403,7 @@ int BackgroundAudio::Play() { lastPlaybackTime_ = now; - return 0; + return true; } void BackgroundAudio::Update() { diff --git a/UI/BackgroundAudio.h b/UI/BackgroundAudio.h index 85c0da4315..818b063a37 100644 --- a/UI/BackgroundAudio.h +++ b/UI/BackgroundAudio.h @@ -17,7 +17,7 @@ public: void SetGame(const Path &path); void Update(); - int Play(); + bool Play(); void LoadSamples(); void PlaySFX(UI::UISound sfx); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 1b6cb93a1c..daebaccc90 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -236,9 +236,6 @@ std::string NativeQueryConfig(std::string query) { } int NativeMix(short *audio, int num_samples) { - if (GetUIState() != UISTATE_INGAME) { - g_BackgroundAudio.Play(); - } int sample_rate = System_GetPropertyInt(SYSPROP_AUDIO_SAMPLE_RATE); return __AudioMix(audio, num_samples, sample_rate > 0 ? sample_rate : 44100); } @@ -1235,6 +1232,7 @@ void NativeUpdate() { g_screenManager->update(); g_Discord.Update(); + g_BackgroundAudio.Play(); UI::SetSoundEnabled(g_Config.bUISound); }