From 9353503833eb19285343cd001ac76de8f84beac7 Mon Sep 17 00:00:00 2001 From: Extremesecrecy <10959169+extremesecrecy@users.noreply.github.com> Date: Sun, 27 Jul 2025 16:08:10 -0700 Subject: [PATCH] Revert --- src/PiPedalModel.cpp | 49 +++++++------------- src/PiPedalModel.hpp | 2 +- src/PiPedalSocket.cpp | 75 +------------------------------ vite/src/pipedal/PiPedalModel.tsx | 3 +- 4 files changed, 21 insertions(+), 108 deletions(-) diff --git a/src/PiPedalModel.cpp b/src/PiPedalModel.cpp index b130cf9..a3b4e95 100644 --- a/src/PiPedalModel.cpp +++ b/src/PiPedalModel.cpp @@ -1911,7 +1911,7 @@ void PiPedalModel::SetOnboarding(bool value) SetJackServerSettings(this->jackServerSettings); } -void PiPedalModel::SetJackServerSettings(const JackServerSettings &jackServerSettings, bool persist) +void PiPedalModel::SetJackServerSettings(const JackServerSettings &jackServerSettings) { std::unique_lock guard(mutex); @@ -1922,7 +1922,6 @@ 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) @@ -1933,25 +1932,14 @@ void PiPedalModel::SetJackServerSettings(const JackServerSettings &jackServerSet } #if ALSA_HOST - if (persist) - { - storage.SetJackServerSettings(jackServerSettings); - } + storage.SetJackServerSettings(jackServerSettings); FireJackConfigurationChanged(this->jackConfiguration); - //Only if different. Trying to decrease audio server restarts. - if (changed) - { - CancelAudioRetry(); - guard.unlock(); - RestartAudio(); - } - else - { - // Only persistence requested. - guard.unlock(); - } + CancelAudioRetry(); + + guard.unlock(); + RestartAudio(); #endif #if JACK_HOST @@ -1962,15 +1950,13 @@ void PiPedalModel::SetJackServerSettings(const JackServerSettings &jackServerSet currentPreset.modified_ = this->hasPresetChanged; currentPreset.preset_ = this->pedalboard; storage.SaveCurrentPreset(currentPreset); - //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) - { + + 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) { @@ -2002,8 +1988,7 @@ void PiPedalModel::SetJackServerSettings(const JackServerSettings &jackServerSet UpdateRealtimeMonitorPortSubscriptions(); #endif } - }); - } + }); } #endif } @@ -3035,7 +3020,6 @@ void PiPedalModel::OnAlsaDriverTerminatedAbnormally() if (audioRestartRetries == 0) { this->audioRetryPostHandle = this->Post( - // No lock to avoid deadlocks! [this]() { Lv2Log::info("Restarting audio."); @@ -3067,7 +3051,7 @@ void PiPedalModel::OnAlsaDriverTerminatedAbnormally() } ++audioRestartRetries; } else { - Lv2Log::error(SS("Unable to restart audio.")); + Lv2Log::error(SS("Unable to reastart audio.")); } }); } @@ -3105,7 +3089,7 @@ void PiPedalModel::SetTone3000Auth(const std::string &apiKey) { std::lock_guard lock(mutex); storage.SetTone3000Auth(apiKey); - + std::vector t{subscribers.begin(), subscribers.end()}; bool hasAuth = apiKey != ""; for (auto &subscriber : t) @@ -3120,3 +3104,4 @@ bool PiPedalModel::HasTone3000Auth() const } + diff --git a/src/PiPedalModel.hpp b/src/PiPedalModel.hpp index 012c5ab..9145be4 100644 --- a/src/PiPedalModel.hpp +++ b/src/PiPedalModel.hpp @@ -449,7 +449,7 @@ namespace pipedal return this->audioHost->getJackStatus(); } JackServerSettings GetJackServerSettings(); - void SetJackServerSettings(const JackServerSettings &jackServerSettings, bool persist = true); + void SetJackServerSettings(const JackServerSettings &jackServerSettings); void ListenForMidiEvent(int64_t clientId, int64_t clientHandle); void CancelListenForMidiEvent(int64_t clientId, int64_t clientHandle); diff --git a/src/PiPedalSocket.cpp b/src/PiPedalSocket.cpp index 15a1a2a..83d1bfe 100644 --- a/src/PiPedalSocket.cpp +++ b/src/PiPedalSocket.cpp @@ -41,73 +41,11 @@ #include "SysExec.hpp" #include "PiPedalAlsa.hpp" #include -#include #include "FileEntry.hpp" using namespace std; using namespace pipedal; -static std::string JoinStrings(const std::vector &values, const std::string &sep = ", ") -{ - std::stringstream ss; - for (size_t i = 0; i < values.size(); ++i) - { - if (i != 0) - ss << sep; - ss << values[i]; - } - return ss.str(); -} - -static void CheckJackServerSettings(const JackServerSettings &settings) -{ - std::vector missing; - if (settings.GetAlsaInputDevice().empty()) - missing.push_back("alsaInputDevice"); - if (settings.GetAlsaOutputDevice().empty()) - missing.push_back("alsaOutputDevice"); - if (settings.GetSampleRate() == 0) - missing.push_back("sampleRate"); - if (settings.GetBufferSize() == 0) - missing.push_back("bufferSize"); - if (settings.GetNumberOfBuffers() == 0) - missing.push_back("numberOfBuffers"); - if (!missing.empty()) - throw PiPedalArgumentException("Missing properties: " + JoinStrings(missing)); -} - -static void CheckWifiConfigSettings(const WifiConfigSettings &settings) -{ - std::vector missing; - if (settings.countryCode_.empty()) - missing.push_back("countryCode"); - if (settings.hotspotName_.empty()) - missing.push_back("hotspotName"); - if (settings.channel_.empty()) - missing.push_back("channel"); - if (settings.IsEnabled() && !settings.hasSavedPassword_ && settings.password_.empty()) - missing.push_back("password"); - if (!missing.empty()) - throw PiPedalArgumentException("Missing properties: " + JoinStrings(missing)); -} - -static void CheckWifiDirectConfigSettings(const WifiDirectConfigSettings &settings) -{ - std::vector missing; - if (settings.countryCode_.empty()) - missing.push_back("countryCode"); - if (settings.hotspotName_.empty()) - missing.push_back("hotspotName"); - if (settings.pin_.empty()) - missing.push_back("pin"); - if (settings.channel_.empty()) - missing.push_back("channel"); - if (settings.wlan_.empty()) - missing.push_back("wlan"); - if (!missing.empty()) - throw PiPedalArgumentException("Missing properties: " + JoinStrings(missing)); -} - class PathPatchPropertyChangedBody { public: @@ -1284,17 +1222,8 @@ public: { JackServerSettings jackServerSettings; pReader->read(&jackServerSettings); - CheckJackServerSettings(jackServerSettings); - this->model.SetJackServerSettings(jackServerSettings, true); + this->model.SetJackServerSettings(jackServerSettings); this->Reply(replyTo, "setJackserverSettings"); - } - else if (message == "applyJackServerSettings") - { - JackServerSettings jackServerSettings; - pReader->read(&jackServerSettings); - CheckJackServerSettings(jackServerSettings); - this->model.SetJackServerSettings(jackServerSettings, false); - this->Reply(replyTo, "applyJackServerSettings"); } else if (message == "setGovernorSettings") { @@ -1312,7 +1241,6 @@ public: { WifiConfigSettings wifiConfigSettings; pReader->read(&wifiConfigSettings); - CheckWifiConfigSettings(wifiConfigSettings); if (!GetAdminClient().CanUseAdminClient()) { throw PiPedalException("Can't change server settings when running interactively."); @@ -1334,7 +1262,6 @@ public: { WifiDirectConfigSettings wifiDirectConfigSettings; pReader->read(&wifiDirectConfigSettings); - CheckWifiDirectConfigSettings(wifiDirectConfigSettings); if (!GetAdminClient().CanUseAdminClient()) { throw PiPedalException("Can't change server settings when running interactively."); diff --git a/vite/src/pipedal/PiPedalModel.tsx b/vite/src/pipedal/PiPedalModel.tsx index b1a0c11..97ac43e 100644 --- a/vite/src/pipedal/PiPedalModel.tsx +++ b/vite/src/pipedal/PiPedalModel.tsx @@ -1,4 +1,3 @@ -@@ -1,3543 +1,3543 @@ // Copyright (c) 2022 Robin Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -3540,3 +3539,5 @@ export class PiPedalModelFactory { } }; + +