mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Stop accepting sockets if Wine crashes on startup
This commit is contained in:
@@ -14,6 +14,11 @@ Versioning](https://semver.org/spec/v2.0.0.html).
|
|||||||
that support individually sandboxed plugins.
|
that support individually sandboxed plugins.
|
||||||
- Respect `YABRIDGE_DEBUG_FILE` when printing initialization errors.
|
- Respect `YABRIDGE_DEBUG_FILE` when printing initialization errors.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Stop waiting for the Wine VST host process on startup if the process has
|
||||||
|
crashed or if Wine was not able to start.
|
||||||
|
|
||||||
## [1.1.0] - 2020-05-07
|
## [1.1.0] - 2020-05-07
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -134,6 +134,29 @@ PluginBridge::PluginBridge(audioMasterCallback host_callback)
|
|||||||
async_log_pipe_lines(wine_stderr, wine_stderr_buffer, "[Wine STDERR] ");
|
async_log_pipe_lines(wine_stderr, wine_stderr_buffer, "[Wine STDERR] ");
|
||||||
wine_io_handler = std::thread([&]() { io_context.run(); });
|
wine_io_handler = std::thread([&]() { io_context.run(); });
|
||||||
|
|
||||||
|
// If the Wine process fails to start, then nothing will connect to the
|
||||||
|
// sockets and we'll be hanging here indefinitely. To prevent this, we'll
|
||||||
|
// periodically poll whether the Wine process is still running, and throw
|
||||||
|
// when it is not. The alternative would be to rewrite this to using
|
||||||
|
// `async_accept`, Boost.Asio timers, and another IO context, but I feel
|
||||||
|
// like this a much simpler solution.
|
||||||
|
std::thread([&]() {
|
||||||
|
using namespace std::literals::chrono_literals;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (finished_accepting_sockets) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!vst_host.running()) {
|
||||||
|
throw std::runtime_error(
|
||||||
|
"The Wine process failed to start. Check the output above "
|
||||||
|
"for more information.");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(1s);
|
||||||
|
}
|
||||||
|
}).detach();
|
||||||
|
|
||||||
// It's very important that these sockets are connected to in the same
|
// It's very important that these sockets are connected to in the same
|
||||||
// order in the Wine VST host
|
// order in the Wine VST host
|
||||||
socket_acceptor.accept(host_vst_dispatch);
|
socket_acceptor.accept(host_vst_dispatch);
|
||||||
@@ -142,6 +165,7 @@ PluginBridge::PluginBridge(audioMasterCallback host_callback)
|
|||||||
socket_acceptor.accept(host_vst_parameters);
|
socket_acceptor.accept(host_vst_parameters);
|
||||||
socket_acceptor.accept(host_vst_process_replacing);
|
socket_acceptor.accept(host_vst_process_replacing);
|
||||||
socket_acceptor.accept(vst_host_aeffect);
|
socket_acceptor.accept(vst_host_aeffect);
|
||||||
|
finished_accepting_sockets = true;
|
||||||
|
|
||||||
// There's no need to keep the socket endpoint file around after accepting
|
// There's no need to keep the socket endpoint file around after accepting
|
||||||
// all the sockets, and RAII won't clean these files up for us
|
// all the sockets, and RAII won't clean these files up for us
|
||||||
|
|||||||
@@ -152,6 +152,15 @@ class PluginBridge {
|
|||||||
*/
|
*/
|
||||||
boost::asio::local::stream_protocol::socket vst_host_aeffect;
|
boost::asio::local::stream_protocol::socket vst_host_aeffect;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether we're done accepting sockets. The plugin may hang indefinitely if
|
||||||
|
* the Wine process fails to start, since then nothing will connect to our
|
||||||
|
* sockets. While we're waiting for our sockets we'll periodically poll the
|
||||||
|
* Wine process to see if it's still running, and terminate the socket
|
||||||
|
* accepting if it is not.
|
||||||
|
*/
|
||||||
|
std::atomic_bool finished_accepting_sockets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The thread that handles host callbacks.
|
* The thread that handles host callbacks.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user