mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Open and close editors without realtime priority
This commit is contained in:
@@ -49,6 +49,9 @@ TODO: Add an updated screenshot with some fancy VST3-only plugins to the readme
|
|||||||
scheduling priority than other tasks. With a properly configured system GUI
|
scheduling priority than other tasks. With a properly configured system GUI
|
||||||
drawing should not affect DSP load at all, but this should help with less than
|
drawing should not affect DSP load at all, but this should help with less than
|
||||||
optimal setups some people were getting DSP load spikes with the editor open.
|
optimal setups some people were getting DSP load spikes with the editor open.
|
||||||
|
- Opening and closing plugin editors is now also no longer done with realtime
|
||||||
|
priority. This should get rid of any latency spikes during those operations,
|
||||||
|
as the this could otherwise preempt the threads that were processing audio.
|
||||||
- Changed part of the build process considering [this Wine
|
- Changed part of the build process considering [this Wine
|
||||||
bug](https://bugs.winehq.org/show_bug.cgi?id=49138). Building with Wine 5.7
|
bug](https://bugs.winehq.org/show_bug.cgi?id=49138). Building with Wine 5.7
|
||||||
and 5.8 required a change, but that change now breaks builds using Wine 6.0
|
and 5.8 required a change, but that change now breaks builds using Wine 6.0
|
||||||
|
|||||||
@@ -386,21 +386,30 @@ intptr_t Vst2Bridge::dispatch_wrapper(AEffect* plugin,
|
|||||||
// provided by the host, and let the plugin embed itself into
|
// provided by the host, and let the plugin embed itself into
|
||||||
// the Wine window
|
// the Wine window
|
||||||
const auto x11_handle = reinterpret_cast<size_t>(data);
|
const auto x11_handle = reinterpret_cast<size_t>(data);
|
||||||
|
|
||||||
|
// NOTE: Just like in the event loop, we want to run this with lower
|
||||||
|
// priority to prevent whatever operation the plugin does
|
||||||
|
// while it's loading its editor from preempting the audio
|
||||||
|
// thread.
|
||||||
|
set_realtime_priority(false);
|
||||||
Editor& editor_instance =
|
Editor& editor_instance =
|
||||||
editor.emplace(config, x11_handle, [plugin = this->plugin]() {
|
editor.emplace(config, x11_handle, [plugin = this->plugin]() {
|
||||||
plugin->dispatcher(plugin, effEditIdle, 0, 0, nullptr, 0.0);
|
plugin->dispatcher(plugin, effEditIdle, 0, 0, nullptr, 0.0);
|
||||||
});
|
});
|
||||||
|
const intptr_t result =
|
||||||
|
plugin->dispatcher(plugin, opcode, index, value,
|
||||||
|
editor_instance.get_win32_handle(), option);
|
||||||
|
set_realtime_priority(true);
|
||||||
|
|
||||||
return plugin->dispatcher(plugin, opcode, index, value,
|
return result;
|
||||||
editor_instance.get_win32_handle(),
|
|
||||||
option);
|
|
||||||
} break;
|
} break;
|
||||||
case effEditClose: {
|
case effEditClose: {
|
||||||
|
// Cleanup is handled through RAII
|
||||||
|
set_realtime_priority(false);
|
||||||
const intptr_t return_value =
|
const intptr_t return_value =
|
||||||
plugin->dispatcher(plugin, opcode, index, value, data, option);
|
plugin->dispatcher(plugin, opcode, index, value, data, option);
|
||||||
|
|
||||||
// Cleanup is handled through RAII
|
|
||||||
editor.reset();
|
editor.reset();
|
||||||
|
set_realtime_priority(true);
|
||||||
|
|
||||||
return return_value;
|
return return_value;
|
||||||
} break;
|
} break;
|
||||||
|
|||||||
@@ -552,15 +552,20 @@ void Vst3Bridge::run() {
|
|||||||
// be done in the main UI thread
|
// be done in the main UI thread
|
||||||
return main_context
|
return main_context
|
||||||
.run_in_context<tresult>([&]() {
|
.run_in_context<tresult>([&]() {
|
||||||
|
// NOTE: Just like in the event loop, we want to run
|
||||||
|
// this with lower priority to prevent whatever
|
||||||
|
// operation the plugin does while it's loading
|
||||||
|
// its editor from preempting the audio thread.
|
||||||
|
set_realtime_priority(false);
|
||||||
Editor& editor_instance =
|
Editor& editor_instance =
|
||||||
object_instances[request.owner_instance_id]
|
object_instances[request.owner_instance_id]
|
||||||
.editor.emplace(config, x11_handle);
|
.editor.emplace(config, x11_handle);
|
||||||
|
|
||||||
const tresult result =
|
const tresult result =
|
||||||
object_instances[request.owner_instance_id]
|
object_instances[request.owner_instance_id]
|
||||||
.plug_view_instance->plug_view->attached(
|
.plug_view_instance->plug_view->attached(
|
||||||
editor_instance.get_win32_handle(),
|
editor_instance.get_win32_handle(),
|
||||||
type.c_str());
|
type.c_str());
|
||||||
|
set_realtime_priority(true);
|
||||||
|
|
||||||
// Get rid of the editor again if the plugin didn't
|
// Get rid of the editor again if the plugin didn't
|
||||||
// embed itself in it
|
// embed itself in it
|
||||||
@@ -577,12 +582,14 @@ void Vst3Bridge::run() {
|
|||||||
-> YaPlugView::Removed::Response {
|
-> YaPlugView::Removed::Response {
|
||||||
return main_context
|
return main_context
|
||||||
.run_in_context<tresult>([&]() {
|
.run_in_context<tresult>([&]() {
|
||||||
|
// Cleanup is handled through RAII
|
||||||
|
set_realtime_priority(false);
|
||||||
const tresult result =
|
const tresult result =
|
||||||
object_instances[request.owner_instance_id]
|
object_instances[request.owner_instance_id]
|
||||||
.plug_view_instance->plug_view->removed();
|
.plug_view_instance->plug_view->removed();
|
||||||
|
|
||||||
object_instances[request.owner_instance_id]
|
object_instances[request.owner_instance_id]
|
||||||
.editor.reset();
|
.editor.reset();
|
||||||
|
set_realtime_priority(true);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user