Browse Source

Fixed a small streaming bug, tidied up some warnings.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
24a121e4dd
12 changed files with 124 additions and 76 deletions
  1. +6
    -0
      build/macosx/Juce.xcodeproj/project.pbxproj
  2. +36
    -40
      juce_amalgamated.cpp
  3. +25
    -0
      juce_amalgamated.h
  4. +1
    -1
      src/audio/audio_file_formats/juce_WavAudioFormat.cpp
  5. +1
    -1
      src/gui/components/code_editor/juce_CodeDocument.cpp
  6. +25
    -0
      src/gui/components/controls/juce_Slider.h
  7. +14
    -17
      src/io/streams/juce_InputStream.cpp
  8. +9
    -10
      src/io/streams/juce_OutputStream.cpp
  9. +2
    -2
      src/native/mac/juce_mac_CoreGraphicsContext.mm
  10. +1
    -1
      src/native/mac/juce_mac_Files.mm
  11. +2
    -2
      src/native/mac/juce_mac_Fonts.mm
  12. +2
    -2
      src/native/mac/juce_mac_QuickTimeMovieComponent.mm

+ 6
- 0
build/macosx/Juce.xcodeproj/project.pbxproj View File

@@ -4236,10 +4236,13 @@
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES;
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
GCC_WARN_MISSING_PARENTHESES = YES;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PRODUCT_NAME = jucedebug;
RUN_CLANG_STATIC_ANALYZER = YES;
@@ -4260,10 +4263,13 @@
"NDEBUG=1",
);
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES;
GCC_WARN_MISSING_PARENTHESES = YES;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PRODUCT_NAME = juce;


+ 36
- 40
juce_amalgamated.cpp View File

@@ -5364,27 +5364,24 @@ int InputStream::readIntBigEndian()

int InputStream::readCompressedInt()
{
int num = 0;
const unsigned char sizeByte = readByte();
if (sizeByte == 0)
return 0;

if (! isExhausted())
const int numBytes = (sizeByte & 0x7f);
if (numBytes > 4)
{
unsigned char numBytes = readByte();
const bool negative = (numBytes & 0x80) != 0;
numBytes &= 0x7f;

if (numBytes <= 4)
{
if (read (&num, numBytes) != numBytes)
return 0;

num = (int) swapIfBigEndian ((uint32) num);

if (negative)
num = -num;
}
jassertfalse // trying to read corrupt data - this method must only be used
// to read data that was written by OutputStream::writeCompressedInt()
return 0;
}

return num;
char bytes[4] = { 0, 0, 0, 0 };
if (read (bytes, numBytes) != numBytes)
return 0;

const int num = (int) littleEndianInt (bytes);
return (sizeByte >> 7) ? -num : num;
}

int64 InputStream::readInt64()
@@ -5639,23 +5636,22 @@ void OutputStream::writeCompressedInt (int value)
{
unsigned int un = (value < 0) ? (unsigned int) -value
: (unsigned int) value;
unsigned int tn = un;

int numSigBytes = 0;
uint8 data[5];
int num = 0;

do
while (un > 0)
{
tn >>= 8;
numSigBytes++;
data[++num] = (uint8) un;
un >>= 8;
}

} while (tn & 0xff);
data[0] = num;

if (value < 0)
numSigBytes |= 0x80;
data[0] |= 0x80;

writeByte ((char) numSigBytes);
un = swapIfBigEndian (un);
write (&un, numSigBytes);
write (data, num + 1);
}

