From 34615d3a74eae6a8a11e3f610ba9fc8b5496e153 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sun, 17 Jul 2022 17:55:12 +0200 Subject: [PATCH] cellMic: slow down if no mics are configured --- rpcs3/Emu/Cell/Modules/cellMic.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellMic.cpp b/rpcs3/Emu/Cell/Modules/cellMic.cpp index bdcc0ef2df..9fd223600f 100644 --- a/rpcs3/Emu/Cell/Modules/cellMic.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMic.cpp @@ -92,9 +92,15 @@ void mic_context::operator()() m_counter++; // Process signals + const auto process_signals = [this]() -> bool { std::lock_guard lock(mutex); + if (mic_list.empty()) + { + return false; + } + for (auto& mic_entry : mic_list) { auto& mic = mic_entry.second; @@ -103,16 +109,25 @@ void mic_context::operator()() auto mic_queue = lv2_event_queue::find(event_queue_key); if (!mic_queue) - continue; - - for (auto& mic_entry : mic_list) { - auto& mic = mic_entry.second; + return true; + } + + for (const auto& [dev_num, mic] : mic_list) + { if (mic.has_data()) { - mic_queue->send(0, CELLMIC_DATA, mic_entry.first, 0); + mic_queue->send(0, CELLMIC_DATA, dev_num, 0); } } + + return true; + }; + + // Get mic input and sleep if mics are idle + if (!process_signals()) + { + thread_ctrl::wait_for(100000); } }