mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Only initialize VST2 audio buffers on activation
Ardour apparently always calls `effMainsChanged()` with a value argument of 0 when unloading the plugin, regardless of whether it has actually initialized audio processing before that point.
This commit is contained in:
@@ -227,8 +227,16 @@ class DispatchDataConverter : public DefaultDataConverter {
|
|||||||
break;
|
break;
|
||||||
case effMainsChanged:
|
case effMainsChanged:
|
||||||
// At this point we'll set up our audio buffers since we (in
|
// At this point we'll set up our audio buffers since we (in
|
||||||
// theory) now know how large they need to be
|
// theory) now know how large they need to be. A value argument
|
||||||
return WantsAudioShmBufferConfig{};
|
// of 1 means that audio playback should be initialized.
|
||||||
|
// NOTE: Ardour unconditionally calls this with a value of 0
|
||||||
|
// unconditionally when unloading a plugin, even if it has
|
||||||
|
// never initialized audio playback
|
||||||
|
if (value == 1) {
|
||||||
|
return WantsAudioShmBufferConfig{};
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
case effEditGetRect:
|
case effEditGetRect:
|
||||||
return WantsVstRect();
|
return WantsVstRect();
|
||||||
break;
|
break;
|
||||||
@@ -367,12 +375,14 @@ class DispatchDataConverter : public DefaultDataConverter {
|
|||||||
update_aeffect(plugin, updated_plugin);
|
update_aeffect(plugin, updated_plugin);
|
||||||
} break;
|
} break;
|
||||||
case effMainsChanged: {
|
case effMainsChanged: {
|
||||||
const auto& audio_buffer_config =
|
if (const auto* audio_buffer_config =
|
||||||
std::get<AudioShmBuffer::Config>(response.payload);
|
std::get_if<AudioShmBuffer::Config>(
|
||||||
if (!process_buffers) {
|
&response.payload)) {
|
||||||
process_buffers.emplace(audio_buffer_config);
|
if (!process_buffers) {
|
||||||
} else {
|
process_buffers.emplace(*audio_buffer_config);
|
||||||
process_buffers->resize(audio_buffer_config);
|
} else {
|
||||||
|
process_buffers->resize(*audio_buffer_config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case effEditGetRect: {
|
case effEditGetRect: {
|
||||||
|
|||||||
@@ -470,7 +470,11 @@ void Vst2Bridge::run() {
|
|||||||
// the same buffers. We cannot use `Vst2Bridge::dispatch_wrapper()`
|
// the same buffers. We cannot use `Vst2Bridge::dispatch_wrapper()`
|
||||||
// for this because we need to directly return payload data that
|
// for this because we need to directly return payload data that
|
||||||
// won't be visible to the plugin at all.
|
// won't be visible to the plugin at all.
|
||||||
if (event.opcode == effMainsChanged) {
|
// NOTE: Ardour will call `effMainsChanged()` with a value of 1
|
||||||
|
// unconditionally when unloading a plugin, even when audio
|
||||||
|
// playback has never been initialized (and `effSetBlockSize`
|
||||||
|
// has never been called)
|
||||||
|
if (event.opcode == effMainsChanged && event.value == 1) {
|
||||||
// Returning another result this way is a bit ugly, but sadly
|
// Returning another result this way is a bit ugly, but sadly
|
||||||
// optimizations have never made code nicer to read
|
// optimizations have never made code nicer to read
|
||||||
return Vst2EventResult{.return_value = result.return_value,
|
return Vst2EventResult{.return_value = result.return_value,
|
||||||
|
|||||||
Reference in New Issue
Block a user