void OutputStream::writeInt64 (int64 value)
@@ -21761,7 +21757,7 @@ const StringPairArray WavAudioFormat::createBWAVMetadata (const String& descript
#if JUCE_MSVC
#pragma pack (push, 1)
#define PACKED
#elif defined (JUCE_GCC)
#elif JUCE_GCC
#define PACKED __attribute__((packed))
#else
#define PACKED
@@ -44691,7 +44687,7 @@ void CodeDocument::setSavePoint() throw()

bool CodeDocument::hasChangedSinceSavePoint() const throw()
{
return currentActionIndex == indexOfSavedState;
return currentActionIndex != indexOfSavedState;
}

static int getCodeCharacterCategory (const tchar character) throw()
@@ -261354,7 +261350,7 @@ bool juce_launchFile (const String& fileName,

ok = [[NSWorkspace sharedWorkspace] openURLs: urls
withAppBundleIdentifier: [[NSBundle bundleWithPath: juceStringToNS (fileName)] bundleIdentifier]
options: nil
options: 0
additionalEventParamDescriptor: nil
launchIdentifiers: nil];
}
@@ -262059,7 +262055,7 @@ public:
const int length = text.length();
CGGlyph* const glyphs = createGlyphsForString (text, length);

int x = 0;
float x = 0;

#if SUPPORT_ONLY_10_4_FONTS
NSSize* const advances = (NSSize*) juce_malloc (length * sizeof (NSSize));
@@ -262129,7 +262125,7 @@ public:
NSSize* const advances = (NSSize*) juce_malloc (length * sizeof (NSSize));
[nsFont getAdvancements: advances forGlyphs: (NSGlyph*) glyphs count: length];

int x = 0;
float x = 0;
for (int i = 0; i < length; ++i)
{
x += advances[i].width;
@@ -262785,8 +262781,8 @@ public:
while (x > clip.origin.x) x -= iw;
while (y > clip.origin.y) y -= ih;

const int right = clip.origin.x + clip.size.width;
const int bottom = clip.origin.y + clip.size.height;
const int right = (int) (clip.origin.x + clip.size.width);
const int bottom = (int) (clip.origin.y + clip.size.height);

while (y < bottom)
{
@@ -266525,7 +266521,7 @@ public:
const int length = text.length();
CGGlyph* const glyphs = createGlyphsForString (text, length);

int x = 0;
float x = 0;

#if SUPPORT_ONLY_10_4_FONTS
NSSize* const advances = (NSSize*) juce_malloc (length * sizeof (NSSize));
@@ -266595,7 +266591,7 @@ public:
NSSize* const advances = (NSSize*) juce_malloc (length * sizeof (NSSize));
[nsFont getAdvancements: advances forGlyphs: (NSGlyph*) glyphs count: length];

int x = 0;
float x = 0;
for (int i = 0; i < length; ++i)
{
x += advances[i].width;
@@ -267253,8 +267249,8 @@ public:
while (x > clip.origin.x) x -= iw;
while (y > clip.origin.y) y -= ih;

const int right = clip.origin.x + clip.size.width;
const int bottom = clip.origin.y + clip.size.height;
const int right = (int) (clip.origin.x + clip.size.width);
const int bottom = (int) (clip.origin.y + clip.size.height);

while (y < bottom)
{
@@ -270806,8 +270802,8 @@ void QuickTimeMovieComponent::getMovieNormalSize (int& width, int& height) const
if (movie != 0)
{
NSSize s = [[theMovie attributeForKey: QTMovieNaturalSizeAttribute] sizeValue];
width = s.width;
height = s.height;
width = (int) s.width;
height = (int) s.height;
}
}



+ 25
- 0
juce_amalgamated.h View File

@@ -46986,6 +46986,11 @@ public:
*/
void setVelocityBasedMode (const bool isVelocityBased) throw();

/** Returns true if velocity-based mode is active.
@see setVelocityBasedMode
*/
bool getVelocityBasedMode() const throw() { return isVelocityBased; }

/** Changes aspects of the scaling used when in velocity-sensitive mode.

These apply when you've used setVelocityBasedMode() to turn on velocity mode,
@@ -47004,6 +47009,26 @@ public:
const double offset = 0.0,
const bool userCanPressKeyToSwapMode = true) throw();

/** Returns the velocity sensitivity setting.
@see setVelocityModeParameters
*/
double getVelocitySensitivity() const throw() { return velocityModeSensitivity; }

/** Returns the velocity threshold setting.
@see setVelocityModeParameters
*/
int getVelocityThreshold() const throw() { return velocityModeThreshold; }

/** Returns the velocity offset setting.
@see setVelocityModeParameters
*/
double getVelocityOffset() const throw() { return velocityModeOffset; }

/** Returns the velocity user key setting.
@see setVelocityModeParameters
*/
bool getVelocityModeIsSwappable() const throw() { return userKeyOverridesVelocity; }

/** Sets up a skew factor to alter the way values are distributed.

You may want to use a range of values on the slider where more accuracy


+ 1
- 1
src/audio/audio_file_formats/juce_WavAudioFormat.cpp View File

@@ -73,7 +73,7 @@ const StringPairArray WavAudioFormat::createBWAVMetadata (const String& descript
#if JUCE_MSVC
#pragma pack (push, 1)
#define PACKED
#elif defined (JUCE_GCC)
#elif JUCE_GCC
#define PACKED __attribute__((packed))
#else
#define PACKED


+ 1
- 1
src/gui/components/code_editor/juce_CodeDocument.cpp View File

@@ -580,7 +580,7 @@ void CodeDocument::setSavePoint() throw()
bool CodeDocument::hasChangedSinceSavePoint() const throw()
{
return currentActionIndex == indexOfSavedState;
return currentActionIndex != indexOfSavedState;
}
//==============================================================================


+ 25
- 0
src/gui/components/controls/juce_Slider.h View File

@@ -151,6 +151,11 @@ public:
*/
void setVelocityBasedMode (const bool isVelocityBased) throw();
/** Returns true if velocity-based mode is active.
@see setVelocityBasedMode
*/
bool getVelocityBasedMode() const throw() { return isVelocityBased; }
/** Changes aspects of the scaling used when in velocity-sensitive mode.
These apply when you've used setVelocityBasedMode() to turn on velocity mode,
@@ -169,6 +174,26 @@ public:
const double offset = 0.0,
const bool userCanPressKeyToSwapMode = true) throw();
/** Returns the velocity sensitivity setting.
@see setVelocityModeParameters
*/
double getVelocitySensitivity() const throw() { return velocityModeSensitivity; }
/** Returns the velocity threshold setting.
@see setVelocityModeParameters
*/
int getVelocityThreshold() const throw() { return velocityModeThreshold; }
/** Returns the velocity offset setting.
@see setVelocityModeParameters
*/
double getVelocityOffset() const throw() { return velocityModeOffset; }
/** Returns the velocity user key setting.
@see setVelocityModeParameters
*/
bool getVelocityModeIsSwappable() const throw() { return userKeyOverridesVelocity; }
//==============================================================================
/** Sets up a skew factor to alter the way values are distributed.


+ 14
- 17
src/io/streams/juce_InputStream.cpp View File

@@ -86,27 +86,24 @@ int InputStream::readIntBigEndian()
int InputStream::readCompressedInt()
{
int num = 0;
const unsigned char sizeByte = readByte();
if (sizeByte == 0)
return 0;
if (! isExhausted())
const int numBytes = (sizeByte & 0x7f);
if (numBytes > 4)
{
unsigned char numBytes = readByte();
const bool negative = (numBytes & 0x80) != 0;
numBytes &= 0x7f;
if (numBytes <= 4)
{
if (read (&num, numBytes) != numBytes)
return 0;
num = (int) swapIfBigEndian ((uint32) num);
if (negative)
num = -num;
}
jassertfalse // trying to read corrupt data - this method must only be used
// to read data that was written by OutputStream::writeCompressedInt()
return 0;
}
return num;
char bytes[4] = { 0, 0, 0, 0 };
if (read (bytes, numBytes) != numBytes)
return 0;
const int num = (int) littleEndianInt (bytes);
return (sizeByte >> 7) ? -num : num;
}
int64 InputStream::readInt64()


+ 9
- 10
src/io/streams/juce_OutputStream.cpp View File

@@ -109,23 +109,22 @@ void OutputStream::writeCompressedInt (int value)
{
unsigned int un = (value < 0) ? (unsigned int) -value
: (unsigned int) value;
unsigned int tn = un;
int numSigBytes = 0;
uint8 data[5];
int num = 0;
do
while (un > 0)
{
tn >>= 8;
numSigBytes++;
data[++num] = (uint8) un;
un >>= 8;
}
} while (tn & 0xff);
data[0] = num;
if (value < 0)
numSigBytes |= 0x80;
data[0] |= 0x80;
writeByte ((char) numSigBytes);
un = swapIfBigEndian (un);
write (&un, numSigBytes);
write (data, num + 1);
}
void OutputStream::writeInt64 (int64 value)


+ 2
- 2
src/native/mac/juce_mac_CoreGraphicsContext.mm View File

@@ -420,8 +420,8 @@ public:
while (x > clip.origin.x) x -= iw;
while (y > clip.origin.y) y -= ih;
const int right = clip.origin.x + clip.size.width;
const int bottom = clip.origin.y + clip.size.height;
const int right = (int) (clip.origin.x + clip.size.width);
const int bottom = (int) (clip.origin.y + clip.size.height);
while (y < bottom)
{


+ 1
- 1
src/native/mac/juce_mac_Files.mm View File

@@ -483,7 +483,7 @@ bool juce_launchFile (const String& fileName,
ok = [[NSWorkspace sharedWorkspace] openURLs: urls
withAppBundleIdentifier: [[NSBundle bundleWithPath: juceStringToNS (fileName)] bundleIdentifier]
options: nil
options: 0
additionalEventParamDescriptor: nil
launchIdentifiers: nil];
}


+ 2
- 2
src/native/mac/juce_mac_Fonts.mm View File

@@ -203,7 +203,7 @@ public:
const int length = text.length();
CGGlyph* const glyphs = createGlyphsForString (text, length);
int x = 0;
float x = 0;
#if SUPPORT_ONLY_10_4_FONTS
NSSize* const advances = (NSSize*) juce_malloc (length * sizeof (NSSize));
@@ -273,7 +273,7 @@ public:
NSSize* const advances = (NSSize*) juce_malloc (length * sizeof (NSSize));
[nsFont getAdvancements: advances forGlyphs: (NSGlyph*) glyphs count: length];
int x = 0;
float x = 0;
for (int i = 0; i < length; ++i)
{
x += advances[i].width;


+ 2
- 2
src/native/mac/juce_mac_QuickTimeMovieComponent.mm View File

@@ -251,8 +251,8 @@ void QuickTimeMovieComponent::getMovieNormalSize (int& width, int& height) const
if (movie != 0)
{
NSSize s = [[theMovie attributeForKey: QTMovieNaturalSizeAttribute] sizeValue];
width = s.width;
height = s.height;
width = (int) s.width;
height = (int) s.height;
}
}


Loading…
Cancel
Save