mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-06-23 04:17:30 +02:00
Store process setup data instead of offline flag
This is needed later when potentially reallocating the shared memory during setActive().
This commit is contained in:
@@ -1352,14 +1352,18 @@ Vst3Bridge::get_instance(size_t instance_id) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AudioShmBuffer::Config Vst3Bridge::setup_shared_audio_buffers(
|
AudioShmBuffer::Config Vst3Bridge::setup_shared_audio_buffers(
|
||||||
size_t instance_id,
|
size_t instance_id) {
|
||||||
const Steinberg::Vst::ProcessSetup& setup) {
|
|
||||||
const auto& [instance, _] = get_instance(instance_id);
|
const auto& [instance, _] = get_instance(instance_id);
|
||||||
|
// TODO: When also calling this in setActive, return a nullopt instead of
|
||||||
|
// asserting
|
||||||
|
assert(instance.process_buffers);
|
||||||
|
|
||||||
const Steinberg::IPtr<Steinberg::Vst::IComponent> component =
|
const Steinberg::IPtr<Steinberg::Vst::IComponent> component =
|
||||||
instance.interfaces.component;
|
instance.interfaces.component;
|
||||||
const Steinberg::IPtr<Steinberg::Vst::IAudioProcessor> audio_processor =
|
const Steinberg::IPtr<Steinberg::Vst::IAudioProcessor> audio_processor =
|
||||||
instance.interfaces.audio_processor;
|
instance.interfaces.audio_processor;
|
||||||
|
// TODO: When also calling this in setActive, return a nullopt instead of
|
||||||
|
// asserting
|
||||||
assert(component && audio_processor);
|
assert(component && audio_processor);
|
||||||
|
|
||||||
// We'll query the plugin for its audio bus layouts, and then create
|
// We'll query the plugin for its audio bus layouts, and then create
|
||||||
@@ -1368,7 +1372,8 @@ AudioShmBuffer::Config Vst3Bridge::setup_shared_audio_buffers(
|
|||||||
// they'll be used with pointer arithmetic in `AudioShmBuffer`).
|
// they'll be used with pointer arithmetic in `AudioShmBuffer`).
|
||||||
uint32_t current_offset = 0;
|
uint32_t current_offset = 0;
|
||||||
|
|
||||||
auto create_bus_offsets = [&](Steinberg::Vst::BusDirection direction) {
|
auto create_bus_offsets = [&, &setup = instance.process_setup](
|
||||||
|
Steinberg::Vst::BusDirection direction) {
|
||||||
const auto num_busses =
|
const auto num_busses =
|
||||||
component->getBusCount(Steinberg::Vst::kAudio, direction);
|
component->getBusCount(Steinberg::Vst::kAudio, direction);
|
||||||
|
|
||||||
@@ -1386,7 +1391,7 @@ AudioShmBuffer::Config Vst3Bridge::setup_shared_audio_buffers(
|
|||||||
|
|
||||||
for (size_t channel = 0; channel < num_channels; channel++) {
|
for (size_t channel = 0; channel < num_channels; channel++) {
|
||||||
bus_offsets[bus][channel] = current_offset;
|
bus_offsets[bus][channel] = current_offset;
|
||||||
current_offset += setup.maxSamplesPerBlock;
|
current_offset += setup->maxSamplesPerBlock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1404,7 +1409,7 @@ AudioShmBuffer::Config Vst3Bridge::setup_shared_audio_buffers(
|
|||||||
// The size of the buffer is in bytes, and it will depend on whether the
|
// The size of the buffer is in bytes, and it will depend on whether the
|
||||||
// host is going to pass 32-bit or 64-bit audio to the plugin
|
// host is going to pass 32-bit or 64-bit audio to the plugin
|
||||||
const bool double_precision =
|
const bool double_precision =
|
||||||
setup.symbolicSampleSize == Steinberg::Vst::kSample64;
|
instance.process_setup->symbolicSampleSize == Steinberg::Vst::kSample64;
|
||||||
const uint32_t buffer_size =
|
const uint32_t buffer_size =
|
||||||
current_offset * (double_precision ? sizeof(double) : sizeof(float));
|
current_offset * (double_precision ? sizeof(double) : sizeof(float));
|
||||||
|
|
||||||
@@ -1559,12 +1564,6 @@ size_t Vst3Bridge::register_object_instance(
|
|||||||
const auto& [instance, _] =
|
const auto& [instance, _] =
|
||||||
get_instance(request.instance_id);
|
get_instance(request.instance_id);
|
||||||
|
|
||||||
// See the comment in the
|
|
||||||
// `YaAudioProcessor::Process` handler
|
|
||||||
instance.is_offline_processing =
|
|
||||||
request.setup.processMode ==
|
|
||||||
Steinberg::Vst::kOffline;
|
|
||||||
|
|
||||||
const tresult result =
|
const tresult result =
|
||||||
instance.interfaces.audio_processor
|
instance.interfaces.audio_processor
|
||||||
->setupProcessing(request.setup);
|
->setupProcessing(request.setup);
|
||||||
@@ -1574,9 +1573,9 @@ size_t Vst3Bridge::register_object_instance(
|
|||||||
// This configuration can then be used on the native
|
// This configuration can then be used on the native
|
||||||
// plugin side to connect to the same shared audio
|
// plugin side to connect to the same shared audio
|
||||||
// buffers.
|
// buffers.
|
||||||
|
instance.process_setup = request.setup;
|
||||||
const AudioShmBuffer::Config audio_buffers_config =
|
const AudioShmBuffer::Config audio_buffers_config =
|
||||||
setup_shared_audio_buffers(request.instance_id,
|
setup_shared_audio_buffers(request.instance_id);
|
||||||
request.setup);
|
|
||||||
|
|
||||||
return YaAudioProcessor::SetupProcessingResponse{
|
return YaAudioProcessor::SetupProcessingResponse{
|
||||||
.result = result,
|
.result = result,
|
||||||
@@ -1636,7 +1635,9 @@ size_t Vst3Bridge::register_object_instance(
|
|||||||
auto& reconstructed = request.data.reconstruct(
|
auto& reconstructed = request.data.reconstruct(
|
||||||
instance.process_buffers_input_pointers,
|
instance.process_buffers_input_pointers,
|
||||||
instance.process_buffers_output_pointers);
|
instance.process_buffers_output_pointers);
|
||||||
if (instance.is_offline_processing) {
|
if (instance.process_setup &&
|
||||||
|
instance.process_setup->processMode ==
|
||||||
|
Steinberg::Vst::kOffline) {
|
||||||
result = main_context_
|
result = main_context_
|
||||||
.run_in_context([&instance = instance,
|
.run_in_context([&instance = instance,
|
||||||
&reconstructed]() {
|
&reconstructed]() {
|
||||||
|
|||||||
@@ -247,12 +247,15 @@ struct Vst3PluginInstance {
|
|||||||
bool is_initialized = false;
|
bool is_initialized = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the plugin instance is currently in offline processing mode or
|
* The plugin's current process setup, containing information about the
|
||||||
* not. Needed as a HACK for IK Multimedia's T-RackS 5 because those plugins
|
* buffer sizes, sample rate, and processing mode. Used for setting up
|
||||||
* will deadlock if they don't process audio from the GUI thread while doing
|
* shared memory audio buffers, and to know whether the plugin instance is
|
||||||
* offline processing.
|
* currently in offline processing mode or not. The latter is needed as a
|
||||||
|
* HACK for IK Multimedia's T-RackS 5 because those plugins will deadlock if
|
||||||
|
* they don't process audio from the GUI thread while doing offline
|
||||||
|
* processing.
|
||||||
*/
|
*/
|
||||||
bool is_offline_processing = false;
|
std::optional<Steinberg::Vst::ProcessSetup> process_setup;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -452,10 +455,11 @@ class Vst3Bridge : public HostBridge {
|
|||||||
* Sets up the shared memory audio buffers for a plugin instance plugin
|
* Sets up the shared memory audio buffers for a plugin instance plugin
|
||||||
* instance and return the configuration so the native plugin can connect to
|
* instance and return the configuration so the native plugin can connect to
|
||||||
* it as well.
|
* it as well.
|
||||||
|
*
|
||||||
|
* This uses the `Vst3PluginInstance::process_setup` field, so that needs to
|
||||||
|
* be set first or this function raise SIGABRT.
|
||||||
*/
|
*/
|
||||||
AudioShmBuffer::Config setup_shared_audio_buffers(
|
AudioShmBuffer::Config setup_shared_audio_buffers(size_t instance_id);
|
||||||
size_t instance_id,
|
|
||||||
const Steinberg::Vst::ProcessSetup& setup);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign a unique identifier to an object and add it to
|
* Assign a unique identifier to an object and add it to
|
||||||
|
|||||||
Reference in New Issue
Block a user