HLE DSP: Implement partial embedded buffer updates (#782)
Some checks are pending
Android Build / x64 (release) (push) Waiting to run
Android Build / arm64 (release) (push) Waiting to run
HTTP Server Build / build (push) Waiting to run
Hydra Core Build / Windows (push) Waiting to run
Hydra Core Build / MacOS (push) Waiting to run
Hydra Core Build / Linux (push) Waiting to run
Hydra Core Build / Android-x64 (push) Waiting to run
Hydra Core Build / ARM-Libretro (push) Waiting to run
Linux AppImage Build / build (push) Waiting to run
Linux Build / build (push) Waiting to run
MacOS Build / MacOS-arm64 (push) Waiting to run
MacOS Build / MacOS-x86_64 (push) Waiting to run
MacOS Build / MacOS-Universal (push) Blocked by required conditions
Qt Build / Windows (push) Waiting to run
Qt Build / MacOS-arm64 (push) Waiting to run
Qt Build / MacOS-x86_64 (push) Waiting to run
Qt Build / MacOS-Universal (push) Blocked by required conditions
Qt Build / Linux (push) Waiting to run
Windows Build / build (push) Waiting to run
iOS Simulator Build / build (push) Waiting to run

This commit is contained in:
wheremyfoodat 2025-07-21 01:59:46 +03:00 committed by GitHub
commit 2ccb264a86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 2 deletions

View file

@ -69,7 +69,9 @@ namespace Audio {
// In order to save up on CPU time.
uint enabledMixStages = 0;
u32 samplePosition; // Sample number into the current audio buffer
u32 samplePosition; // Sample number into the current audio buffer
u32 currentBufferPaddr; // Physical address of current audio buffer
float rateMultiplier;
u16 syncCount;
u16 currentBufferID;

View file

@ -396,7 +396,28 @@ namespace Audio {
if (config.partialEmbeddedBufferDirty) {
config.partialEmbeddedBufferDirty = 0;
printf("Partial embedded buffer dirty for voice %d\n", source.index);
const u8* data = getPointerPhys<u8>(source.currentBufferPaddr & ~0x3);
if (data != nullptr) {
switch (source.sampleFormat) {
case SampleFormat::PCM8: source.currentSamples = decodePCM8(data, config.length, source); break;
case SampleFormat::PCM16: source.currentSamples = decodePCM16(data, config.length, source); break;
case SampleFormat::ADPCM: source.currentSamples = decodeADPCM(data, config.length, source); break;
default:
Helpers::warn("Invalid DSP sample format");
source.currentSamples = {};
break;
}
// We're skipping the first samplePosition samples, so remove them from the buffer so as not to consume them later
if (source.samplePosition > 0) {
auto start = source.currentSamples.begin();
auto end = std::next(start, source.samplePosition);
source.currentSamples.erase(start, end);
}
}
}
if (config.bufferQueueDirty) {
@ -478,6 +499,7 @@ namespace Audio {
return;
}
source.currentBufferPaddr = buffer.paddr;
source.currentBufferID = buffer.bufferID;
source.previousBufferID = 0;
// For looping buffers, this is only set for the first time we play it. Loops do not set the dirty bit.
@ -766,6 +788,7 @@ namespace Audio {
interpolationMode = InterpolationMode::Linear;
samplePosition = 0;
currentBufferPaddr = 0;
previousBufferID = 0;
currentBufferID = 0;
syncCount = 0;