diff --git a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp index 9128db7017..7e64340baf 100644 --- a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp @@ -645,7 +645,7 @@ namespace AAXClasses JuceAAX_GUI& owner; #if JUCE_WINDOWS - WindowsHooks hooks; + detail::WindowsHooks hooks; #endif juce::Rectangle lastValidSize; diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index 77ca9aabc9..40d85050ff 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -1629,7 +1629,7 @@ public: bool keyPressed (const KeyPress&) override { - if (getHostType().isAbletonLive()) + if (detail::PluginUtilities::getHostType().isAbletonLive()) { static NSTimeInterval lastEventTime = 0; // check we're not recursively sending the same event NSTimeInterval eventTime = [[NSApp currentEvent] timestamp]; @@ -2575,7 +2575,7 @@ private: static int maxChannelsToProbeFor() { - return (getHostType().isLogic() ? 8 : 64); + return (detail::PluginUtilities::getHostType().isLogic() ? 8 : 64); } //============================================================================== diff --git a/modules/juce_audio_plugin_client/LV2/juce_LV2_Client.cpp b/modules/juce_audio_plugin_client/LV2/juce_LV2_Client.cpp index d89f5578a3..04f1efe7f1 100644 --- a/modules/juce_audio_plugin_client/LV2/juce_LV2_Client.cpp +++ b/modules/juce_audio_plugin_client/LV2/juce_LV2_Client.cpp @@ -777,7 +777,7 @@ private: ScopedJuceInitialiser_GUI scopedJuceInitialiser; #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer messageThread; + SharedResourcePointer messageThread; #endif std::unique_ptr processor = createProcessorInstance(); @@ -1677,7 +1677,7 @@ private: } #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer messageThread; + SharedResourcePointer messageThread; #endif LV2UI_Write_Function writeFunction; @@ -1710,7 +1710,7 @@ LV2_SYMBOL_EXPORT const LV2UI_Descriptor* lv2ui_descriptor (uint32_t index) const LV2_Feature* const* features) -> LV2UI_Handle { #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer messageThread; + SharedResourcePointer messageThread; #endif auto* plugin = findMatchingFeatureData (features, LV2_INSTANCE_ACCESS_URI); @@ -1750,7 +1750,7 @@ LV2_SYMBOL_EXPORT const LV2UI_Descriptor* lv2ui_descriptor (uint32_t index) [] (LV2UI_Handle ui) { #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer messageThread; + SharedResourcePointer messageThread; #endif JUCE_AUTORELEASEPOOL diff --git a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp index ba8d3ac105..30aaec29c1 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp @@ -125,8 +125,6 @@ namespace juce #if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE JUCE_API double getScaleFactorForWindow (HWND); #endif - - JUCE_API bool handleManufacturerSpecificVST2Opcode (int32, pointer_sized_int, void*, float); } //============================================================================== @@ -357,7 +355,7 @@ public: processor->setNonRealtime (isProcessLevelOffline()); #if JUCE_WINDOWS - if (getHostType().isWavelab()) + if (detail::PluginUtilities::getHostType().isWavelab()) { int priority = GetThreadPriority (GetCurrentThread()); @@ -552,7 +550,7 @@ public: hostCallback (&vstEffect, Vst2::audioMasterWantMidi, 0, 1, nullptr, 0); } - if (getHostType().isAbletonLive() + if (detail::PluginUtilities::getHostType().isAbletonLive() && hostCallback != nullptr && processor->getTailLengthSeconds() == std::numeric_limits::infinity()) { @@ -963,7 +961,7 @@ public: setSize (editorBounds.getWidth(), editorBounds.getHeight()); #if JUCE_WINDOWS - if (! getHostType().isReceptor()) + if (! detail::PluginUtilities::getHostType().isReceptor()) addMouseListener (this, true); #endif @@ -1105,7 +1103,7 @@ public: { auto status = host (wrapper.getAEffect(), Vst2::audioMasterCanDo, 0, 0, const_cast ("sizeWindow"), 0); - if (status == (pointer_sized_int) 1 || getHostType().isAbletonLive()) + if (status == (pointer_sized_int) 1 || detail::PluginUtilities::getHostType().isAbletonLive()) { const ScopedValueSetter resizingParentSetter (resizingParent, true); @@ -1280,7 +1278,7 @@ public: //============================================================================== #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer hostEventLoop; + SharedResourcePointer hostEventLoop; #endif //============================================================================== @@ -1294,7 +1292,7 @@ public: ::Display* display = XWindowSystem::getInstance()->getDisplay(); #elif JUCE_WINDOWS using HostWindowType = HWND; - WindowsHooks hooks; + detail::WindowsHooks hooks; #else using HostWindowType = void*; #endif @@ -1396,7 +1394,7 @@ private: // Workarounds for hosts which attempt to open editor windows on a non-GUI thread.. (Grrrr...) static void checkWhetherMessageThreadIsCorrect() { - auto host = getHostType(); + auto host = detail::PluginUtilities::getHostType(); if (host.isWavelab() || host.isCubaseBridged() || host.isPremiere()) { @@ -1592,7 +1590,7 @@ private: { checkWhetherMessageThreadIsCorrect(); #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer hostDrivenEventLoop; + SharedResourcePointer hostDrivenEventLoop; #else const MessageManagerLock mmLock; #endif @@ -1612,7 +1610,7 @@ private: { checkWhetherMessageThreadIsCorrect(); #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer hostDrivenEventLoop; + SharedResourcePointer hostDrivenEventLoop; #else const MessageManagerLock mmLock; #endif @@ -1637,7 +1635,7 @@ private: checkWhetherMessageThreadIsCorrect(); #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer hostDrivenEventLoop; + SharedResourcePointer hostDrivenEventLoop; #else const MessageManagerLock mmLock; #endif @@ -1840,7 +1838,7 @@ private: pointer_sized_int handleManufacturerSpecific (VstOpCodeArguments args) { - if (handleManufacturerSpecificVST2Opcode (args.index, args.value, args.ptr, args.opt)) + if (detail::PluginUtilities::handleManufacturerSpecificVST2Opcode (args.index, args.value, args.ptr, args.opt)) return 1; if (args.index == (int32) ByteOrder::bigEndianInt ("PreS") @@ -2004,7 +2002,7 @@ private: { checkWhetherMessageThreadIsCorrect(); #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer hostDrivenEventLoop; + SharedResourcePointer hostDrivenEventLoop; #else const MessageManagerLock mmLock; #endif @@ -2072,7 +2070,7 @@ private: pointer_sized_int handleEditIdle() { #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer hostDrivenEventLoop; + SharedResourcePointer hostDrivenEventLoop; hostDrivenEventLoop->processPendingEvents(); #endif @@ -2083,7 +2081,7 @@ private: ScopedJuceInitialiser_GUI libraryInitialiser; #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer messageThread; + SharedResourcePointer messageThread; #endif Vst2::audioMasterCallback hostCallback; @@ -2139,7 +2137,7 @@ namespace ScopedJuceInitialiser_GUI libraryInitialiser; #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer hostDrivenEventLoop; + SharedResourcePointer hostDrivenEventLoop; #endif try diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index c0388209e2..9e6757b5ab 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -308,7 +308,7 @@ private: attachedEventLoop = AttachedEventLoop (*hostRunLoops.begin(), this); } - SharedResourcePointer messageThread; + SharedResourcePointer messageThread; std::atomic refCount { 1 }; @@ -1242,8 +1242,8 @@ public: && name != nullptr && std::strcmp (name, Vst::ViewType::kEditor) == 0 && (pluginInstance->getActiveEditor() == nullptr - || getHostType().isAdobeAudition() - || getHostType().isPremiere()); + || detail::PluginUtilities::getHostType().isAdobeAudition() + || detail::PluginUtilities::getHostType().isPremiere()); if (mayCreateEditor) return new JuceVST3Editor (*this, *audioProcessor); @@ -1726,7 +1726,7 @@ private: createContentWrapperComponentIfNeeded(); #if JUCE_MAC - if (getHostType().type == PluginHostType::SteinbergCubase10) + if (detail::PluginUtilities::getHostType().type == PluginHostType::SteinbergCubase10) cubase10Workaround.reset (new Cubase10WindowResizeWorkaround (*this)); #endif } @@ -1807,7 +1807,7 @@ private: attachedToParent(); // Life's too short to faff around with wave lab - if (getHostType().isWavelab()) + if (detail::PluginUtilities::getHostType().isWavelab()) startTimer (200); return kResultTrue; @@ -1870,7 +1870,7 @@ private: tresult PLUGIN_API getSize (ViewRect* size) override { #if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE - if (getHostType().isAbletonLive() && systemWindow == nullptr) + if (detail::PluginUtilities::getHostType().isAbletonLive() && systemWindow == nullptr) return kResultFalse; #endif @@ -1936,7 +1936,7 @@ private: { bool adjustWidth = (width / height > aspectRatio); - if (getHostType().type == PluginHostType::SteinbergCubase9) + if (detail::PluginUtilities::getHostType().type == PluginHostType::SteinbergCubase9) { auto currentEditorBounds = editor->getBounds().toFloat(); @@ -1992,7 +1992,7 @@ private: { #if JUCE_WINDOWS && JUCE_WIN_PER_MONITOR_DPI_AWARE // Cubase 10 only sends integer scale factors, so correct this for fractional scales - if (getHostType().type != PluginHostType::SteinbergCubase10) + if (detail::PluginUtilities::getHostType().type != PluginHostType::SteinbergCubase10) return factor; const auto hostWindowScale = (Steinberg::IPlugViewContentScaleSupport::ScaleFactor) getScaleFactorForWindow (static_cast (systemWindow)); @@ -2137,7 +2137,7 @@ private: resizeHostWindow(); #if JUCE_LINUX || JUCE_BSD - if (getHostType().isBitwigStudio()) + if (detail::PluginUtilities::getHostType().isBitwigStudio()) repaint(); #endif @@ -2186,7 +2186,7 @@ private: owner.plugFrame->resizeView (&owner, &newSize); } - auto host = getHostType(); + auto host = detail::PluginUtilities::getHostType(); #if JUCE_MAC if (host.isWavelab() || host.isReaper() || owner.owner->blueCatPatchwork) @@ -2261,7 +2261,7 @@ private: ScopedJuceInitialiser_GUI libraryInitialiser; #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer messageThread; + SharedResourcePointer messageThread; SharedResourcePointer eventHandler; #endif @@ -2342,7 +2342,7 @@ private: StoredScaleFactor scaleFactor; #if JUCE_WINDOWS - WindowsHooks hooks; + detail::WindowsHooks hooks; #endif #endif @@ -2445,7 +2445,7 @@ public: // Constructing the underlying static object involves dynamic allocation. // This call ensures that the construction won't happen on the audio thread. - getHostType(); + detail::PluginUtilities::getHostType(); } ~JuceVST3Component() override @@ -2808,7 +2808,7 @@ public: block.setSize (static_cast (len)); // Adobe Audition CS6 hack to avoid trying to use corrupted streams: - if (getHostType().isAdobeAudition()) + if (detail::PluginUtilities::getHostType().isAdobeAudition()) if (block.getSize() >= 5 && memcmp (block.getData(), "VC2!E", 5) == 0) return false; @@ -2832,7 +2832,7 @@ public: Steinberg::int32 bytesRead = 0; auto status = state->read (buffer, (Steinberg::int32) bytesPerBlock, &bytesRead); - if (bytesRead <= 0 || (status != kResultTrue && ! getHostType().isWavelab())) + if (bytesRead <= 0 || (status != kResultTrue && ! detail::PluginUtilities::getHostType().isWavelab())) break; allData.write (buffer, static_cast (bytesRead)); @@ -2861,7 +2861,7 @@ public: if (state->seek (0, IBStream::kIBSeekSet, nullptr) == kResultTrue) { - if (! getHostType().isFruityLoops() && readFromMemoryStream (state)) + if (! detail::PluginUtilities::getHostType().isFruityLoops() && readFromMemoryStream (state)) return kResultTrue; if (readFromUnknownStream (state)) @@ -3533,7 +3533,7 @@ public: MidiEventList::toMidiBuffer (midiBuffer, *data.inputEvents); #endif - if (getHostType().isWavelab()) + if (detail::PluginUtilities::getHostType().isWavelab()) { const int numInputChans = (data.inputs != nullptr && data.inputs[0].channelBuffers32 != nullptr) ? (int) data.inputs[0].numChannels : 0; const int numOutputChans = (data.outputs != nullptr && data.outputs[0].channelBuffers32 != nullptr) ? (int) data.outputs[0].numChannels : 0; @@ -3748,7 +3748,7 @@ private: ScopedJuceInitialiser_GUI libraryInitialiser; #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer messageThread; + SharedResourcePointer messageThread; #endif std::atomic refCount { 1 }; @@ -3824,13 +3824,10 @@ DECLARE_CLASS_IID (JuceAudioProcessor, 0x0101ABAB, 0xABCDEF01, JucePlugin_Manufa DEF_CLASS_IID (JuceAudioProcessor) #if JUCE_VST3_CAN_REPLACE_VST2 - // Defined in PluginUtilities.cpp - void getUUIDForVST2ID (bool, uint8[16]); - static FUID getFUIDForVST2ID (bool forControllerUID) { TUID uuid; - getUUIDForVST2ID (forControllerUID, (uint8*) uuid); + detail::PluginUtilities::getUUIDForVST2ID (forControllerUID, (uint8*) uuid); return FUID (uuid); } const Steinberg::FUID JuceVST3Component ::iid (getFUIDForVST2ID (false)); @@ -4083,7 +4080,7 @@ struct JucePluginFactory : public IPluginFactory3 ScopedJuceInitialiser_GUI libraryInitialiser; #if JUCE_LINUX || JUCE_BSD - SharedResourcePointer messageThread; + SharedResourcePointer messageThread; #endif *obj = nullptr; diff --git a/modules/juce_audio_plugin_client/detail/juce_IncludeModuleHeaders.h b/modules/juce_audio_plugin_client/detail/juce_IncludeModuleHeaders.h index ad3b99e8a9..2388d651ce 100644 --- a/modules/juce_audio_plugin_client/detail/juce_IncludeModuleHeaders.h +++ b/modules/juce_audio_plugin_client/detail/juce_IncludeModuleHeaders.h @@ -27,19 +27,8 @@ #include -namespace juce -{ - #define Component juce::Component +#define Component juce::Component - #if JUCE_MAC - #define Point juce::Point - void repostCurrentNSEvent(); - #endif - - //============================================================================== - inline const PluginHostType& getHostType() - { - static PluginHostType hostType; - return hostType; - } -} +#if JUCE_MAC + #define Point juce::Point +#endif diff --git a/modules/juce_audio_plugin_client/detail/juce_LinuxMessageThread.h b/modules/juce_audio_plugin_client/detail/juce_LinuxMessageThread.h index 267a86fe11..062af71499 100644 --- a/modules/juce_audio_plugin_client/detail/juce_LinuxMessageThread.h +++ b/modules/juce_audio_plugin_client/detail/juce_LinuxMessageThread.h @@ -25,7 +25,7 @@ #if JUCE_LINUX || JUCE_BSD -namespace juce +namespace juce::detail { // Implemented in juce_linux_Messaging.cpp @@ -112,6 +112,6 @@ private: SharedResourcePointer messageThread; }; -} // namespace juce +} // namespace juce::detail #endif diff --git a/modules/juce_audio_plugin_client/detail/juce_PluginUtilities.cpp b/modules/juce_audio_plugin_client/detail/juce_PluginUtilities.cpp index 68d682a579..2fc19ae41f 100644 --- a/modules/juce_audio_plugin_client/detail/juce_PluginUtilities.cpp +++ b/modules/juce_audio_plugin_client/detail/juce_PluginUtilities.cpp @@ -23,134 +23,123 @@ ============================================================================== */ -#if _MSC_VER || defined (__MINGW32__) || defined (__MINGW64__) +#include + +#if JUCE_WINDOWS #include #endif -#include -#include -#include - -namespace juce +namespace juce::detail { #if JucePlugin_Build_Unity - bool juce_isRunningInUnity(); - bool juce_isRunningInUnity() { return PluginHostType::getPluginLoadedAs() == AudioProcessor::wrapperType_Unity; } +bool isRunningInUnity(); +bool isRunningInUnity() { return PluginHostType::getPluginLoadedAs() == AudioProcessor::wrapperType_Unity; } #endif -#ifndef JUCE_VST3_CAN_REPLACE_VST2 - #define JUCE_VST3_CAN_REPLACE_VST2 1 -#endif +#if VST3_REPLACEMENT_AVAILABLE -#if JucePlugin_Build_VST3 && JUCE_VST3_CAN_REPLACE_VST2 && (JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX || JUCE_BSD) - #define VST3_REPLACEMENT_AVAILABLE 1 - - // NB: Nasty old-fashioned code in here because it's copied from the Steinberg example code. - void getUUIDForVST2ID (bool forControllerUID, uint8 uuid[16]); - void getUUIDForVST2ID (bool forControllerUID, uint8 uuid[16]) - { - #if JUCE_MSVC - const auto juce_sprintf = [] (auto&& head, auto&&... tail) { sprintf_s (head, numElementsInArray (head), tail...); }; - const auto juce_strcpy = [] (auto&& head, auto&&... tail) { strcpy_s (head, numElementsInArray (head), tail...); }; - const auto juce_strcat = [] (auto&& head, auto&&... tail) { strcat_s (head, numElementsInArray (head), tail...); }; - const auto juce_sscanf = [] (auto&&... args) { sscanf_s (args...); }; - #else - const auto juce_sprintf = [] (auto&& head, auto&&... tail) { snprintf (head, (size_t) numElementsInArray (head), tail...); }; - const auto juce_strcpy = [] (auto&&... args) { strcpy (args...); }; - const auto juce_strcat = [] (auto&&... args) { strcat (args...); }; - const auto juce_sscanf = [] (auto&&... args) { sscanf (args...); }; - #endif - - char uidString[33]; - - const int vstfxid = (('V' << 16) | ('S' << 8) | (forControllerUID ? 'E' : 'T')); - char vstfxidStr[7] = { 0 }; - juce_sprintf (vstfxidStr, "%06X", vstfxid); - - juce_strcpy (uidString, vstfxidStr); - - char uidStr[9] = { 0 }; - juce_sprintf (uidStr, "%08X", JucePlugin_VSTUniqueID); - juce_strcat (uidString, uidStr); - - char nameidStr[3] = { 0 }; - const size_t len = strlen (JucePlugin_Name); - - for (size_t i = 0; i <= 8; ++i) - { - juce::uint8 c = i < len ? static_cast (JucePlugin_Name[i]) : 0; - - if (c >= 'A' && c <= 'Z') - c += 'a' - 'A'; - - juce_sprintf (nameidStr, "%02X", c); - juce_strcat (uidString, nameidStr); - } - - unsigned long p0; - unsigned int p1, p2; - unsigned int p3[8]; - - juce_sscanf (uidString, "%08lX%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X", - &p0, &p1, &p2, &p3[0], &p3[1], &p3[2], &p3[3], &p3[4], &p3[5], &p3[6], &p3[7]); - - union q0_u { - uint32 word; - uint8 bytes[4]; - } q0; - - union q1_u { - uint16 half; - uint8 bytes[2]; - } q1, q2; - - q0.word = static_cast (p0); - q1.half = static_cast (p1); - q2.half = static_cast (p2); - - // VST3 doesn't use COM compatible UUIDs on non windows platforms - #if ! JUCE_WINDOWS - q0.word = ByteOrder::swap (q0.word); - q1.half = ByteOrder::swap (q1.half); - q2.half = ByteOrder::swap (q2.half); +// NB: Nasty old-fashioned code in here because it's copied from the Steinberg example code. +void PluginUtilities::getUUIDForVST2ID (bool forControllerUID, uint8 uuid[16]) +{ + #if JUCE_MSVC + const auto juce_sprintf = [] (auto&& head, auto&&... tail) { sprintf_s (head, numElementsInArray (head), tail...); }; + const auto juce_strcpy = [] (auto&& head, auto&&... tail) { strcpy_s (head, numElementsInArray (head), tail...); }; + const auto juce_strcat = [] (auto&& head, auto&&... tail) { strcat_s (head, numElementsInArray (head), tail...); }; + const auto juce_sscanf = [] (auto&&... args) { sscanf_s (args...); }; + #else + const auto juce_sprintf = [] (auto&& head, auto&&... tail) { snprintf (head, (size_t) numElementsInArray (head), tail...); }; + const auto juce_strcpy = [] (auto&&... args) { strcpy (args...); }; + const auto juce_strcat = [] (auto&&... args) { strcat (args...); }; + const auto juce_sscanf = [] (auto&&... args) { sscanf (args...); }; #endif - for (int i = 0; i < 4; ++i) - uuid[i+0] = q0.bytes[i]; + char uidString[33]; - for (int i = 0; i < 2; ++i) - uuid[i+4] = q1.bytes[i]; + const int vstfxid = (('V' << 16) | ('S' << 8) | (forControllerUID ? 'E' : 'T')); + char vstfxidStr[7] = { 0 }; + juce_sprintf (vstfxidStr, "%06X", vstfxid); - for (int i = 0; i < 2; ++i) - uuid[i+6] = q2.bytes[i]; + juce_strcpy (uidString, vstfxidStr); - for (int i = 0; i < 8; ++i) - uuid[i+8] = static_cast (p3[i]); - } -#else - #define VST3_REPLACEMENT_AVAILABLE 0 + char uidStr[9] = { 0 }; + juce_sprintf (uidStr, "%08X", JucePlugin_VSTUniqueID); + juce_strcat (uidString, uidStr); + + char nameidStr[3] = { 0 }; + const size_t len = strlen (JucePlugin_Name); + + for (size_t i = 0; i <= 8; ++i) + { + juce::uint8 c = i < len ? static_cast (JucePlugin_Name[i]) : 0; + + if (c >= 'A' && c <= 'Z') + c += 'a' - 'A'; + + juce_sprintf (nameidStr, "%02X", c); + juce_strcat (uidString, nameidStr); + } + + unsigned long p0; + unsigned int p1, p2; + unsigned int p3[8]; + + juce_sscanf (uidString, "%08lX%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X", + &p0, &p1, &p2, &p3[0], &p3[1], &p3[2], &p3[3], &p3[4], &p3[5], &p3[6], &p3[7]); + + union q0_u { + uint32 word; + uint8 bytes[4]; + } q0; + + union q1_u { + uint16 half; + uint8 bytes[2]; + } q1, q2; + + q0.word = static_cast (p0); + q1.half = static_cast (p1); + q2.half = static_cast (p2); + + // VST3 doesn't use COM compatible UUIDs on non windows platforms + #if ! JUCE_WINDOWS + q0.word = ByteOrder::swap (q0.word); + q1.half = ByteOrder::swap (q1.half); + q2.half = ByteOrder::swap (q2.half); + #endif + + for (int i = 0; i < 4; ++i) + uuid[i+0] = q0.bytes[i]; + + for (int i = 0; i < 2; ++i) + uuid[i+4] = q1.bytes[i]; + + for (int i = 0; i < 2; ++i) + uuid[i+6] = q2.bytes[i]; + + for (int i = 0; i < 8; ++i) + uuid[i+8] = static_cast (p3[i]); +} #endif #if JucePlugin_Build_VST - bool JUCE_API handleManufacturerSpecificVST2Opcode (int32 index, pointer_sized_int value, void* ptr, float); - bool JUCE_API handleManufacturerSpecificVST2Opcode ([[maybe_unused]] int32 index, - [[maybe_unused]] pointer_sized_int value, - [[maybe_unused]] void* ptr, - float) - { - #if VST3_REPLACEMENT_AVAILABLE - if ((index == (int32) ByteOrder::bigEndianInt ("stCA") || index == (int32) ByteOrder::bigEndianInt ("stCa")) - && value == (int32) ByteOrder::bigEndianInt ("FUID") && ptr != nullptr) - { - uint8 fuid[16]; - getUUIDForVST2ID (false, fuid); - ::memcpy (ptr, fuid, 16); - return true; - } - #endif - return false; - } +bool PluginUtilities::handleManufacturerSpecificVST2Opcode ([[maybe_unused]] int32 index, + [[maybe_unused]] pointer_sized_int value, + [[maybe_unused]] void* ptr, + float) +{ + #if VST3_REPLACEMENT_AVAILABLE + if ((index == (int32) ByteOrder::bigEndianInt ("stCA") || index == (int32) ByteOrder::bigEndianInt ("stCa")) + && value == (int32) ByteOrder::bigEndianInt ("FUID") && ptr != nullptr) + { + uint8 fuid[16]; + getUUIDForVST2ID (false, fuid); + ::memcpy (ptr, fuid, 16); + return true; + } + #endif + return false; +} #endif } // namespace juce diff --git a/modules/juce_audio_plugin_client/detail/juce_PluginUtilities.h b/modules/juce_audio_plugin_client/detail/juce_PluginUtilities.h index 7269e8f09a..7e718e13d9 100644 --- a/modules/juce_audio_plugin_client/detail/juce_PluginUtilities.h +++ b/modules/juce_audio_plugin_client/detail/juce_PluginUtilities.h @@ -50,6 +50,32 @@ struct PluginUtilities { editor.addToDesktop (getDesktopFlags (editor), parent); } + + static const PluginHostType& getHostType() + { + static PluginHostType hostType; + return hostType; + } + + #ifndef JUCE_VST3_CAN_REPLACE_VST2 + #define JUCE_VST3_CAN_REPLACE_VST2 1 + #endif + + #if JucePlugin_Build_VST3 && JUCE_VST3_CAN_REPLACE_VST2 && (JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX || JUCE_BSD) + #define VST3_REPLACEMENT_AVAILABLE 1 + + static void getUUIDForVST2ID (bool forControllerUID, uint8 uuid[16]); + + #else + #define VST3_REPLACEMENT_AVAILABLE 0 + #endif + + #if JucePlugin_Build_VST + static bool handleManufacturerSpecificVST2Opcode (int32 index, + pointer_sized_int value, + void* ptr, + float); + #endif }; } // namespace juce::detail diff --git a/modules/juce_audio_plugin_client/detail/juce_VSTWindowUtilities.mm b/modules/juce_audio_plugin_client/detail/juce_VSTWindowUtilities.mm index 7e8ee6dd91..4d8a8f5aa8 100644 --- a/modules/juce_audio_plugin_client/detail/juce_VSTWindowUtilities.mm +++ b/modules/juce_audio_plugin_client/detail/juce_VSTWindowUtilities.mm @@ -36,7 +36,27 @@ namespace juce::detail { -#if ! JUCE_64BIT +#if JUCE_32BIT +class EventReposter : private CallbackMessage +{ +public: + EventReposter() : e ([[NSApp currentEvent] retain]) {} + ~EventReposter() override { [e release]; } + + static void repostCurrentNSEvent() + { + (new EventReposter())->post(); + } + +private: + void messageCallback() override + { + [NSApp postEvent: e atStart: YES]; + } + + NSEvent* e; +}; + void VSTWindowUtilities::updateEditorCompBoundsVST (Component* comp) { HIViewRef dummyView = (HIViewRef) (void*) (pointer_sized_int) @@ -302,7 +322,7 @@ bool VSTWindowUtilities::forwardCurrentKeyEventToHostVST ([[maybe_unused]] Compo { NSWindow* win = [(NSView*) comp->getWindowHandle() window]; [[win parentWindow] makeKeyWindow]; - repostCurrentNSEvent(); + EventReposter::repostCurrentNSEvent(); return true; } #endif diff --git a/modules/juce_audio_plugin_client/detail/juce_WindowsHooks.h b/modules/juce_audio_plugin_client/detail/juce_WindowsHooks.h index 4e947569e1..d9c1a6e124 100644 --- a/modules/juce_audio_plugin_client/detail/juce_WindowsHooks.h +++ b/modules/juce_audio_plugin_client/detail/juce_WindowsHooks.h @@ -25,11 +25,11 @@ #if JUCE_WINDOWS -namespace juce +namespace juce::detail { // This function is in juce_win32_Windowing.cpp -extern bool offerKeyMessageToJUCEWindow (MSG&); +bool offerKeyMessageToJUCEWindow (MSG&); static HHOOK mouseWheelHook = nullptr, keyboardHook = nullptr; static int numHookUsers = 0; @@ -102,6 +102,6 @@ struct WindowsHooks } }; -} // namespace juce +} // namespace juce::detail #endif diff --git a/modules/juce_events/messages/juce_MessageManager.cpp b/modules/juce_events/messages/juce_MessageManager.cpp index cca2d4925a..f11ec403de 100644 --- a/modules/juce_events/messages/juce_MessageManager.cpp +++ b/modules/juce_events/messages/juce_MessageManager.cpp @@ -82,7 +82,10 @@ bool MessageManager::MessageBase::post() //============================================================================== #if ! (JUCE_MAC || JUCE_IOS || JUCE_ANDROID) // implemented in platform-specific code (juce_linux_Messaging.cpp and juce_win32_Messaging.cpp) +namespace detail +{ bool dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages); +} // namespace detail class MessageManager::QuitMessage : public MessageManager::MessageBase { @@ -106,7 +109,7 @@ void MessageManager::runDispatchLoop() { JUCE_TRY { - if (! dispatchNextMessageOnSystemQueue (false)) + if (! detail::dispatchNextMessageOnSystemQueue (false)) Thread::sleep (1); } JUCE_CATCH_EXCEPTION @@ -130,7 +133,7 @@ bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) { JUCE_TRY { - if (! dispatchNextMessageOnSystemQueue (millisecondsToRunFor >= 0)) + if (! detail::dispatchNextMessageOnSystemQueue (millisecondsToRunFor >= 0)) Thread::sleep (1); } JUCE_CATCH_EXCEPTION diff --git a/modules/juce_events/native/juce_linux_Messaging.cpp b/modules/juce_events/native/juce_linux_Messaging.cpp index 69fa23943f..1564d4b520 100644 --- a/modules/juce_events/native/juce_linux_Messaging.cpp +++ b/modules/juce_events/native/juce_linux_Messaging.cpp @@ -327,6 +327,8 @@ void MessageManager::broadcastMessage (const String&) // TODO } +namespace detail +{ // this function expects that it will NEVER be called simultaneously for two concurrent threads bool dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages) { @@ -349,6 +351,7 @@ bool dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages) return true; } +} // namespace detail //============================================================================== void LinuxEventLoop::registerFdCallback (int fd, std::function readCallback, short eventMask) diff --git a/modules/juce_events/native/juce_mac_MessageManager.mm b/modules/juce_events/native/juce_mac_MessageManager.mm index e254a96760..245bed7601 100644 --- a/modules/juce_events/native/juce_mac_MessageManager.mm +++ b/modules/juce_events/native/juce_mac_MessageManager.mm @@ -459,27 +459,6 @@ void MessageManager::broadcastMessage (const String& message) userInfo: info]; } -// Special function used by some plugin classes to re-post carbon events -void repostCurrentNSEvent(); -void repostCurrentNSEvent() -{ - struct EventReposter : public CallbackMessage - { - EventReposter() : e ([[NSApp currentEvent] retain]) {} - ~EventReposter() override { [e release]; } - - void messageCallback() override - { - [NSApp postEvent: e atStart: YES]; - } - - NSEvent* e; - }; - - (new EventReposter())->post(); -} - - //============================================================================== #if JUCE_MAC struct MountedVolumeListChangeDetector::Pimpl diff --git a/modules/juce_events/native/juce_win32_Messaging.cpp b/modules/juce_events/native/juce_win32_Messaging.cpp index b970ebb134..9ac232394e 100644 --- a/modules/juce_events/native/juce_win32_Messaging.cpp +++ b/modules/juce_events/native/juce_win32_Messaging.cpp @@ -25,9 +25,14 @@ namespace juce extern HWND juce_messageWindowHandle; -#if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client && JucePlugin_Build_Unity - bool juce_isRunningInUnity(); -#endif +namespace detail +{ + #if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client && JucePlugin_Build_Unity + bool isRunningInUnity(); + #else + constexpr bool isRunningInUnity() { return false; } + #endif +} // namespace detail #if JUCE_MODULE_AVAILABLE_juce_gui_extra LRESULT juce_offerEventToActiveXControl (::MSG&); @@ -94,13 +99,11 @@ public: if (! shouldTriggerMessageQueueDispatch) return; - #if JUCE_MODULE_AVAILABLE_juce_audio_plugin_client && JucePlugin_Build_Unity - if (juce_isRunningInUnity()) + if (detail::isRunningInUnity()) { SendNotifyMessage (juce_messageWindowHandle, customMessageID, 0, 0); return; } - #endif PostMessage (juce_messageWindowHandle, customMessageID, 0, 0); } @@ -260,6 +263,9 @@ JUCE_IMPLEMENT_SINGLETON (InternalMessageQueue) const TCHAR InternalMessageQueue::messageWindowName[] = _T("JUCEWindow"); //============================================================================== +namespace detail +{ + bool dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages) { if (auto* queue = InternalMessageQueue::getInstanceWithoutCreating()) @@ -268,6 +274,8 @@ bool dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages) return false; } +} // namespace detail + bool MessageManager::postMessageToSystemQueue (MessageManager::MessageBase* const message) { if (auto* queue = InternalMessageQueue::getInstanceWithoutCreating()) diff --git a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp index ac6f1d97c4..6f320ba777 100644 --- a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp @@ -27,7 +27,10 @@ namespace juce { // Implemented in juce_win32_Messaging.cpp +namespace detail +{ bool dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages); +} // namespace detail class Win32NativeFileChooser : private Thread { @@ -77,7 +80,7 @@ public: while (isThreadRunning()) { - if (! dispatchNextMessageOnSystemQueue (true)) + if (! detail::dispatchNextMessageOnSystemQueue (true)) Thread::sleep (1); } } diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index d5b3f07c1d..d9d844c978 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -4731,8 +4731,11 @@ bool KeyPress::isKeyCurrentlyDown (const int keyCode) } // (This internal function is used by the plugin client module) +namespace detail +{ bool offerKeyMessageToJUCEWindow (MSG& m); bool offerKeyMessageToJUCEWindow (MSG& m) { return HWNDComponentPeer::offerKeyMessageToJUCEWindow (m); } +} // namespace detail //============================================================================== static DWORD getProcess (HWND hwnd)