From 359f6e29aa786b6a8eefd10a475259871f6df013 Mon Sep 17 00:00:00 2001 From: hogliux Date: Tue, 28 Jul 2015 18:11:50 +0100 Subject: [PATCH] Fix multiple warnings in VS 2015 --- .../AAX/juce_AAX_Wrapper.cpp | 2 +- .../VST/juce_VST_Wrapper.cpp | 4 +- .../VST3/juce_VST3_Wrapper.cpp | 12 +-- .../format_types/juce_VST3PluginFormat.cpp | 14 +-- .../format_types/juce_VSTPluginFormat.cpp | 18 ++-- modules/juce_core/containers/juce_HashMap.h | 2 + modules/juce_core/memory/juce_Atomic.h | 89 ++++++++++++++++--- 7 files changed, 104 insertions(+), 37 deletions(-) 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 127226b3f3..5140cf4123 100644 --- a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp @@ -333,7 +333,7 @@ struct AAXClasses { AudioProcessorEditor::ParameterControlHighlightInfo info; info.parameterIndex = getParamIndexFromID (paramID); - info.isHighlighted = isHighlighted; + info.isHighlighted = (isHighlighted != 0); info.suggestedColour = getColourFromHighlightEnum (colour); component->pluginEditor->setControlHighlight (info); 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 1a75f0f1e9..3302e983b0 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp @@ -1374,8 +1374,8 @@ public: void resized() override { - if (Component* const editor = getChildComponent(0)) - editor->setBounds (getLocalBounds()); + if (Component* const editorChildComp = getChildComponent(0)) + editorChildComp->setBounds (getLocalBounds()); #if JUCE_MAC && ! JUCE_64BIT if (! wrapper.useNSView) 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 1fb10ad55e..6eb9cb32a0 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -204,11 +204,11 @@ public: toString128 (result, owner.getParameterText (paramIndex, 128)); } - bool fromString (const Vst::TChar* text, Vst::ParamValue& valueNormalized) const override + bool fromString (const Vst::TChar* text, Vst::ParamValue& outValueNormalized) const override { if (AudioProcessorParameter* p = owner.getParameters()[paramIndex]) { - valueNormalized = p->getValueForText (getStringFromVstTChars (text)); + outValueNormalized = p->getValueForText (getStringFromVstTChars (text)); return true; } @@ -460,12 +460,12 @@ private: tresult PLUGIN_API canResize() override { return kResultTrue; } - tresult PLUGIN_API checkSizeConstraint (ViewRect* rect) override + tresult PLUGIN_API checkSizeConstraint (ViewRect* rectToCheck) override { - if (rect != nullptr && component != nullptr) + if (rectToCheck != nullptr && component != nullptr) { - rect->right = rect->left + component->getWidth(); - rect->bottom = rect->top + component->getHeight(); + rectToCheck->right = rectToCheck->left + component->getWidth(); + rectToCheck->bottom = rectToCheck->top + component->getHeight(); return kResultTrue; } diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index 4de9ec85e6..440aaedf26 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -1690,11 +1690,11 @@ public: outputArrangements.add (getArrangementForBus (processor, false, i)); } - void prepareToPlay (double sampleRate, int estimatedSamplesPerBlock) override + void prepareToPlay (double newSampleRate, int estimatedSamplesPerBlock) override { // Avoid redundantly calling things like setActive, which can be a heavy-duty call for some plugins: if (isActive - && getSampleRate() == sampleRate + && getSampleRate() == newSampleRate && getBlockSize() == estimatedSamplesPerBlock) return; @@ -1703,7 +1703,7 @@ public: ProcessSetup setup; setup.symbolicSampleSize = kSample32; setup.maxSamplesPerBlock = estimatedSamplesPerBlock; - setup.sampleRate = sampleRate; + setup.sampleRate = newSampleRate; setup.processMode = isNonRealtime() ? kOffline : kRealtime; warnOnFailure (processor->setupProcessing (setup)); @@ -1736,7 +1736,7 @@ public: // Needed for having the same sample rate in processBlock(); some plugins need this! setPlayConfigDetails (getNumSingleDirectionChannelsFor (component, true, true), getNumSingleDirectionChannelsFor (component, false, true), - sampleRate, estimatedSamplesPerBlock); + newSampleRate, estimatedSamplesPerBlock); setStateForAllBusses (true); @@ -1858,10 +1858,10 @@ public: { if (processor != nullptr) { - const double sampleRate = getSampleRate(); + const double currentSampleRate = getSampleRate(); - if (sampleRate > 0.0) - return jlimit (0, 0x7fffffff, (int) processor->getTailSamples()) / sampleRate; + if (currentSampleRate > 0.0) + return jlimit (0, 0x7fffffff, (int) processor->getTailSamples()) / currentSampleRate; } return 0.0; diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 0a88d5c569..b2a8179ecd 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -895,13 +895,13 @@ public: if (effect == nullptr) return 0.0; - const double sampleRate = getSampleRate(); + const double currentSampleRate = getSampleRate(); - if (sampleRate <= 0) + if (currentSampleRate <= 0) return 0.0; VstIntPtr samples = dispatch (effGetTailSize, 0, 0, 0, 0); - return samples / sampleRate; + return samples / currentSampleRate; } bool acceptsMidi() const override { return wantsMidiMessages; } @@ -986,10 +986,10 @@ public: if (initialised) { - if (AudioPlayHead* const playHead = getPlayHead()) + if (AudioPlayHead* const currentPlayHead = getPlayHead()) { AudioPlayHead::CurrentPositionInfo position; - if (playHead->getCurrentPosition (position)) + if (currentPlayHead->getCurrentPosition (position)) { vstHostTime.samplePos = (double) position.timeInSamples; @@ -2089,13 +2089,13 @@ public: } #endif - static bool reentrant = false; + static bool reentrantGuard = false; - if (! reentrant) + if (! reentrantGuard) { - reentrant = true; + reentrantGuard = true; plugin.dispatch (effEditIdle, 0, 0, 0, 0); - reentrant = false; + reentrantGuard = false; } #if JUCE_LINUX diff --git a/modules/juce_core/containers/juce_HashMap.h b/modules/juce_core/containers/juce_HashMap.h index cadfdac2a6..c1c0988765 100644 --- a/modules/juce_core/containers/juce_HashMap.h +++ b/modules/juce_core/containers/juce_HashMap.h @@ -46,6 +46,8 @@ struct DefaultHashFunctions int generateHash (const String& key, const int upperLimit) const noexcept { return (int) (((uint32) key.hashCode()) % (uint32) upperLimit); } /** Generates a simple hash from a variant. */ int generateHash (const var& key, const int upperLimit) const noexcept { return generateHash (key.toString(), upperLimit); } + /** Generates a simple hash from a void ptr. */ + int generateHash (const void* key, const int upperLimit) const noexcept { return (int)(((pointer_sized_uint) key) % ((pointer_sized_uint) upperLimit)); } }; diff --git a/modules/juce_core/memory/juce_Atomic.h b/modules/juce_core/memory/juce_Atomic.h index 5942094751..1ca3bde0ab 100644 --- a/modules/juce_core/memory/juce_Atomic.h +++ b/modules/juce_core/memory/juce_Atomic.h @@ -256,6 +256,77 @@ private: template static Type juce_InterlockedDecrement64 (volatile Type* a) noexcept { jassertfalse; return --*a; } #define JUCE_64BIT_ATOMICS_UNAVAILABLE 1 #endif + + template + struct WindowsInterlockedHelpersBase + {}; + + template + struct WindowsInterlockedHelpersBase + { + static inline Type exchange(volatile Type* value, Type other) noexcept + { + return castFrom (juce_InterlockedExchange (reinterpret_cast (value), castTo (other))); + } + + static inline Type add(volatile Type* value, Type other) noexcept + { + return castFrom (juce_InterlockedExchangeAdd (reinterpret_cast (value), castTo (other)) + castTo (other)); + } + + static inline Type inc(volatile Type* value) noexcept + { + return castFrom (juce_InterlockedIncrement (reinterpret_cast (value))); + } + + static inline Type dec(volatile Type* value) noexcept + { + return castFrom (juce_InterlockedDecrement (reinterpret_cast (value))); + } + + static inline Type cmp(volatile Type* value, Type other, Type comparand) noexcept + { + return castFrom (juce_InterlockedCompareExchange (reinterpret_cast (value), castTo (other), castTo (comparand))); + } + + static inline Type castFrom (long value) { union { long in; Type out; } u; u.in = value; return u.out; } + static inline long castTo (Type value) { union { Type in; long out; } u; u.in = value; return u.out; } + }; + + template + struct WindowsInterlockedHelpersBase + { + static inline Type exchange(volatile Type* value, Type other) noexcept + { + return castFrom (juce_InterlockedExchange64 (reinterpret_cast (value), castTo (other))); + } + + static inline Type add(volatile Type* value, Type other) noexcept + { + return castFrom (juce_InterlockedExchangeAdd64 (reinterpret_cast (value), castTo (other)) + castTo (other)); + } + + static inline Type inc(volatile Type* value) noexcept + { + return castFrom (juce_InterlockedIncrement64 (reinterpret_cast (value))); + } + + static inline Type dec(volatile Type* value) noexcept + { + return castFrom (juce_InterlockedDecrement64 (reinterpret_cast (value))); + } + + static inline Type cmp(volatile Type* value, Type other, Type comparand) noexcept + { + return castFrom (juce_InterlockedCompareExchange64 (reinterpret_cast (value), castTo (other), castTo (comparand))); + } + + static inline Type castFrom (__int64 value) { union { __int64 in; Type out; } u; u.in = value; return u.out; } + static inline __int64 castTo (Type value) { union { Type in; __int64 out; } u; u.in = value; return u.out; } + }; + + template + struct WindowsInterlockedHelpers : WindowsInterlockedHelpersBase {}; #endif @@ -272,8 +343,7 @@ inline Type Atomic::get() const noexcept return sizeof (Type) == 4 ? castFrom32Bit ((int32) OSAtomicAdd32Barrier ((int32_t) 0, (JUCE_MAC_ATOMICS_VOLATILE int32_t*) &value)) : castFrom64Bit ((int64) OSAtomicAdd64Barrier ((int64_t) 0, (JUCE_MAC_ATOMICS_VOLATILE int64_t*) &value)); #elif JUCE_ATOMICS_WINDOWS - return sizeof (Type) == 4 ? castFrom32Bit ((int32) juce_InterlockedExchangeAdd ((volatile long*) &value, (long) 0)) - : castFrom64Bit ((int64) juce_InterlockedExchangeAdd64 ((volatile __int64*) &value, (__int64) 0)); + return WindowsInterlockedHelpers::add (const_cast (&value), (Type) 0); #elif JUCE_ATOMICS_GCC return sizeof (Type) == 4 ? castFrom32Bit ((int32) __sync_add_and_fetch ((volatile int32*) &value, 0)) : castFrom64Bit ((int64) __sync_add_and_fetch ((volatile int64*) &value, 0)); @@ -288,8 +358,7 @@ inline Type Atomic::exchange (const Type newValue) noexcept while (! compareAndSetBool (newValue, currentVal)) { currentVal = value; } return currentVal; #elif JUCE_ATOMICS_WINDOWS - return sizeof (Type) == 4 ? castFrom32Bit ((int32) juce_InterlockedExchange ((volatile long*) &value, (long) castTo32Bit (newValue))) - : castFrom64Bit ((int64) juce_InterlockedExchange64 ((volatile __int64*) &value, (__int64) castTo64Bit (newValue))); + return WindowsInterlockedHelpers::exchange (&value, newValue); #endif } @@ -300,8 +369,7 @@ inline Type Atomic::operator+= (const Type amountToAdd) noexcept return sizeof (Type) == 4 ? (Type) OSAtomicAdd32Barrier ((int32_t) castTo32Bit (amountToAdd), (JUCE_MAC_ATOMICS_VOLATILE int32_t*) &value) : (Type) OSAtomicAdd64Barrier ((int64_t) amountToAdd, (JUCE_MAC_ATOMICS_VOLATILE int64_t*) &value); #elif JUCE_ATOMICS_WINDOWS - return sizeof (Type) == 4 ? (Type) (juce_InterlockedExchangeAdd ((volatile long*) &value, (long) amountToAdd) + (long) amountToAdd) - : (Type) (juce_InterlockedExchangeAdd64 ((volatile __int64*) &value, (__int64) amountToAdd) + (__int64) amountToAdd); + return WindowsInterlockedHelpers::add (&value, amountToAdd); #elif JUCE_ATOMICS_GCC return (Type) __sync_add_and_fetch (&value, amountToAdd); #endif @@ -320,8 +388,7 @@ inline Type Atomic::operator++() noexcept return sizeof (Type) == 4 ? (Type) OSAtomicIncrement32Barrier ((JUCE_MAC_ATOMICS_VOLATILE int32_t*) &value) : (Type) OSAtomicIncrement64Barrier ((JUCE_MAC_ATOMICS_VOLATILE int64_t*) &value); #elif JUCE_ATOMICS_WINDOWS - return sizeof (Type) == 4 ? (Type) juce_InterlockedIncrement ((volatile long*) &value) - : (Type) juce_InterlockedIncrement64 ((volatile __int64*) &value); + return WindowsInterlockedHelpers::inc (&value); #elif JUCE_ATOMICS_GCC return sizeof (Type) == 4 ? (Type) __sync_add_and_fetch (&value, (Type) 1) : (Type) __sync_add_and_fetch ((int64_t*) &value, 1); @@ -335,8 +402,7 @@ inline Type Atomic::operator--() noexcept return sizeof (Type) == 4 ? (Type) OSAtomicDecrement32Barrier ((JUCE_MAC_ATOMICS_VOLATILE int32_t*) &value) : (Type) OSAtomicDecrement64Barrier ((JUCE_MAC_ATOMICS_VOLATILE int64_t*) &value); #elif JUCE_ATOMICS_WINDOWS - return sizeof (Type) == 4 ? (Type) juce_InterlockedDecrement ((volatile long*) &value) - : (Type) juce_InterlockedDecrement64 ((volatile __int64*) &value); + return WindowsInterlockedHelpers::dec (&value); #elif JUCE_ATOMICS_GCC return sizeof (Type) == 4 ? (Type) __sync_add_and_fetch (&value, (Type) -1) : (Type) __sync_add_and_fetch ((int64_t*) &value, -1); @@ -372,8 +438,7 @@ inline Type Atomic::compareAndSetValue (const Type newValue, const Type va } #elif JUCE_ATOMICS_WINDOWS - return sizeof (Type) == 4 ? castFrom32Bit ((int32) juce_InterlockedCompareExchange ((volatile long*) &value, (long) castTo32Bit (newValue), (long) castTo32Bit (valueToCompare))) - : castFrom64Bit ((int64) juce_InterlockedCompareExchange64 ((volatile __int64*) &value, (__int64) castTo64Bit (newValue), (__int64) castTo64Bit (valueToCompare))); + return WindowsInterlockedHelpers::cmp (&value, newValue, valueToCompare); #elif JUCE_ATOMICS_GCC return sizeof (Type) == 4 ? castFrom32Bit ((int32) __sync_val_compare_and_swap ((volatile int32*) &value, castTo32Bit (valueToCompare), castTo32Bit (newValue))) : castFrom64Bit ((int64) __sync_val_compare_and_swap ((volatile int64*) &value, castTo64Bit (valueToCompare), castTo64Bit (newValue)));