cellMic: slow down if no mics are configured

This commit is contained in:
Megamouse 2022-07-17 17:55:12 +02:00
parent 189499c10b
commit 34615d3a74

View File

@ -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);
}
}