Create base class for sockets and derive from that

Now the host launching procedure can be agnostic of the socket
implementation.
This commit is contained in:
Robbert van der Helm
2020-11-30 16:24:47 +01:00
parent 5b2221b251
commit fa719c286d
5 changed files with 99 additions and 67 deletions
+4 -4
View File
@@ -87,7 +87,7 @@ void HostProcess::async_log_pipe_lines(patched_async_pipe& pipe,
IndividualHost::IndividualHost(boost::asio::io_context& io_context,
Logger& logger,
fs::path plugin_path,
const Vst2Sockets<std::jthread>& sockets)
const Sockets& sockets)
: HostProcess(io_context, logger),
plugin_arch(find_vst_architecture(plugin_path)),
host_path(find_vst_host(plugin_arch, false)),
@@ -134,7 +134,7 @@ void IndividualHost::terminate() {
GroupHost::GroupHost(boost::asio::io_context& io_context,
Logger& logger,
fs::path plugin_path,
Vst2Sockets<std::jthread>& sockets,
Sockets& sockets,
std::string group_name)
: HostProcess(io_context, logger),
plugin_arch(find_vst_architecture(plugin_path)),
@@ -251,8 +251,8 @@ bool GroupHost::running() {
void GroupHost::terminate() {
// There's no need to manually terminate group host processes as they will
// shut down automatically after all plugins have exited. Manually closing
// the dispatch socket will cause the associated plugin to exit.
sockets.host_vst_dispatch.close();
// the sockets will cause the associated plugin to exit.
sockets.close();
}
bool pid_running(pid_t pid) {
+4 -7
View File
@@ -25,10 +25,7 @@
#include <boost/process/child.hpp>
#include <thread>
// TODO: Those host process implementation now directly uses the Vst2Sockets and
// thus requires `communication/vst2.h`. We should create a simple common
// interface for this instead.
#include "../common/communication/vst2.h"
#include "../common/communication/common.h"
#include "../common/logging.h"
#include "utils.h"
@@ -130,7 +127,7 @@ class IndividualHost : public HostProcess {
IndividualHost(boost::asio::io_context& io_context,
Logger& logger,
boost::filesystem::path plugin_path,
const Vst2Sockets<std::jthread>& sockets);
const Sockets& sockets);
PluginArchitecture architecture() override;
boost::filesystem::path path() override;
@@ -172,7 +169,7 @@ class GroupHost : public HostProcess {
GroupHost(boost::asio::io_context& io_context,
Logger& logger,
boost::filesystem::path plugin_path,
Vst2Sockets<std::jthread>& socket_endpoint,
Sockets& socket_endpoint,
std::string group_name);
PluginArchitecture architecture() override;
@@ -206,7 +203,7 @@ class GroupHost : public HostProcess {
* The associated sockets for the plugin we're hosting. This is used to
* terminate the plugin.
*/
Vst2Sockets<std::jthread>& sockets;
Sockets& sockets;
/**
* A thread that waits for the group host to have started and then ask it to