mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
VST3PluginFormat: Extract headless plugin format type
This commit is contained in:
parent
6fa7b21435
commit
9c88358e46
14 changed files with 4022 additions and 3812 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,316 +0,0 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-8-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if JUCE_BSD && ! JUCE_CUSTOM_VST3_SDK
|
||||
#error To build JUCE VST3 plug-ins on BSD you must use an external BSD-compatible VST3 SDK with JUCE_CUSTOM_VST3_SDK=1
|
||||
#endif
|
||||
|
||||
// It's important to include this *before* any of the Steinberg headers.
|
||||
// On Windows, the VST3 headers might end up defining `stricmp` as `_stricmp` before including
|
||||
// <cstring> or <string.h>, which prevents the use of stricmp in JUCE source.
|
||||
#include <cstring>
|
||||
|
||||
// Wow, those Steinberg guys really don't worry too much about compiler warnings.
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_LEVEL_MSVC (0, 4505 4702 6011 6031 6221 6386 6387 6330 6001 28199)
|
||||
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-W#warnings",
|
||||
"-Wcast-align",
|
||||
"-Wclass-memaccess",
|
||||
"-Wcomma",
|
||||
"-Wconversion",
|
||||
"-Wcpp",
|
||||
"-Wdelete-non-virtual-dtor",
|
||||
"-Wdeprecated",
|
||||
"-Wdeprecated-copy-dtor",
|
||||
"-Wdeprecated-declarations",
|
||||
"-Wdeprecated-register",
|
||||
"-Wextra",
|
||||
"-Wextra-semi",
|
||||
"-Wfloat-equal",
|
||||
"-Wformat",
|
||||
"-Wformat-truncation=",
|
||||
"-Wformat=",
|
||||
"-Wignored-qualifiers",
|
||||
"-Winconsistent-missing-destructor-override",
|
||||
"-Wint-to-pointer-cast",
|
||||
"-Wlogical-op-parentheses",
|
||||
"-Wmaybe-uninitialized",
|
||||
"-Wmissing-braces",
|
||||
"-Wmissing-field-initializers",
|
||||
"-Wmissing-prototypes",
|
||||
"-Wnon-virtual-dtor",
|
||||
"-Woverloaded-virtual",
|
||||
"-Wparentheses",
|
||||
"-Wpedantic",
|
||||
"-Wpragma-pack",
|
||||
"-Wredundant-decls",
|
||||
"-Wreorder",
|
||||
"-Wshadow",
|
||||
"-Wshadow-field",
|
||||
"-Wsign-compare",
|
||||
"-Wsign-conversion",
|
||||
"-Wswitch-default",
|
||||
"-Wtype-limits",
|
||||
"-Wunsequenced",
|
||||
"-Wunused-but-set-variable",
|
||||
"-Wunused-function",
|
||||
"-Wunused-parameter",
|
||||
"-Wzero-as-null-pointer-constant",
|
||||
"-Wdangling-else",
|
||||
"-Wnontrivial-memcall")
|
||||
|
||||
#undef DEVELOPMENT
|
||||
#define DEVELOPMENT 0 // This avoids a Clang warning in Steinberg code about unused values
|
||||
|
||||
// As of at least 3.7.12 there is a bug in fplatform.h that leads to SMTG_CPP20
|
||||
// having the wrong value when the /Zc:__cplusplus is not enabled. This work
|
||||
// around prevents needing to provide that flag
|
||||
|
||||
#include <pluginterfaces/base/fplatform.h>
|
||||
|
||||
#ifdef SMTG_CPP20
|
||||
#undef SMTG_CPP20
|
||||
#define SMTG_CPP20 JUCE_CXX20_IS_AVAILABLE
|
||||
#endif
|
||||
|
||||
#if JUCE_VST3HEADERS_INCLUDE_HEADERS_ONLY
|
||||
#include <base/source/fstring.h>
|
||||
#include <pluginterfaces/base/conststringtable.h>
|
||||
#include <pluginterfaces/base/funknown.h>
|
||||
#include <pluginterfaces/base/ipluginbase.h>
|
||||
#include <pluginterfaces/base/iplugincompatibility.h>
|
||||
#include <pluginterfaces/base/ustring.h>
|
||||
#include <pluginterfaces/gui/iplugview.h>
|
||||
#include <pluginterfaces/gui/iplugviewcontentscalesupport.h>
|
||||
#include <pluginterfaces/vst/ivstattributes.h>
|
||||
#include <pluginterfaces/vst/ivstaudioprocessor.h>
|
||||
#include <pluginterfaces/vst/ivstcomponent.h>
|
||||
#include <pluginterfaces/vst/ivstcontextmenu.h>
|
||||
#include <pluginterfaces/vst/ivsteditcontroller.h>
|
||||
#include <pluginterfaces/vst/ivstevents.h>
|
||||
#include <pluginterfaces/vst/ivsthostapplication.h>
|
||||
#include <pluginterfaces/vst/ivstmessage.h>
|
||||
#include <pluginterfaces/vst/ivstmidicontrollers.h>
|
||||
#include <pluginterfaces/vst/ivstparameterchanges.h>
|
||||
#include <pluginterfaces/vst/ivstplugview.h>
|
||||
#include <pluginterfaces/vst/ivstprocesscontext.h>
|
||||
#include <pluginterfaces/vst/ivstremapparamid.h>
|
||||
#include <pluginterfaces/vst/vsttypes.h>
|
||||
#include <pluginterfaces/vst/ivstunits.h>
|
||||
#include <pluginterfaces/vst/ivstmidicontrollers.h>
|
||||
#include <pluginterfaces/vst/ivstchannelcontextinfo.h>
|
||||
#include <public.sdk/source/common/memorystream.h>
|
||||
#include <public.sdk/source/vst/utility/uid.h>
|
||||
#include <public.sdk/source/vst/utility/vst2persistence.h>
|
||||
#include <public.sdk/source/vst/vsteditcontroller.h>
|
||||
#include <public.sdk/source/vst/vstpresetfile.h>
|
||||
|
||||
#include <juce_audio_processors_headless/format_types/pslextensions/ipslviewembedding.h>
|
||||
#else
|
||||
// needed for VST_VERSION
|
||||
#include <pluginterfaces/vst/vsttypes.h>
|
||||
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX // Some of the steinberg sources don't set this before including windows.h
|
||||
#endif
|
||||
|
||||
#include <base/source/baseiids.cpp>
|
||||
#include <base/source/fbuffer.cpp>
|
||||
#include <base/source/fdebug.cpp>
|
||||
#include <base/source/fobject.cpp>
|
||||
#include <base/source/fstreamer.cpp>
|
||||
#include <base/source/fstring.cpp>
|
||||
|
||||
// The following shouldn't leak from fstring.cpp
|
||||
#undef stricmp
|
||||
#undef strnicmp
|
||||
#undef snprintf
|
||||
#undef vsnprintf
|
||||
#undef snwprintf
|
||||
#undef vsnwprintf
|
||||
|
||||
#if VST_VERSION >= 0x030608
|
||||
#include <base/thread/source/flock.cpp>
|
||||
#include <pluginterfaces/base/coreiids.cpp>
|
||||
#else
|
||||
#include <base/source/flock.cpp>
|
||||
#endif
|
||||
|
||||
#pragma push_macro ("True")
|
||||
#undef True
|
||||
#pragma push_macro ("False")
|
||||
#undef False
|
||||
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wmultichar", "-Wfour-char-constants")
|
||||
|
||||
#include <base/source/updatehandler.cpp>
|
||||
#include <pluginterfaces/base/conststringtable.cpp>
|
||||
#include <pluginterfaces/base/funknown.cpp>
|
||||
#include <pluginterfaces/base/ipluginbase.h>
|
||||
#include <pluginterfaces/base/ustring.cpp>
|
||||
#include <pluginterfaces/gui/iplugview.h>
|
||||
#include <pluginterfaces/gui/iplugviewcontentscalesupport.h>
|
||||
#include <pluginterfaces/vst/ivstchannelcontextinfo.h>
|
||||
#include <pluginterfaces/vst/ivstmidicontrollers.h>
|
||||
#include <public.sdk/source/common/commonstringconvert.cpp>
|
||||
#include <public.sdk/source/common/memorystream.cpp>
|
||||
#include <public.sdk/source/common/pluginview.cpp>
|
||||
#include <public.sdk/source/vst/hosting/hostclasses.cpp>
|
||||
#include <public.sdk/source/vst/moduleinfo/moduleinfoparser.cpp>
|
||||
#include <public.sdk/source/vst/utility/stringconvert.cpp>
|
||||
#include <public.sdk/source/vst/utility/vst2persistence.cpp>
|
||||
#include <public.sdk/source/vst/utility/uid.h>
|
||||
#include <public.sdk/source/vst/vstbus.cpp>
|
||||
#include <public.sdk/source/vst/vstcomponent.cpp>
|
||||
#include <public.sdk/source/vst/vstcomponentbase.cpp>
|
||||
#include <public.sdk/source/vst/vsteditcontroller.cpp>
|
||||
#include <public.sdk/source/vst/vstinitiids.cpp>
|
||||
#include <public.sdk/source/vst/vstparameters.cpp>
|
||||
#include <public.sdk/source/vst/vstpresetfile.cpp>
|
||||
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
|
||||
#pragma pop_macro ("True")
|
||||
#pragma pop_macro ("False")
|
||||
|
||||
#if VST_VERSION >= 0x03060c // 3.6.12
|
||||
#include <public.sdk/source/vst/hosting/pluginterfacesupport.cpp>
|
||||
#endif
|
||||
|
||||
#include <juce_audio_processors_headless/format_types/pslextensions/ipslviewembedding.h>
|
||||
|
||||
//==============================================================================
|
||||
namespace Steinberg
|
||||
{
|
||||
/** Missing IIDs */
|
||||
#if VST_VERSION < 0x03060d // 3.6.13
|
||||
DEF_CLASS_IID (IPluginBase)
|
||||
DEF_CLASS_IID (IPluginFactory)
|
||||
DEF_CLASS_IID (IPluginFactory2)
|
||||
DEF_CLASS_IID (IPluginFactory3)
|
||||
#if VST_VERSION < 0x030608
|
||||
DEF_CLASS_IID (IBStream)
|
||||
#endif
|
||||
#endif
|
||||
DEF_CLASS_IID (IPlugView)
|
||||
DEF_CLASS_IID (IPlugFrame)
|
||||
DEF_CLASS_IID (IPlugViewContentScaleSupport)
|
||||
|
||||
#if JUCE_LINUX || JUCE_BSD
|
||||
DEF_CLASS_IID (Linux::IRunLoop)
|
||||
DEF_CLASS_IID (Linux::IEventHandler)
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace Presonus
|
||||
{
|
||||
DEF_CLASS_IID (IPlugInViewEmbedding)
|
||||
}
|
||||
|
||||
#endif // JUCE_VST3HEADERS_INCLUDE_HEADERS_ONLY
|
||||
|
||||
JUCE_END_IGNORE_WARNINGS_MSVC
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
|
||||
//==============================================================================
|
||||
#if JucePlugin_Enable_ARA || JUCE_PLUGINHOST_ARA
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wpragma-pack")
|
||||
#include <ARA_API/ARAVST3.h>
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
|
||||
#if ARA_SUPPORT_VERSION_1
|
||||
#error "Unsupported ARA version - only ARA version 2 and onward are supported by the current implementation"
|
||||
#endif
|
||||
|
||||
#if ! JUCE_VST3HEADERS_INCLUDE_HEADERS_ONLY
|
||||
DEF_CLASS_IID (ARA::IPlugInEntryPoint)
|
||||
DEF_CLASS_IID (ARA::IPlugInEntryPoint2)
|
||||
DEF_CLASS_IID (ARA::IMainFactory)
|
||||
#endif
|
||||
#endif // JucePlugin_Enable_ARA || JUCE_PLUGINHOST_ARA
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
//==============================================================================
|
||||
#undef ASSERT
|
||||
#undef WARNING
|
||||
#undef PRINTSYSERROR
|
||||
#undef DEBUGSTR
|
||||
#undef DBPRT0
|
||||
#undef DBPRT1
|
||||
#undef DBPRT2
|
||||
#undef DBPRT3
|
||||
#undef DBPRT4
|
||||
#undef DBPRT5
|
||||
#undef min
|
||||
#undef max
|
||||
#undef MIN
|
||||
#undef MAX
|
||||
#undef calloc
|
||||
#undef free
|
||||
#undef malloc
|
||||
#undef realloc
|
||||
#undef NEW
|
||||
#undef NEWVEC
|
||||
#undef VERIFY
|
||||
#undef VERIFY_IS
|
||||
#undef VERIFY_NOT
|
||||
#undef META_CREATE_FUNC
|
||||
#undef CLASS_CREATE_FUNC
|
||||
#undef SINGLE_CREATE_FUNC
|
||||
#undef _META_CLASS
|
||||
#undef _META_CLASS_IFACE
|
||||
#undef _META_CLASS_SINGLE
|
||||
#undef META_CLASS
|
||||
#undef META_CLASS_IFACE
|
||||
#undef META_CLASS_SINGLE
|
||||
#undef SINGLETON
|
||||
#undef OBJ_METHODS
|
||||
#undef QUERY_INTERFACE
|
||||
#undef LICENCE_UID
|
||||
#undef BEGIN_FACTORY
|
||||
#undef DEF_CLASS
|
||||
#undef DEF_CLASS1
|
||||
#undef DEF_CLASS2
|
||||
#undef DEF_CLASS_W
|
||||
#undef END_FACTORY
|
||||
|
||||
#ifdef atomic_thread_fence
|
||||
#undef atomic_thread_fence
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -42,52 +42,9 @@ namespace juce
|
|||
|
||||
@tags{Audio}
|
||||
*/
|
||||
class JUCE_API VST3PluginFormat : public AudioPluginFormat
|
||||
class JUCE_API VST3PluginFormat : public VST3PluginFormatHeadless
|
||||
{
|
||||
public:
|
||||
/** Constructor */
|
||||
VST3PluginFormat();
|
||||
|
||||
/** Destructor */
|
||||
~VST3PluginFormat() override;
|
||||
|
||||
//==============================================================================
|
||||
/** @cond */
|
||||
/** Attempts to reload a VST3 plugin's state from some preset file data.
|
||||
|
||||
@see VSTPluginFormat::loadFromFXBFile
|
||||
*/
|
||||
[[deprecated ("Instead of using this function, use AudioPluginInstance::getExtensions() "
|
||||
"to visit the ExtensionsVisitor::VST3 struct for the instance, if it exists. "
|
||||
"Then, call ExtensionsVisitor::VST3::setPreset() to set the state using the "
|
||||
"contents of a vstpreset file.")]]
|
||||
static bool setStateFromVSTPresetFile (AudioPluginInstance*, const MemoryBlock&);
|
||||
/** @endcond */
|
||||
|
||||
//==============================================================================
|
||||
static String getFormatName() { return "VST3"; }
|
||||
String getName() const override { return getFormatName(); }
|
||||
bool canScanForPlugins() const override { return true; }
|
||||
bool isTrivialToScan() const override { return false; }
|
||||
|
||||
void findAllTypesForFile (OwnedArray<PluginDescription>&, const String& fileOrIdentifier) override;
|
||||
bool fileMightContainThisPluginType (const String& fileOrIdentifier) override;
|
||||
String getNameOfPluginFromIdentifier (const String& fileOrIdentifier) override;
|
||||
bool pluginNeedsRescanning (const PluginDescription&) override;
|
||||
StringArray searchPathsForPlugins (const FileSearchPath&, bool recursive, bool) override;
|
||||
bool doesPluginStillExist (const PluginDescription&) override;
|
||||
FileSearchPath getDefaultLocationsToSearch() override;
|
||||
void createARAFactoryAsync (const PluginDescription&, ARAFactoryCreationCallback callback) override;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
void createPluginInstance (const PluginDescription&, double initialSampleRate,
|
||||
int initialBufferSize, PluginCreationCallback) override;
|
||||
bool requiresUnblockedMessageThreadDuringCreation (const PluginDescription&) const override;
|
||||
void recursiveFileSearch (StringArray&, const File&, bool recursive);
|
||||
StringArray getLibraryPaths (const String&);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VST3PluginFormat)
|
||||
void createPluginInstance (const PluginDescription&, double, int, PluginCreationCallback) override;
|
||||
};
|
||||
|
||||
#endif // JUCE_PLUGINHOST_VST3
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
#include "juce_VST3Headers.h"
|
||||
#include "juce_VST3Utilities.h"
|
||||
#include "juce_VST3Common.h"
|
||||
#include <juce_audio_processors_headless/format_types/juce_VST3Headers.h>
|
||||
#include <juce_audio_processors_headless/format_types/juce_VST3Utilities.h>
|
||||
#include <juce_audio_processors_headless/format_types/juce_VST3Common.h>
|
||||
|
||||
namespace juce
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,264 +0,0 @@
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE framework.
|
||||
Copyright (c) Raw Material Software Limited
|
||||
|
||||
JUCE is an open source framework subject to commercial or open source
|
||||
licensing.
|
||||
|
||||
By downloading, installing, or using the JUCE framework, or combining the
|
||||
JUCE framework with any other source code, object code, content or any other
|
||||
copyrightable work, you agree to the terms of the JUCE End User Licence
|
||||
Agreement, and all incorporated terms including the JUCE Privacy Policy and
|
||||
the JUCE Website Terms of Service, as applicable, which will bind you. If you
|
||||
do not agree to the terms of these agreements, we will not license the JUCE
|
||||
framework to you, and you must discontinue the installation or download
|
||||
process and cease use of the JUCE framework.
|
||||
|
||||
JUCE End User Licence Agreement: https://juce.com/legal/juce-8-licence/
|
||||
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
|
||||
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
|
||||
|
||||
Or:
|
||||
|
||||
You may also use this code under the terms of the AGPLv3:
|
||||
https://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
|
||||
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
|
||||
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
|
||||
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/** @cond */
|
||||
namespace juce
|
||||
{
|
||||
|
||||
JUCE_BEGIN_NO_SANITIZE ("vptr")
|
||||
|
||||
//==============================================================================
|
||||
#define JUCE_DECLARE_VST3_COM_REF_METHODS \
|
||||
Steinberg::uint32 PLUGIN_API addRef() override { return (Steinberg::uint32) ++refCount; } \
|
||||
Steinberg::uint32 PLUGIN_API release() override { const int r = --refCount; if (r == 0) delete this; return (Steinberg::uint32) r; }
|
||||
|
||||
#define JUCE_DECLARE_VST3_COM_QUERY_METHODS \
|
||||
Steinberg::tresult PLUGIN_API queryInterface (const Steinberg::TUID, void** obj) override \
|
||||
{ \
|
||||
jassertfalse; \
|
||||
*obj = nullptr; \
|
||||
return Steinberg::kNotImplemented; \
|
||||
}
|
||||
|
||||
inline bool doUIDsMatch (const Steinberg::TUID a, const Steinberg::TUID b) noexcept
|
||||
{
|
||||
return std::memcmp (a, b, sizeof (Steinberg::TUID)) == 0;
|
||||
}
|
||||
|
||||
/* Holds a tresult and a pointer to an object.
|
||||
|
||||
Useful for holding intermediate results of calls to queryInterface.
|
||||
*/
|
||||
class QueryInterfaceResult
|
||||
{
|
||||
public:
|
||||
QueryInterfaceResult() = default;
|
||||
|
||||
QueryInterfaceResult (Steinberg::tresult resultIn, void* ptrIn)
|
||||
: result (resultIn), ptr (ptrIn) {}
|
||||
|
||||
bool isOk() const noexcept { return result == Steinberg::kResultOk; }
|
||||
|
||||
Steinberg::tresult extract (void** obj) const
|
||||
{
|
||||
*obj = result == Steinberg::kResultOk ? ptr : nullptr;
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
Steinberg::tresult result = Steinberg::kResultFalse;
|
||||
void* ptr = nullptr;
|
||||
};
|
||||
|
||||
/* Holds a tresult and a pointer to an object.
|
||||
|
||||
Calling InterfaceResultWithDeferredAddRef::extract() will also call addRef
|
||||
on the pointed-to object. It is expected that users will use
|
||||
InterfaceResultWithDeferredAddRef to hold intermediate results of a queryInterface
|
||||
call. When a suitable interface is found, the function can be exited with
|
||||
`return suitableInterface.extract (obj)`, which will set the obj pointer,
|
||||
add a reference to the interface, and return the appropriate result code.
|
||||
*/
|
||||
class InterfaceResultWithDeferredAddRef
|
||||
{
|
||||
public:
|
||||
InterfaceResultWithDeferredAddRef() = default;
|
||||
|
||||
template <typename Ptr>
|
||||
InterfaceResultWithDeferredAddRef (Steinberg::tresult resultIn, Ptr* ptrIn)
|
||||
: result (resultIn, ptrIn),
|
||||
addRefFn (doAddRef<Ptr>) {}
|
||||
|
||||
bool isOk() const noexcept { return result.isOk(); }
|
||||
|
||||
Steinberg::tresult extract (void** obj) const
|
||||
{
|
||||
const auto toReturn = result.extract (obj);
|
||||
|
||||
if (result.isOk() && *obj != nullptr && addRefFn != nullptr)
|
||||
addRefFn (*obj);
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Ptr>
|
||||
static void doAddRef (void* obj) { static_cast<Ptr*> (obj)->addRef(); }
|
||||
|
||||
QueryInterfaceResult result;
|
||||
void (*addRefFn) (void*) = nullptr;
|
||||
};
|
||||
|
||||
template <typename ClassType> struct UniqueBase {};
|
||||
template <typename CommonClassType, typename SourceClassType> struct SharedBase {};
|
||||
|
||||
template <typename ToTest, typename CommonClassType, typename SourceClassType>
|
||||
InterfaceResultWithDeferredAddRef testFor (ToTest& toTest,
|
||||
const Steinberg::TUID targetIID,
|
||||
SharedBase<CommonClassType, SourceClassType>)
|
||||
{
|
||||
if (! doUIDsMatch (targetIID, CommonClassType::iid))
|
||||
return {};
|
||||
|
||||
return { Steinberg::kResultOk, static_cast<CommonClassType*> (static_cast<SourceClassType*> (std::addressof (toTest))) };
|
||||
}
|
||||
|
||||
template <typename ToTest, typename ClassType>
|
||||
InterfaceResultWithDeferredAddRef testFor (ToTest& toTest,
|
||||
const Steinberg::TUID targetIID,
|
||||
UniqueBase<ClassType>)
|
||||
{
|
||||
return testFor (toTest, targetIID, SharedBase<ClassType, ClassType>{});
|
||||
}
|
||||
|
||||
template <typename ToTest>
|
||||
InterfaceResultWithDeferredAddRef testForMultiple (ToTest&, const Steinberg::TUID) { return {}; }
|
||||
|
||||
template <typename ToTest, typename Head, typename... Tail>
|
||||
InterfaceResultWithDeferredAddRef testForMultiple (ToTest& toTest, const Steinberg::TUID targetIID, Head head, Tail... tail)
|
||||
{
|
||||
const auto result = testFor (toTest, targetIID, head);
|
||||
|
||||
if (result.isOk())
|
||||
return result;
|
||||
|
||||
return testForMultiple (toTest, targetIID, tail...);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// We have to trust that Steinberg won't double-delete
|
||||
// NOLINTBEGIN(clang-analyzer-cplusplus.NewDelete)
|
||||
template <class ObjectType>
|
||||
class VSTComSmartPtr
|
||||
{
|
||||
public:
|
||||
VSTComSmartPtr() = default;
|
||||
|
||||
~VSTComSmartPtr()
|
||||
{
|
||||
if (source != nullptr)
|
||||
source->release();
|
||||
}
|
||||
|
||||
VSTComSmartPtr (const VSTComSmartPtr& other) noexcept
|
||||
: VSTComSmartPtr (other.get(), true) {}
|
||||
|
||||
template <typename Other, std::enable_if_t<! std::is_same_v<Other, ObjectType>, int> = 0>
|
||||
VSTComSmartPtr (const VSTComSmartPtr<Other>& other) noexcept
|
||||
: VSTComSmartPtr (other.get(), true) {}
|
||||
|
||||
explicit operator bool() const noexcept { return operator!= (nullptr); }
|
||||
ObjectType* get() const noexcept { return source; }
|
||||
ObjectType& operator*() const noexcept { return *source; }
|
||||
ObjectType* operator->() const noexcept { return source; }
|
||||
|
||||
VSTComSmartPtr& operator= (const VSTComSmartPtr& other)
|
||||
{
|
||||
auto p = other;
|
||||
std::swap (p.source, source);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Other, std::enable_if_t<! std::is_same_v<Other, ObjectType>, int> = 0>
|
||||
VSTComSmartPtr& operator= (const VSTComSmartPtr<Other>& other)
|
||||
{
|
||||
return operator= (VSTComSmartPtr { other });
|
||||
}
|
||||
|
||||
VSTComSmartPtr& operator= (std::nullptr_t)
|
||||
{
|
||||
return operator= (VSTComSmartPtr{});
|
||||
}
|
||||
|
||||
bool operator== (std::nullptr_t) const noexcept { return source == nullptr; }
|
||||
bool operator!= (std::nullptr_t) const noexcept { return source != nullptr; }
|
||||
|
||||
bool loadFrom (Steinberg::FUnknown* o)
|
||||
{
|
||||
*this = nullptr;
|
||||
return o != nullptr && o->queryInterface (ObjectType::iid, (void**) &source) == Steinberg::kResultOk;
|
||||
}
|
||||
|
||||
bool loadFrom (Steinberg::IPluginFactory* factory, const Steinberg::TUID& uuid)
|
||||
{
|
||||
jassert (factory != nullptr);
|
||||
*this = nullptr;
|
||||
return factory->createInstance (uuid, ObjectType::iid, (void**) &source) == Steinberg::kResultOk;
|
||||
}
|
||||
|
||||
/** Increments refcount. */
|
||||
static auto addOwner (ObjectType* t)
|
||||
{
|
||||
return VSTComSmartPtr (t, true);
|
||||
}
|
||||
|
||||
/** Does not initially increment refcount; assumes t has a positive refcount. */
|
||||
static auto becomeOwner (ObjectType* t)
|
||||
{
|
||||
return VSTComSmartPtr (t, false);
|
||||
}
|
||||
|
||||
private:
|
||||
VSTComSmartPtr (ObjectType* object, bool autoAddRef) noexcept
|
||||
: source (object)
|
||||
{
|
||||
if (source != nullptr && autoAddRef)
|
||||
source->addRef();
|
||||
}
|
||||
|
||||
ObjectType* source = nullptr;
|
||||
};
|
||||
|
||||
/** Increments refcount. */
|
||||
template <class ObjectType>
|
||||
auto addVSTComSmartPtrOwner (ObjectType* t)
|
||||
{
|
||||
return VSTComSmartPtr<ObjectType>::addOwner (t);
|
||||
}
|
||||
|
||||
/** Does not initially increment refcount; assumes t has a positive refcount. */
|
||||
template <class ObjectType>
|
||||
auto becomeVSTComSmartPtrOwner (ObjectType* t)
|
||||
{
|
||||
return VSTComSmartPtr<ObjectType>::becomeOwner (t);
|
||||
}
|
||||
|
||||
// NOLINTEND(clang-analyzer-cplusplus.NewDelete)
|
||||
|
||||
JUCE_END_NO_SANITIZE
|
||||
|
||||
} // namespace juce
|
||||
/** @endcond */
|
||||
|
|
@ -46,17 +46,17 @@
|
|||
#define JUCE_GUI_BASICS_INCLUDE_XHEADERS 1
|
||||
#define JUCE_GUI_BASICS_INCLUDE_SCOPED_THREAD_DPI_AWARENESS_SETTER 1
|
||||
#define JUCE_GRAPHICS_INCLUDE_COREGRAPHICS_HELPERS 1
|
||||
#define JUCE_VST3HEADERS_INCLUDE_HEADERS_ONLY 1
|
||||
|
||||
#include "juce_audio_processors.h"
|
||||
#include <juce_gui_extra/juce_gui_extra.h>
|
||||
|
||||
//==============================================================================
|
||||
#if (JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_VST3) && (JUCE_LINUX || JUCE_BSD)
|
||||
#if JUCE_PLUGINHOST_VST && (JUCE_LINUX || JUCE_BSD)
|
||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wvariadic-macros")
|
||||
#include <X11/Xlib.h>
|
||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
|
||||
#include <X11/Xutil.h>
|
||||
#include <sys/utsname.h>
|
||||
#undef KeyPress
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue