mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-28 11:35:11 +00:00
@@ -46,13 +46,15 @@ void AudioRenderer::Stop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mailbox.Send(Direction::DSP, Message::Shutdown);
|
if (main_thread.joinable()) {
|
||||||
if (mailbox.Receive(Direction::Host) != Message::Shutdown) {
|
main_thread.request_stop();
|
||||||
LOG_ERROR(Service_Audio, "Host Audio Renderer -- Failed to receive shutdown "
|
mailbox.Send(Direction::DSP, Message::Shutdown);
|
||||||
"message response from ADSP!");
|
if (mailbox.Receive(Direction::Host, main_thread.get_stop_token()) != Message::Shutdown) {
|
||||||
|
LOG_ERROR(Service_Audio, "Host Audio Renderer -- Failed to receive shutdown "
|
||||||
|
"message response from ADSP!");
|
||||||
|
}
|
||||||
|
main_thread.join();
|
||||||
}
|
}
|
||||||
main_thread.request_stop();
|
|
||||||
main_thread.join();
|
|
||||||
|
|
||||||
for (auto& stream : streams) {
|
for (auto& stream : streams) {
|
||||||
if (stream) {
|
if (stream) {
|
||||||
@@ -147,7 +149,9 @@ void AudioRenderer::Main(std::stop_token stop_token) {
|
|||||||
constexpr u64 max_process_time{2'304'000ULL};
|
constexpr u64 max_process_time{2'304'000ULL};
|
||||||
|
|
||||||
while (!stop_token.stop_requested()) {
|
while (!stop_token.stop_requested()) {
|
||||||
auto msg{mailbox.Receive(Direction::DSP)};
|
auto msg = mailbox.Receive(Direction::DSP, stop_token);
|
||||||
|
if (stop_token.stop_requested())
|
||||||
|
break;
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case Message::Shutdown:
|
case Message::Shutdown:
|
||||||
mailbox.Send(Direction::Host, Message::Shutdown);
|
mailbox.Send(Direction::Host, Message::Shutdown);
|
||||||
|
|||||||
@@ -109,12 +109,6 @@ private:
|
|||||||
if (read_index == producer.index.load(std::memory_order::acquire)) {
|
if (read_index == producer.index.load(std::memory_order::acquire)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if constexpr (Mode == PopMode::Wait) {
|
|
||||||
// Wait until the queue is not empty.
|
|
||||||
std::unique_lock lock{consumer.cv_mutex};
|
|
||||||
consumer.cv.wait(lock, [this, read_index] {
|
|
||||||
return read_index != producer.index.load(std::memory_order::acquire);
|
|
||||||
});
|
|
||||||
} else if constexpr (Mode == PopMode::WaitWithStopToken) {
|
} else if constexpr (Mode == PopMode::WaitWithStopToken) {
|
||||||
// Wait until the queue is not empty.
|
// Wait until the queue is not empty.
|
||||||
std::unique_lock lock{consumer.cv_mutex};
|
std::unique_lock lock{consumer.cv_mutex};
|
||||||
@@ -124,6 +118,12 @@ private:
|
|||||||
if (stop_token.stop_requested()) {
|
if (stop_token.stop_requested()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} else if constexpr (Mode == PopMode::Wait) {
|
||||||
|
// Wait until the queue is not empty.
|
||||||
|
std::unique_lock lock{consumer.cv_mutex};
|
||||||
|
consumer.cv.wait(lock, [this, read_index] {
|
||||||
|
return read_index != producer.index.load(std::memory_order::acquire);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
static_assert(Mode < PopMode::Count, "Invalid PopMode.");
|
static_assert(Mode < PopMode::Count, "Invalid PopMode.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ KWorkerTaskManager::KWorkerTaskManager(KernelCore& kernel) {
|
|||||||
KWorkerTask* t;
|
KWorkerTask* t;
|
||||||
{
|
{
|
||||||
std::unique_lock lk{m_task_mutex};
|
std::unique_lock lk{m_task_mutex};
|
||||||
m_task_cv.wait(lk);
|
m_task_cv.wait(lk, m_waiting_thread.get_stop_token(), [&]() {
|
||||||
|
return !m_task_queue.empty();
|
||||||
|
});
|
||||||
if (stop_token.stop_requested())
|
if (stop_token.stop_requested())
|
||||||
break;
|
break;
|
||||||
t = m_task_queue.back();
|
t = m_task_queue.back();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ private:
|
|||||||
std::jthread m_waiting_thread;
|
std::jthread m_waiting_thread;
|
||||||
|
|
||||||
std::mutex m_task_mutex;
|
std::mutex m_task_mutex;
|
||||||
std::condition_variable m_task_cv;
|
std::condition_variable_any m_task_cv;
|
||||||
std::vector<KWorkerTask*> m_task_queue;
|
std::vector<KWorkerTask*> m_task_queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -66,14 +66,17 @@ void EmuThread::run() {
|
|||||||
} else {
|
} else {
|
||||||
QtCommon::system->Pause();
|
QtCommon::system->Pause();
|
||||||
m_stopped.Set();
|
m_stopped.Set();
|
||||||
|
|
||||||
EmulationPaused(lk);
|
EmulationPaused(lk);
|
||||||
m_should_run_cv.wait(lk, stop_token, [&] { return m_should_run; });
|
m_should_run_cv.wait(lk, stop_token, [&] {
|
||||||
|
return m_should_run;
|
||||||
|
});
|
||||||
EmulationResumed(lk);
|
EmulationResumed(lk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shutdown the main emulated process
|
// Shutdown the main emulated process
|
||||||
|
// Needs to pause first, we may not have paused before shutting down.
|
||||||
|
QtCommon::system->Pause();
|
||||||
QtCommon::system->DetachDebugger();
|
QtCommon::system->DetachDebugger();
|
||||||
QtCommon::system->ShutdownMainProcess();
|
QtCommon::system->ShutdownMainProcess();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user