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
This commit is contained in:
Extremesecrecy
2025-07-25 21:41:49 -07:00
parent 2ae24f0b32
commit 530277ed71
2 changed files with 7 additions and 4 deletions
+2
View File
@@ -2086,6 +2086,8 @@ public:
virtual void UpdateServerConfiguration(const JackServerSettings &jackServerSettings, virtual void UpdateServerConfiguration(const JackServerSettings &jackServerSettings,
std::function<void(bool success, const std::string &errorMessage)> onComplete) std::function<void(bool success, const std::string &errorMessage)> onComplete)
{ {
// Only allow one restart operation at a time.
CleanRestartThreads(true);
std::lock_guard guard(restart_mutex); std::lock_guard guard(restart_mutex);
RestartThread *pShutdown = new RestartThread(this, jackServerSettings, onComplete); RestartThread *pShutdown = new RestartThread(this, jackServerSettings, onComplete);
restartThreads.push_back(pShutdown); restartThreads.push_back(pShutdown);
+5 -4
View File
@@ -3015,24 +3015,25 @@ void PiPedalModel::OnAlsaDriverTerminatedAbnormally()
auto now = clock::now(); auto now = clock::now();
clock::duration timeSinceLastRetry = now-this->lastRestartTime; clock::duration timeSinceLastRetry = now-this->lastRestartTime;
this->lastRestartTime = now; this->lastRestartTime = now;
if (timeSinceLastRetry > std::chrono::duration_cast<clock::duration>(std::chrono::milliseconds(1000))) { if (timeSinceLastRetry > std::chrono::duration_cast<clock::duration>(std::chrono::seconds(6))) {
audioRestartRetries = 0; audioRestartRetries = 0;
} }
CancelAudioRetry(); CancelAudioRetry();
if (audioRestartRetries == 0) if (audioRestartRetries == 0)
{ {
this->audioRetryPostHandle = this->Post( this->audioRetryPostHandle = this->PostDelayed(
std::chrono::seconds(5),
// No lock to avoid deadlocks! // No lock to avoid deadlocks!
[this]() { [this]() {
Lv2Log::info("Restarting audio."); Lv2Log::info("Restarting audio.");
this->RestartAudio(); this->RestartAudio();
}); });
++audioRestartRetries; ++audioRestartRetries;
} else if (audioRestartRetries < 3) } else if (audioRestartRetries < 3)
{ {
this->audioRetryPostHandle = this->PostDelayed( this->audioRetryPostHandle = this->PostDelayed(
std::chrono::milliseconds(100 * audioRestartRetries), std::chrono::seconds(5),
[this]() { [this]() {
if (closed) { if (closed) {
return; return;