HLE DSP: Init/deinit sources better

This commit is contained in:
wheremyfoodat 2024-04-05 20:53:17 +03:00
parent 5da93d17bd
commit 43a1c89478
2 changed files with 17 additions and 2 deletions

View file

@ -23,6 +23,8 @@ namespace Audio {
u16 bufferID;
};
int index = 0; // Index of the voice in [0, 23] for debugging
void reset();
DSPSource() { reset(); }
};
@ -57,7 +59,8 @@ namespace Audio {
static constexpr size_t pipeCount = 8;
DSPState dspState;
std::array<std::vector<u8>, pipeCount> pipeData; // The data of each pipe
std::array<std::vector<u8>, pipeCount> pipeData; // The data of each pipe
std::array<Source, Audio::HLE::sourceCount> sources; // DSP voices
Audio::HLE::DspMemory dspRam;
void resetAudioPipe();
@ -86,7 +89,7 @@ namespace Audio {
void generateFrame(StereoFrame<s16>& frame);
void outputFrame();
public:
HLE_DSP(Memory& mem, Scheduler& scheduler, DSPService& dspService) : DSPCore(mem, scheduler, dspService) {}
HLE_DSP(Memory& mem, Scheduler& scheduler, DSPService& dspService);
~HLE_DSP() override {}
void reset() override;

View file

@ -14,6 +14,13 @@ namespace Audio {
};
}
HLE_DSP::HLE_DSP(Memory& mem, Scheduler& scheduler, DSPService& dspService) : DSPCore(mem, scheduler, dspService) {
// Set up source indices
for (int i = 0; i < sources.size(); i++) {
sources[i].index = i;
}
}
void HLE_DSP::resetAudioPipe() {
#define DSPOffset(var) (0x8000 + offsetof(Audio::HLE::SharedMemory, var) / 2)
@ -56,6 +63,10 @@ namespace Audio {
e.clear();
}
for (auto& source : sources) {
source.reset();
}
// Note: Reset audio pipe AFTER resetting all pipes, otherwise the new data will be yeeted
resetAudioPipe();
}
@ -189,6 +200,7 @@ namespace Audio {
SharedMemory& write = writeRegion();
for (int source = 0; source < sourceCount; source++) {
//updateSourceConfig(sources[source]);
Helpers::panic("Panda");
}
}