Revert
This commit is contained in:
+17
-32
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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
@@ -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.");
|
||||
|
||||
Reference in New Issue
Block a user