diff --git a/react/src/AboutDialog.tsx b/react/src/AboutDialog.tsx index 2c41a38..5b14644 100644 --- a/react/src/AboutDialog.tsx +++ b/react/src/AboutDialog.tsx @@ -188,7 +188,9 @@ const AboutDialog = withStyles(styles, { withTheme: true })( return ( { this.props.onClose() }} TransitionComponent={Transition}> + onClose={() => { this.props.onClose() }} TransitionComponent={Transition} + style={{userSelect: "none"}} + >
@@ -206,7 +208,7 @@ const AboutDialog = withStyles(styles, { withTheme: true })(
diff --git a/react/src/BankDialog.tsx b/react/src/BankDialog.tsx index 7ce79f4..950a345 100644 --- a/react/src/BankDialog.tsx +++ b/react/src/BankDialog.tsx @@ -407,7 +407,9 @@ const BankDialog = withStyles(styles, { withTheme: true })( return ( { this.handleDialogClose() }} TransitionComponent={Transition}> + onClose={() => { this.handleDialogClose() }} TransitionComponent={Transition} + style={{userSelect: "none"}} + >
@@ -539,7 +541,8 @@ const BankDialog = withStyles(styles, { withTheme: true })( style={{ display: "none" }} /> - this.handleDeletePromptClose()}> + this.handleDeletePromptClose()} + style={{userSelect: "none"}}> Are you sure you want to delete bank '{this.getSelectedBankName()}'? diff --git a/react/src/JackServerSettings.tsx b/react/src/JackServerSettings.tsx index 0fd5b51..908856a 100644 --- a/react/src/JackServerSettings.tsx +++ b/react/src/JackServerSettings.tsx @@ -51,7 +51,9 @@ export default class JackServerSettings { getSummaryText() { if (this.valid) { - return this.alsaDevice + " Sample Rate: " + this.sampleRate + " BufferSize: " + this.bufferSize + " Number of Buffers: " + this.numberOfBuffers; + let device = this.alsaDevice; + if (device.startsWith("hw:")) device = device.substr(3); + return device + " - Rate: " + this.sampleRate + " BufferSize: " + this.bufferSize + " Buffers: " + this.numberOfBuffers; } else { return "Not configured"; } diff --git a/react/src/PiPedalModel.tsx b/react/src/PiPedalModel.tsx index 0dfbc0b..24dcddc 100644 --- a/react/src/PiPedalModel.tsx +++ b/react/src/PiPedalModel.tsx @@ -408,9 +408,9 @@ class PiPedalModelImpl implements PiPedalModel { this.onSocketReconnected = this.onSocketReconnected.bind(this); } onSocketReconnecting(retry: number, maxRetries: number): void { - if (retry !== 0) { + //if (retry !== 0) { this.setState(State.Reconnecting); - } + //} } @@ -455,14 +455,10 @@ class PiPedalModelImpl implements PiPedalModel { ); } else if (message === "onPedalBoardChanged") { let pedalChangedBody = body as PedalBoardChangedBody; - // xxx: do we want to optimize for messages we went ourselves?? - // we could actually protect against preview collisions in the model. this.pedalBoard.set(new PedalBoard().deserialize(pedalChangedBody.pedalBoard)); } else if (message === "onMidiValueChanged") { let controlChangedBody = body as ControlChangedBody; - // xxx: do we want to optimize for messages we went ourselves?? - // we could actually protect against preview collisions in the model. this._setPedalBoardControlValue( controlChangedBody.instanceId, controlChangedBody.symbol, @@ -480,8 +476,6 @@ class PiPedalModelImpl implements PiPedalModel { this.handleNotifyMidiListener(clientHandle, isNote, noteOrControl); } else if (message === "onControlChanged") { let controlChangedBody = body as ControlChangedBody; - // xxx: do we want to optimize for messages we went ourselves?? - // we could actually protect against preview collisions in the model. this._setPedalBoardControlValue( controlChangedBody.instanceId, controlChangedBody.symbol, diff --git a/react/src/PresetDialog.tsx b/react/src/PresetDialog.tsx index fcbcf9a..ab30407 100644 --- a/react/src/PresetDialog.tsx +++ b/react/src/PresetDialog.tsx @@ -335,7 +335,8 @@ const PresetDialog = withStyles(styles, { withTheme: true })( return ( { this.handleDialogClose() }} TransitionComponent={Transition}> + onClose={() => { this.handleDialogClose() }} TransitionComponent={Transition} + style={{userSelect: "none"}}>
diff --git a/react/src/RenameDialog.tsx b/react/src/RenameDialog.tsx index 3b5a35b..0b8a095 100644 --- a/react/src/RenameDialog.tsx +++ b/react/src/RenameDialog.tsx @@ -96,8 +96,9 @@ export default class RenameDialog extends ResizeResponsiveComponent { this.props.onClose() }} TransitionComponent={Transition}> + onClose={() => { this.props.onClose() }} TransitionComponent={Transition} + style={{userSelect: "none"}} + >
@@ -426,11 +428,19 @@ const SettingsDialog = withStyles(styles, { withTheme: true })( JackHostStatus.getDisplayView("Status:\u00A0", this.state.jackStatus) }
+ { this.state.jackConfiguration.errorState !== "" && + ( +
+ {this.state.jackConfiguration.errorState } +
+ + ) + } this.handleJackServerSettings()} >
- Jack Server Settings + Audio device {this.state.jackServerSettings.getSummaryText()}
@@ -454,7 +464,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })( >
- Input Channels + Input channels {this.state.jackSettings.getAudioInputDisplayValue(this.state.jackConfiguration)}
@@ -473,7 +483,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })( this.handleMidiSelection()} >
- Select MIDI Input Channels + Select MIDI input channels {this.midiSummary()}
@@ -488,7 +498,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
- Configure Wi-fi Hotspot + Configure Wi-Fi hotspot {this.state.wifiConfigSettings.getSummaryText()} diff --git a/react/src/UploadDialog.tsx b/react/src/UploadDialog.tsx index e544661..8f54c5e 100644 --- a/react/src/UploadDialog.tsx +++ b/react/src/UploadDialog.tsx @@ -153,8 +153,9 @@ export default class UploadDialog extends ResizeResponsiveComponent this.handleClose()} style={{}} + this.handleClose()} fullScreen={this.state.fullScreen} + style={{userSelect: "none"}} > Upload preset diff --git a/react/src/WifiConfigDialog.tsx b/react/src/WifiConfigDialog.tsx index dd9e124..17281d8 100644 --- a/react/src/WifiConfigDialog.tsx +++ b/react/src/WifiConfigDialog.tsx @@ -250,7 +250,7 @@ const WifiConfigDialog = withStyles(styles, { withTheme: true })( }; return ( - { this.state.fullScreen && ( @@ -335,7 +335,8 @@ const WifiConfigDialog = withStyles(styles, { withTheme: true })( OK - + Enabling the Wi-Fi hotspot will disable regular Wi-Fi network access on the PiPedal device. Once diff --git a/src/BeastServer.cpp b/src/BeastServer.cpp index a3d77c8..c0ec89c 100644 --- a/src/BeastServer.cpp +++ b/src/BeastServer.cpp @@ -813,7 +813,11 @@ public: void do_read() { - // Set the timer + // make the request empty before reading + // otherwise the operation behavour is undefined. + req_ = {}; + + // Set the time timer_.expires_after(std::chrono::seconds(15)); // Read a request diff --git a/src/ConfigMain.cpp b/src/ConfigMain.cpp index 4231899..3b2691f 100644 --- a/src/ConfigMain.cpp +++ b/src/ConfigMain.cpp @@ -193,6 +193,59 @@ static bool userExists(const char *userName) return true; } +void InstallPamEnv() +{ + std::string newLine = "JACK_PROMISCOUS_SERVER DEFAULT=jack"; + std::vector lines; + std::filesystem::path path = "/etc/security/pam_env.conf"; + try + { + if (std::filesystem::exists(path)) + { + { + ifstream f(path); + if (!f.is_open()) + { + throw PiPedalException("Can't open pam_env.conf"); + } + while (true) + { + std::string line; + if (f.eof()) + break; + std::getline(f, line); + lines.push_back(line); + } + } + + for (auto &line : lines) + { + if (line == newLine) + { + return; + } + } + lines.push_back(newLine); + + { + std::ofstream f(path); + if (!f.is_open()) + { + throw PiPedalException("Can't write to file."); + } + for (auto&line: lines) + { + f << line << endl; + } + } + } + } + catch (const std::exception &e) + { + cout << "Failed to update " << path << ". " << e.what(); + } +} + void InstallLimits() { if (SysExec(GROUPADD_BIN " -f " AUDIO_SERVICE_GROUP_NAME) != EXIT_SUCCESS) @@ -227,6 +280,7 @@ void MaybeStartJackService() void InstallJackService() { InstallLimits(); + InstallPamEnv(); if (SysExec(GROUPADD_BIN " -f " JACK_SERVICE_GROUP_NAME) != EXIT_SUCCESS) { throw PiPedalException("Failed to create jack service group."); @@ -554,7 +608,7 @@ int main(int argc, char **argv) args.push_back((char *)(pkexec.c_str())); std::string sPath = GetSelfExePath(); - args.push_back(const_cast(sPath.c_str())); + args.push_back(const_cast(sPath.c_str())); for (int arg = 1; arg < argc; ++arg) { args.push_back(const_cast(argv[arg])); diff --git a/src/JackHost.cpp b/src/JackHost.cpp index 85304cb..facc3b9 100644 --- a/src/JackHost.cpp +++ b/src/JackHost.cpp @@ -1275,10 +1275,10 @@ private: void ThreadProc() { this_->restarting = true; - this_->Close(); + // this_->Close(); (JackServerConfiguration now does a service restart.) try { ShutdownClient::SetJackServerConfiguration(jackServerSettings); - this_->Open(this_->channelSelection); + //this_->Open(this_->channelSelection); this_->restarting = false; onComplete(true, ""); isComplete = true; diff --git a/src/JackServerSettings.cpp b/src/JackServerSettings.cpp index 4458833..aa8c218 100644 --- a/src/JackServerSettings.cpp +++ b/src/JackServerSettings.cpp @@ -214,20 +214,17 @@ void JackServerSettings::Write() output << line << endl; } // the style used by qjackctl. :-/ + // Lower to -P70 in order to allow the USB soft-irq to run at higher priority than JACK (it runs at 80). output << "/usr/bin/jackd " - << "-R -P90" + << "-R -P70 --silent" << " -dalsa -d" << this->alsaDevice_ << " -r" << this->sampleRate_ << " -p" << this->bufferSize_ << " -n" << this->numberOfBuffers_ << " -Xseq" << endl; system("/usr/bin/chmod 755 " DRC_FILENAME); - system("pulseaudio --kill"); + system("/usr/bin/systemctl unmask jack"); system("/usr/bin/systemctl enable jack"); - if (system("/usr/bin/systemctl restart jack") != 0) - { - throw PiPedalException("Failed to start jack audio service."); - } } catch (const std::exception &e) { diff --git a/src/PiPedalModel.cpp b/src/PiPedalModel.cpp index 3b4210b..bfe0fad 100644 --- a/src/PiPedalModel.cpp +++ b/src/PiPedalModel.cpp @@ -910,13 +910,17 @@ void PiPedalModel::SetJackServerSettings(const JackServerSettings &jackServerSet Lv2Log::error(s.str().c_str()); } // Update jack server status. - this->jackConfiguration.SetIsRestarting(false); if (!success) { + this->jackConfiguration.SetIsRestarting(false); this->jackConfiguration.SetErrorStatus(errorMessage); + fireJackConfigurationChanged(this->jackConfiguration); } else { + // we now do a complete restart of the services, + // so just sit tight and wait for the restart. +#ifdef JUNK this->jackConfiguration.SetErrorStatus(""); fireJackConfigurationChanged(this->jackConfiguration); @@ -927,6 +931,7 @@ void PiPedalModel::SetJackServerSettings(const JackServerSettings &jackServerSet jackHost->SetPedalBoard(lv2PedalBoard); updateRealtimeVuSubscriptions(); updateRealtimeMonitorPortSubscriptions(); +#endif } }); } diff --git a/src/ShutdownMain.cpp b/src/ShutdownMain.cpp index fa40e29..4fa6b4c 100644 --- a/src/ShutdownMain.cpp +++ b/src/ShutdownMain.cpp @@ -86,11 +86,16 @@ static void ReleaseAccessPoint(const std::string gatewayAddress) void delayedRestartProc() { sleep(1); // give a chance for websocket messages to propagate. - std::string pipedalConfigPath = std::filesystem::path(GetSelfExePath()).parent_path() / "pipedalConfig"; + Lv2Log::error("Delayed Restart"); + std::string pipedalConfigPath = std::filesystem::path(GetSelfExePath()).parent_path() / "pipedalconfig"; std::stringstream s; s << pipedalConfigPath.c_str() << " --restart --excludeShutdownService"; - ::system(s.str().c_str()); + if (::system(s.str().c_str())!= EXIT_SUCCESS) + { + Lv2Log::error("Delayed Restart failed."); + + } } bool setJackConfiguration(JackServerSettings serverSettings) @@ -247,8 +252,6 @@ private: { auto remainder = s.substr(strlen("setJackConfiguration ")); - // xxx delete me - Lv2Log::error("setJackConfiguration: " + remainder); std::stringstream input(remainder); JackServerSettings serverSettings; diff --git a/src/json.cpp b/src/json.cpp index 85c2c7c..e5ce2b9 100644 --- a/src/json.cpp +++ b/src/json.cpp @@ -60,7 +60,7 @@ void json_writer::write(string_view v,bool enforceValidUtf8Encoding) { // convert to utf-32. // convert utf-32 to normalized utf-16. - // write non-7-bit and unsafe characters as \uxxxx. + // write non-7-bit and unsafe characters as \uHHHH. auto p = v.begin(); os << '"'; diff --git a/src/main.cpp b/src/main.cpp index 42599ca..79e9989 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -579,9 +579,10 @@ int main(int argc, char *argv[]) PiPedalModel model; // Pre-populate ALSA device info,wait for jackd service (daemon only) + model.GetAlsaDevices(); // pre-cache ALSA devices. if (systemd) { - auto devices = model.GetAlsaDevices(); + auto devices = model.GetAlsaDevices(); // pre-cache ALSA devices (most especially, the one which Jack will open, that we can no longer read) auto serverSettings = model.GetJackServerSettings(); if (serverSettings.IsValid()) @@ -590,7 +591,7 @@ int main(int argc, char *argv[]) if (!HasAlsaDevice(devices, serverSettings.GetAlsaDevice())) { Lv2Log::info("Waiting for ALSA device " + serverSettings.GetAlsaDevice()); - for (int i = 0; i < 15; ++i) + for (int i = 0; i < 10; ++i) { sleep(1); devices = model.GetAlsaDevices();