mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 20:10:13 +02:00
💥 Encapsulate and rework all socket logic
This is a pretty huge change that will be important for being able to handle nested or mutually recursive `dispatch()` and `audioMaster()` calls. This sadly all had to be done in a single commit, so here's a summary: - `src/common/sockets.h:Sockets` contains all sockets on both the plugin and the Wine host side, and is used to both listen on and connect to the sockets. - Sockets and other temporary files respect `$XDG_RUNTIME_DIR` instead of being dumped in `/tmp`. - All sockets now have a unique endpoint in `/run/user/<uid>/yabridge-<plugin_name>-<random_id>/`. This is important for when we want to have multiple socket connections for handling `dispatch()` and `audioMaster()`. - Because of the above, we no longer clean up the socket endpoint files after the connection gets established during initialization. Instead we'll remove the socket base directory when shutting down.
This commit is contained in:
+11
-13
@@ -26,6 +26,7 @@
|
||||
#include <thread>
|
||||
|
||||
#include "../common/logging.h"
|
||||
#include "../common/communication.h"
|
||||
#include "utils.h"
|
||||
|
||||
/**
|
||||
@@ -117,7 +118,7 @@ class IndividualHost : public HostProcess {
|
||||
* handled on.
|
||||
* @param logger The `Logger` instance the redirected STDIO streams will be
|
||||
* written to.
|
||||
* @param socket_endpoint The endpoint that should be used to communicate
|
||||
* @param sockets The socket endpoints that will be used for communication
|
||||
* with the plugin.
|
||||
*
|
||||
* @throw std::runtime_error When `plugin_path` does not point to a valid
|
||||
@@ -126,7 +127,7 @@ class IndividualHost : public HostProcess {
|
||||
IndividualHost(boost::asio::io_context& io_context,
|
||||
Logger& logger,
|
||||
boost::filesystem::path plugin_path,
|
||||
boost::filesystem::path socket_endpoint);
|
||||
const Sockets& sockets);
|
||||
|
||||
PluginArchitecture architecture() override;
|
||||
boost::filesystem::path path() override;
|
||||
@@ -160,19 +161,16 @@ class GroupHost : public HostProcess {
|
||||
* handled on.
|
||||
* @param logger The `Logger` instance the redirected STDIO streams will be
|
||||
* written to.
|
||||
* @param socket_endpoint The endpoint that should be used to communicate
|
||||
* with the plugin.
|
||||
* @param sockets The socket endpoints that will be used for communication
|
||||
* with the plugin. When the plugin shuts down, we'll terminate the
|
||||
* dispatch socket contained in this object.
|
||||
* @param group_name The name of the plugin group.
|
||||
* @param host_vst_dispatch The socket used to communicate
|
||||
* `AEffect::dispatcher()` events with this plugin. Will be closed as to
|
||||
* shut down the plugin.
|
||||
*/
|
||||
GroupHost(boost::asio::io_context& io_context,
|
||||
Logger& logger,
|
||||
boost::filesystem::path plugin_path,
|
||||
boost::filesystem::path socket_endpoint,
|
||||
std::string group_name,
|
||||
boost::asio::local::stream_protocol::socket& host_vst_dispatch);
|
||||
Sockets& socket_endpoint,
|
||||
std::string group_name);
|
||||
|
||||
PluginArchitecture architecture() override;
|
||||
boost::filesystem::path path() override;
|
||||
@@ -191,10 +189,10 @@ class GroupHost : public HostProcess {
|
||||
pid_t host_pid;
|
||||
|
||||
/**
|
||||
* The associated dispatch socket for the plugin we're hosting. This is used
|
||||
* to terminate the plugin.
|
||||
* The associated sockets for the plugin we're hosting. This is used to
|
||||
* terminate the plugin.
|
||||
*/
|
||||
boost::asio::local::stream_protocol::socket& host_vst_dispatch;
|
||||
Sockets& sockets;
|
||||
|
||||
/**
|
||||
* A thread that waits for the group host to have started and then ask it to
|
||||
|
||||
Reference in New Issue
Block a user