Add Controller::PlayAudio for Emulator

This commit is contained in:
scawful
2024-04-20 07:40:44 -04:00
parent 2de3b283cd
commit 7072c18a92
3 changed files with 16 additions and 1 deletions

View File

@@ -168,6 +168,15 @@ void Controller::OnInput() {
void Controller::OnLoad() { PRINT_IF_ERROR(master_editor_.Update()); }
void Controller::PlayAudio() {
if (master_editor_.emulator().running()) {
master_editor_.emulator().snes().SetSamples(audio_buffer_, wanted_samples_);
if (SDL_GetQueuedAudioSize(audio_device_) <= wanted_samples_ * 4 * 6) {
SDL_QueueAudio(audio_device_, audio_buffer_, wanted_samples_ * 4);
}
}
}
void Controller::DoRender() const {
ImGui::Render();
SDL_RenderClear(renderer_.get());