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

Removed a few pedantic warnings.

This commit is contained in:
jules 2013-08-26 14:58:23 +01:00
parent d9498b28cc
commit 2786eadaf9
35 changed files with 235 additions and 237 deletions

View file

@ -84,7 +84,7 @@
#endif
#ifndef JUCE_USE_MP3AUDIOFORMAT
//#define JUCE_USE_MP3AUDIOFORMAT
#define JUCE_USE_MP3AUDIOFORMAT 1
#endif
#ifndef JUCE_USE_LAME_AUDIO_FORMAT

View file

@ -120,7 +120,7 @@ public:
// We need to clear the output buffers, in case they're full of junk..
for (int i = 0; i < numOutputChannels; ++i)
if (outputChannelData[i] != 0)
zeromem (outputChannelData[i], sizeof (float) * numSamples);
zeromem (outputChannelData[i], sizeof (float) * (size_t) numSamples);
}
private:

View file

@ -36,8 +36,8 @@ public:
averageFPS = 0;
lastPaintTime = 0;
rgbImage = ImageFileFormat::loadFrom (RenderingTestComponent::demoJpeg_jpg, RenderingTestComponent::demoJpeg_jpgSize);
argbImage = ImageFileFormat::loadFrom (RenderingTestComponent::demoPng_png, RenderingTestComponent::demoPng_pngSize);
rgbImage = ImageFileFormat::loadFrom (RenderingTestComponent::demoJpeg_jpg, (size_t) RenderingTestComponent::demoJpeg_jpgSize);
argbImage = ImageFileFormat::loadFrom (RenderingTestComponent::demoPng_png, (size_t) RenderingTestComponent::demoPng_pngSize);
createSVGDrawable();
glyphs.addFittedText (Font (20.0f), "The Quick Brown Fox Jumped Over The Lazy Dog",

View file

@ -49,7 +49,7 @@ public:
size = Random::getSystemRandom().nextFloat() * 30.0f + 30.0f;
colour = Colour (Random::getSystemRandom().nextInt())
colour = Colour ((uint32) Random::getSystemRandom().nextInt())
.withAlpha (0.5f)
.withBrightness (0.7f);
}

View file

@ -56,7 +56,7 @@ public:
g.fillAll (Colours::blue.withAlpha (0.3f));
// use a "colour" attribute in the xml tag for this node to set the text colour..
g.setColour (Colour (xml.getStringAttribute ("colour", "ff000000").getHexValue32()));
g.setColour (Colour ((uint32) xml.getStringAttribute ("colour", "ff000000").getHexValue32()));
g.setFont (height * 0.7f);

View file

@ -43,7 +43,7 @@ public:
direction.x = random.nextFloat() * 8.0f - 4.0f;
direction.y = random.nextFloat() * 8.0f - 4.0f;
colour = Colour (random.nextInt())
colour = Colour ((uint32) random.nextInt())
.withAlpha (0.5f)
.withBrightness (0.7f);

View file

