Allow resizing shared memory buffers in setActive

REAPER apparently changes bus arrangements between
`IAudioProcessor::setupProcessing()` and `IAudioProcessor::setActive()`.
This commit is contained in:
Robbert van der Helm
2022-05-18 17:46:51 +02:00
parent 5d9029d839
commit dedcdefebf
8 changed files with 95 additions and 20 deletions
+13
View File
@@ -1897,6 +1897,19 @@ void Vst3Logger::log_response(
});
}
void Vst3Logger::log_response(bool is_host_vst,
const YaComponent::SetActiveResponse& response) {
log_response_base(is_host_vst, [&](auto& message) {
message << response.result.string();
if (response.result == Steinberg::kResultOk &&
response.updated_audio_buffers_config) {
message << ", <new shared memory configuration for \""
<< response.updated_audio_buffers_config->name << "\", "
<< response.updated_audio_buffers_config->size << " bytes>";
}
});
}
void Vst3Logger::log_response(
bool is_host_vst,
const YaPrefetchableSupport::GetPrefetchableSupportResponse& response) {
+1
View File
@@ -319,6 +319,7 @@ class Vst3Logger {
bool from_cache = false);
void log_response(bool is_host_vst,
const YaComponent::GetRoutingInfoResponse&);
void log_response(bool is_host_vst, const YaComponent::SetActiveResponse&);
void log_response(
bool is_host_vst,
const YaPrefetchableSupport::GetPrefetchableSupportResponse&);
@@ -194,6 +194,11 @@ class YaAudioProcessor : public Steinberg::Vst::IAudioProcessor {
/**
* Message to pass through a call to
* `IAudioProcessor::setupProcessing(setup)` to the Wine plugin host.
*
* Here Wine plugin host will set up the shared memory buffers.
*
* NOTE: This process is repeated as part of `SetActive`. Apparently REAPER
* can change bus arrangements after the processing has been set up.
*/
struct SetupProcessing {
using Response = SetupProcessingResponse;
@@ -18,6 +18,7 @@
#include <pluginterfaces/vst/ivstcomponent.h>
#include "../../../audio-shm.h"
#include "../../../bitsery/ext/in-place-optional.h"
#include "../../common.h"
#include "../base.h"
@@ -251,12 +252,32 @@ class YaComponent : public Steinberg::Vst::IComponent {
int32 index,
TBool state) override = 0;
/**
* The response code and written state for a call to
* `IAudioProcessor::setupProcessing(setup)`.
*/
struct SetActiveResponse {
UniversalTResult result;
std::optional<AudioShmBuffer::Config> updated_audio_buffers_config;
template <typename S>
void serialize(S& s) {
s.object(result);
s.ext(updated_audio_buffers_config,
bitsery::ext::InPlaceOptional{});
}
};
/**
* Message to pass through a call to `IComponent::setActive(state)` to the
* Wine plugin host.
*
* NOTE: REAPER may change a plugin's bus arrangements after the processing
* has been set up, so we need to check for this on every
* `setActive()` call
*/
struct SetActive {
using Response = UniversalTResult;
using Response = SetActiveResponse;
native_size_t instance_id;