mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-28 11:35:11 +00:00
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ public:
|
||||
explicit AudioCore(Core::System& system);
|
||||
~AudioCore();
|
||||
|
||||
void NotifyShutdown();
|
||||
|
||||
/**
|
||||
* Shutdown the audio core.
|
||||
*/
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user