2026-09-21 00:39:13

Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie
2026-09-21 00:39:13 +00:00
parent 86761a1892
commit c9c5e5c677
13 changed files with 90 additions and 27 deletions
+4
View File
@@ -19,6 +19,10 @@ ADSP::ADSP(Core::System& system, Sink::Sink& sink) {
}
}
void ADSP::NotifyShutdown() {
opus_decoder->NotifyShutdown();
}
AudioRenderer::AudioRenderer& ADSP::AudioRenderer() {
return *audio_renderer;
}
+1
View File
@@ -45,6 +45,7 @@ public:
explicit ADSP(Core::System& system, Sink::Sink& sink);
~ADSP() = default;
void NotifyShutdown();
AudioRenderer::AudioRenderer& AudioRenderer();
OpusDecoder::OpusDecoder& OpusDecoder();
@@ -82,6 +82,9 @@ void OpusDecoder::Main(std::stop_token stop_token) {
while (!stop_token.stop_requested()) {
auto msg = Receive(Direction::DSP, stop_token);
if (stop_token.stop_requested())
break;
switch (msg) {
case Shutdown:
Send(Direction::Host, Message::ShutdownOK);
@@ -266,4 +269,9 @@ void OpusDecoder::Main(std::stop_token stop_token) {
}
}
void OpusDecoder::NotifyShutdown() {
init_thread.request_stop();
main_thread.request_stop();
}
} // namespace AudioCore::ADSP::OpusDecoder
@@ -67,6 +67,8 @@ public:
shared_memory = &shared_memory_;
}
void NotifyShutdown();
private:
/**
* Initializing thread, launched at audio_core boot to avoid blocking the main emu boot thread.
+5
View File
@@ -31,6 +31,11 @@ void AudioCore::CreateSinks() {
input_sink = Sink::CreateSinkFromID(sink_id.GetValue(), audio_input_device_id.GetValue());
}
void AudioCore::NotifyShutdown() {
audio_manager->NotifyShutdown();
adsp->NotifyShutdown();
}
void AudioCore::Shutdown() {
audio_manager->Shutdown();
}
+2
View File
@@ -24,6 +24,8 @@ public:
explicit AudioCore(Core::System& system);
~AudioCore();
void NotifyShutdown();
/**
* Shutdown the audio core.
*/
+6 -1
View File
@@ -17,7 +17,7 @@ AudioManager::AudioManager() {
std::unique_lock l{events.GetAudioEventLock()};
events.ClearEvents();
while (!stop_token.stop_requested()) {
const auto timed_out{events.Wait(l, std::chrono::seconds(2))};
const auto timed_out = events.Wait(l, std::chrono::seconds{2});
if (events.CheckAudioEventSet(Event::Type::Max)) {
break;
}
@@ -34,6 +34,11 @@ AudioManager::AudioManager() {
});
}
void AudioManager::NotifyShutdown() {
events.SetAudioEvent(Event::Type::Max, true);
thread.request_stop();
}
void AudioManager::Shutdown() {
events.SetAudioEvent(Event::Type::Max, true);
if (thread.joinable()) {
+4 -3
View File
@@ -39,9 +39,10 @@ class AudioManager {
public:
explicit AudioManager();
/**
* Shutdown the audio manager.
*/
/// @brief Notify of impending shutdown
void NotifyShutdown();
/// @brief Shutdown the audio manager.
void Shutdown();
/**