mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-21 01:24:21 +00:00
VST Host: Correctly retrieve results of effGetSpeakerArrangement
The plugin should interpret the arguments as VstSpeakerArrangement** instances. It should modify the pointed-to VstSpeakerArrangement* so that it points to a long-lived VstSpeakerArrangement in the plugin.
This commit is contained in:
parent
a1337a3863
commit
36653e8b30
1 changed files with 25 additions and 20 deletions
|
|
@ -2186,20 +2186,14 @@ private:
|
|||
(pointer_sized_int) &canonicalIn.get(), (void*) &canonicalOut.get(), 0.0f);
|
||||
}
|
||||
|
||||
HeapBlock<Vst2::VstSpeakerArrangement> inArrBlock (1, true), outArrBlock (1, true);
|
||||
|
||||
auto* inArr = inArrBlock.get();
|
||||
auto* outArr = outArrBlock.get();
|
||||
|
||||
if (! getSpeakerArrangementWrapper (effect, inArr, outArr))
|
||||
inArr = outArr = nullptr;
|
||||
const auto arrangement = getSpeakerArrangementWrapper (effect);
|
||||
|
||||
for (int dir = 0; dir < 2; ++dir)
|
||||
{
|
||||
const bool isInput = (dir == 0);
|
||||
const int opcode = (isInput ? Vst2::effGetInputProperties : Vst2::effGetOutputProperties);
|
||||
const int maxChannels = (isInput ? effect->numInputs : effect->numOutputs);
|
||||
const Vst2::VstSpeakerArrangement* arr = (isInput ? inArr : outArr);
|
||||
const auto* arr = (isInput ? arrangement.in : arrangement.out);
|
||||
bool busAdded = false;
|
||||
|
||||
Vst2::VstPinProperties pinProps;
|
||||
|
|
@ -2250,12 +2244,7 @@ private:
|
|||
|
||||
static bool pluginHasDefaultChannelLayouts (Vst2::AEffect* effect)
|
||||
{
|
||||
HeapBlock<Vst2::VstSpeakerArrangement> inArrBlock (1, true), outArrBlock (1, true);
|
||||
|
||||
auto* inArr = inArrBlock.get();
|
||||
auto* outArr = outArrBlock.get();
|
||||
|
||||
if (getSpeakerArrangementWrapper (effect, inArr, outArr))
|
||||
if (getSpeakerArrangementWrapper (effect).isValid())
|
||||
return true;
|
||||
|
||||
for (int dir = 0; dir < 2; ++dir)
|
||||
|
|
@ -2283,19 +2272,35 @@ private:
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool getSpeakerArrangementWrapper (Vst2::AEffect* effect,
|
||||
Vst2::VstSpeakerArrangement* inArr,
|
||||
Vst2::VstSpeakerArrangement* outArr)
|
||||
struct SpeakerArrangements
|
||||
{
|
||||
const Vst2::VstSpeakerArrangement* in;
|
||||
const Vst2::VstSpeakerArrangement* out;
|
||||
|
||||
bool isValid() const noexcept { return in != nullptr && out != nullptr; }
|
||||
};
|
||||
|
||||
static SpeakerArrangements getSpeakerArrangementWrapper (Vst2::AEffect* effect)
|
||||
{
|
||||
// Workaround: unfortunately old JUCE VST-2 plug-ins had a bug and would crash if
|
||||
// you try to get the speaker arrangement when there are no input channels present.
|
||||
// Hopefully, one day (when there are no more old JUCE plug-ins around), we can
|
||||
// comment out the next two lines.
|
||||
if (effect->numInputs == 0)
|
||||
return false;
|
||||
return { nullptr, nullptr };
|
||||
|
||||
return (effect->dispatcher (effect, Vst2::effGetSpeakerArrangement, 0,
|
||||
reinterpret_cast<pointer_sized_int> (&inArr), &outArr, 0.0f) != 0);
|
||||
SpeakerArrangements result;
|
||||
const auto dispatchResult = effect->dispatcher (effect,
|
||||
Vst2::effGetSpeakerArrangement,
|
||||
0,
|
||||
reinterpret_cast<pointer_sized_int> (&result.in),
|
||||
&result.out,
|
||||
0.0f);
|
||||
|
||||
if (dispatchResult != 0)
|
||||
return result;
|
||||
|
||||
return { nullptr, nullptr };
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue