This commit is contained in:
Extremesecrecy
2025-07-27 16:08:10 -07:00
parent 3396907782
commit 9353503833
4 changed files with 21 additions and 108 deletions
+17 -32
View File
@@ -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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> lock(mutex);
storage.SetTone3000Auth(apiKey);
std::vector<IPiPedalModelSubscriber::ptr> t{subscribers.begin(), subscribers.end()};
bool hasAuth = apiKey != "";
for (auto &subscriber : t)
@@ -3120,3 +3104,4 @@ bool PiPedalModel::HasTone3000Auth() const
}
+1 -1
View File
@@ -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);
+1 -74
View File
@@ -41,73 +41,11 @@
#include "SysExec.hpp"
#include "PiPedalAlsa.hpp"
#include <filesystem>
#include <sstream>
#include "FileEntry.hpp"
using namespace std;
using namespace pipedal;
static std::string JoinStrings(const std::vector<std::string> &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<std::string> 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<std::string> 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<std::string> 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.");
+2 -1
View File
@@ -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 {
}
};