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

Fixed some g++ compiler warnings

This commit is contained in:
tpoole 2017-08-29 14:47:04 +01:00
parent 35facc3656
commit 9b687968db
19 changed files with 198 additions and 280 deletions

View file

@ -309,7 +309,7 @@ void AudioDataConverters::convertInt24BEToFloat (const void* const source, float
void AudioDataConverters::convertInt32LEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
{
const float scale = 1.0f / 0x7fffffff;
const auto scale = 1.0f / (float) 0x7fffffff;
const char* intData = static_cast<const char*> (source);
if (source != (void*) dest || srcBytesPerSample >= 4)
@ -334,7 +334,7 @@ void AudioDataConverters::convertInt32LEToFloat (const void* const source, float
void AudioDataConverters::convertInt32BEToFloat (const void* const source, float* const dest, int numSamples, const int srcBytesPerSample)
{
const float scale = 1.0f / 0x7fffffff;
const auto scale = 1.0f / (float) 0x7fffffff;
const char* intData = static_cast<const char*> (source);
if (source != (void*) dest || srcBytesPerSample >= 4)

View file

@ -629,7 +629,7 @@ public:
jassert (isPositiveAndBelow (channel, numChannels));
jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
const auto increment = (endGain - startGain) / numSamples;
const auto increment = (endGain - startGain) / (float) numSamples;
auto* d = channels[channel] + startSample;
while (--numSamples >= 0)

View file

@ -874,7 +874,7 @@ void JUCE_CALLTYPE FloatVectorOperations::convertFixedToFloat (float* dest, cons
vmulq_n_f32 (vcvtq_f32_s32 (vld1q_s32 (src)), multiplier),
JUCE_LOAD_NONE, JUCE_INCREMENT_SRC_DEST, )
#else
JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = src[i] * multiplier,
JUCE_PERFORM_VEC_OP_SRC_DEST (dest[i] = (float) src[i] * multiplier,
Mode::mul (mult, _mm_cvtepi32_ps (_mm_loadu_si128 ((const __m128i*) src))),
JUCE_LOAD_NONE, JUCE_INCREMENT_SRC_DEST,
const Mode::ParallelType mult = Mode::load1 (multiplier);)
@ -1158,7 +1158,7 @@ public:
static void convertFixed (float* d, const int* s, ValueType multiplier, int num)
{
while (--num >= 0)
*d++ = *s++ * multiplier;
*d++ = (float) *s++ * multiplier;
}
static bool areAllValuesEqual (const ValueType* d, int num, ValueType target)

View file

@ -34,7 +34,7 @@ namespace MidiBufferHelpers
inline uint16 getEventTotalSize (const void* const d) noexcept
{
return getEventDataSize (d) + sizeof (int32) + sizeof (uint16);
return (uint16) (getEventDataSize (d) + sizeof (int32) + sizeof (uint16));
}
static int findActualEventLength (const uint8* const data, const int maxBytes) noexcept

View file

@ -929,7 +929,7 @@ void AudioDeviceManager::LevelMeter::updateLevel (const float* const* channelDat
for (int i = 0; i < numChannels; ++i)
s += std::abs (channelData[i][j]);
s /= numChannels;
s /= (float) numChannels;
const double decayFactor = 0.99992;

View file

@ -137,7 +137,7 @@ public:
numBytes -= numSent;
data += numSent;
snd_seq_ev_set_source (&event, portId);
snd_seq_ev_set_source (&event, (unsigned char) portId);
snd_seq_ev_set_subs (&event);
snd_seq_ev_set_direct (&event);

View file

@ -159,7 +159,7 @@ void AudioTransportSource::setPosition (double newPosition)
double AudioTransportSource::getCurrentPosition() const
{
if (sampleRate > 0.0)
return getNextReadPosition() / sampleRate;
return (double) getNextReadPosition() / sampleRate;
return 0.0;
}
@ -167,7 +167,7 @@ double AudioTransportSource::getCurrentPosition() const
double AudioTransportSource::getLengthInSeconds() const
{
if (sampleRate > 0.0)
return getTotalLength() / sampleRate;
return (double) getTotalLength() / sampleRate;
return 0.0;
}
@ -177,7 +177,7 @@ void AudioTransportSource::setNextReadPosition (int64 newPosition)
if (positionableSource != nullptr)
{
if (sampleRate > 0 && sourceSampleRate > 0)
newPosition = (int64) (newPosition * sourceSampleRate / sampleRate);
newPosition = (int64) ((double) newPosition * sourceSampleRate / sampleRate);
positionableSource->setNextReadPosition (newPosition);
@ -193,7 +193,7 @@ int64 AudioTransportSource::getNextReadPosition() const
if (positionableSource != nullptr)
{
const double ratio = (sampleRate > 0 && sourceSampleRate > 0) ? sampleRate / sourceSampleRate : 1.0;
return (int64) (positionableSource->getNextReadPosition() * ratio);
return (int64) ((double) positionableSource->getNextReadPosition() * ratio);
}
return 0;
@ -206,7 +206,7 @@ int64 AudioTransportSource::getTotalLength() const
if (positionableSource != nullptr)
{
const double ratio = (sampleRate > 0 && sourceSampleRate > 0) ? sampleRate / sourceSampleRate : 1.0;
return (int64) (positionableSource->getTotalLength() * ratio);
return (int64) ((double) positionableSource->getTotalLength() * ratio);
}
return 0;

View file

@ -161,7 +161,7 @@ extern "C" {
int flac_snprintf(char *str, size_t size, const char *fmt, ...);
int flac_vsnprintf(char *str, size_t size, const char *fmt, va_list va);
#ifdef __cplusplus
};
}
#endif
#endif /* FLAC__SHARE__COMPAT_H */

View file

@ -892,7 +892,7 @@ namespace WavFileHelpers
return xml.getMemoryBlock();
}
};
}
//==============================================================================
struct ExtensibleWavSubFormat

View file

@ -38,7 +38,7 @@
#endif
#else
JUCE_CREATE_APPLICATION_DEFINE(StandaloneFilterApp);
JUCE_CREATE_APPLICATION_DEFINE(StandaloneFilterApp)
#endif
JUCE_MAIN_FUNCTION_DEFINITION

View file

@ -228,38 +228,8 @@ static pointer_sized_int VSTINTERFACECALL audioMaster (VstEffectInterface*, int3
namespace
{
static bool xErrorTriggered = false;
static int temporaryErrorHandler (::Display*, XErrorEvent*)
{
xErrorTriggered = true;
return 0;
}
typedef void (*EventProcPtr) (XEvent* ev);
static EventProcPtr getPropertyFromXWindow (Window handle, Atom atom)
{
XErrorHandler oldErrorHandler = XSetErrorHandler (temporaryErrorHandler);
xErrorTriggered = false;
int userSize;
unsigned long bytes, userCount;
unsigned char* data;
Atom userType;
{
ScopedXDisplay xDisplay;
XGetWindowProperty (xDisplay.display, handle, atom, 0, 1, false, AnyPropertyType,
&userType, &userSize, &userCount, &bytes, &data);
}
XSetErrorHandler (oldErrorHandler);
return (userCount == 1 && ! xErrorTriggered) ? *reinterpret_cast<EventProcPtr*> (data) : nullptr;
}
Window getChildWindow (Window windowToCheck)
{
Window rootWindow, parentWindow;
@ -276,55 +246,6 @@ namespace
return 0;
}
static void translateJuceToXButtonModifiers (const MouseEvent& e, XEvent& ev) noexcept
{
if (e.mods.isLeftButtonDown())
{
ev.xbutton.button = Button1;
ev.xbutton.state |= Button1Mask;
}
else if (e.mods.isRightButtonDown())
{
ev.xbutton.button = Button3;
ev.xbutton.state |= Button3Mask;
}
else if (e.mods.isMiddleButtonDown())
{
ev.xbutton.button = Button2;
ev.xbutton.state |= Button2Mask;
}
}
static void translateJuceToXMotionModifiers (const MouseEvent& e, XEvent& ev) noexcept
{
if (e.mods.isLeftButtonDown()) ev.xmotion.state |= Button1Mask;
else if (e.mods.isRightButtonDown()) ev.xmotion.state |= Button3Mask;
else if (e.mods.isMiddleButtonDown()) ev.xmotion.state |= Button2Mask;
}
static void translateJuceToXCrossingModifiers (const MouseEvent& e, XEvent& ev) noexcept
{
if (e.mods.isLeftButtonDown()) ev.xcrossing.state |= Button1Mask;
else if (e.mods.isRightButtonDown()) ev.xcrossing.state |= Button3Mask;
else if (e.mods.isMiddleButtonDown()) ev.xcrossing.state |= Button2Mask;
}
static void translateJuceToXMouseWheelModifiers (const MouseEvent& e, const float increment, XEvent& ev) noexcept
{
ignoreUnused (e);
if (increment < 0)
{
ev.xbutton.button = Button5;
ev.xbutton.state |= Button5Mask;
}
else if (increment > 0)
{
ev.xbutton.button = Button4;
ev.xbutton.state |= Button4Mask;
}
}
}
#endif

View file

@ -32,8 +32,8 @@
namespace FunctionTestsHelpers
{
void incrementArgument (int& x) { x++; };
double multiply (double x, double a) noexcept { return a * x; };
void incrementArgument (int& x) { x++; }
double multiply (double x, double a) noexcept { return a * x; }
struct BigData
{

View file

@ -71,7 +71,7 @@ namespace internal
template <> struct make_unsigned<int> { typedef unsigned int type; };
template <> struct make_unsigned<long> { typedef unsigned long type; };
template <> struct make_unsigned<long long> { typedef unsigned long long type; };
};
}
//==============================================================================
/**
@ -181,7 +181,7 @@ public:
|| ((numSigFigs == 0 && (! decimalPointFound)) && digit == 0))
continue;
*currentCharacter++ = '0' + (char) digit;
*currentCharacter++ = (char) ('0' + (char) digit);
numSigFigs++;
}
else if ((! decimalPointFound) && *text == '.')
@ -219,7 +219,7 @@ public:
if (digit != 0 || exponentMagnitude != 0)
{
*currentCharacter++ = '0' + (char) digit;
*currentCharacter++ = (char) ('0' + (char) digit);
exponentMagnitude = (exponentMagnitude * 10) + digit;
}
}

View file

@ -198,7 +198,7 @@ struct SIMDNativeOps<int8_t>
const int8_t* lo_ptr = reinterpret_cast<const int8_t*> (&lo);
const int8_t* hi_ptr = reinterpret_cast<const int8_t*> (&hi);
return lo_ptr[0] + hi_ptr[0] + lo_ptr[16] + hi_ptr[16];
return (int8_t) (lo_ptr[0] + hi_ptr[0] + lo_ptr[16] + hi_ptr[16]);
}
static forcedinline __m256i JUCE_VECTOR_CALLTYPE mul (__m256i a, __m256i b)
@ -257,7 +257,7 @@ struct SIMDNativeOps<uint8_t>
const uint8_t* lo_ptr = reinterpret_cast<const uint8_t*> (&lo);
const uint8_t* hi_ptr = reinterpret_cast<const uint8_t*> (&hi);
return lo_ptr[0] + hi_ptr[0] + lo_ptr[16] + hi_ptr[16];
return (uint8_t) (lo_ptr[0] + hi_ptr[0] + lo_ptr[16] + hi_ptr[16]);
}
static forcedinline __m256i JUCE_VECTOR_CALLTYPE mul (__m256i a, __m256i b)
@ -308,7 +308,7 @@ struct SIMDNativeOps<int16_t>
tmp = _mm256_hadd_epi16 (tmp, tmp);
tmp = _mm256_hadd_epi16 (tmp, tmp);
int16_t* ptr = reinterpret_cast<int16_t*> (&tmp);
return ptr[0] + ptr[8];
return (int16_t) (ptr[0] + ptr[8]);
}
};
@ -351,7 +351,7 @@ struct SIMDNativeOps<uint16_t>
tmp = _mm256_hadd_epi16 (tmp, tmp);
tmp = _mm256_hadd_epi16 (tmp, tmp);
uint16_t* ptr = reinterpret_cast<uint16_t*> (&tmp);
return ptr[0] + ptr[8];
return (uint16_t) (ptr[0] + ptr[8]);
}
};

View file

@ -844,8 +844,8 @@ FlexItem FlexItem::withWidth (float newWidth) const noexcept { auto fi =
FlexItem FlexItem::withMinWidth (float newMinWidth) const noexcept { auto fi = *this; fi.minWidth = newMinWidth; return fi; }
FlexItem FlexItem::withMaxWidth (float newMaxWidth) const noexcept { auto fi = *this; fi.maxWidth = newMaxWidth; return fi; }
FlexItem FlexItem::withMinHeight (float newMinHeight) const noexcept { auto fi = *this; fi.minHeight = newMinHeight; return fi; };
FlexItem FlexItem::withMaxHeight (float newMaxHeight) const noexcept { auto fi = *this; fi.maxHeight = newMaxHeight; return fi; };
FlexItem FlexItem::withMinHeight (float newMinHeight) const noexcept { auto fi = *this; fi.minHeight = newMinHeight; return fi; }
FlexItem FlexItem::withMaxHeight (float newMaxHeight) const noexcept { auto fi = *this; fi.maxHeight = newMaxHeight; return fi; }
FlexItem FlexItem::withHeight (float newHeight) const noexcept { auto fi = *this; fi.height = newHeight; return fi; }
FlexItem FlexItem::withMargin (Margin m) const noexcept { auto fi = *this; fi.margin = m; return fi; }

View file

@ -77,7 +77,7 @@ struct ReportingThreadContainer : public ChangeListener,
juce_DeclareSingleton_SingleThreaded_Minimal (ReportingThreadContainer)
};
juce_ImplementSingleton_SingleThreaded (ReportingThreadContainer);
juce_ImplementSingleton_SingleThreaded (ReportingThreadContainer)
//==============================================================================
struct ReportingThread : public Thread,

View file

@ -128,8 +128,8 @@ private:
// calling any of the mouse input methods!
jassert (scale > 0);
return Point<float> ((mousePos.x - area.getCentreX()) / scale,
(area.getCentreY() - mousePos.y) / scale);
return Point<float> ((mousePos.x - (float) area.getCentreX()) / (float) scale,
((float) area.getCentreY() - mousePos.y) / (float) scale);
}
VectorType projectOnSphere (const Point<float> pos) const noexcept

View file

@ -42,9 +42,6 @@ OSCTimeTag::OSCTimeTag (Time time) noexcept
{
const uint64 milliseconds = (uint64) time.toMilliseconds() + millisecondsBetweenOscAndJuceEpochs;
// something went seriously wrong if the line above didn't render the time nonnegative!
jassert (milliseconds >= 0);
uint64 seconds = milliseconds / 1000;
uint32 fractionalPart = uint32 (4294967.296 * (milliseconds % 1000));

View file

@ -48,7 +48,7 @@ void InAppPurchases::getProductsInformation (const StringArray& productIdentifie
#else
Array<Product> products;
for (auto productId : productIdentifiers)
products.add (Product {productId});
products.add (Product { productId, {}, {}, {}, {} });
listeners.call (&Listener::productsInfoReturned, products);
#endif
@ -63,7 +63,7 @@ void InAppPurchases::purchaseProduct (const String& productIdentifier,
pimpl->purchaseProduct (productIdentifier, isSubscription,
upgradeProductIdentifiers, creditForUnusedSubscription);
#else
Listener::PurchaseInfo purchaseInfo { Purchase {"", productIdentifier}, {} };
Listener::PurchaseInfo purchaseInfo { Purchase { "", productIdentifier, {}, {}, {} }, {} };
listeners.call (&Listener::productPurchaseFinished, purchaseInfo, false, "In-app purchases unavailable");
ignoreUnused (isSubscription, upgradeProductIdentifiers, creditForUnusedSubscription);