1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

VST2 Host: Avoid C-style casts of function pointers

This commit is contained in:
reuk 2024-11-18 13:32:07 +00:00
parent 6e910d8010
commit 73cb3b88ad
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -81,7 +81,7 @@ JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4355)
#endif
#ifndef JUCE_VST_WRAPPER_INVOKE_MAIN
#define JUCE_VST_WRAPPER_INVOKE_MAIN effect = module->moduleMain ((Vst2::audioMasterCallback) &audioMaster);
#define JUCE_VST_WRAPPER_INVOKE_MAIN effect = module->moduleMain (audioMaster);
#endif
#ifndef JUCE_VST_FALLBACK_HOST_NAME
@ -222,8 +222,7 @@ namespace
}
//==============================================================================
typedef Vst2::AEffect* (VSTCALLBACK *MainCall) (Vst2::audioMasterCallback);
static pointer_sized_int VSTCALLBACK audioMaster (Vst2::AEffect*, int32, int32, pointer_sized_int, void*, float);
using MainCall = Vst2::AEffect* (VSTCALLBACK*) (Vst2::audioMasterCallback);
//==============================================================================
// Change this to disable logging of various VST activities
@ -2156,6 +2155,20 @@ private:
UseResFile (module->resFileId);
#endif
constexpr Vst2::audioMasterCallback audioMaster = [] (Vst2::AEffect* eff,
Vst2::VstInt32 opcode,
Vst2::VstInt32 index,
Vst2::VstIntPtr value,
void* ptr,
float opt) -> Vst2::VstIntPtr
{
if (eff != nullptr)
if (auto* instance = (VSTPluginInstance*) (eff->resvd2))
return instance->handleCallback (opcode, index, value, ptr, opt);
return VSTPluginInstance::handleGeneralCallback (opcode, index, value, ptr, opt);
};
{
JUCE_VST_WRAPPER_INVOKE_MAIN
}
@ -3458,15 +3471,6 @@ bool VSTPluginInstance::updateSizeFromEditor ([[maybe_unused]] int w, [[maybe_un
//==============================================================================
// entry point for all callbacks from the plugin
static pointer_sized_int VSTCALLBACK audioMaster (Vst2::AEffect* effect, int32 opcode, int32 index, pointer_sized_int value, void* ptr, float opt)
{
if (effect != nullptr)
if (auto* instance = (VSTPluginInstance*) (effect->resvd2))
return instance->handleCallback (opcode, index, value, ptr, opt);
return VSTPluginInstance::handleGeneralCallback (opcode, index, value, ptr, opt);
}
//==============================================================================
VSTPluginFormat::VSTPluginFormat() {}
VSTPluginFormat::~VSTPluginFormat() {}