Ubuntu 21.04 aarch64 portability; Bug fixes.
This commit is contained in:
+17
-8
@@ -97,6 +97,7 @@ namespace pipedal {
|
||||
class BeastServerImpl : public BeastServer
|
||||
{
|
||||
private:
|
||||
int signalOnDone = -1;
|
||||
std::string address;
|
||||
int port = -1;
|
||||
std::filesystem::path rootPath;
|
||||
@@ -210,6 +211,9 @@ private:
|
||||
}
|
||||
void on_close(connection_hdl hdl)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
|
||||
#endif
|
||||
auto shThis = this->shared_from_this(); // we will destruct as we return.
|
||||
pServer->on_session_closed(shThis,hdl);
|
||||
}
|
||||
@@ -472,13 +476,19 @@ private:
|
||||
using websocketpp::lib::bind;
|
||||
using websocketpp::lib::placeholders::_1;
|
||||
using websocketpp::lib::placeholders::_2;
|
||||
|
||||
m_endpoint.set_open_handler(bind(&BeastServerImpl::on_open, this, _1));
|
||||
m_endpoint.set_close_handler(bind(&BeastServerImpl::on_close, this, _1));
|
||||
m_endpoint.set_http_handler(bind(&BeastServerImpl::on_http, this, _1));
|
||||
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Listening on " << this->address << ":" << this->port;
|
||||
Lv2Log::info(ss.str());
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << port;
|
||||
|
||||
m_endpoint.listen(this->address, ss.str());
|
||||
m_endpoint.start_accept();
|
||||
|
||||
@@ -494,11 +504,6 @@ private:
|
||||
|
||||
// Start the ASIO io_service run loop
|
||||
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Listening on " << this->address << ":" << this->port;
|
||||
Lv2Log::info(ss.str());
|
||||
}
|
||||
m_endpoint.run();
|
||||
//ioc.run();
|
||||
/****************** */
|
||||
@@ -514,8 +519,11 @@ private:
|
||||
catch (websocketpp::exception const &e)
|
||||
{
|
||||
std::cout << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
if (this->signalOnDone != -1) {
|
||||
kill(getpid(),this->signalOnDone);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void ThreadProc(BeastServerImpl *server)
|
||||
@@ -565,12 +573,13 @@ public:
|
||||
this->pBgThread = nullptr;
|
||||
}
|
||||
|
||||
virtual void RunInBackground()
|
||||
virtual void RunInBackground(int signalOnDone)
|
||||
{
|
||||
if (this->pBgThread != nullptr)
|
||||
{
|
||||
throw std::runtime_error("Bad state.");
|
||||
}
|
||||
this->signalOnDone = signalOnDone;
|
||||
this->pBgThread = new std::thread(ThreadProc, this);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -191,7 +191,8 @@ public:
|
||||
virtual void ShutDown(int timeoutMs) = 0;
|
||||
virtual void Join() = 0;
|
||||
|
||||
virtual void RunInBackground() = 0;
|
||||
// signalOnDone: fire the specified POSIX signal when the service thread terminates. -1 for no signal.
|
||||
virtual void RunInBackground(int signalOnDone = -1) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ endif()
|
||||
|
||||
message (STATUS "Cxx flags: ${CMAKE_CXX_FLAGS}" )
|
||||
|
||||
add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
|
||||
add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY -DBOOST_BIND_GLOBAL_PLACEHOLDERS)
|
||||
|
||||
set (PIPEDAL_SOURCES
|
||||
SysExec.cpp SysExec.hpp
|
||||
|
||||
@@ -89,6 +89,13 @@ PiPedalModel::~PiPedalModel()
|
||||
|
||||
#include <fstream>
|
||||
|
||||
|
||||
void PiPedalModel::LoadLv2PluginInfo(const PiPedalConfiguration&configuration)
|
||||
{
|
||||
lv2Host.Load(configuration.GetLv2Path().c_str());
|
||||
|
||||
}
|
||||
|
||||
void PiPedalModel::Load(const PiPedalConfiguration &configuration)
|
||||
{
|
||||
|
||||
@@ -112,7 +119,7 @@ void PiPedalModel::Load(const PiPedalConfiguration &configuration)
|
||||
s << "Unable to load " << pluginClassesPath << ". " << e.what();
|
||||
throw PiPedalException(s.str().c_str());
|
||||
}
|
||||
lv2Host.Load(configuration.GetLv2Path().c_str());
|
||||
// lv2Host.Load(configuration.GetLv2Path().c_str());
|
||||
|
||||
this->pedalBoard = storage.GetCurrentPreset(); // the current *saved* preset.
|
||||
|
||||
|
||||
@@ -127,6 +127,7 @@ public:
|
||||
virtual ~PiPedalModel();
|
||||
|
||||
void Close();
|
||||
void LoadLv2PluginInfo(const PiPedalConfiguration&configuration);
|
||||
void Load(const PiPedalConfiguration&configuration);
|
||||
|
||||
const Lv2Host& getPlugins() const { return lv2Host; }
|
||||
|
||||
@@ -156,7 +156,7 @@ void pipedal::SetWifiConfig(const WifiConfigSettings&settings)
|
||||
dhcpcd.InsertLine(line++,"interface wlan0");
|
||||
dhcpcd.InsertLine(line++," static ip_address=" PIPEDAL_NETWORK);
|
||||
dhcpcd.InsertLine(line++," nohook wpa_supplicant");
|
||||
dhcpcd.Save(dhcpcdConfig);adding
|
||||
dhcpcd.Save(dhcpcdConfig);
|
||||
}
|
||||
|
||||
// ***** save the config files ***
|
||||
|
||||
+19
-7
@@ -66,8 +66,11 @@ public:
|
||||
static volatile bool g_SigBreak = false;
|
||||
void sig_handler(int signo)
|
||||
{
|
||||
g_SigBreak = true;
|
||||
sem_post(&signalSemaphore);
|
||||
if (!g_SigBreak)
|
||||
{
|
||||
g_SigBreak = true;
|
||||
sem_post(&signalSemaphore);
|
||||
}
|
||||
}
|
||||
using namespace boost::system;
|
||||
|
||||
@@ -465,6 +468,7 @@ int main(int argc, char *argv[])
|
||||
Lv2Log::set_logger(MakeLv2SystemdLogger());
|
||||
}
|
||||
signal(SIGTERM, sig_handler);
|
||||
signal(SIGUSR1, sig_handler);
|
||||
|
||||
std::filesystem::path doc_root = parser.Arguments()[0];
|
||||
std::filesystem::path web_root = doc_root;
|
||||
@@ -548,10 +552,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
Lv2Log::info("Waiting for jack service.");
|
||||
|
||||
// pre-cache device info.
|
||||
// pre-cache device info before we let audio services run.
|
||||
model.GetAlsaDevices();
|
||||
|
||||
// Get heavy IO out of the way before letting dependent (Jack) services run.
|
||||
model.LoadLv2PluginInfo(configuration);
|
||||
// Tell systemd we're done.
|
||||
sd_notify(0, "READY=1");
|
||||
|
||||
if (!isJackServiceRunning())
|
||||
@@ -570,9 +577,14 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
}
|
||||
Lv2Log::info("Found Jack service.");
|
||||
}
|
||||
sleep(3); // jack needs a little time to get up to speed.
|
||||
if (isJackServiceRunning())
|
||||
{
|
||||
Lv2Log::info("Found Jack service.");
|
||||
sleep(3); // jack needs a little time to get up to speed.
|
||||
} else {
|
||||
Lv2Log::info("Jack service not started.");
|
||||
}
|
||||
}
|
||||
|
||||
model.Load(configuration);
|
||||
@@ -587,7 +599,7 @@ int main(int argc, char *argv[])
|
||||
std::shared_ptr<DownloadIntercept> downloadIntercept = std::make_shared<DownloadIntercept>(&model);
|
||||
server->AddRequestHandler(downloadIntercept);
|
||||
|
||||
server->RunInBackground();
|
||||
server->RunInBackground(SIGUSR1);
|
||||
|
||||
sem_wait(&signalSemaphore);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ ExecStart=${COMMAND}
|
||||
User=pipedal_d
|
||||
Group=pipedal_d
|
||||
Restart=always
|
||||
TimeoutStartSec=60
|
||||
RestartSec=25
|
||||
TimeoutStopSec=10
|
||||
WorkingDirectory=/var/pipedal
|
||||
|
||||
Reference in New Issue
Block a user