@ -158,8 +158,8 @@ void AudioSampleBuffer::setSize (const int newNumChannels,
if (newNumSamples != size || newNumChannels != numChannels)
{
const size_t allocatedSamplesPerChannel = (newNumSamples + 3) & ~3;
const size_t channelListSize = ((sizeof (float*) * (size_t) (newNumChannels + 1)) + 15) & ~15;
const size_t allocatedSamplesPerChannel = ((size_t) newNumSamples + 3) & ~3u;
const size_t channelListSize = ((sizeof (float*) * (size_t) (newNumChannels + 1)) + 15) & ~15u;
const size_t newTotalBytes = ((size_t) newNumChannels * (size_t) allocatedSamplesPerChannel * sizeof (float))
+ channelListSize + 32;
@ -168,7 +168,7 @@ void AudioSampleBuffer::setSize (const int newNumChannels,
HeapBlock <char, true> newData;
newData.allocate (newTotalBytes, clearExtraSpace);
const size_t numSamplesToCopy = jmin (newNumSamples, size);
const size_t numSamplesToCopy = (size_t) jmin (newNumSamples, size);
float** const newChannels = reinterpret_cast <float**> (newData.getData());
float* newChan = reinterpret_cast <float*> (newData + channelListSize);

View file

@ -162,7 +162,7 @@ namespace FloatVectorHelpers
void JUCE_CALLTYPE FloatVectorOperations::clear (float* dest, int num) noexcept
{
#if JUCE_USE_VDSP_FRAMEWORK
vDSP_vclr (dest, 1, num);
vDSP_vclr (dest, 1, (size_t) num);
#else
zeromem (dest, num * sizeof (float));
#endif
@ -171,7 +171,7 @@ void JUCE_CALLTYPE FloatVectorOperations::clear (float* dest, int num) noexcept
void JUCE_CALLTYPE FloatVectorOperations::fill (float* dest, float valueToFill, int num) noexcept
{
#if JUCE_USE_VDSP_FRAMEWORK
vDSP_vfill (&valueToFill, dest, 1, num);
vDSP_vfill (&valueToFill, dest, 1, (size_t) num);
#else
#if JUCE_USE_SSE_INTRINSICS
const __m128 val = _mm_load1_ps (&valueToFill);
@ -183,7 +183,7 @@ void JUCE_CALLTYPE FloatVectorOperations::fill (float* dest, float valueToFill,
void JUCE_CALLTYPE FloatVectorOperations::copy (float* dest, const float* src, int num) noexcept
{
memcpy (dest, src, num * sizeof (float));
memcpy (dest, src, (size_t) num * sizeof (float));
}
void JUCE_CALLTYPE FloatVectorOperations::copyWithMultiply (float* dest, const float* src, float multiplier, int num) noexcept

View file

@ -83,7 +83,7 @@ int LagrangeInterpolator::process (const double actualRatio, const float* in,
{
if (actualRatio == 1.0)
{
memcpy (out, in, numOut * sizeof (float));
memcpy (out, in, (size_t) numOut * sizeof (float));
if (numOut >= 4)
{

View file

@ -48,9 +48,14 @@
#include <emmintrin.h>
#endif
#if JUCE_MAC || JUCE_IOS
#ifndef JUCE_USE_VDSP_FRAMEWORK
#define JUCE_USE_VDSP_FRAMEWORK 1
#endif
#if (JUCE_MAC || JUCE_IOS) && JUCE_USE_VDSP_FRAMEWORK
#include <Accelerate/Accelerate.h>
#else
#undef JUCE_USE_VDSP_FRAMEWORK
#endif
namespace juce

View file

@ -137,13 +137,13 @@ namespace AiffFileHelpers
{
zerostruct (*this);
flags = input.readIntBigEndian();
numBeats = input.readIntBigEndian();
rootNote = input.readShortBigEndian();
key = input.readShortBigEndian();
timeSigNum = input.readShortBigEndian();
timeSigDen = input.readShortBigEndian();
oneShot = input.readShortBigEndian();
flags = (uint32) input.readIntBigEndian();
numBeats = (uint32) input.readIntBigEndian();
rootNote = (uint16) input.readShortBigEndian();
key = (uint16) input.readShortBigEndian();
timeSigNum = (uint16) input.readShortBigEndian();
timeSigDen = (uint16) input.readShortBigEndian();
oneShot = (uint16) input.readShortBigEndian();
input.read (unknown, sizeof (unknown));
}
@ -199,7 +199,7 @@ namespace AiffFileHelpers
{
MemoryBlock mb;
input.skipNextBytes (4);
input.readIntoMemoryBlock (mb, length - 4);
input.readIntoMemoryBlock (mb, (ssize_t) length - 4);
static const char* appleGenres[] =
{
@ -910,8 +910,10 @@ bool AiffAudioFormat::canHandleFile (const File& f)
return true;
const OSType type = f.getMacOSType();
return type == 'AIFF' || type == 'AIFC'
|| type == 'aiff' || type == 'aifc';
// (NB: written as hex to avoid four-char-constant warnings)
return type == 0x41494646 /* AIFF */ || type == 0x41494643 /* AIFC */
|| type == 0x61696666 /* aiff */ || type == 0x61696663 /* aifc */;
}
#endif

View file

@ -64,9 +64,9 @@ struct CoreAudioFormatMetatdata
{
FileHeader (InputStream& input)
{
fileType = input.readIntBigEndian();
fileVersion = input.readShortBigEndian();
fileFlags = input.readShortBigEndian();
fileType = (uint32) input.readIntBigEndian();
fileVersion = (uint16) input.readShortBigEndian();
fileFlags = (uint16) input.readShortBigEndian();
}
uint32 fileType;
@ -79,8 +79,8 @@ struct CoreAudioFormatMetatdata
{
ChunkHeader (InputStream& input)
{
chunkType = input.readIntBigEndian();
chunkSize = input.readInt64BigEndian();
chunkType = (uint32) input.readIntBigEndian();
chunkSize = (int64) input.readInt64BigEndian();
}
uint32 chunkType;
@ -93,12 +93,12 @@ struct CoreAudioFormatMetatdata
AudioDescriptionChunk (InputStream& input)
{
sampleRate = input.readDoubleBigEndian();
formatID = input.readIntBigEndian();
formatFlags = input.readIntBigEndian();
bytesPerPacket = input.readIntBigEndian();
framesPerPacket = input.readIntBigEndian();
channelsPerFrame = input.readIntBigEndian();
bitsPerChannel = input.readIntBigEndian();
formatID = (uint32) input.readIntBigEndian();
formatFlags = (uint32) input.readIntBigEndian();
bytesPerPacket = (uint32) input.readIntBigEndian();
framesPerPacket = (uint32) input.readIntBigEndian();
channelsPerFrame = (uint32) input.readIntBigEndian();
bitsPerChannel = (uint32) input.readIntBigEndian();
}
double sampleRate;
@ -478,12 +478,12 @@ AudioFormatReader* CoreAudioFormat::createReaderFor (InputStream* sourceStream,
return nullptr;
}
AudioFormatWriter* CoreAudioFormat::createWriterFor (OutputStream* streamToWriteTo,
double sampleRateToUse,
unsigned int numberOfChannels,
int bitsPerSample,
const StringPairArray& metadataValues,
int qualityOptionIndex)
AudioFormatWriter* CoreAudioFormat::createWriterFor (OutputStream*,
double /*sampleRateToUse*/,
unsigned int /*numberOfChannels*/,
int /*bitsPerSample*/,
const StringPairArray& /*metadataValues*/,
int /*qualityOptionIndex*/)
{
jassertfalse; // not yet implemented!
return nullptr;

View file

@ -436,14 +436,15 @@ struct VBRTagData
vbrScale = -1;
if (flags & 8)
vbrScale = ByteOrder::bigEndianInt (data);
vbrScale = (int) ByteOrder::bigEndianInt (data);
headersize = ((type + 1) * 72000 * bitrate) / sampleRate;
return true;
}
uint8 toc[100];
int sampleRate, flags, frames, bytes, vbrScale, headersize;
int sampleRate, vbrScale, headersize;
unsigned int flags, frames, bytes;
private:
static bool isVbrTag (const uint8* const d) noexcept
@ -492,7 +493,7 @@ struct MP3Frame
mpeg25 = (header & (1 << 20)) == 0;
lsf = mpeg25 ? 1 : ((header & (1 << 19)) ? 0 : 1);
layer = 4 - ((header >> 17) & 3);
sampleRateIndex = mpeg25 ? (6 + ((header >> 10) & 3)) : (((header >> 10) & 3) + (lsf * 3));
sampleRateIndex = mpeg25 ? (6 + ((header >> 10) & 3)) : ((int) ((header >> 10) & 3) + (lsf * 3));
crc16FollowsHeader = ((header >> 16) & 1) == 0;
bitrateIndex = (header >> 12) & 15;
padding = (header >> 9) & 1;
@ -545,13 +546,13 @@ struct Constants
initLayer3Tables();
}
const uint8* getGroupTable (const int16 d1, const int index) const noexcept
const uint8* getGroupTable (const int16 d1, const uint32 index) const noexcept
{
switch (d1)
{
case 3: return &group3tab [3 * jmin (index, 3 * 3 * 3)];
case 5: return &group5tab [3 * jmin (index, 5 * 5 * 5)];
case 9: return &group9tab [3 * jmin (index, 9 * 9 * 9)];
case 3: return &group3tab [3 * jmin (index, 3u * 3u * 3u)];
case 5: return &group5tab [3 * jmin (index, 5u * 5u * 5u)];
case 9: return &group9tab [3 * jmin (index, 9u * 9u * 9u)];
default: break;
}
@ -808,7 +809,7 @@ private:
for (int k = 0; k < 6; ++k)
{
const int n = k + j * 6 + i * 36;
iLength2[n] = i | (j << 3) | (k << 6) | (3 << 12);
iLength2[n] = (unsigned int) (i | (j << 3) | (k << 6) | (3 << 12));
}
for (i = 0; i < 4; ++i)
@ -816,15 +817,15 @@ private:
for (int k = 0; k < 4; ++k)
{
const int n = k + j * 4 + i * 16;
iLength2[n + 180] = i | (j << 3) | (k << 6) | (4 << 12);
iLength2[n + 180] = (unsigned int) (i | (j << 3) | (k << 6) | (4 << 12));
}
for (i = 0; i < 4; ++i)
for (j = 0; j < 3; ++j)
{
const int n = j + i * 3;
iLength2[n + 244] = i | (j << 3) | (5 << 12);
nLength2[n + 500] = i | (j << 3) | (2 << 12) | (1 << 15);
iLength2[n + 244] = (unsigned int) (i | (j << 3) | (5 << 12));
nLength2[n + 500] = (unsigned int) (i | (j << 3) | (2 << 12) | (1 << 15));
}
for (i = 0; i < 5; ++i)
@ -833,7 +834,7 @@ private:
for (int l = 0; l < 4; ++l)
{
const int n = l + k * 4 + j * 16 + i * 80;
nLength2[n] = i | (j << 3) | (k << 6) | (l << 9) | (0 << 12);
nLength2[n] = (unsigned int) (i | (j << 3) | (k << 6) | (l << 9) | (0 << 12));
}
for (i = 0; i < 5; ++i)
@ -841,7 +842,7 @@ private:
for (int k = 0; k < 4; ++k)
{
const int n = k + j * 4 + i * 20;
nLength2[n + 400] = i | (j << 3) | (k << 6) | (1 << 12);
nLength2[n + 400] = (unsigned int) (i | (j << 3) | (k << 6) | (1 << 12));
}
}
};
@ -867,7 +868,7 @@ struct Layer3SideInfo
sb = 1;
}
else
sb = maxb - 1;
sb = (int) maxb - 1;
for (; sb != 0; --sb, xr1 += 10)
{
@ -923,9 +924,9 @@ struct Layer3SideInfo
{
bool doL = mixedBlockFlag != 0;
for (int lwin = 0; lwin < 3; ++lwin)
for (uint32 lwin = 0; lwin < 3; ++lwin)
{
int sfb = maxBand[lwin];
uint32 sfb = maxBand[lwin];
doL = doL && (sfb <= 3);
for (; sfb < 12; ++sfb)
@ -936,7 +937,7 @@ struct Layer3SideInfo
const float t1 = tabl1[p];
const float t2 = tabl2[p];
int sb = bi.shortDiff[sfb];
int index = sb + lwin;
uint32 index = (uint32) sb + lwin;
for (; sb > 0; --sb, index += 3)
{
@ -954,7 +955,7 @@ struct Layer3SideInfo
const float t1 = tabl1[p];
const float t2 = tabl2[p];
int sb = bi.shortDiff[12];
int index = sb + lwin;
uint32 index = (uint32) sb + lwin;
for (; sb > 0; --sb, index += 3)
{
@ -969,7 +970,7 @@ struct Layer3SideInfo
{
int index = bi.longIndex[maxBandl];
for (int sfb = maxBandl; sfb < 8; ++sfb)
for (uint32 sfb = maxBandl; sfb < 8; ++sfb)
{
int sb = bi.longDiff[sfb];
const int p = scaleFactors[sfb];
@ -995,7 +996,7 @@ struct Layer3SideInfo
{
int index = bi.longIndex[maxBandl];
for (int sfb = maxBandl; sfb < 21; ++sfb)
for (uint32 sfb = maxBandl; sfb < 21; ++sfb)
{
int sb = bi.longDiff[sfb];
const int p = scaleFactors[sfb];
@ -1081,7 +1082,7 @@ namespace DCT
dct36_0 (v, ts, out1, out2, wintab, tmp2a - tmp1a, (tmp2b - tmp1b) * cos36[v]);
}
void dct36 (float* const in, float* const out1, float* const out2, const float* const wintab, float* const ts) noexcept
static void dct36 (float* const in, float* const out1, float* const out2, const float* const wintab, float* const ts) noexcept
{
in[17] += in[16]; in[16] += in[15]; in[15] += in[14]; in[14] += in[13]; in[13] += in[12];
in[12] += in[11]; in[11] += in[10]; in[10] += in[9]; in[9] += in[8]; in[8] += in[7];
@ -1163,7 +1164,7 @@ namespace DCT
}
};
void dct12 (const float* in, float* const out1, float* const out2, const float* wi, float* ts) noexcept
static void dct12 (const float* in, float* const out1, float* const out2, const float* wi, float* ts) noexcept
{
{
ts[0] = out1[0];
@ -1250,7 +1251,7 @@ namespace DCT
}
}
void dct64 (float* const out0, float* const out1, float* const b1, float* const b2, const float* const samples) noexcept
static void dct64 (float* const out0, float* const out1, float* const b1, float* const b2, const float* const samples) noexcept
{
{
const float* const costab = constants.cosTables[0];
@ -1376,7 +1377,7 @@ namespace DCT
out1[0x10 * 13] = b1[0x17] + b1[0x1F]; out1[0x10 * 15] = b1[0x1F];
}
void dct64 (float* const a, float* const b, const float* const c) noexcept
static void dct64 (float* const a, float* const b, const float* const c) noexcept
{
float temp[64];
dct64 (a, b, temp, temp + 32, c);
@ -1436,7 +1437,7 @@ struct MP3Stream
lastFrameSize += nextFrameOffset;
}
frame.decodeHeader (stream.readIntBigEndian());
frame.decodeHeader ((uint32) stream.readIntBigEndian());
headerParsed = true;
frameSize = frame.frameSize;
isFreeFormat = (frameSize == 0);
@ -1707,14 +1708,14 @@ private:
if (! checkTypeAgainstLastFrame)
break;
const bool mpeg25 = (header & (1 << 20)) == 0;
const int lsf = mpeg25 ? 1 : ((header & (1 << 19)) ? 0 : 1);
const int sampleRateIndex = mpeg25 ? (6 + ((header >> 10) & 3)) : (((header >> 10) & 3) + (lsf * 3));
const int mode = (header >> 6) & 3;
const int numChannels = (mode == 3) ? 1 : 2;
const bool mpeg25 = (header & (1 << 20)) == 0;
const uint32 lsf = mpeg25 ? 1 : ((header & (1 << 19)) ? 0 : 1);
const uint32 sampleRateIndex = mpeg25 ? (6 + ((header >> 10) & 3)) : (((header >> 10) & 3) + (lsf * 3));
const uint32 mode = (header >> 6) & 3;
const uint32 numChannels = (mode == 3) ? 1 : 2;
if (numChannels == frame.numChannels && lsf == frame.lsf
&& mpeg25 == frame.mpeg25 && sampleRateIndex == frame.sampleRateIndex)
if (numChannels == (uint32) frame.numChannels && lsf == (uint32) frame.lsf
&& mpeg25 == frame.mpeg25 && sampleRateIndex == (uint32) frame.sampleRateIndex)
break;
}
@ -1743,7 +1744,7 @@ private:
if (vbrHeaderFound)
{
numFrames = vbrTagData.frames;
numFrames = (int) vbrTagData.frames;
oldPos += jmax (vbrTagData.headersize, 1);
}
@ -1914,7 +1915,7 @@ private:
for (int ch = 0; ch < numChannels; ++ch)
databits += sideinfo.ch[ch].gr[gr].part2_3Length;
return databits - 8 * sideinfo.mainDataStart;
return databits - 8 * (int) sideinfo.mainDataStart;
}
void layer1Step1 (SideInfoLayer1& si) noexcept
@ -1969,7 +1970,7 @@ private:
if (n > 0)
{
const uint32 w = ((-1 << n) + getBitsUint16 (n + 1) + 1);
const uint32 w = ((uint32) (-1 << n) + getBitsUint16 (n + 1) + 1);
fraction[0][i] = (float) (w * constants.muls[n + 1][si.scaleFactor[i][0]]);
fraction[1][i] = (float) (w * constants.muls[n + 1][si.scaleFactor[i][1]]);
}
@ -2098,9 +2099,9 @@ private:
if (d1 < 0)
{
const double cm = constants.muls[k][x1];
fraction[ch][0][i] = (float) ((getBits (k) + d1) * cm);
fraction[ch][1][i] = (float) ((getBits (k) + d1) * cm);
fraction[ch][2][i] = (float) ((getBits (k) + d1) * cm);
fraction[ch][0][i] = (float) (((int) getBits (k) + d1) * cm);
fraction[ch][1][i] = (float) (((int) getBits (k) + d1) * cm);
fraction[ch][2][i] = (float) (((int) getBits (k) + d1) * cm);
}
else
{
@ -2133,9 +2134,9 @@ private:
if (d1 < 0)
{
const int v0 = getBits (k);
const int v1 = getBits (k);
const int v2 = getBits (k);
const int v0 = (int) getBits (k);
const int v1 = (int) getBits (k);
const int v2 = (int) getBits (k);
for (int ch = 0; ch < frame.numChannels; ++ch)
{
@ -2184,7 +2185,7 @@ private:
for (int ch = 0; ch < stereo; ++ch)
{
sideinfo.ch[ch].gr[0].scfsi = -1;
sideinfo.ch[ch].gr[1].scfsi = getBitsUnchecked (4);
sideinfo.ch[ch].gr[1].scfsi = (int) getBitsUnchecked (4);
}
for (int gr = 0; gr < 2; ++gr)
@ -2194,9 +2195,9 @@ private:
Layer3SideInfo::Info& granule = sideinfo.ch[ch].gr[gr];
granule.part2_3Length = getBits (12);
granule.bigValues = jmin (288, (int) getBitsUnchecked (9));
granule.bigValues = jmin (288u, getBitsUnchecked (9));
const int qss = getBitsUnchecked (8);
const int qss = (int) getBitsUnchecked (8);
granule.pow2gain = constants.powToGains + 256 - qss + powdiff;
if (msStereo)
@ -2214,7 +2215,7 @@ private:
for (int i = 0; i < 3; ++i)
{
const int sbg = (getBitsUnchecked (3) << 3);
const uint32 sbg = (getBitsUnchecked (3) << 3);
granule.fullGain[i] = granule.pow2gain + sbg;
}
@ -2226,13 +2227,13 @@ private:
for (int i = 0; i < 3; ++i)
granule.tableSelect[i] = getBitsUnchecked (5);
const int r0c = getBitsUnchecked (4);
const int r1c = getBitsUnchecked (3);
const int r0c = (int) getBitsUnchecked (4);
const int r1c = (int) getBitsUnchecked (3);
const int region0index = jmin (22, r0c + 1);
const int region1index = jmin (22, r0c + 1 + r1c + 1);
granule.region1Start = bandInfo[sampleRate].longIndex[region0index] >> 1;
granule.region2Start = bandInfo[sampleRate].longIndex[region1index] >> 1;
granule.region1Start = (uint32) (bandInfo[sampleRate].longIndex[region0index] >> 1);
granule.region2Start = (uint32) (bandInfo[sampleRate].longIndex[region1index] >> 1);
granule.blockType = 0;
granule.mixedBlockFlag = 0;
}
@ -2255,7 +2256,7 @@ private:
Layer3SideInfo::Info& granule = sideinfo.ch[ch].gr[0];
granule.part2_3Length = getBits (12);
granule.bigValues = jmin (288, (int) getBitsUnchecked (9));
granule.bigValues = jmin (288u, getBitsUnchecked (9));
const uint32 qss = getBitsUnchecked (8);
granule.pow2gain = constants.powToGains + 256 - qss + powdiff;
@ -2294,13 +2295,13 @@ private:
for (int i = 0; i < 3; ++i)
granule.tableSelect[i] = getBitsUnchecked (5);
const int r0c = getBitsUnchecked (4);
const int r1c = getBitsUnchecked (3);
const int r0c = (int) getBitsUnchecked (4);
const int r1c = (int) getBitsUnchecked (3);
const int region0index = jmin (22, r0c + 1);
const int region1index = jmin (22, r0c + 1 + r1c + 1);
granule.region1Start = bandInfo[sampleRate].longIndex[region0index] >> 1;
granule.region2Start = bandInfo[sampleRate].longIndex[region1index] >> 1;
granule.region1Start = (uint32) (bandInfo[sampleRate].longIndex[region0index] >> 1);
granule.region2Start = (uint32) (bandInfo[sampleRate].longIndex[region1index] >> 1);
granule.blockType = 0;
granule.mixedBlockFlag = 0;
}
@ -2328,13 +2329,13 @@ private:
if (granule.mixedBlockFlag)
{
for (int j = 8; --j >= 0;) *scf++ = getBitsUnchecked (num0);
for (int j = 8; --j >= 0;) *scf++ = (int) getBitsUnchecked (num0);
numBits -= num0;
i = 9;
}
for (; --i >= 0;) *scf++ = getBitsUnchecked (num0);
for (i = 18; --i >= 0;) *scf++ = getBitsUnchecked (num1);
for (; --i >= 0;) *scf++ = (int) getBitsUnchecked (num0);
for (i = 18; --i >= 0;) *scf++ = (int) getBitsUnchecked (num1);
*scf++ = 0;
*scf++ = 0;
@ -2346,8 +2347,8 @@ private:
if (scfsi < 0)
{
for (int i = 11; --i >= 0;) *scf++ = getBitsUnchecked (num0);
for (int j = 10; --j >= 0;) *scf++ = getBitsUnchecked (num1);
for (int i = 11; --i >= 0;) *scf++ = (int) getBitsUnchecked (num0);
for (int j = 10; --j >= 0;) *scf++ = (int) getBitsUnchecked (num1);
numBits = (num0 + num1) * 10 + num0;
}
else
@ -2355,7 +2356,7 @@ private:
numBits = 0;
if ((scfsi & 8) == 0)
{
for (int i = 6; --i >= 0;) *scf++ = getBitsUnchecked (num0);
for (int i = 6; --i >= 0;) *scf++ = (int) getBitsUnchecked (num0);
numBits += num0 * 6;
}
else
@ -2363,7 +2364,7 @@ private:
if ((scfsi & 4) == 0)
{
for (int i = 5; --i >= 0;) *scf++ = getBitsUnchecked (num0);
for (int i = 5; --i >= 0;) *scf++ = (int) getBitsUnchecked (num0);
numBits += num0 * 5;
}
else
@ -2371,7 +2372,7 @@ private:
if ((scfsi & 2) == 0)
{
for (int i = 5; --i >= 0;) *scf++ = getBitsUnchecked (num1);
for (int i = 5; --i >= 0;) *scf++ = (int) getBitsUnchecked (num1);
numBits += num1 * 5;
}
else
@ -2379,7 +2380,7 @@ private:
if ((scfsi & 1) == 0)
{
for (int i = 5; --i >= 0;) *scf++ = getBitsUnchecked (num1);
for (int i = 5; --i >= 0;) *scf++ = (int) getBitsUnchecked (num1);
numBits += num1 * 5;
}
else
@ -2425,7 +2426,7 @@ private:
if (num)
{
for (int j = 0; j < (int) (data[i]); ++j)
*scf++ = getBitsUnchecked (num);
*scf++ = (int) getBitsUnchecked (num);
numBits += data[i] * num;
}
@ -2445,15 +2446,15 @@ private:
bool layer3DequantizeSample (float xr[32][18], int* scf, Layer3SideInfo::Info& granule, int sampleRate, int part2bits) noexcept
{
const int shift = 1 + granule.scaleFactorScale;
const uint32 shift = 1 + granule.scaleFactorScale;
float* xrpnt = (float*) xr;
int part2remain = granule.part2_3Length - part2bits;
int part2remain = (int) granule.part2_3Length - part2bits;
zeromem (xrpnt, sizeof (float) * (&xr[32][0] - xrpnt));
zeromem (xrpnt, sizeof (float) * (size_t) (&xr[32][0] - xrpnt));
const int bv = granule.bigValues;
const int region1 = granule.region1Start;
const int region2 = granule.region2Start;
const int bv = (int) granule.bigValues;
const int region1 = (int) granule.region1Start;
const int region2 = (int) granule.region2Start;
int l3 = ((576 >> 1) - bv) >> 1;
int l[3];
@ -2657,14 +2658,14 @@ private:
*xrpnt = 0; xrpnt += step;
}
granule.maxBand[0] = max[0] + 1;
granule.maxBand[1] = max[1] + 1;
granule.maxBand[2] = max[2] + 1;
granule.maxBandl = max[3] + 1;
granule.maxBand[0] = (uint32) (max[0] + 1);
granule.maxBand[1] = (uint32) (max[1] + 1);
granule.maxBand[2] = (uint32) (max[2] + 1);
granule.maxBandl = (uint32) (max[3] + 1);
const int rmax = jmax (max[0], max[1], max[3]) + 1;
granule.maxb = rmax ? constants.shortLimit[sampleRate][rmax]
: constants.longLimit[sampleRate][max[3] + 1];
granule.maxb = rmax ? (uint32) constants.shortLimit[sampleRate][rmax]
: (uint32) constants.longLimit[sampleRate][max[3] + 1];
}
else
{
@ -2782,10 +2783,10 @@ private:
}
}
zeromem (xrpnt, sizeof (float) * (&xr[32][0] - xrpnt));
zeromem (xrpnt, sizeof (float) * (size_t) (&xr[32][0] - xrpnt));
granule.maxBandl = max + 1;
granule.maxb = constants.longLimit[sampleRate][granule.maxBandl];
granule.maxBandl = (uint32) (max + 1);
granule.maxb = (uint32) constants.longLimit[sampleRate][granule.maxBandl];
}
while (part2remain > 16)
@ -2826,7 +2827,7 @@ private:
ts += 2;
}
const int bt = granule.blockType;
const uint32 bt = granule.blockType;
if (bt == 2)
{
for (; sb < (int) granule.maxb; sb += 2, ts += 2, rawout1 += 36, rawout2 += 36)
@ -2947,7 +2948,7 @@ public:
bitsPerSample = 32;
usesFloatingPointData = true;
sampleRate = stream.frame.getFrequency();
numChannels = stream.frame.numChannels;
numChannels = (unsigned int) stream.frame.numChannels;
lengthInSamples = findLength (streamPos);
}
}
@ -3001,17 +3002,17 @@ public:
{
for (int i = numDestChannels; --i >= 0;)
if (destSamples[i] != nullptr)
zeromem (destSamples[i] + startOffsetInDestBuffer, sizeof (float) * numSamples);
zeromem (destSamples[i] + startOffsetInDestBuffer, sizeof (float) * (size_t) numSamples);
return false;
}
const int numToCopy = jmin (decodedEnd - decodedStart, numSamples);
float* const* const dst = reinterpret_cast <float**> (destSamples);
memcpy (dst[0] + startOffsetInDestBuffer, decoded0 + decodedStart, sizeof (float) * numToCopy);
memcpy (dst[0] + startOffsetInDestBuffer, decoded0 + decodedStart, sizeof (float) * (size_t) numToCopy);
if (numDestChannels > 1 && dst[1] != nullptr)
memcpy (dst[1] + startOffsetInDestBuffer, (numChannels < 2 ? decoded0 : decoded1) + decodedStart, sizeof (float) * numToCopy);
memcpy (dst[1] + startOffsetInDestBuffer, (numChannels < 2 ? decoded0 : decoded1) + decodedStart, sizeof (float) * (size_t) numToCopy);
startOffsetInDestBuffer += numToCopy;
decodedStart += numToCopy;
@ -3064,7 +3065,7 @@ private:
void skipID3()
{
const int64 originalPosition = stream.stream.getPosition();
const uint32 firstWord = stream.stream.readInt();
const uint32 firstWord = (uint32) stream.stream.readInt();
if ((firstWord & 0xffffff) == 0x334449)
{
@ -3074,10 +3075,10 @@ private:
&& buffer[0] != 0xff
&& ((buffer[2] | buffer[3] | buffer[4] | buffer[5]) & 0x80) == 0)
{
const int length = (((uint32) buffer[2]) << 21)
| (((uint32) buffer[3]) << 14)
| (((uint32) buffer[4]) << 7)
| ((uint32) buffer[5]);
const uint32 length = (((uint32) buffer[2]) << 21)
| (((uint32) buffer[3]) << 14)
| (((uint32) buffer[4]) << 7)
| ((uint32) buffer[5]);
stream.stream.skipNextBytes (length);
return;

View file

@ -308,8 +308,8 @@ public:
if (ogg_stream_flush (&os, &og) == 0)
break;
output->write (og.header, og.header_len);
output->write (og.body, og.body_len);
output->write (og.header, (size_t) og.header_len);
output->write (og.body, (size_t) og.body_len);
}
ok = true;
@ -391,8 +391,8 @@ public:
if (ogg_stream_pageout (&os, &og) == 0)
break;
output->write (og.header, og.header_len);
output->write (og.body, og.body_len);
output->write (og.header, (size_t) og.header_len);
output->write (og.body, (size_t) og.body_len);
if (ogg_page_eos (&og))
break;

View file

@ -70,6 +70,7 @@ const char* const WavAudioFormat::acidTempo = "acid tempo";
namespace WavFileHelpers
{
inline int chunkName (const char* const name) noexcept { return (int) ByteOrder::littleEndianInt (name); }
inline size_t roundUpSize (size_t sz) noexcept { return (sz + 3) & ~3u; }
#if JUCE_MSVC
#pragma pack (push, 1)
@ -108,8 +109,7 @@ namespace WavFileHelpers
static MemoryBlock createFrom (const StringPairArray& values)
{
const size_t sizeNeeded = sizeof (BWAVChunk) + values [WavAudioFormat::bwavCodingHistory].getNumBytesAsUTF8();
MemoryBlock data ((sizeNeeded + 3) & ~3);
MemoryBlock data (roundUpSize (sizeof (BWAVChunk) + values [WavAudioFormat::bwavCodingHistory].getNumBytesAsUTF8()));
data.fillWith (0);
BWAVChunk* b = (BWAVChunk*) data.getData();
@ -223,8 +223,7 @@ namespace WavFileHelpers
if (numLoops > 0)
{
const size_t sizeNeeded = sizeof (SMPLChunk) + (size_t) (numLoops - 1) * sizeof (SampleLoop);
data.setSize ((sizeNeeded + 3) & ~3, true);
data.setSize (roundUpSize (sizeof (SMPLChunk) + (size_t) (numLoops - 1) * sizeof (SampleLoop)), true);
SMPLChunk* const s = static_cast <SMPLChunk*> (data.getData());
@ -353,8 +352,7 @@ namespace WavFileHelpers
if (numCues > 0)
{
const size_t sizeNeeded = sizeof (CueChunk) + (size_t) (numCues - 1) * sizeof (Cue);
data.setSize ((sizeNeeded + 3) & ~3, true);
data.setSize (roundUpSize (sizeof (CueChunk) + (size_t) (numCues - 1) * sizeof (Cue)), true);
CueChunk* const c = static_cast <CueChunk*> (data.getData());
@ -417,7 +415,7 @@ namespace WavFileHelpers
out.writeInt (chunkType);
out.writeInt (chunkLength);
out.writeInt (getValue (values, prefix, "Identifier"));
out.write (label.toUTF8(), labelLength);
out.write (label.toUTF8(), (size_t) labelLength);
if ((out.getDataSize() & 1) != 0)
out.writeByte (0);
@ -439,7 +437,7 @@ namespace WavFileHelpers
out.writeShort ((short) getValue (values, prefix, "Language"));
out.writeShort ((short) getValue (values, prefix, "Dialect"));
out.writeShort ((short) getValue (values, prefix, "CodePage"));
out.write (text.toUTF8(), textLength);
out.write (text.toUTF8(), (size_t) textLength);
if ((out.getDataSize() & 1) != 0)
out.writeByte (0);
@ -471,10 +469,10 @@ namespace WavFileHelpers
struct AcidChunk
{
/** Reads an acid RIFF chunk from a stream positioned just after the size byte. */
AcidChunk (InputStream& input, int length)
AcidChunk (InputStream& input, size_t length)
{
zerostruct (*this);
input.read (this, jmin ((int) sizeof (*this), length));
input.read (this, (int) jmin (sizeof (*this), length));
}
void addToMetadata (StringPairArray& values) const
@ -876,6 +874,7 @@ public:
//==============================================================================
bool write (const int** data, int numSamples) override
{
jassert (numSamples >= 0);
jassert (data != nullptr && *data != nullptr); // the input must contain at least one channel!
if (writeFailed)
@ -905,7 +904,7 @@ public:
else
{
bytesWritten += bytes;
lengthInSamples += numSamples;
lengthInSamples += (uint64) numSamples;
return true;
}

View file

@ -89,7 +89,7 @@ bool BufferingAudioReader::readSamples (int** destSamples, int numDestChannels,
}
else
{
if (timeoutMs >= 0 && Time::getMillisecondCounter() >= startTime + timeoutMs)
if (timeoutMs >= 0 && Time::getMillisecondCounter() >= startTime + (uint32) timeoutMs)
{
for (int j = 0; j < numDestChannels; ++j)
if (float* dest = (float*) destSamples[j])
@ -110,7 +110,7 @@ bool BufferingAudioReader::readSamples (int** destSamples, int numDestChannels,
BufferingAudioReader::BufferedBlock::BufferedBlock (AudioFormatReader& reader, int64 pos, int numSamples)
: range (pos, pos + numSamples),
buffer (reader.numChannels, numSamples)
buffer ((int) reader.numChannels, numSamples)
{
reader.read (&buffer, 0, numSamples, pos, true, true);
}

View file

@ -95,7 +95,7 @@ protected:
{
typedef AudioData::Pointer <SampleType, Endianness, AudioData::Interleaved, AudioData::Const> SourceType;
SourceType (addBytesToPointer (sampleToPointer (startSampleInFile), (bitsPerSample / 8) * channel), (int) numChannels)
SourceType (addBytesToPointer (sampleToPointer (startSampleInFile), ((int) bitsPerSample / 8) * channel), (int) numChannels)
.findMinAndMax ((size_t) numSamples, mn, mx);
}

View file

@ -153,7 +153,7 @@ void AudioProcessorPlayer::audioDeviceAboutToStart (AudioIODevice* const device)
numOutputChans = numChansOut;
messageCollector.reset (sampleRate);
channels.calloc (jmax (numChansIn, numChansOut) + 2);
channels.calloc ((size_t) jmax (numChansIn, numChansOut) + 2);
if (processor != nullptr)
{

View file

@ -678,12 +678,12 @@ var var::readFromStream (InputStream& input)
case varMarker_Binary:
{
MemoryBlock mb (numBytes - 1);
MemoryBlock mb ((size_t) numBytes - 1);
if (numBytes > 1)
{
const int numRead = input.read (mb.getData(), numBytes - 1);
mb.setSize (numRead);
mb.setSize ((size_t) numRead);
}
return var (mb);

View file

@ -665,7 +665,7 @@ FileInputStream* File::createInputStream() const
return nullptr;
}
FileOutputStream* File::createOutputStream (const int bufferSize) const
FileOutputStream* File::createOutputStream (const size_t bufferSize) const
{
ScopedPointer<FileOutputStream> out (new FileOutputStream (*this, bufferSize));

View file

@ -580,7 +580,7 @@ public:
end of the file), or nullptr if the file can't be opened for some reason
@see createInputStream, appendData, appendText
*/
FileOutputStream* createOutputStream (int bufferSize = 0x8000) const;
FileOutputStream* createOutputStream (size_t bufferSize = 0x8000) const;
//==============================================================================
/** Loads a file's contents into memory as a block of binary data.

View file

@ -29,14 +29,14 @@
int64 juce_fileSetPosition (void* handle, int64 pos);
//==============================================================================
FileOutputStream::FileOutputStream (const File& f, const int bufferSize_)
FileOutputStream::FileOutputStream (const File& f, const size_t bufferSizeToUse)
: file (f),
fileHandle (nullptr),
status (Result::ok()),
currentPosition (0),
bufferSize (bufferSize_),
bufferSize (bufferSizeToUse),
bytesInBuffer (0),
buffer ((size_t) jmax (bufferSize_, 16))
buffer (jmax (bufferSizeToUse, (size_t) 16))
{
openHandle();
}

View file

@ -54,7 +54,7 @@ public:
@see TemporaryFile
*/
FileOutputStream (const File& fileToWriteTo,
int bufferSizeToUse = 16384);
size_t bufferSizeToUse = 16384);
/** Destructor. */
~FileOutputStream();

View file

@ -229,12 +229,12 @@ void MemoryBlock::copyFrom (const void* const src, int offset, size_t num) noexc
if (offset < 0)
{
d -= offset;
num -= offset;
num += (size_t) -offset;
offset = 0;
}
if (offset + num > size)
num = size - offset;
if ((size_t) offset + num > size)
num = size - (size_t) offset;
if (num > 0)
memcpy (data + offset, d, num);
@ -248,14 +248,13 @@ void MemoryBlock::copyTo (void* const dst, int offset, size_t num) const noexcep
{
zeromem (d, (size_t) -offset);
d -= offset;
num += offset;
num -= (size_t) -offset;
offset = 0;
}
if (offset + num > size)
if ((size_t) offset + num > size)
{
const size_t newNum = size - offset;
const size_t newNum = size - (size_t) offset;
zeromem (d + newNum, num - newNum);
num = newNum;
}
@ -275,12 +274,12 @@ int MemoryBlock::getBitRange (const size_t bitRangeStart, size_t numBits) const
int res = 0;
size_t byte = bitRangeStart >> 3;
int offsetInByte = (int) bitRangeStart & 7;
size_t offsetInByte = bitRangeStart & 7;
size_t bitsSoFar = 0;
while (numBits > 0 && (size_t) byte < size)
{
const int bitsThisTime = jmin ((int) numBits, 8 - offsetInByte);
const size_t bitsThisTime = jmin (numBits, 8 - offsetInByte);
const int mask = (0xff >> (8 - bitsThisTime)) << offsetInByte;
res |= (((data[byte] & mask) >> offsetInByte) << bitsSoFar);
@ -297,17 +296,17 @@ int MemoryBlock::getBitRange (const size_t bitRangeStart, size_t numBits) const
void MemoryBlock::setBitRange (const size_t bitRangeStart, size_t numBits, int bitsToSet) noexcept
{
size_t byte = bitRangeStart >> 3;
int offsetInByte = (int) bitRangeStart & 7;
unsigned int mask = ~((((unsigned int) 0xffffffff) << (32 - numBits)) >> (32 - numBits));
size_t offsetInByte = bitRangeStart & 7;
uint32 mask = ~((((uint32) 0xffffffff) << (32 - numBits)) >> (32 - numBits));
while (numBits > 0 && (size_t) byte < size)
{
const int bitsThisTime = jmin ((int) numBits, 8 - offsetInByte);
const size_t bitsThisTime = jmin (numBits, 8 - offsetInByte);
const unsigned int tempMask = (mask << offsetInByte) | ~((((unsigned int) 0xffffffff) >> offsetInByte) << offsetInByte);
const unsigned int tempBits = (unsigned int) bitsToSet << offsetInByte;
const uint32 tempMask = (mask << offsetInByte) | ~((((uint32) 0xffffffff) >> offsetInByte) << offsetInByte);
const uint32 tempBits = (uint32) bitsToSet << offsetInByte;
data[byte] = (char) ((data[byte] & tempMask) | tempBits);
data[byte] = (char) (((uint32) data[byte] & tempMask) | tempBits);
++byte;
numBits -= bitsThisTime;
@ -336,22 +335,11 @@ void MemoryBlock::loadFromHexString (const String& hex)
{
const juce_wchar c = t.getAndAdvance();
if (c >= '0' && c <= '9')
{
byte |= c - '0';
break;
}
else if (c >= 'a' && c <= 'z')
{
byte |= c - ('a' - 10);
break;
}
else if (c >= 'A' && c <= 'Z')
{
byte |= c - ('A' - 10);
break;
}
else if (c == 0)
if (c >= '0' && c <= '9') { byte |= c - '0'; break; }
if (c >= 'a' && c <= 'z') { byte |= c - ('a' - 10); break; }
if (c >= 'A' && c <= 'Z') { byte |= c - ('A' - 10); break; }
if (c == 0)
{
setSize (static_cast <size_t> (dest - data));
return;
@ -372,7 +360,7 @@ String MemoryBlock::toBase64Encoding() const
String destString ((unsigned int) size); // store the length, followed by a '.', and then the data.
const int initialLen = destString.length();
destString.preallocateBytes (sizeof (String::CharPointerType::CharType) * (size_t) (initialLen + 2 + numChars));
destString.preallocateBytes (sizeof (String::CharPointerType::CharType) * (size_t) initialLen + 2 + numChars);
String::CharPointerType d (destString.getCharPointer());
d += initialLen;

View file

@ -1151,7 +1151,7 @@ struct HighResolutionTimer::Pimpl
shouldStop = false;
if (pthread_create (&thread, nullptr, timerThread, this) == 0)
setThreadToRealtime (thread, newPeriod);
setThreadToRealtime (thread, (uint64) newPeriod);
else
jassertfalse;
}

View file

@ -101,12 +101,12 @@ static void findIPAddresses (int sock, Array<IPAddress>& result)
{
ifconf cfg;
HeapBlock<char> buffer;
size_t bufferSize = 1024;
int bufferSize = 1024;
do
{
bufferSize *= 2;
buffer.calloc (bufferSize);
buffer.calloc ((size_t) bufferSize);
cfg.ifc_len = bufferSize;
cfg.ifc_buf = buffer;
@ -114,7 +114,7 @@ static void findIPAddresses (int sock, Array<IPAddress>& result)
if (ioctl (sock, SIOCGIFCONF, &cfg) < 0 && errno != EINVAL)
return;
} while (bufferSize < cfg.ifc_len + 2 * (IFNAMSIZ + sizeof (struct sockaddr_in6)));
} while (bufferSize < cfg.ifc_len + 2 * (int) (IFNAMSIZ + sizeof (struct sockaddr_in6)));
#if JUCE_MAC || JUCE_IOS
while (cfg.ifc_len >= (int) (IFNAMSIZ + sizeof (struct sockaddr_in)))

View file

@ -129,7 +129,7 @@ bool OutputStream::writeCompressedInt (int value)
if (value < 0)
data[0] |= 0x80;
return write (data, num + 1);
return write (data, (size_t) num + 1);
}
bool OutputStream::writeInt64 (int64 value)
@ -219,7 +219,7 @@ bool OutputStream::writeText (const String& text, const bool asUTF16,
if (*t == '\n')
{
if (t > src)
if (! write (src, (int) (t - src)))
if (! write (src, (size_t) (t - src)))
return false;
if (! write ("\r\n", 2))
@ -235,7 +235,7 @@ bool OutputStream::writeText (const String& text, const bool asUTF16,
else if (*t == 0)
{
if (t > src)
if (! write (src, (int) (t - src)))
if (! write (src, (size_t) (t - src)))
return false;
break;
@ -263,7 +263,7 @@ int OutputStream::writeFromInputStream (InputStream& source, int64 numBytesToWri
if (num <= 0)
break;
write (buffer, num);
write (buffer, (size_t) num);
numBytesToWrite -= num;
numWritten += num;

View file

@ -209,7 +209,7 @@ namespace XmlOutputFunctions
}
}
static void writeSpaces (OutputStream& out, const int numSpaces)
static void writeSpaces (OutputStream& out, const size_t numSpaces)
{
out.writeRepeatedByte (' ', numSpaces);
}
@ -222,7 +222,7 @@ void XmlElement::writeElementAsText (OutputStream& outputStream,
using namespace XmlOutputFunctions;
if (indentationLevel >= 0)
writeSpaces (outputStream, indentationLevel);
writeSpaces (outputStream, (size_t) indentationLevel);
if (! isTextElement())
{
@ -230,7 +230,7 @@ void XmlElement::writeElementAsText (OutputStream& outputStream,
outputStream << tagName;
{
const int attIndent = indentationLevel + tagName.length() + 1;
const size_t attIndent = (size_t) (indentationLevel + tagName.length() + 1);
int lineLen = 0;
for (const XmlAttributeNode* att = attributes; att != nullptr; att = att->nextListItem)
@ -279,7 +279,7 @@ void XmlElement::writeElementAsText (OutputStream& outputStream,
if (indentationLevel >= 0 && ! lastWasTextNode)
{
outputStream << newLine;
writeSpaces (outputStream, indentationLevel);
writeSpaces (outputStream, (size_t) indentationLevel);
}
outputStream.write ("</", 2);

View file

@ -103,7 +103,7 @@ private:
{
data += dataSize - stream.avail_in;
dataSize = stream.avail_in;
const ssize_t bytesDone = sizeof (buffer) - (ssize_t) stream.avail_out;
const ssize_t bytesDone = (ssize_t) sizeof (buffer) - (ssize_t) stream.avail_out;
return bytesDone <= 0 || out.write (buffer, (size_t) bytesDone);
}

View file

@ -28,8 +28,8 @@
class CoreGraphicsImage : public ImagePixelData
{
public:
CoreGraphicsImage (const Image::PixelFormat format, const int width_, const int height_, const bool clearImage)
: ImagePixelData (format, width_, height_)
CoreGraphicsImage (const Image::PixelFormat format, const int w, const int h, const bool clearImage)
: ImagePixelData (format, w, h)
{
pixelStride = format == Image::RGB ? 3 : ((format == Image::ARGB) ? 4 : 1);
lineStride = (pixelStride * jmax (1, width) + 3) & ~3;
@ -39,7 +39,7 @@ public:
CGColorSpaceRef colourSpace = (format == Image::SingleChannel) ? CGColorSpaceCreateDeviceGray()
: CGColorSpaceCreateDeviceRGB();
context = CGBitmapContextCreate (imageData, width, height, 8, lineStride,
context = CGBitmapContextCreate (imageData, (size_t) width, (size_t) height, 8, (size_t) lineStride,
colourSpace, getCGImageFlags (format));
CGColorSpaceRelease (colourSpace);
@ -66,15 +66,14 @@ public:
ImagePixelData* clone() override
{
CoreGraphicsImage* im = new CoreGraphicsImage (pixelFormat, width, height, false);
memcpy (im->imageData, imageData, lineStride * height);
memcpy (im->imageData, imageData, (size_t) (lineStride * height));
return im;
}
ImageType* createType() const override { return new NativeImageType(); }
//==============================================================================
static CGImageRef createImage (const Image& juceImage, CGColorSpaceRef colourSpace,
const bool mustOutliveSource)
static CGImageRef createImage (const Image& juceImage, CGColorSpaceRef colourSpace, const bool mustOutliveSource)
{
const Image::BitmapData srcData (juceImage, Image::BitmapData::readOnly);
CGDataProviderRef provider;
@ -87,11 +86,13 @@ public:
}
else
{
provider = CGDataProviderCreateWithData (0, srcData.data, srcData.lineStride * srcData.height, 0);
provider = CGDataProviderCreateWithData (0, srcData.data, (size_t) (srcData.lineStride * srcData.height), 0);
}
CGImageRef imageRef = CGImageCreate (srcData.width, srcData.height,
8, srcData.pixelStride * 8, srcData.lineStride,
CGImageRef imageRef = CGImageCreate ((size_t) srcData.width,
(size_t) srcData.height,
8, (size_t) srcData.pixelStride * 8,
(size_t) srcData.lineStride,
colourSpace, getCGImageFlags (juceImage.getFormat()), provider,
0, true, kCGRenderingIntentDefault);
@ -209,7 +210,7 @@ bool CoreGraphicsContext::clipToRectangleListWithoutTest (const RectangleList<in
}
else
{
const int numRects = clipRegion.getNumRectangles();
const size_t numRects = (size_t) clipRegion.getNumRectangles();
HeapBlock <CGRect> rects (numRects);
int i = 0;
@ -639,10 +640,10 @@ CoreGraphicsContext::SavedState::SavedState()
CoreGraphicsContext::SavedState::SavedState (const SavedState& other)
: fillType (other.fillType), font (other.font), fontRef (other.fontRef),
fontTransform (other.fontTransform), shading (0),
gradientLookupTable (other.numGradientLookupEntries),
gradientLookupTable ((size_t) other.numGradientLookupEntries),
numGradientLookupEntries (other.numGradientLookupEntries)
{
memcpy (gradientLookupTable, other.gradientLookupTable, sizeof (PixelARGB) * numGradientLookupEntries);
memcpy (gradientLookupTable, other.gradientLookupTable, sizeof (PixelARGB) * (size_t) numGradientLookupEntries);
}
CoreGraphicsContext::SavedState::~SavedState()

View file

@ -293,7 +293,7 @@ namespace CoreTextTypeLayout
#endif
};
CTParagraphStyleRef ctParagraphStyleRef = CTParagraphStyleCreate (settings, numElementsInArray (settings));
CTParagraphStyleRef ctParagraphStyleRef = CTParagraphStyleCreate (settings, (size_t) numElementsInArray (settings));
CFAttributedStringSetAttribute (attribString, CFRangeMake (0, CFAttributedStringGetLength (attribString)),
kCTParagraphStyleAttributeName, ctParagraphStyleRef);
CFRelease (ctParagraphStyleRef);

View file

@ -27,6 +27,7 @@
//==============================================================================
namespace MouseCursorHelpers
{
NSImage* createNSImage (const Image&);
NSImage* createNSImage (const Image& image)
{
JUCE_AUTORELEASEPOOL

View file

@ -829,14 +829,15 @@ void OpenGLContext::copyTexture (const Rectangle<int>& targetClipArea,
const OverlayShaderProgram& program = OverlayShaderProgram::select (*this);
program.params.set ((float) contextWidth, (float) contextHeight, anchorPosAndTextureSize.toFloat(), flippedVertically);
extensions.glVertexAttribPointer (program.params.positionAttribute.attributeID, 2, GL_SHORT, GL_FALSE, 4, vertices);
extensions.glEnableVertexAttribArray (program.params.positionAttribute.attributeID);
const GLuint index = (GLuint) program.params.positionAttribute.attributeID;
extensions.glVertexAttribPointer (index, 2, GL_SHORT, GL_FALSE, 4, vertices);
extensions.glEnableVertexAttribArray (index);
JUCE_CHECK_OPENGL_ERROR
glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
extensions.glUseProgram (0);
extensions.glDisableVertexAttribArray (program.params.positionAttribute.attributeID);
extensions.glDisableVertexAttribArray (index);
}
#if JUCE_USE_OPENGL_FIXED_FUNCTION
else

View file

@ -108,7 +108,7 @@ private:
: area (et.getMaximumBounds().withSize (nextPowerOfTwo (et.getMaximumBounds().getWidth()),
nextPowerOfTwo (et.getMaximumBounds().getHeight())))
{
data.calloc (area.getWidth() * area.getHeight());
data.calloc ((size_t) (area.getWidth() * area.getHeight()));
et.iterate (*this);
}
@ -129,12 +129,12 @@ private:
inline void handleEdgeTableLine (int x, int width, const int alphaLevel) const noexcept
{
memset (currentLine + x, (uint8) alphaLevel, width);
memset (currentLine + x, (uint8) alphaLevel, (size_t) width);
}
inline void handleEdgeTableLineFull (int x, int width) const noexcept
{
memset (currentLine + x, 255, width);
memset (currentLine + x, 255, (size_t) width);
}
HeapBlock<uint8> data;
@ -215,16 +215,16 @@ public:
void bindAttributes (OpenGLContext& context)
{
context.extensions.glVertexAttribPointer (positionAttribute.attributeID, 2, GL_SHORT, GL_FALSE, 8, (void*) 0);
context.extensions.glVertexAttribPointer (colourAttribute.attributeID, 4, GL_UNSIGNED_BYTE, GL_TRUE, 8, (void*) 4);
context.extensions.glEnableVertexAttribArray (positionAttribute.attributeID);
context.extensions.glEnableVertexAttribArray (colourAttribute.attributeID);
context.extensions.glVertexAttribPointer ((GLuint) positionAttribute.attributeID, 2, GL_SHORT, GL_FALSE, 8, (void*) 0);
context.extensions.glVertexAttribPointer ((GLuint) colourAttribute.attributeID, 4, GL_UNSIGNED_BYTE, GL_TRUE, 8, (void*) 4);
context.extensions.glEnableVertexAttribArray ((GLuint) positionAttribute.attributeID);
context.extensions.glEnableVertexAttribArray ((GLuint) colourAttribute.attributeID);
}
void unbindAttributes (OpenGLContext& context)
{
context.extensions.glDisableVertexAttribArray (positionAttribute.attributeID);
context.extensions.glDisableVertexAttribArray (colourAttribute.attributeID);
context.extensions.glDisableVertexAttribArray ((GLuint) positionAttribute.attributeID);
context.extensions.glDisableVertexAttribArray ((GLuint) colourAttribute.attributeID);
}
OpenGLShaderProgram::Attribute positionAttribute, colourAttribute;
@ -813,7 +813,7 @@ struct StateHelpers
if (currentActiveTexture != index)
{
currentActiveTexture = index;
context.extensions.glActiveTexture (GL_TEXTURE0 + index);
context.extensions.glActiveTexture ((GLenum) (GL_TEXTURE0 + index));
JUCE_CHECK_OPENGL_ERROR
}
}
@ -1029,7 +1029,7 @@ struct StateHelpers
void draw() noexcept
{
context.extensions.glBufferSubData (GL_ARRAY_BUFFER, 0, numVertices * sizeof (VertexInfo), vertexData);
context.extensions.glBufferSubData (GL_ARRAY_BUFFER, 0, (GLsizeiptr) ((size_t) numVertices * sizeof (VertexInfo)), vertexData);
// NB: If you get a random crash in here and are running in a Parallels VM, it seems to be a bug in
// their driver.. Can't find a workaround unfortunately.
glDrawElements (GL_TRIANGLES, (numVertices * 3) / 2, GL_UNSIGNED_SHORT, 0);
@ -1158,7 +1158,7 @@ public:
{
activeTextures.setTexturesEnabled (shaderQuadQueue, 3);
activeTextures.setActiveTexture (1);
activeTextures.bindTexture (maskTextureID);
activeTextures.bindTexture ((GLuint) maskTextureID);
activeTextures.setActiveTexture (0);
textureCache.bindTextureForGradient (activeTextures, g);
}
@ -1259,7 +1259,7 @@ public:
if (maskArea != nullptr)
{
activeTextures.setTwoTextureMode (shaderQuadQueue, image.textureID, maskTextureID);
activeTextures.setTwoTextureMode (shaderQuadQueue, image.textureID, (GLuint) maskTextureID);
if (clampTiledImages)
{

View file

@ -100,8 +100,8 @@ private:
static void verticalRowFlip (PixelARGB* const data, const int w, const int h)
{
HeapBlock<PixelARGB> tempRow (w);
const int rowSize = sizeof (PixelARGB) * w;
HeapBlock<PixelARGB> tempRow ((size_t) w);
const size_t rowSize = sizeof (PixelARGB) * (size_t) w;
for (int y = 0; y < h / 2; ++y)
{
@ -122,8 +122,8 @@ private:
void write (const PixelARGB* const data) const noexcept
{
HeapBlock<PixelARGB> invertedCopy (area.getWidth() * area.getHeight());
const int rowSize = sizeof (PixelARGB) * area.getWidth();
HeapBlock<PixelARGB> invertedCopy ((size_t) (area.getWidth() * area.getHeight()));
const size_t rowSize = sizeof (PixelARGB) * (size_t) area.getWidth();
for (int y = 0; y < area.getHeight(); ++y)
memcpy (invertedCopy + area.getWidth() * y,
@ -142,7 +142,7 @@ private:
struct DataReleaser : public Image::BitmapData::BitmapDataReleaser
{
DataReleaser (OpenGLFrameBuffer& fb, int x, int y, int w, int h)
: data (w * h),
: data ((size_t) (w * h)),
writer (fb, x, y, w, h)
{}