mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Pass the game selection screen audio through the resampler. Fixes #7316 .
This commit is contained in:
1 parent
74ae85ff0e
commit
2792602252
5 files changed
+33
-12
No files matched your search
@@ -377,4 +377,12 @@ int __AudioMix(short *outstereo, int numFrames, int sampleRate) {
|
||||
const AudioDebugStats *__AudioGetDebugStats() {
|
||||
resampler.GetAudioDebugStats(&g_AudioDebugStats);
|
||||
return &g_AudioDebugStats;
|
||||
}
|
||||
|
||||
void __PushExternalAudio(const s32 *audio, int numSamples) {
|
||||
if (audio) {
|
||||
resampler.PushSamples(audio, numSamples);
|
||||
} else {
|
||||
resampler.Clear();
|
||||
}
|
||||
}
|
||||
@@ -43,4 +43,5 @@ void __AudioWakeThreads(AudioChannel &chan, int result, int step);
|
||||
void __AudioWakeThreads(AudioChannel &chan, int result);
|
||||
|
||||
int __AudioMix(short *outstereo, int numSamples, int sampleRate);
|
||||
const AudioDebugStats *__AudioGetDebugStats();
|
||||
const AudioDebugStats *__AudioGetDebugStats();
|
||||
void __PushExternalAudio(const s32 *audio, int numSamples); // Should not be used in-game, only at the menu!
|
||||
+17
-5
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/HW/SimpleAudioDec.h"
|
||||
#include "Core/HLE/__sceAudio.h"
|
||||
#include "Common/FixedSizeQueue.h"
|
||||
#include "GameInfoCache.h"
|
||||
|
||||
@@ -120,7 +121,7 @@ public:
|
||||
|
||||
bool IsOK() { return raw_data_ != 0; }
|
||||
|
||||
bool Read(short *buffer, int len) {
|
||||
bool Read(int *buffer, int len) {
|
||||
if (!raw_data_)
|
||||
return false;
|
||||
while (bgQueue.size() < (size_t)(len * 2)) {
|
||||
@@ -163,6 +164,8 @@ static std::string bgGamePath;
|
||||
static int playbackOffset;
|
||||
static AT3PlusReader *at3Reader;
|
||||
static double gameLastChanged;
|
||||
static double lastPlaybackTime;
|
||||
static int buffer[44100];
|
||||
|
||||
void SetBackgroundAudioGame(const std::string &path) {
|
||||
time_update();
|
||||
@@ -183,7 +186,7 @@ void SetBackgroundAudioGame(const std::string &path) {
|
||||
bgGamePath = path;
|
||||
}
|
||||
|
||||
int MixBackgroundAudio(short *buffer, int size) {
|
||||
int PlayBackgroundAudio() {
|
||||
time_update();
|
||||
|
||||
lock_guard lock(bgMutex);
|
||||
@@ -198,12 +201,21 @@ int MixBackgroundAudio(short *buffer, int size) {
|
||||
if (gameInfo->sndFileData.size()) {
|
||||
const std::string &data = gameInfo->sndFileData;
|
||||
at3Reader = new AT3PlusReader(data);
|
||||
lastPlaybackTime = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!at3Reader || !at3Reader->Read(buffer, size)) {
|
||||
memset(buffer, 0, size * 2 * sizeof(s16));
|
||||
double now = time_now();
|
||||
if (at3Reader) {
|
||||
const int sz = (now - lastPlaybackTime) * 44100;
|
||||
if (sz >= 16 && sz < ARRAY_SIZE(buffer)/2) {
|
||||
if (at3Reader->Read(buffer, sz))
|
||||
__PushExternalAudio(buffer, sz);
|
||||
}
|
||||
lastPlaybackTime = now;
|
||||
} else {
|
||||
__PushExternalAudio(0, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
#include <string>
|
||||
|
||||
void SetBackgroundAudioGame(const std::string &path);
|
||||
int MixBackgroundAudio(short *buffer, int size);
|
||||
int PlayBackgroundAudio();
|
||||
+5
-5
@@ -232,13 +232,13 @@ std::string NativeQueryConfig(std::string query) {
|
||||
}
|
||||
|
||||
int NativeMix(short *audio, int num_samples) {
|
||||
if (GetUIState() == UISTATE_INGAME) {
|
||||
int sample_rate = System_GetPropertyInt(SYSPROP_AUDIO_SAMPLE_RATE);
|
||||
num_samples = __AudioMix(audio, num_samples, sample_rate > 0 ? sample_rate : 44100);
|
||||
} else {
|
||||
MixBackgroundAudio(audio, num_samples);
|
||||
if (GetUIState() != UISTATE_INGAME) {
|
||||
PlayBackgroundAudio();
|
||||
}
|
||||
|
||||
int sample_rate = System_GetPropertyInt(SYSPROP_AUDIO_SAMPLE_RATE);
|
||||
num_samples = __AudioMix(audio, num_samples, sample_rate > 0 ? sample_rate : 44100);
|
||||
|
||||
#ifdef _WIN32
|
||||
winAudioBackend->Update();
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user