From 530277ed71f72796c9a32076266b7d6d0a1eabc4 Mon Sep 17 00:00:00 2001 From: Extremesecrecy <10959169+extremesecrecy@users.noreply.github.com> Date: Fri, 25 Jul 2025 21:41:49 -0700 Subject: [PATCH] Wait going mad. Pressing ok/apply/refresh all were starting a cascade o waits. A restart request now cleans up any previous restart thread so multiple restarts cannot overlap --- src/AudioHost.cpp | 2 ++ src/PiPedalModel.cpp | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/AudioHost.cpp b/src/AudioHost.cpp index 99bcc9f..43d9bb6 100644 --- a/src/AudioHost.cpp +++ b/src/AudioHost.cpp @@ -2086,6 +2086,8 @@ public: virtual void UpdateServerConfiguration(const JackServerSettings &jackServerSettings, std::function onComplete) { + // Only allow one restart operation at a time. + CleanRestartThreads(true); std::lock_guard guard(restart_mutex); RestartThread *pShutdown = new RestartThread(this, jackServerSettings, onComplete); restartThreads.push_back(pShutdown); diff --git a/src/PiPedalModel.cpp b/src/PiPedalModel.cpp index 95306d1..b4f51fa 100644 --- a/src/PiPedalModel.cpp +++ b/src/PiPedalModel.cpp @@ -3015,24 +3015,25 @@ void PiPedalModel::OnAlsaDriverTerminatedAbnormally() auto now = clock::now(); clock::duration timeSinceLastRetry = now-this->lastRestartTime; this->lastRestartTime = now; - if (timeSinceLastRetry > std::chrono::duration_cast(std::chrono::milliseconds(1000))) { + if (timeSinceLastRetry > std::chrono::duration_cast(std::chrono::seconds(6))) { audioRestartRetries = 0; } CancelAudioRetry(); if (audioRestartRetries == 0) { - this->audioRetryPostHandle = this->Post( + this->audioRetryPostHandle = this->PostDelayed( + std::chrono::seconds(5), // No lock to avoid deadlocks! [this]() { Lv2Log::info("Restarting audio."); this->RestartAudio(); }); ++audioRestartRetries; - } else if (audioRestartRetries < 3) + } else if (audioRestartRetries < 3) { this->audioRetryPostHandle = this->PostDelayed( - std::chrono::milliseconds(100 * audioRestartRetries), + std::chrono::seconds(5), [this]() { if (closed) { return;