From 8b3cdcf3f3e553cf31e05bed7908f78d5f9b591d Mon Sep 17 00:00:00 2001 From: Extremesecrecy <10959169+extremesecrecy@users.noreply.github.com> Date: Sat, 26 Jul 2025 13:49:19 -0700 Subject: [PATCH] Handle multiple server restarts Trying to decrease by only taking steps if different. --- src/PiPedalModel.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/PiPedalModel.cpp b/src/PiPedalModel.cpp index f45c396..b130cf9 100644 --- a/src/PiPedalModel.cpp +++ b/src/PiPedalModel.cpp @@ -1922,6 +1922,7 @@ void PiPedalModel::SetJackServerSettings(const JackServerSettings &jackServerSet } #endif + bool changed = !jackServerSettings.Equals(this->jackServerSettings); this->jackServerSettings = jackServerSettings; // take a snapshot incase a client unsusbscribes in the notification handler (in which case the mutex won't protect us) @@ -1938,11 +1939,19 @@ void PiPedalModel::SetJackServerSettings(const JackServerSettings &jackServerSet } FireJackConfigurationChanged(this->jackConfiguration); + //Only if different. Trying to decrease audio server restarts. + if (changed) + { + CancelAudioRetry(); - CancelAudioRetry(); - - guard.unlock(); - RestartAudio(); + guard.unlock(); + RestartAudio(); + } + else + { + // Only persistence requested. + guard.unlock(); + } #endif #if JACK_HOST @@ -1953,13 +1962,15 @@ void PiPedalModel::SetJackServerSettings(const JackServerSettings &jackServerSet currentPreset.modified_ = this->hasPresetChanged; currentPreset.preset_ = this->pedalboard; storage.SaveCurrentPreset(currentPreset); - - this->jackConfiguration.SetIsRestarting(true); - FireJackConfigurationChanged(this->jackConfiguration); - this->audioHost->UpdateServerConfiguration( - jackServerSettings, - [this](bool success, const std::string &errorMessage) - { + //Only if different. Trying to decrease server restarts. + if (changed) + { + this->jackConfiguration.SetIsRestarting(true); + FireJackConfigurationChanged(this->jackConfiguration); + this->audioHost->UpdateServerConfiguration( + jackServerSettings, + [this](bool success, const std::string &errorMessage) + { std::lock_guard lock(mutex); if (!success) { @@ -1991,7 +2002,8 @@ void PiPedalModel::SetJackServerSettings(const JackServerSettings &jackServerSet UpdateRealtimeMonitorPortSubscriptions(); #endif } - }); + }); + } } #endif }