Commit a3444fec authored by James's avatar James
Browse files

Correctly shutdown audio when core is deinited + handle audio_set_state

parent 214302eb
......@@ -50,7 +50,14 @@ void LibRetroSink::SubmitAudioFrames(const int16_t* samples, size_t sample_count
queue.emplace_back(samples, samples + sample_count * 2);
}
bool audio_state = false;
// TODO: Let LibRetroSink register itself for this, and clean up automatically internally
void audio_callback() {
if (!audio_state) {
return;
}
u8 buffer_backing[512];
size_t remaining_size =
static_cast<size_t>(512) / sizeof(s16); // Keep track of size in 16-bit increments.
......@@ -78,7 +85,9 @@ void audio_callback() {
LibRetro::SubmitAudio((const int16_t*)&buffer_backing, (max_size - remaining_size) / 2);
}
void audio_set_state(bool state) {}
void audio_set_state(bool state) {
audio_state = state;
}
} // namespace AudioCore
......
......@@ -478,6 +478,11 @@ bool retro_load_game(const struct retro_game_info* info) {
}
void retro_unload_game() {
struct retro_audio_callback audio_cb = {nullptr, nullptr};
if (!LibRetro::SetAudioCallback(&audio_cb)) {
LOG_CRITICAL(Frontend, "Async audio could not be halted.");
}
LOG_DEBUG(Frontend, "Unloading game...");
Core::System::GetInstance().Shutdown();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment