mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-08 20:40:11 +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:
+12
-19
@@ -46,15 +46,17 @@ class patched_async_pipe : public boost::process::async_pipe {
|
||||
enum class PluginArchitecture { vst_32, vst_64 };
|
||||
|
||||
/**
|
||||
* Create a logger prefix based on the unique socket path for easy
|
||||
* identification. The socket path contains both the plugin's name and a unique
|
||||
* identifier.
|
||||
* Create a logger prefix based on the endpoint base directory used for the
|
||||
* sockets for easy identification. This will result in a prefix of the form
|
||||
* `[<plugin_name>-<random_id>] `.
|
||||
*
|
||||
* @param socket_path The path to the socket endpoint in use.
|
||||
* @param endpoint_base_dir A directory name generated by
|
||||
* `generate_endpoint_base()`.
|
||||
*
|
||||
* @return A prefix string for log messages.
|
||||
*/
|
||||
std::string create_logger_prefix(const boost::filesystem::path& socket_path);
|
||||
std::string create_logger_prefix(
|
||||
const boost::filesystem::path& endpoint_base_dir);
|
||||
|
||||
/**
|
||||
* Determine the architecture of a VST plugin (or rather, a .dll file) based on
|
||||
@@ -117,10 +119,11 @@ std::optional<boost::filesystem::path> find_wineprefix();
|
||||
/**
|
||||
* Generate the group socket endpoint name used based on the name of the group,
|
||||
* the Wine prefix in use and the plugin architecture. The resulting format is
|
||||
* `/tmp/yabridge-group-<group_name>-<wine_prefix_id>-<architecture>.sock`. In
|
||||
* this socket name the `wine_prefix_id` is a numerical hash based on the Wine
|
||||
* prefix in use. This way the same group name can be used for multiple Wine
|
||||
* prefixes and for both 32 and 64 bit plugins without clashes.
|
||||
* in the form
|
||||
* `/run/user/<uid>/yabridge-group-<group_name>-<wine_prefix_id>-<architecture>.sock`.
|
||||
* In this socket name the `wine_prefix_id` is a numerical hash based on the
|
||||
* Wine prefix in use. This way the same group name can be used for multiple
|
||||
* Wine prefixes and for both 32 and 64 bit plugins without clashes.
|
||||
*
|
||||
* @param group_name The name of the plugin group.
|
||||
* @param wine_prefix The name of the Wine prefix in use. This should be
|
||||
@@ -140,16 +143,6 @@ boost::filesystem::path generate_group_endpoint(
|
||||
const boost::filesystem::path& wine_prefix,
|
||||
const PluginArchitecture architecture);
|
||||
|
||||
/**
|
||||
* Generate a unique name for the Unix domain socket endpoint based on the VST
|
||||
* plugin's name. This will also generate the parent directory if it does not
|
||||
* yet exist since we're using this in the constructor's initializer list.
|
||||
*
|
||||
* @return A path to a not yet existing Unix domain socket endpoint.
|
||||
* @throw std::runtime_error If no matching .dll file could be found.
|
||||
*/
|
||||
boost::filesystem::path generate_plugin_endpoint();
|
||||
|
||||
/**
|
||||
* Return a path to this `.so` file. This can be used to find out from where
|
||||
* this link to or copy of `libyabridge.so` was loaded.
|
||||
|
||||
Reference in New Issue
Block a user