Also sync VST3 audio thread scheduling priorities

The exact same thing as the last commit, but for VST3 plugins.
This commit is contained in:
Robbert van der Helm
2021-01-23 15:22:10 +01:00
parent f03b9b1497
commit d5e4424463
6 changed files with 50 additions and 10 deletions
-8
View File
@@ -19,14 +19,6 @@
#include "../../common/communication/vst2.h"
#include "../utils.h"
/**
* The interval in seconds between synchronizing the Wine plugin host's audio
* thread scheduling priority with the host's audio thread.
*
* @relates Vst2Bridge::last_audio_thread_priority_synchronization
*/
constexpr time_t audio_thread_priority_synchronization_interval = 10;
intptr_t dispatch_proxy(AEffect*, int, int, intptr_t, void*, float);
void process_proxy(AEffect*, float**, float**, int);
void process_replacing_proxy(AEffect*, float**, float**, int);
+15 -2
View File
@@ -141,10 +141,23 @@ tresult PLUGIN_API Vst3PluginProxyImpl::setProcessing(TBool state) {
tresult PLUGIN_API
Vst3PluginProxyImpl::process(Steinberg::Vst::ProcessData& data) {
// We'll synchronize the scheduling priority of the audio thread on the Wine
// plugin host with that of the host's audio thread every once in a while
std::optional<int> new_realtime_priority = std::nullopt;
time_t now = std::time(nullptr);
if (now > last_audio_thread_priority_synchronization +
audio_thread_priority_synchronization_interval) {
new_realtime_priority = get_realtime_priority();
last_audio_thread_priority_synchronization = now;
}
// TODO: Check whether reusing a `YaProcessData` object make a difference in
// terms of performance
ProcessResponse response = bridge.send_audio_processor_message(
YaAudioProcessor::Process{.instance_id = instance_id(), .data = data});
ProcessResponse response =
bridge.send_audio_processor_message(YaAudioProcessor::Process{
.instance_id = instance_id(),
.data = data,
.new_realtime_priority = new_realtime_priority});
response.output_data.write_back_outputs(data);
@@ -375,6 +375,13 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy {
*/
Steinberg::IPtr<Steinberg::FUnknown> host_context;
/**
* We'll periodically synchronize the Wine host's audio thread priority with
* that of the host. Since the overhead from doing so does add up, we'll
* only do this every once in a while.
*/
time_t last_audio_thread_priority_synchronization = 0;
/**
* Used to assign unique identifiers to context menus created by
* `IComponentHandler3::CreateContextMenu`.