diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index b0349f32..d242b43e 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -180,6 +180,14 @@ void Vst3Logger::log_request(bool is_host_vst, }); } +void Vst3Logger::log_request(bool is_host_vst, + const YaComponent::GetLatencySamples& request) { + log_request_base(is_host_vst, [&](auto& message) { + message << "::getLatencySamples()"; + }); +} + void Vst3Logger::log_request(bool is_host_vst, const YaPluginFactory::Construct&) { log_request_base(is_host_vst, @@ -199,6 +207,10 @@ void Vst3Logger::log_request(bool is_host_vst, const WantsConfiguration&) { }); } +void Vst3Logger::log_response(bool is_host_vst, const uint32& value) { + log_response_base(is_host_vst, [&](auto& message) { message << value; }); +} + void Vst3Logger::log_response(bool is_host_vst, const Ack&) { log_response_base(is_host_vst, [&](auto& message) { message << "ACK"; }); } diff --git a/src/common/logging/vst3.h b/src/common/logging/vst3.h index 10ff9356..813e6add 100644 --- a/src/common/logging/vst3.h +++ b/src/common/logging/vst3.h @@ -72,10 +72,12 @@ class Vst3Logger { void log_request(bool is_host_vst, const YaComponent::GetBusArrangement&); void log_request(bool is_host_vst, const YaComponent::CanProcessSampleSize&); + void log_request(bool is_host_vst, const YaComponent::GetLatencySamples&); void log_request(bool is_host_vst, const YaPluginFactory::Construct&); void log_request(bool is_host_vst, const YaPluginFactory::SetHostContext&); void log_request(bool is_host_vst, const WantsConfiguration&); + void log_response(bool is_host_vst, const uint32&); void log_response(bool is_host_vst, const Ack&); void log_response( bool is_host_vst, diff --git a/src/common/serialization/vst3.h b/src/common/serialization/vst3.h index f038cf1a..bb860cd5 100644 --- a/src/common/serialization/vst3.h +++ b/src/common/serialization/vst3.h @@ -72,6 +72,7 @@ using ControlRequest = std::variant; diff --git a/src/common/serialization/vst3/component.h b/src/common/serialization/vst3/component.h index 201ac9ee..d3ceeb63 100644 --- a/src/common/serialization/vst3/component.h +++ b/src/common/serialization/vst3/component.h @@ -522,6 +522,23 @@ class YaComponent : public Steinberg::Vst::IComponent, virtual tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override = 0; + + /** + * Message to pass through a call to + * `IAudioProcessor::getLatencySamples()` to the Wine + * plugin host. + */ + struct GetLatencySamples { + using Response = PrimitiveWrapper; + + native_size_t instance_id; + + template + void serialize(S& s) { + s.value8b(instance_id); + } + }; + virtual uint32 PLUGIN_API getLatencySamples() override = 0; virtual tresult PLUGIN_API setupProcessing(Steinberg::Vst::ProcessSetup& setup) override = 0; diff --git a/src/plugin/bridges/vst3-impls/component.cpp b/src/plugin/bridges/vst3-impls/component.cpp index 134a20f2..02fab9e8 100644 --- a/src/plugin/bridges/vst3-impls/component.cpp +++ b/src/plugin/bridges/vst3-impls/component.cpp @@ -201,9 +201,8 @@ YaComponentPluginImpl::canProcessSampleSize(int32 symbolicSampleSize) { } uint32 PLUGIN_API YaComponentPluginImpl::getLatencySamples() { - // TODO: Implement - bridge.logger.log("TODO: IAudioProcessor::getLatencySamples()"); - return 0; + return bridge.send_message( + YaComponent::GetLatencySamples{.instance_id = arguments.instance_id}); } tresult PLUGIN_API diff --git a/src/wine-host/bridges/vst3.cpp b/src/wine-host/bridges/vst3.cpp index 9ac44011..5552b96d 100644 --- a/src/wine-host/bridges/vst3.cpp +++ b/src/wine-host/bridges/vst3.cpp @@ -190,6 +190,11 @@ void Vst3Bridge::run() { .audio_processor->canProcessSampleSize( request.symbolic_sample_size); }, + [&](YaComponent::GetLatencySamples& request) + -> YaComponent::GetLatencySamples::Response { + return component_instances[request.instance_id] + .audio_processor->getLatencySamples(); + }, [&](const YaPluginFactory::Construct&) -> YaPluginFactory::Construct::Response { return YaPluginFactory::ConstructArgs(