mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Make realtime priority setting more granular
On the plugin side.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <future>
|
||||
#include <iomanip>
|
||||
|
||||
// Generated inside of the build directory
|
||||
@@ -88,8 +89,12 @@ class PluginBridge {
|
||||
info.windows_plugin_path.string(),
|
||||
.endpoint_base_dir =
|
||||
sockets.base_dir.string()}))),
|
||||
has_realtime_priority(set_realtime_priority(true)),
|
||||
wine_io_handler([&]() { io_context.run(); }) {}
|
||||
has_realtime_priority(has_realtime_priority_promise.get_future()),
|
||||
wine_io_handler([&]() {
|
||||
has_realtime_priority_promise.set_value(
|
||||
set_realtime_priority(true));
|
||||
io_context.run();
|
||||
}) {}
|
||||
|
||||
virtual ~PluginBridge(){};
|
||||
|
||||
@@ -108,8 +113,9 @@ class PluginBridge {
|
||||
<< "'" << std::endl;
|
||||
init_msg << "plugin type: '" << plugin_type_to_string(info.plugin_type)
|
||||
<< "'" << std::endl;
|
||||
init_msg << "realtime: '" << (has_realtime_priority ? "yes" : "no")
|
||||
<< "'" << std::endl;
|
||||
init_msg << "realtime: '"
|
||||
<< (has_realtime_priority.get() ? "yes" : "no") << "'"
|
||||
<< std::endl;
|
||||
init_msg << "sockets: '" << sockets.base_dir.string() << "'"
|
||||
<< std::endl;
|
||||
init_msg << "wine prefix: '";
|
||||
@@ -300,12 +306,19 @@ class PluginBridge {
|
||||
*/
|
||||
std::unique_ptr<HostProcess> plugin_host;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Whether this process runs with realtime priority. We'll set this _after_
|
||||
* spawning the Wine process because from my testing running wineserver with
|
||||
* realtime priority can actually increase latency.
|
||||
* The promise belonging to `has_realtime_priority` below.
|
||||
*/
|
||||
bool has_realtime_priority;
|
||||
std::promise<bool> has_realtime_priority_promise;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Whether this process runs with realtime priority. This is set on the
|
||||
* thread that's relaying STDOUT and STDERR output from Wine, hence the need
|
||||
* for a future.
|
||||
*/
|
||||
std::future<bool> has_realtime_priority;
|
||||
|
||||
/**
|
||||
* Runs the Boost.Asio `io_context` thread for logging the Wine process
|
||||
|
||||
@@ -72,6 +72,8 @@ Vst2PluginBridge::Vst2PluginBridge(audioMasterCallback host_callback)
|
||||
// instead of asynchronous IO since communication has to be handled in
|
||||
// lockstep anyway
|
||||
host_callback_handler = std::jthread([&]() {
|
||||
set_realtime_priority(true);
|
||||
|
||||
sockets.vst_host_callback.receive_events(
|
||||
std::pair<Vst2Logger&, bool>(logger, false),
|
||||
[&](Event& event, bool /*on_main_thread*/) {
|
||||
|
||||
@@ -244,6 +244,8 @@ class Vst3PlugViewProxyImpl : public Vst3PlugViewProxy {
|
||||
// to from this thread
|
||||
std::promise<TResponse> response_promise{};
|
||||
std::jthread sending_thread([&]() {
|
||||
set_realtime_priority(true);
|
||||
|
||||
const TResponse response = bridge.send_message(object);
|
||||
|
||||
// Stop accepting additional work to be run from the calling thread
|
||||
|
||||
@@ -47,6 +47,8 @@ Vst3PluginBridge::Vst3PluginBridge()
|
||||
// first thing, the Wine VST host will ask us for a copy of the
|
||||
// configuration.
|
||||
host_callback_handler = std::jthread([&]() {
|
||||
set_realtime_priority(true);
|
||||
|
||||
sockets.vst_host_callback.receive_messages(
|
||||
std::pair<Vst3Logger&, bool>(logger, false),
|
||||
overload{
|
||||
|
||||
Reference in New Issue
Block a user