Call Dsp::GetSamples from SNES SetSamples

This commit is contained in:
scawful
2024-04-20 08:10:18 -04:00
parent e89d768b5a
commit 541e045c46
2 changed files with 2 additions and 18 deletions

View File

@@ -45,16 +45,6 @@ uint16_t GetHeaderOffset(const Memory& memory) {
return offset;
}
void audio_callback(void* userdata, uint8_t* stream, int len) {
auto* apu = static_cast<audio::Apu*>(userdata);
auto* buffer = reinterpret_cast<int16_t*>(stream);
for (int i = 0; i < len / 2; i++) { // Assuming 16-bit samples
buffer[i] = apu->GetNextSample(); // This function should be implemented in
// APU to fetch the next sample
}
}
} // namespace
RomInfo SNES::ReadRomHeader(uint32_t offset) {
@@ -134,9 +124,6 @@ void SNES::Init(Rom& rom) {
// Initialize APU
apu_.Init();
// Initialize SDL_Mixer to play the audio samples
// Mix_HookMusic(audio_callback, &apu);
// Disable interrupts and rendering
memory_.WriteByte(0x4200, 0x00); // NMITIMEN
memory_.WriteByte(0x420C, 0x00); // HDMAEN
@@ -350,7 +337,7 @@ void SNES::LoadState(const std::string& path) {
}
void SNES::SetSamples(int16_t* sample_data, int wanted_samples) {
// Set the samples in the apu
apu_.dsp().GetSamples(sample_data, wanted_samples, pal_timing_);
}
} // namespace emu