From 766e98b01f5a51d3b25d6e549c133048b6759ca0 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 30 Apr 2014 17:27:42 +0100 Subject: [PATCH] VST3 hosting fixes --- .../format_types/juce_VST3Common.h | 6 +++--- .../format_types/juce_VST3PluginFormat.cpp | 16 +++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_VST3Common.h b/modules/juce_audio_processors/format_types/juce_VST3Common.h index c91411cc42..a54f0e1871 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3Common.h +++ b/modules/juce_audio_processors/format_types/juce_VST3Common.h @@ -126,9 +126,9 @@ class ComSmartPtr { public: ComSmartPtr() noexcept : source (nullptr) {} - ComSmartPtr (ObjectType* object) noexcept : source (object) { if (source != nullptr) source->addRef(); } - ComSmartPtr (const ComSmartPtr& other) noexcept : source (other.source) { if (source != nullptr) source->addRef(); } - ~ComSmartPtr() { if (source != nullptr) source->release(); } + ComSmartPtr (ObjectType* object, bool autoAddRef = true) noexcept : source (object) { if (source != nullptr && autoAddRef) source->addRef(); } + ComSmartPtr (const ComSmartPtr& other) noexcept : source (other.source) { if (source != nullptr) source->addRef(); } + ~ComSmartPtr() { if (source != nullptr) source->release(); } operator ObjectType*() const noexcept { return source; } ObjectType* get() const noexcept { return source; } diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index c96b506b84..6d18bf26aa 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -1243,7 +1243,8 @@ public: VST3PluginWindow (AudioProcessor* owner, IPlugView* pluginView) : AudioProcessorEditor (owner), ComponentMovementWatcher (this), - view (pluginView), + refCount (1), + view (pluginView, false), pluginHandle (nullptr), recursiveResize (false) { @@ -1545,10 +1546,11 @@ public: Array inArrangements, outArrangements; - for (int i = 0; i < numInputAudioBusses; ++i) + // NB: Some plugins need a valid arrangement despite specifying 0 for their I/O busses + for (int i = 0; i < jmax (1, numInputAudioBusses); ++i) inArrangements.add (getArrangementForNumChannels (jmax (0, (int) getBusInfo (true, true, i).channelCount))); - for (int i = 0; i < numOutputAudioBusses; ++i) + for (int i = 0; i < jmax (1, numOutputAudioBusses); ++i) outArrangements.add (getArrangementForNumChannels (jmax (0, (int) getBusInfo (false, true, i).channelCount))); warnOnFailure (processor->setBusArrangements (inArrangements.getRawDataPointer(), numInputAudioBusses, @@ -1688,7 +1690,7 @@ public: if (getActiveEditor() != nullptr) return true; - ComSmartPtr view (tryCreatingView()); + ComSmartPtr view (tryCreatingView(), false); return view != nullptr; } @@ -2079,11 +2081,11 @@ private: Vst::BusInfo getBusInfo (bool forInput, bool forAudio, int index = 0) const { Vst::BusInfo busInfo; + busInfo.mediaType = forAudio ? Vst::kAudio : Vst::kEvent; + busInfo.direction = forInput ? Vst::kInput : Vst::kOutput; - component->getBusInfo (forAudio ? Vst::kAudio : Vst::kEvent, - forInput ? Vst::kInput : Vst::kOutput, + component->getBusInfo (busInfo.mediaType, busInfo.direction, (Steinberg::int32) index, busInfo); - return busInfo; }