mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Move g_backgroundAudio.Play to NativeUpdate
This commit is contained in:
1 parent
91620e38bd
commit
8421c1e2a1
3 files changed
+10
-7
No files matched your search
@@ -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<std::mutex> 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() {
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
|
||||
void SetGame(const Path &path);
|
||||
void Update();
|
||||
int Play();
|
||||
bool Play();
|
||||
|
||||
void LoadSamples();
|
||||
void PlaySFX(UI::UISound sfx);
|
||||
|
||||
+1
-3
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user