💥 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:
Robbert van der Helm
2020-10-25 16:50:58 +01:00
parent 4b4b19bbd8
commit 4b53342514
17 changed files with 439 additions and 285 deletions
+5 -5
View File
@@ -39,7 +39,7 @@ void async_handle_events(boost::asio::steady_timer& timer, Vst2Bridge& bridge);
/**
* This is the default VST host application. It will load the specified VST2
* plugin, and then connect back to the `libyabridge.so` instace that spawned
* plugin, and then connect back to the `libyabridge.so` instance that spawned
* this over the socket.
*
* The explicit calling convention is needed to work around a bug introduced in
@@ -48,9 +48,9 @@ void async_handle_events(boost::asio::steady_timer& timer, Vst2Bridge& bridge);
int __cdecl main(int argc, char* argv[]) {
set_realtime_priority();
// We pass the name of the VST plugin .dll file to load and the Unix domain
// socket to connect to in plugin/bridge.cpp as the first two arguments of
// this process.
// We pass the name of the VST plugin .dll file to load and the base
// directory for the Unix domain socket endpoints to connect to as the first
// two arguments of this process in plugin/bridge.cpp.
if (argc < 3) {
std::cerr << "Usage: "
#ifdef __i386__
@@ -58,7 +58,7 @@ int __cdecl main(int argc, char* argv[]) {
#else
<< yabridge_individual_host_name
#endif
<< " <vst_plugin_dll> <unix_domain_socket>" << std::endl;
<< " <vst_plugin_dll> <endpoint_base_directory>" << std::endl;
return 1;
}