diff --git a/extras/audio plugins/wrapper/juce_PluginHostType.h b/extras/audio plugins/wrapper/juce_PluginHostType.h index cc52cc3a57..269642d8c9 100644 --- a/extras/audio plugins/wrapper/juce_PluginHostType.h +++ b/extras/audio plugins/wrapper/juce_PluginHostType.h @@ -29,7 +29,7 @@ class PluginHostType { public: //============================================================================== - PluginHostType() throw() : type (getHostType()) + PluginHostType() : type (getHostType()) { } @@ -41,11 +41,12 @@ public: AbletonLive7, AbletonLive8, AbletonLiveGeneric, + AdobePremierePro, AppleLogic, - EmagicLogic, - DigidesignProTools, CakewalkSonar8, CakewalkSonarGeneric, + DigidesignProTools, + EmagicLogic, Reaper, MackieTracktion3, MackieTracktionGeneric, @@ -88,14 +89,24 @@ public: return type == CakewalkSonar8 || type == CakewalkSonarGeneric; } - bool isLogic() const throw() + bool isWavelab() const throw() { - return type == AppleLogic || type == EmagicLogic; + return type == SteinbergWavelab5 || type == SteinbergWavelab6 || type == SteinbergWavelab7 || type == SteinbergWavelabGeneric; } - bool isWavelab() const throw() + bool isWavelabLegacy() const throw() + { + return type == SteinbergWavelab5 || type == SteinbergWavelab6; + } + + bool isPremiere() const throw() + { + return type == AdobePremierePro; + } + + bool isLogic() const throw() { - return type == SteinbergWavelabGeneric || type == SteinbergWavelab5 || type == SteinbergWavelab6 || type == SteinbergWavelab7; + return type == AppleLogic || type == EmagicLogic; } bool isReceptor() const throw() @@ -103,46 +114,55 @@ public: return type == MuseReceptorGeneric; } + //============================================================================== + static String getHostPath() + { + return File::getSpecialLocation (File::hostApplicationPath).getFullPathName(); + } + //============================================================================== private: static HostType getHostType() { - const String hostPath (File::getSpecialLocation (File::hostApplicationPath).getFullPathName()); + const String hostPath (getHostPath()); const String hostFilename (File (hostPath).getFileName()); #if JUCE_MAC - if (hostPath.containsIgnoreCase ("Live 6.")) return AbletonLive6; - if (hostPath.containsIgnoreCase ("Live 7.")) return AbletonLive7; - if (hostPath.containsIgnoreCase ("Live 8.")) return AbletonLive8; - if (hostFilename.containsIgnoreCase ("Live")) return AbletonLiveGeneric; - if (hostFilename.containsIgnoreCase ("Pro Tools")) return DigidesignProTools; - if (hostFilename.containsIgnoreCase ("Cubase 4")) return SteinbergCubase4; - if (hostFilename.containsIgnoreCase ("Cubase 5")) return SteinbergCubase5; - if (hostFilename.containsIgnoreCase ("Wavelab 7" )) return SteinbergWavelab7; - if (hostFilename.containsIgnoreCase ("Wavelab")) return SteinbergWavelabGeneric; - if (hostFilename.contains ("Logic")) return AppleLogic; + if (hostPath.containsIgnoreCase ("Live 6.")) return AbletonLive6; + if (hostPath.containsIgnoreCase ("Live 7.")) return AbletonLive7; + if (hostPath.containsIgnoreCase ("Live 8.")) return AbletonLive8; + if (hostFilename.containsIgnoreCase ("Live")) return AbletonLiveGeneric; + if (hostFilename.containsIgnoreCase ("Adobe Premiere")) return AdobePremierePro; + if (hostFilename.contains ("Logic")) return AppleLogic; + if (hostFilename.containsIgnoreCase ("Pro Tools")) return DigidesignProTools; + if (hostFilename.containsIgnoreCase ("Cubase 4")) return SteinbergCubase4; + if (hostFilename.containsIgnoreCase ("Cubase 5")) return SteinbergCubase5; + if (hostPath.containsIgnoreCase ("Wavelab 7")) return SteinbergWavelab7; + if (hostFilename.containsIgnoreCase ("Wavelab")) return SteinbergWavelabGeneric; #elif JUCE_WINDOWS - if (hostFilename.containsIgnoreCase ("Live 6.")) return AbletonLive6; - if (hostFilename.containsIgnoreCase ("Live 7.")) return AbletonLive7; - if (hostFilename.containsIgnoreCase ("Live 8.")) return AbletonLive8; - if (hostFilename.containsIgnoreCase ("Live ")) return AbletonLiveGeneric; - if (hostFilename.containsIgnoreCase ("ProTools")) return DigidesignProTools; - if (hostPath.containsIgnoreCase ("SONAR 8")) return CakewalkSonar8; - if (hostFilename.containsIgnoreCase ("SONAR")) return CakewalkSonarGeneric; - if (hostPath.containsIgnoreCase ("Tracktion 3")) return MackieTracktion3; - if (hostFilename.containsIgnoreCase ("Tracktion")) return MackieTracktionGeneric; - if (hostFilename.containsIgnoreCase ("Cubase4")) return SteinbergCubase4; - if (hostFilename.containsIgnoreCase ("Cubase5")) return SteinbergCubase5; - if (hostFilename.containsIgnoreCase ("VSTBridgeApp")) return SteinbergCubase5Bridged; - if (hostFilename.containsIgnoreCase ("Cubase")) return SteinbergCubaseGeneric; - if (hostFilename.containsIgnoreCase ("Wavelab 5")) return SteinbergWavelab5; - if (hostFilename.containsIgnoreCase ("Wavelab 6" )) return SteinbergWavelab6; - if (hostFilename.containsIgnoreCase ("Wavelab 7" )) return SteinbergWavelab7; - if (hostFilename.containsIgnoreCase ("Wavelab")) return SteinbergWavelabGeneric; - if (hostFilename.containsIgnoreCase ("reaper")) return Reaper; - if (hostFilename.containsIgnoreCase ("Logic")) return EmagicLogic; - if (hostFilename.containsIgnoreCase ("rm-host")) return MuseReceptorGeneric; + if (hostFilename.containsIgnoreCase ("Live 6.")) return AbletonLive6; + if (hostFilename.containsIgnoreCase ("Live 7.")) return AbletonLive7; + if (hostFilename.containsIgnoreCase ("Live 8.")) return AbletonLive8; + if (hostFilename.containsIgnoreCase ("Live ")) return AbletonLiveGeneric; + if (hostFilename.containsIgnoreCase ("Adobe Premiere")) return AdobePremierePro; + if (hostFilename.containsIgnoreCase ("ProTools")) return DigidesignProTools; + if (hostPath.containsIgnoreCase ("SONAR 8")) return CakewalkSonar8; + if (hostFilename.containsIgnoreCase ("SONAR")) return CakewalkSonarGeneric; + if (hostFilename.containsIgnoreCase ("Logic")) return EmagicLogic; + if (hostPath.containsIgnoreCase ("Tracktion 3")) return MackieTracktion3; + if (hostFilename.containsIgnoreCase ("Tracktion")) return MackieTracktionGeneric; + if (hostFilename.containsIgnoreCase ("reaper")) return Reaper; + if (hostFilename.containsIgnoreCase ("Cubase4")) return SteinbergCubase4; + if (hostFilename.containsIgnoreCase ("Cubase5")) return SteinbergCubase5; + if (hostFilename.containsIgnoreCase ("Cubase")) return SteinbergCubaseGeneric; + if (hostFilename.containsIgnoreCase ("VSTBridgeApp")) return SteinbergCubase5Bridged; + if (hostPath.containsIgnoreCase ("Wavelab 5")) return SteinbergWavelab5; + if (hostPath.containsIgnoreCase ("Wavelab 6")) return SteinbergWavelab6; + if (hostPath.containsIgnoreCase ("Wavelab 7")) return SteinbergWavelab7; + if (hostFilename.containsIgnoreCase ("Wavelab")) return SteinbergWavelabGeneric; + if (hostFilename.containsIgnoreCase ("reaper")) return Reaper; + if (hostFilename.containsIgnoreCase ("rm-host")) return MuseReceptorGeneric; #elif JUCE_LINUX diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 20fd65f3e8..83fdc016cb 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -2435,7 +2435,7 @@ void AbstractFifo::setTotalSize (int newSize) throw() bufferSize = newSize; } -void AbstractFifo::prepareToWrite (int numToWrite, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) throw() +void AbstractFifo::prepareToWrite (int numToWrite, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) const throw() { const int vs = validStart.get(); const int ve = validEnd.get(); @@ -2466,7 +2466,7 @@ void AbstractFifo::finishedWrite (int numWritten) throw() validEnd += numWritten; } -void AbstractFifo::prepareToRead (int numWanted, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) throw() +void AbstractFifo::prepareToRead (int numWanted, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) const throw() { const int vs = validStart.get(); const int ve = validEnd.get(); @@ -10731,7 +10731,7 @@ bool ZipFile::uncompressEntry (const int index, if (zei->entry.filename.endsWithChar ('/')) { - targetFile.createDirectory(); // (entry is a directory, not a file) + return targetFile.createDirectory(); // (entry is a directory, not a file) } else { @@ -11774,6 +11774,7 @@ public: static void copyChars (juce_wchar* const dest, const juce_wchar* const src, const size_t numChars) throw() { + jassert (src != 0 & dest != 0); memcpy (dest, src, numChars * sizeof (juce_wchar)); dest [numChars] = 0; } @@ -13771,7 +13772,10 @@ int String::copyToCString (char* destBuffer, const int maxBufferSizeBytes) const void String::copyToUnicode (juce_wchar* const destBuffer, const int maxCharsToCopy) const throw() { - StringHolder::copyChars (destBuffer, text, jmin (maxCharsToCopy, length())); + jassert (destBuffer != 0 && maxCharsToCopy >= 0); + + if (destBuffer != 0 && maxCharsToCopy >= 0) + StringHolder::copyChars (destBuffer, text, jmin (maxCharsToCopy, length())); } String::Concatenator::Concatenator (String& stringToAppendTo) @@ -22710,7 +22714,7 @@ public: bufferList->mNumberBuffers = 1; bufferList->mBuffers[0].mNumberChannels = inputStreamDesc.mChannelsPerFrame; - bufferList->mBuffers[0].mDataByteSize = (UInt32) (samplesPerFrame * inputStreamDesc.mBytesPerFrame) + 16; + bufferList->mBuffers[0].mDataByteSize = jmax ((UInt32) 4096, (UInt32) (samplesPerFrame * inputStreamDesc.mBytesPerFrame) + 16); dataBuffer.malloc (bufferList->mBuffers[0].mDataByteSize); bufferList->mBuffers[0].mData = dataBuffer; @@ -22746,13 +22750,44 @@ public: int64 startSampleInFile, int numSamples) { checkThreadIsAttached(); + bool ok = true; while (numSamples > 0) { - if (! loadFrame ((int) startSampleInFile)) - return false; + if (lastSampleRead != startSampleInFile) + { + TimeRecord time; + time.scale = (TimeScale) inputStreamDesc.mSampleRate; + time.base = 0; + time.value.hi = 0; + time.value.lo = (UInt32) startSampleInFile; + + OSStatus err = MovieAudioExtractionSetProperty (extractor, + kQTPropertyClass_MovieAudioExtraction_Movie, + kQTMovieAudioExtractionMoviePropertyID_CurrentTime, + sizeof (time), &time); - const int numToDo = jmin (numSamples, samplesPerFrame); + if (err != noErr) + { + ok = false; + break; + } + } + + int framesToDo = bufferList->mBuffers[0].mDataByteSize / inputStreamDesc.mBytesPerFrame; + bufferList->mBuffers[0].mDataByteSize = inputStreamDesc.mBytesPerFrame * framesToDo; + + UInt32 outFlags = 0; + UInt32 actualNumFrames = framesToDo; + OSStatus err = MovieAudioExtractionFillBuffer (extractor, &actualNumFrames, bufferList, &outFlags); + if (err != noErr) + { + ok = false; + break; + } + + lastSampleRead = startSampleInFile + actualNumFrames * samplesPerFrame; + const int samplesReceived = actualNumFrames * samplesPerFrame; for (int j = numDestChannels; --j >= 0;) { @@ -22760,49 +22795,27 @@ public: { const short* const src = ((const short*) bufferList->mBuffers[0].mData) + j; - for (int i = 0; i < numToDo; ++i) + for (int i = 0; i < samplesReceived; ++i) destSamples[j][startOffsetInDestBuffer + i] = src [i << 1] << 16; } } - startOffsetInDestBuffer += numToDo; - startSampleInFile += numToDo; - numSamples -= numToDo; - } - - detachThread(); - return true; - } - - bool loadFrame (const int sampleNum) - { - if (lastSampleRead != sampleNum) - { - TimeRecord time; - time.scale = (TimeScale) inputStreamDesc.mSampleRate; - time.base = 0; - time.value.hi = 0; - time.value.lo = (UInt32) sampleNum; + startOffsetInDestBuffer += samplesReceived; + startSampleInFile += samplesReceived; + numSamples -= samplesReceived; - OSStatus err = MovieAudioExtractionSetProperty (extractor, - kQTPropertyClass_MovieAudioExtraction_Movie, - kQTMovieAudioExtractionMoviePropertyID_CurrentTime, - sizeof (time), &time); + if ((outFlags & kQTMovieAudioExtractionComplete) != 0 && numSamples > 0) + { + for (int j = numDestChannels; --j >= 0;) + if (destSamples[j] != 0) + zeromem (destSamples[j] + startOffsetInDestBuffer, sizeof (int) * numSamples); - if (err != noErr) - return false; + break; + } } - bufferList->mBuffers[0].mDataByteSize = inputStreamDesc.mBytesPerFrame * samplesPerFrame; - - UInt32 outFlags = 0; - UInt32 actualNumSamples = samplesPerFrame; - OSStatus err = MovieAudioExtractionFillBuffer (extractor, &actualNumSamples, - bufferList, &outFlags); - - lastSampleRead = sampleNum + samplesPerFrame; - - return err == noErr; + detachThread(); + return ok; } juce_UseDebuggingNewOperator @@ -22816,7 +22829,7 @@ private: const int trackNum; double trackUnitsPerFrame; int samplesPerFrame; - int lastSampleRead; + int64 lastSampleRead; Thread::ThreadID lastThreadId; MovieAudioExtractionRef extractor; AudioStreamBasicDescription inputStreamDesc; @@ -34118,7 +34131,7 @@ private: #pragma warning (push) #pragma warning (disable: 4244) - originalWndProc = (void*) GetWindowLongPtr (pluginHWND, GWL_WNDPROC); + originalWndProc = (void*) GetWindowLongPtr (pluginHWND, GWLP_WNDPROC); if (! pluginWantsKeys) SetWindowLongPtr (pluginHWND, GWLP_WNDPROC, (LONG_PTR) vstHookWndProc); @@ -52364,7 +52377,7 @@ struct TextAtom String atomText; float width; - uint16 numChars; + int numChars; bool isWhitespace() const { return CharacterFunctions::isWhitespace (atomText[0]); } bool isNewLine() const { return atomText[0] == '\r' || atomText[0] == '\n'; } @@ -89398,13 +89411,13 @@ Font::SharedFontInternal::SharedFontInternal (const SharedFontInternal& other) t { } -Font::Font() throw() +Font::Font() : font (new SharedFontInternal (getDefaultSansSerifFontName(), FontValues::defaultFontHeight, 1.0f, 0, 0, Font::plain, 0)) { } -Font::Font (const float fontHeight, const int styleFlags_) throw() +Font::Font (const float fontHeight, const int styleFlags_) : font (new SharedFontInternal (getDefaultSansSerifFontName(), FontValues::limitFontHeight (fontHeight), 1.0f, 0, 0, styleFlags_, 0)) { @@ -89412,7 +89425,7 @@ Font::Font (const float fontHeight, const int styleFlags_) throw() Font::Font (const String& typefaceName_, const float fontHeight, - const int styleFlags_) throw() + const int styleFlags_) : font (new SharedFontInternal (typefaceName_, FontValues::limitFontHeight (fontHeight), 1.0f, 0, 0, styleFlags_, 0)) { @@ -89433,7 +89446,7 @@ Font::~Font() throw() { } -Font::Font (const Typeface::Ptr& typeface) throw() +Font::Font (const Typeface::Ptr& typeface) : font (new SharedFontInternal (typeface->getName(), FontValues::defaultFontHeight, 1.0f, 0, 0, Font::plain, typeface)) { @@ -89454,31 +89467,31 @@ bool Font::operator!= (const Font& other) const throw() return ! operator== (other); } -void Font::dupeInternalIfShared() throw() +void Font::dupeInternalIfShared() { if (font->getReferenceCount() > 1) font = new SharedFontInternal (*font); } -const String Font::getDefaultSansSerifFontName() throw() +const String Font::getDefaultSansSerifFontName() { static const String name (""); return name; } -const String Font::getDefaultSerifFontName() throw() +const String Font::getDefaultSerifFontName() { static const String name (""); return name; } -const String Font::getDefaultMonospacedFontName() throw() +const String Font::getDefaultMonospacedFontName() { static const String name (""); return name; } -void Font::setTypefaceName (const String& faceName) throw() +void Font::setTypefaceName (const String& faceName) { if (faceName != font->typefaceName) { @@ -89489,17 +89502,17 @@ void Font::setTypefaceName (const String& faceName) throw() } } -const String Font::getFallbackFontName() throw() +const String Font::getFallbackFontName() { return FontValues::fallbackFont; } -void Font::setFallbackFontName (const String& name) throw() +void Font::setFallbackFontName (const String& name) { FontValues::fallbackFont = name; } -void Font::setHeight (float newHeight) throw() +void Font::setHeight (float newHeight) { newHeight = FontValues::limitFontHeight (newHeight); @@ -89510,7 +89523,7 @@ void Font::setHeight (float newHeight) throw() } } -void Font::setHeightWithoutChangingWidth (float newHeight) throw() +void Font::setHeightWithoutChangingWidth (float newHeight) { newHeight = FontValues::limitFontHeight (newHeight); @@ -89522,7 +89535,7 @@ void Font::setHeightWithoutChangingWidth (float newHeight) throw() } } -void Font::setStyleFlags (const int newFlags) throw() +void Font::setStyleFlags (const int newFlags) { if (font->styleFlags != newFlags) { @@ -89536,7 +89549,7 @@ void Font::setStyleFlags (const int newFlags) throw() void Font::setSizeAndStyle (float newHeight, const int newStyleFlags, const float newHorizontalScale, - const float newKerningAmount) throw() + const float newKerningAmount) { newHeight = FontValues::limitFontHeight (newHeight); @@ -89553,41 +89566,55 @@ void Font::setSizeAndStyle (float newHeight, setStyleFlags (newStyleFlags); } -void Font::setHorizontalScale (const float scaleFactor) throw() +void Font::setHorizontalScale (const float scaleFactor) { dupeInternalIfShared(); font->horizontalScale = scaleFactor; } -void Font::setExtraKerningFactor (const float extraKerning) throw() +void Font::setExtraKerningFactor (const float extraKerning) { dupeInternalIfShared(); font->kerning = extraKerning; } -void Font::setBold (const bool shouldBeBold) throw() +void Font::setBold (const bool shouldBeBold) { setStyleFlags (shouldBeBold ? (font->styleFlags | bold) : (font->styleFlags & ~bold)); } +const Font Font::boldened() const +{ + Font f (*this); + f.setBold (true); + return f; +} + bool Font::isBold() const throw() { return (font->styleFlags & bold) != 0; } -void Font::setItalic (const bool shouldBeItalic) throw() +void Font::setItalic (const bool shouldBeItalic) { setStyleFlags (shouldBeItalic ? (font->styleFlags | italic) : (font->styleFlags & ~italic)); } +const Font Font::italicised() const +{ + Font f (*this); + f.setItalic (true); + return f; +} + bool Font::isItalic() const throw() { return (font->styleFlags & italic) != 0; } -void Font::setUnderline (const bool shouldBeUnderlined) throw() +void Font::setUnderline (const bool shouldBeUnderlined) { setStyleFlags (shouldBeUnderlined ? (font->styleFlags | underlined) : (font->styleFlags & ~underlined)); @@ -89598,7 +89625,7 @@ bool Font::isUnderlined() const throw() return (font->styleFlags & underlined) != 0; } -float Font::getAscent() const throw() +float Font::getAscent() const { if (font->ascent == 0) font->ascent = getTypeface()->getAscent(); @@ -89606,17 +89633,17 @@ float Font::getAscent() const throw() return font->height * font->ascent; } -float Font::getDescent() const throw() +float Font::getDescent() const { return font->height - getAscent(); } -int Font::getStringWidth (const String& text) const throw() +int Font::getStringWidth (const String& text) const { return roundToInt (getStringWidthFloat (text)); } -float Font::getStringWidthFloat (const String& text) const throw() +float Font::getStringWidthFloat (const String& text) const { float w = getTypeface()->getStringWidth (text); @@ -89626,7 +89653,7 @@ float Font::getStringWidthFloat (const String& text) const throw() return w * font->height * font->horizontalScale; } -void Font::getGlyphPositions (const String& text, Array & glyphs, Array & xOffsets) const throw() +void Font::getGlyphPositions (const String& text, Array & glyphs, Array & xOffsets) const { getTypeface()->getGlyphPositions (text, glyphs, xOffsets); @@ -89650,7 +89677,7 @@ void Font::getGlyphPositions (const String& text, Array & glyphs, Array & destArray) throw() +void Font::findFonts (Array& destArray) { const StringArray names (findAllTypefaceNames()); @@ -89708,7 +89735,7 @@ const Font Font::fromString (const String& fontDescription) class TypefaceCache : public DeletedAtShutdown { public: - TypefaceCache (int numToCache = 10) throw() + TypefaceCache (int numToCache = 10) : counter (1) { while (--numToCache >= 0) @@ -89722,7 +89749,7 @@ public: juce_DeclareSingleton_SingleThreaded_Minimal (TypefaceCache) - const Typeface::Ptr findTypefaceFor (const Font& font) throw() + const Typeface::Ptr findTypefaceFor (const Font& font) { const int flags = font.getStyleFlags() & (Font::bold | Font::italic); const String faceName (font.getTypefaceName()); @@ -89789,7 +89816,7 @@ private: juce_ImplementSingleton_SingleThreaded (TypefaceCache) -Typeface* Font::getTypeface() const throw() +Typeface* Font::getTypeface() const { if (font->typeface == 0) font->typeface = TypefaceCache::getInstance()->findTypefaceFor (*this); @@ -254571,7 +254598,7 @@ bool File::setAsCurrentWorkingDirectory() const return chdir (getFullPathName().toUTF8()) == 0; } -#if JUCE_IOS +#if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T typedef struct stat64 juce_statStruct; // (need to use the 64-bit version to work around a simulator bug) #else typedef struct stat juce_statStruct; @@ -254580,11 +254607,11 @@ bool File::setAsCurrentWorkingDirectory() const static bool juce_stat (const String& fileName, juce_statStruct& info) { return fileName.isNotEmpty() -#if JUCE_IOS + #if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T && (stat64 (fileName.toUTF8(), &info) == 0); -#else + #else && (stat (fileName.toUTF8(), &info) == 0); -#endif + #endif } bool File::isDirectory() const @@ -264408,7 +264435,7 @@ bool File::setAsCurrentWorkingDirectory() const return chdir (getFullPathName().toUTF8()) == 0; } -#if JUCE_IOS +#if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T typedef struct stat64 juce_statStruct; // (need to use the 64-bit version to work around a simulator bug) #else typedef struct stat juce_statStruct; @@ -264417,11 +264444,11 @@ bool File::setAsCurrentWorkingDirectory() const static bool juce_stat (const String& fileName, juce_statStruct& info) { return fileName.isNotEmpty() -#if JUCE_IOS + #if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T && (stat64 (fileName.toUTF8(), &info) == 0); -#else + #else && (stat (fileName.toUTF8(), &info) == 0); -#endif + #endif } bool File::isDirectory() const diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 919b3568ea..ecb9c9645f 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -64,7 +64,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 52 -#define JUCE_BUILDNUMBER 71 +#define JUCE_BUILDNUMBER 72 /** Current Juce version number. @@ -2531,7 +2531,7 @@ public: @param destBuffer the place to copy it to @param maxCharsToCopy the maximum number of characters to copy to the buffer, - not including the tailing zero, so this shouldn't be + NOT including the trailing zero, so this shouldn't be larger than the size of your destination buffer - 1 */ void copyToUnicode (juce_wchar* destBuffer, int maxCharsToCopy) const throw(); @@ -3193,10 +3193,11 @@ public: the second. If the number of items you ask for is too large to fit within the buffer's free space, then - blockSize1 + blockSize2 may add up to a lower value than numToWrite. + blockSize1 + blockSize2 may add up to a lower value than numToWrite. If this happens, you + may decide to keep waiting and re-trying the method until there's enough space available. - After calling this method, and writing your data, you must call finishedWrite() to tell the - FIFO how much data you actually added. + After calling this method, if you choose to write your data into the blocks returned, you + must call finishedWrite() to tell the FIFO how much data you actually added. e.g. @code @@ -3220,10 +3221,10 @@ public: @param blockSize1 on exit, this indicates how many items can be written to the block starting at startIndex1 @param startIndex2 on exit, this will contain the start index in your buffer at which any data that didn't fit into the first block should be written - @param blockSize1 on exit, this indicates how many items can be written to the block starting at startIndex2 + @param blockSize2 on exit, this indicates how many items can be written to the block starting at startIndex2 @see finishedWrite */ - void prepareToWrite (int numToWrite, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) throw(); + void prepareToWrite (int numToWrite, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) const throw(); /** Called after reading from the FIFO, to indicate that this many items have been added. @see prepareToWrite @@ -3237,10 +3238,11 @@ public: should read from both of them. If the number of items you ask for is greater than the amount of data available, then - blockSize1 + blockSize2 may add up to a lower value than numWanted. + blockSize1 + blockSize2 may add up to a lower value than numWanted. If this happens, you + may decide to keep waiting and re-trying the method until there's enough data available. - After calling this method, and reading the data, you must call finishedRead() to tell the - FIFO how much data you have consumed. + After calling this method, if you choose to read the data, you must call finishedRead() to + tell the FIFO how much data you have consumed. e.g. @code @@ -3259,15 +3261,15 @@ public: } @endcode - @param numToWrite indicates how many items you'd like to add to the buffer + @param numWanted indicates how many items you'd like to add to the buffer @param startIndex1 on exit, this will contain the start index in your buffer at which your data should be written @param blockSize1 on exit, this indicates how many items can be written to the block starting at startIndex1 @param startIndex2 on exit, this will contain the start index in your buffer at which any data that didn't fit into the first block should be written - @param blockSize1 on exit, this indicates how many items can be written to the block starting at startIndex2 + @param blockSize2 on exit, this indicates how many items can be written to the block starting at startIndex2 @see finishedRead */ - void prepareToRead (int numWanted, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) throw(); + void prepareToRead (int numWanted, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) const throw(); /** Called after reading from the FIFO, to indicate that this many items have now been consumed. @see prepareToRead @@ -22703,8 +22705,7 @@ public: just Font::plain for the normal style. @see FontStyleFlags, getDefaultSansSerifFontName */ - Font (float fontHeight, - int styleFlags = plain) throw(); + Font (float fontHeight, int styleFlags = plain); /** Creates a font with a given typeface and parameters. @@ -22715,15 +22716,13 @@ public: just Font::plain for the normal style. @see FontStyleFlags, getDefaultSansSerifFontName */ - Font (const String& typefaceName, - float fontHeight, - int styleFlags) throw(); + Font (const String& typefaceName, float fontHeight, int styleFlags); /** Creates a copy of another Font object. */ Font (const Font& other) throw(); /** Creates a font for a typeface. */ - Font (const Typeface::Ptr& typeface) throw(); + Font (const Typeface::Ptr& typeface); /** Creates a basic sans-serif font at a default height. @@ -22731,7 +22730,7 @@ public: on drawing with - this constructor is here to help initialise objects before changing the font's settings later. */ - Font() throw(); + Font(); /** Copies this font from another one. */ Font& operator= (const Font& other) throw(); @@ -22754,7 +22753,7 @@ public: If a suitable font isn't found on the machine, it'll just use a default instead. */ - void setTypefaceName (const String& faceName) throw(); + void setTypefaceName (const String& faceName); /** Returns the name of the typeface family that this font uses. @@ -22780,7 +22779,7 @@ public: @see setTypefaceName, getDefaultSerifFontName, getDefaultMonospacedFontName */ - static const String getDefaultSansSerifFontName() throw(); + static const String getDefaultSansSerifFontName(); /** Returns a typeface name that represents the default sans-serif font. @@ -22790,7 +22789,7 @@ public: @see setTypefaceName, getDefaultSansSerifFontName, getDefaultMonospacedFontName */ - static const String getDefaultSerifFontName() throw(); + static const String getDefaultSerifFontName(); /** Returns a typeface name that represents the default sans-serif font. @@ -22800,7 +22799,7 @@ public: @see setTypefaceName, getDefaultSansSerifFontName, getDefaultSerifFontName */ - static const String getDefaultMonospacedFontName() throw(); + static const String getDefaultMonospacedFontName(); /** Returns the typeface names of the default fonts on the current platform. */ static void getPlatformDefaultFontNames (String& defaultSans, String& defaultSerif, String& defaultFixed); @@ -22818,13 +22817,13 @@ public: @see getHeight, setHeightWithoutChangingWidth */ - void setHeight (float newHeight) throw(); + void setHeight (float newHeight); /** Changes the font's height without changing its width. This alters the horizontal scale to compensate for the change in height. */ - void setHeightWithoutChangingWidth (float newHeight) throw(); + void setHeightWithoutChangingWidth (float newHeight); /** Returns the height of the font above its baseline. @@ -22832,7 +22831,7 @@ public: @see getHeight, getDescent */ - float getAscent() const throw(); + float getAscent() const; /** Returns the amount that the font descends below its baseline. @@ -22840,7 +22839,7 @@ public: @see getAscent, getHeight */ - float getDescent() const throw(); + float getDescent() const; /** Returns the font's style flags. @@ -22857,20 +22856,24 @@ public: enum, to set the font's properties @see FontStyleFlags */ - void setStyleFlags (int newFlags) throw(); + void setStyleFlags (int newFlags); /** Makes the font bold or non-bold. */ - void setBold (bool shouldBeBold) throw(); + void setBold (bool shouldBeBold); + /** Returns a copy of this font with the bold attribute set. */ + const Font boldened() const; /** Returns true if the font is bold. */ bool isBold() const throw(); /** Makes the font italic or non-italic. */ - void setItalic (bool shouldBeItalic) throw(); + void setItalic (bool shouldBeItalic); + /** Returns a copy of this font with the italic attribute set. */ + const Font italicised() const; /** Returns true if the font is italic. */ bool isItalic() const throw(); /** Makes the font underlined or non-underlined. */ - void setUnderline (bool shouldBeUnderlined) throw(); + void setUnderline (bool shouldBeUnderlined); /** Returns true if the font is underlined. */ bool isUnderlined() const throw(); @@ -22879,7 +22882,7 @@ public: @param scaleFactor a value of 1.0 is the normal scale, less than this will be narrower, greater than 1.0 will be stretched out. */ - void setHorizontalScale (float scaleFactor) throw(); + void setHorizontalScale (float scaleFactor); /** Returns the font's horizontal scale. @@ -22897,7 +22900,7 @@ public: normal spacing, positive values spread the letters out, negative values make them closer together. */ - void setExtraKerningFactor (float extraKerning) throw(); + void setExtraKerningFactor (float extraKerning); /** Returns the font's kerning. @@ -22913,33 +22916,33 @@ public: void setSizeAndStyle (float newHeight, int newStyleFlags, float newHorizontalScale, - float newKerningAmount) throw(); + float newKerningAmount); /** Returns the total width of a string as it would be drawn using this font. For a more accurate floating-point result, use getStringWidthFloat(). */ - int getStringWidth (const String& text) const throw(); + int getStringWidth (const String& text) const; /** Returns the total width of a string as it would be drawn using this font. @see getStringWidth */ - float getStringWidthFloat (const String& text) const throw(); + float getStringWidthFloat (const String& text) const; /** Returns the series of glyph numbers and their x offsets needed to represent a string. An extra x offset is added at the end of the run, to indicate where the right hand edge of the last character is. */ - void getGlyphPositions (const String& text, Array & glyphs, Array & xOffsets) const throw(); + void getGlyphPositions (const String& text, Array & glyphs, Array & xOffsets) const; /** Returns the typeface used by this font. Note that the object returned may go out of scope if this font is deleted or has its style changed. */ - Typeface* getTypeface() const throw(); + Typeface* getTypeface() const; /** Creates an array of Font objects to represent all the fonts on the system. @@ -22948,7 +22951,7 @@ public: @param results the array to which new Font objects will be added. */ - static void findFonts (Array& results) throw(); + static void findFonts (Array& results); /** Returns a list of all the available typeface names. @@ -22962,12 +22965,12 @@ public: /** Returns the name of the typeface to be used for rendering glyphs that aren't found in the requested typeface. */ - static const String getFallbackFontName() throw(); + static const String getFallbackFontName(); /** Sets the (platform-specific) name of the typeface to use to find glyphs that aren't available in whatever font you're trying to use. */ - static void setFallbackFontName (const String& name) throw(); + static void setFallbackFontName (const String& name); /** Creates a string to describe this font. The string will contain information to describe the font's typeface, size, and @@ -23003,7 +23006,7 @@ private: }; ReferenceCountedObjectPtr font; - void dupeInternalIfShared() throw(); + void dupeInternalIfShared(); }; #endif // __JUCE_FONT_JUCEHEADER__ diff --git a/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp b/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp index acd3321b09..203dda2eee 100644 --- a/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp +++ b/src/audio/audio_file_formats/juce_QuickTimeAudioFormat.cpp @@ -196,7 +196,7 @@ public: bufferList->mNumberBuffers = 1; bufferList->mBuffers[0].mNumberChannels = inputStreamDesc.mChannelsPerFrame; - bufferList->mBuffers[0].mDataByteSize = (UInt32) (samplesPerFrame * inputStreamDesc.mBytesPerFrame) + 16; + bufferList->mBuffers[0].mDataByteSize = jmax ((UInt32) 4096, (UInt32) (samplesPerFrame * inputStreamDesc.mBytesPerFrame) + 16); dataBuffer.malloc (bufferList->mBuffers[0].mDataByteSize); bufferList->mBuffers[0].mData = dataBuffer; @@ -232,13 +232,44 @@ public: int64 startSampleInFile, int numSamples) { checkThreadIsAttached(); + bool ok = true; while (numSamples > 0) { - if (! loadFrame ((int) startSampleInFile)) - return false; + if (lastSampleRead != startSampleInFile) + { + TimeRecord time; + time.scale = (TimeScale) inputStreamDesc.mSampleRate; + time.base = 0; + time.value.hi = 0; + time.value.lo = (UInt32) startSampleInFile; + + OSStatus err = MovieAudioExtractionSetProperty (extractor, + kQTPropertyClass_MovieAudioExtraction_Movie, + kQTMovieAudioExtractionMoviePropertyID_CurrentTime, + sizeof (time), &time); + + if (err != noErr) + { + ok = false; + break; + } + } + + int framesToDo = bufferList->mBuffers[0].mDataByteSize / inputStreamDesc.mBytesPerFrame; + bufferList->mBuffers[0].mDataByteSize = inputStreamDesc.mBytesPerFrame * framesToDo; - const int numToDo = jmin (numSamples, samplesPerFrame); + UInt32 outFlags = 0; + UInt32 actualNumFrames = framesToDo; + OSStatus err = MovieAudioExtractionFillBuffer (extractor, &actualNumFrames, bufferList, &outFlags); + if (err != noErr) + { + ok = false; + break; + } + + lastSampleRead = startSampleInFile + actualNumFrames * samplesPerFrame; + const int samplesReceived = actualNumFrames * samplesPerFrame; for (int j = numDestChannels; --j >= 0;) { @@ -246,49 +277,27 @@ public: { const short* const src = ((const short*) bufferList->mBuffers[0].mData) + j; - for (int i = 0; i < numToDo; ++i) + for (int i = 0; i < samplesReceived; ++i) destSamples[j][startOffsetInDestBuffer + i] = src [i << 1] << 16; } } - startOffsetInDestBuffer += numToDo; - startSampleInFile += numToDo; - numSamples -= numToDo; - } - - detachThread(); - return true; - } - - bool loadFrame (const int sampleNum) - { - if (lastSampleRead != sampleNum) - { - TimeRecord time; - time.scale = (TimeScale) inputStreamDesc.mSampleRate; - time.base = 0; - time.value.hi = 0; - time.value.lo = (UInt32) sampleNum; + startOffsetInDestBuffer += samplesReceived; + startSampleInFile += samplesReceived; + numSamples -= samplesReceived; - OSStatus err = MovieAudioExtractionSetProperty (extractor, - kQTPropertyClass_MovieAudioExtraction_Movie, - kQTMovieAudioExtractionMoviePropertyID_CurrentTime, - sizeof (time), &time); + if ((outFlags & kQTMovieAudioExtractionComplete) != 0 && numSamples > 0) + { + for (int j = numDestChannels; --j >= 0;) + if (destSamples[j] != 0) + zeromem (destSamples[j] + startOffsetInDestBuffer, sizeof (int) * numSamples); - if (err != noErr) - return false; + break; + } } - bufferList->mBuffers[0].mDataByteSize = inputStreamDesc.mBytesPerFrame * samplesPerFrame; - - UInt32 outFlags = 0; - UInt32 actualNumSamples = samplesPerFrame; - OSStatus err = MovieAudioExtractionFillBuffer (extractor, &actualNumSamples, - bufferList, &outFlags); - - lastSampleRead = sampleNum + samplesPerFrame; - - return err == noErr; + detachThread(); + return ok; } juce_UseDebuggingNewOperator @@ -302,7 +311,7 @@ private: const int trackNum; double trackUnitsPerFrame; int samplesPerFrame; - int lastSampleRead; + int64 lastSampleRead; Thread::ThreadID lastThreadId; MovieAudioExtractionRef extractor; AudioStreamBasicDescription inputStreamDesc; diff --git a/src/audio/plugins/formats/juce_VSTPluginFormat.cpp b/src/audio/plugins/formats/juce_VSTPluginFormat.cpp index 489961b0e9..ddeb801e35 100644 --- a/src/audio/plugins/formats/juce_VSTPluginFormat.cpp +++ b/src/audio/plugins/formats/juce_VSTPluginFormat.cpp @@ -1456,7 +1456,7 @@ private: #pragma warning (push) #pragma warning (disable: 4244) - originalWndProc = (void*) GetWindowLongPtr (pluginHWND, GWL_WNDPROC); + originalWndProc = (void*) GetWindowLongPtr (pluginHWND, GWLP_WNDPROC); if (! pluginWantsKeys) SetWindowLongPtr (pluginHWND, GWLP_WNDPROC, (LONG_PTR) vstHookWndProc); diff --git a/src/containers/juce_AbstractFifo.cpp b/src/containers/juce_AbstractFifo.cpp index 0aa450829b..534c87da00 100644 --- a/src/containers/juce_AbstractFifo.cpp +++ b/src/containers/juce_AbstractFifo.cpp @@ -57,7 +57,7 @@ void AbstractFifo::setTotalSize (int newSize) throw() } //============================================================================== -void AbstractFifo::prepareToWrite (int numToWrite, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) throw() +void AbstractFifo::prepareToWrite (int numToWrite, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) const throw() { const int vs = validStart.get(); const int ve = validEnd.get(); @@ -88,7 +88,7 @@ void AbstractFifo::finishedWrite (int numWritten) throw() validEnd += numWritten; } -void AbstractFifo::prepareToRead (int numWanted, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) throw() +void AbstractFifo::prepareToRead (int numWanted, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) const throw() { const int vs = validStart.get(); const int ve = validEnd.get(); diff --git a/src/containers/juce_AbstractFifo.h b/src/containers/juce_AbstractFifo.h index 52871b3ead..e85baf3c83 100644 --- a/src/containers/juce_AbstractFifo.h +++ b/src/containers/juce_AbstractFifo.h @@ -123,10 +123,11 @@ public: the second. If the number of items you ask for is too large to fit within the buffer's free space, then - blockSize1 + blockSize2 may add up to a lower value than numToWrite. + blockSize1 + blockSize2 may add up to a lower value than numToWrite. If this happens, you + may decide to keep waiting and re-trying the method until there's enough space available. - After calling this method, and writing your data, you must call finishedWrite() to tell the - FIFO how much data you actually added. + After calling this method, if you choose to write your data into the blocks returned, you + must call finishedWrite() to tell the FIFO how much data you actually added. e.g. @code @@ -150,10 +151,10 @@ public: @param blockSize1 on exit, this indicates how many items can be written to the block starting at startIndex1 @param startIndex2 on exit, this will contain the start index in your buffer at which any data that didn't fit into the first block should be written - @param blockSize1 on exit, this indicates how many items can be written to the block starting at startIndex2 + @param blockSize2 on exit, this indicates how many items can be written to the block starting at startIndex2 @see finishedWrite */ - void prepareToWrite (int numToWrite, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) throw(); + void prepareToWrite (int numToWrite, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) const throw(); /** Called after reading from the FIFO, to indicate that this many items have been added. @see prepareToWrite @@ -167,10 +168,11 @@ public: should read from both of them. If the number of items you ask for is greater than the amount of data available, then - blockSize1 + blockSize2 may add up to a lower value than numWanted. + blockSize1 + blockSize2 may add up to a lower value than numWanted. If this happens, you + may decide to keep waiting and re-trying the method until there's enough data available. - After calling this method, and reading the data, you must call finishedRead() to tell the - FIFO how much data you have consumed. + After calling this method, if you choose to read the data, you must call finishedRead() to + tell the FIFO how much data you have consumed. e.g. @code @@ -189,15 +191,15 @@ public: } @endcode - @param numToWrite indicates how many items you'd like to add to the buffer + @param numWanted indicates how many items you'd like to add to the buffer @param startIndex1 on exit, this will contain the start index in your buffer at which your data should be written @param blockSize1 on exit, this indicates how many items can be written to the block starting at startIndex1 @param startIndex2 on exit, this will contain the start index in your buffer at which any data that didn't fit into the first block should be written - @param blockSize1 on exit, this indicates how many items can be written to the block starting at startIndex2 + @param blockSize2 on exit, this indicates how many items can be written to the block starting at startIndex2 @see finishedRead */ - void prepareToRead (int numWanted, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) throw(); + void prepareToRead (int numWanted, int& startIndex1, int& blockSize1, int& startIndex2, int& blockSize2) const throw(); /** Called after reading from the FIFO, to indicate that this many items have now been consumed. @see prepareToRead diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index bf591cccd4..43b6cf7a9b 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 52 -#define JUCE_BUILDNUMBER 71 +#define JUCE_BUILDNUMBER 72 /** Current Juce version number. diff --git a/src/gui/components/controls/juce_TextEditor.cpp b/src/gui/components/controls/juce_TextEditor.cpp index 7c5053e9e3..b486b9e8bf 100644 --- a/src/gui/components/controls/juce_TextEditor.cpp +++ b/src/gui/components/controls/juce_TextEditor.cpp @@ -43,7 +43,7 @@ struct TextAtom //============================================================================== String atomText; float width; - uint16 numChars; + int numChars; //============================================================================== bool isWhitespace() const { return CharacterFunctions::isWhitespace (atomText[0]); } diff --git a/src/gui/graphics/fonts/juce_Font.cpp b/src/gui/graphics/fonts/juce_Font.cpp index d6db35c1ed..913539f48f 100644 --- a/src/gui/graphics/fonts/juce_Font.cpp +++ b/src/gui/graphics/fonts/juce_Font.cpp @@ -75,13 +75,13 @@ Font::SharedFontInternal::SharedFontInternal (const SharedFontInternal& other) t //============================================================================== -Font::Font() throw() +Font::Font() : font (new SharedFontInternal (getDefaultSansSerifFontName(), FontValues::defaultFontHeight, 1.0f, 0, 0, Font::plain, 0)) { } -Font::Font (const float fontHeight, const int styleFlags_) throw() +Font::Font (const float fontHeight, const int styleFlags_) : font (new SharedFontInternal (getDefaultSansSerifFontName(), FontValues::limitFontHeight (fontHeight), 1.0f, 0, 0, styleFlags_, 0)) { @@ -89,7 +89,7 @@ Font::Font (const float fontHeight, const int styleFlags_) throw() Font::Font (const String& typefaceName_, const float fontHeight, - const int styleFlags_) throw() + const int styleFlags_) : font (new SharedFontInternal (typefaceName_, FontValues::limitFontHeight (fontHeight), 1.0f, 0, 0, styleFlags_, 0)) { @@ -110,7 +110,7 @@ Font::~Font() throw() { } -Font::Font (const Typeface::Ptr& typeface) throw() +Font::Font (const Typeface::Ptr& typeface) : font (new SharedFontInternal (typeface->getName(), FontValues::defaultFontHeight, 1.0f, 0, 0, Font::plain, typeface)) { @@ -131,32 +131,32 @@ bool Font::operator!= (const Font& other) const throw() return ! operator== (other); } -void Font::dupeInternalIfShared() throw() +void Font::dupeInternalIfShared() { if (font->getReferenceCount() > 1) font = new SharedFontInternal (*font); } //============================================================================== -const String Font::getDefaultSansSerifFontName() throw() +const String Font::getDefaultSansSerifFontName() { static const String name (""); return name; } -const String Font::getDefaultSerifFontName() throw() +const String Font::getDefaultSerifFontName() { static const String name (""); return name; } -const String Font::getDefaultMonospacedFontName() throw() +const String Font::getDefaultMonospacedFontName() { static const String name (""); return name; } -void Font::setTypefaceName (const String& faceName) throw() +void Font::setTypefaceName (const String& faceName) { if (faceName != font->typefaceName) { @@ -168,18 +168,18 @@ void Font::setTypefaceName (const String& faceName) throw() } //============================================================================== -const String Font::getFallbackFontName() throw() +const String Font::getFallbackFontName() { return FontValues::fallbackFont; } -void Font::setFallbackFontName (const String& name) throw() +void Font::setFallbackFontName (const String& name) { FontValues::fallbackFont = name; } //============================================================================== -void Font::setHeight (float newHeight) throw() +void Font::setHeight (float newHeight) { newHeight = FontValues::limitFontHeight (newHeight); @@ -190,7 +190,7 @@ void Font::setHeight (float newHeight) throw() } } -void Font::setHeightWithoutChangingWidth (float newHeight) throw() +void Font::setHeightWithoutChangingWidth (float newHeight) { newHeight = FontValues::limitFontHeight (newHeight); @@ -202,7 +202,7 @@ void Font::setHeightWithoutChangingWidth (float newHeight) throw() } } -void Font::setStyleFlags (const int newFlags) throw() +void Font::setStyleFlags (const int newFlags) { if (font->styleFlags != newFlags) { @@ -216,7 +216,7 @@ void Font::setStyleFlags (const int newFlags) throw() void Font::setSizeAndStyle (float newHeight, const int newStyleFlags, const float newHorizontalScale, - const float newKerningAmount) throw() + const float newKerningAmount) { newHeight = FontValues::limitFontHeight (newHeight); @@ -233,41 +233,55 @@ void Font::setSizeAndStyle (float newHeight, setStyleFlags (newStyleFlags); } -void Font::setHorizontalScale (const float scaleFactor) throw() +void Font::setHorizontalScale (const float scaleFactor) { dupeInternalIfShared(); font->horizontalScale = scaleFactor; } -void Font::setExtraKerningFactor (const float extraKerning) throw() +void Font::setExtraKerningFactor (const float extraKerning) { dupeInternalIfShared(); font->kerning = extraKerning; } -void Font::setBold (const bool shouldBeBold) throw() +void Font::setBold (const bool shouldBeBold) { setStyleFlags (shouldBeBold ? (font->styleFlags | bold) : (font->styleFlags & ~bold)); } +const Font Font::boldened() const +{ + Font f (*this); + f.setBold (true); + return f; +} + bool Font::isBold() const throw() { return (font->styleFlags & bold) != 0; } -void Font::setItalic (const bool shouldBeItalic) throw() +void Font::setItalic (const bool shouldBeItalic) { setStyleFlags (shouldBeItalic ? (font->styleFlags | italic) : (font->styleFlags & ~italic)); } +const Font Font::italicised() const +{ + Font f (*this); + f.setItalic (true); + return f; +} + bool Font::isItalic() const throw() { return (font->styleFlags & italic) != 0; } -void Font::setUnderline (const bool shouldBeUnderlined) throw() +void Font::setUnderline (const bool shouldBeUnderlined) { setStyleFlags (shouldBeUnderlined ? (font->styleFlags | underlined) : (font->styleFlags & ~underlined)); @@ -278,7 +292,7 @@ bool Font::isUnderlined() const throw() return (font->styleFlags & underlined) != 0; } -float Font::getAscent() const throw() +float Font::getAscent() const { if (font->ascent == 0) font->ascent = getTypeface()->getAscent(); @@ -286,17 +300,17 @@ float Font::getAscent() const throw() return font->height * font->ascent; } -float Font::getDescent() const throw() +float Font::getDescent() const { return font->height - getAscent(); } -int Font::getStringWidth (const String& text) const throw() +int Font::getStringWidth (const String& text) const { return roundToInt (getStringWidthFloat (text)); } -float Font::getStringWidthFloat (const String& text) const throw() +float Font::getStringWidthFloat (const String& text) const { float w = getTypeface()->getStringWidth (text); @@ -306,7 +320,7 @@ float Font::getStringWidthFloat (const String& text) const throw() return w * font->height * font->horizontalScale; } -void Font::getGlyphPositions (const String& text, Array & glyphs, Array & xOffsets) const throw() +void Font::getGlyphPositions (const String& text, Array & glyphs, Array & xOffsets) const { getTypeface()->getGlyphPositions (text, glyphs, xOffsets); @@ -330,7 +344,7 @@ void Font::getGlyphPositions (const String& text, Array & glyphs, Array & destArray) throw() +void Font::findFonts (Array& destArray) { const StringArray names (findAllTypefaceNames()); @@ -390,7 +404,7 @@ const Font Font::fromString (const String& fontDescription) class TypefaceCache : public DeletedAtShutdown { public: - TypefaceCache (int numToCache = 10) throw() + TypefaceCache (int numToCache = 10) : counter (1) { while (--numToCache >= 0) @@ -404,7 +418,7 @@ public: juce_DeclareSingleton_SingleThreaded_Minimal (TypefaceCache) - const Typeface::Ptr findTypefaceFor (const Font& font) throw() + const Typeface::Ptr findTypefaceFor (const Font& font) { const int flags = font.getStyleFlags() & (Font::bold | Font::italic); const String faceName (font.getTypefaceName()); @@ -472,7 +486,7 @@ private: juce_ImplementSingleton_SingleThreaded (TypefaceCache) -Typeface* Font::getTypeface() const throw() +Typeface* Font::getTypeface() const { if (font->typeface == 0) font->typeface = TypefaceCache::getInstance()->findTypefaceFor (*this); diff --git a/src/gui/graphics/fonts/juce_Font.h b/src/gui/graphics/fonts/juce_Font.h index bafe7787e4..7c4787728f 100644 --- a/src/gui/graphics/fonts/juce_Font.h +++ b/src/gui/graphics/fonts/juce_Font.h @@ -67,8 +67,7 @@ public: just Font::plain for the normal style. @see FontStyleFlags, getDefaultSansSerifFontName */ - Font (float fontHeight, - int styleFlags = plain) throw(); + Font (float fontHeight, int styleFlags = plain); /** Creates a font with a given typeface and parameters. @@ -79,15 +78,13 @@ public: just Font::plain for the normal style. @see FontStyleFlags, getDefaultSansSerifFontName */ - Font (const String& typefaceName, - float fontHeight, - int styleFlags) throw(); + Font (const String& typefaceName, float fontHeight, int styleFlags); /** Creates a copy of another Font object. */ Font (const Font& other) throw(); /** Creates a font for a typeface. */ - Font (const Typeface::Ptr& typeface) throw(); + Font (const Typeface::Ptr& typeface); /** Creates a basic sans-serif font at a default height. @@ -95,7 +92,7 @@ public: on drawing with - this constructor is here to help initialise objects before changing the font's settings later. */ - Font() throw(); + Font(); /** Copies this font from another one. */ Font& operator= (const Font& other) throw(); @@ -119,7 +116,7 @@ public: If a suitable font isn't found on the machine, it'll just use a default instead. */ - void setTypefaceName (const String& faceName) throw(); + void setTypefaceName (const String& faceName); /** Returns the name of the typeface family that this font uses. @@ -146,7 +143,7 @@ public: @see setTypefaceName, getDefaultSerifFontName, getDefaultMonospacedFontName */ - static const String getDefaultSansSerifFontName() throw(); + static const String getDefaultSansSerifFontName(); /** Returns a typeface name that represents the default sans-serif font. @@ -156,7 +153,7 @@ public: @see setTypefaceName, getDefaultSansSerifFontName, getDefaultMonospacedFontName */ - static const String getDefaultSerifFontName() throw(); + static const String getDefaultSerifFontName(); /** Returns a typeface name that represents the default sans-serif font. @@ -166,7 +163,7 @@ public: @see setTypefaceName, getDefaultSansSerifFontName, getDefaultSerifFontName */ - static const String getDefaultMonospacedFontName() throw(); + static const String getDefaultMonospacedFontName(); /** Returns the typeface names of the default fonts on the current platform. */ static void getPlatformDefaultFontNames (String& defaultSans, String& defaultSerif, String& defaultFixed); @@ -185,13 +182,13 @@ public: @see getHeight, setHeightWithoutChangingWidth */ - void setHeight (float newHeight) throw(); + void setHeight (float newHeight); /** Changes the font's height without changing its width. This alters the horizontal scale to compensate for the change in height. */ - void setHeightWithoutChangingWidth (float newHeight) throw(); + void setHeightWithoutChangingWidth (float newHeight); /** Returns the height of the font above its baseline. @@ -199,7 +196,7 @@ public: @see getHeight, getDescent */ - float getAscent() const throw(); + float getAscent() const; /** Returns the amount that the font descends below its baseline. @@ -207,7 +204,7 @@ public: @see getAscent, getHeight */ - float getDescent() const throw(); + float getDescent() const; //============================================================================== /** Returns the font's style flags. @@ -225,21 +222,25 @@ public: enum, to set the font's properties @see FontStyleFlags */ - void setStyleFlags (int newFlags) throw(); + void setStyleFlags (int newFlags); //============================================================================== /** Makes the font bold or non-bold. */ - void setBold (bool shouldBeBold) throw(); + void setBold (bool shouldBeBold); + /** Returns a copy of this font with the bold attribute set. */ + const Font boldened() const; /** Returns true if the font is bold. */ bool isBold() const throw(); /** Makes the font italic or non-italic. */ - void setItalic (bool shouldBeItalic) throw(); + void setItalic (bool shouldBeItalic); + /** Returns a copy of this font with the italic attribute set. */ + const Font italicised() const; /** Returns true if the font is italic. */ bool isItalic() const throw(); /** Makes the font underlined or non-underlined. */ - void setUnderline (bool shouldBeUnderlined) throw(); + void setUnderline (bool shouldBeUnderlined); /** Returns true if the font is underlined. */ bool isUnderlined() const throw(); @@ -249,7 +250,7 @@ public: @param scaleFactor a value of 1.0 is the normal scale, less than this will be narrower, greater than 1.0 will be stretched out. */ - void setHorizontalScale (float scaleFactor) throw(); + void setHorizontalScale (float scaleFactor); /** Returns the font's horizontal scale. @@ -267,7 +268,7 @@ public: normal spacing, positive values spread the letters out, negative values make them closer together. */ - void setExtraKerningFactor (float extraKerning) throw(); + void setExtraKerningFactor (float extraKerning); /** Returns the font's kerning. @@ -285,27 +286,27 @@ public: void setSizeAndStyle (float newHeight, int newStyleFlags, float newHorizontalScale, - float newKerningAmount) throw(); + float newKerningAmount); //============================================================================== /** Returns the total width of a string as it would be drawn using this font. For a more accurate floating-point result, use getStringWidthFloat(). */ - int getStringWidth (const String& text) const throw(); + int getStringWidth (const String& text) const; /** Returns the total width of a string as it would be drawn using this font. @see getStringWidth */ - float getStringWidthFloat (const String& text) const throw(); + float getStringWidthFloat (const String& text) const; /** Returns the series of glyph numbers and their x offsets needed to represent a string. An extra x offset is added at the end of the run, to indicate where the right hand edge of the last character is. */ - void getGlyphPositions (const String& text, Array & glyphs, Array & xOffsets) const throw(); + void getGlyphPositions (const String& text, Array & glyphs, Array & xOffsets) const; //============================================================================== /** Returns the typeface used by this font. @@ -313,7 +314,7 @@ public: Note that the object returned may go out of scope if this font is deleted or has its style changed. */ - Typeface* getTypeface() const throw(); + Typeface* getTypeface() const; /** Creates an array of Font objects to represent all the fonts on the system. @@ -322,7 +323,7 @@ public: @param results the array to which new Font objects will be added. */ - static void findFonts (Array& results) throw(); + static void findFonts (Array& results); /** Returns a list of all the available typeface names. @@ -337,12 +338,12 @@ public: /** Returns the name of the typeface to be used for rendering glyphs that aren't found in the requested typeface. */ - static const String getFallbackFontName() throw(); + static const String getFallbackFontName(); /** Sets the (platform-specific) name of the typeface to use to find glyphs that aren't available in whatever font you're trying to use. */ - static void setFallbackFontName (const String& name) throw(); + static void setFallbackFontName (const String& name); //============================================================================== /** Creates a string to describe this font. @@ -380,7 +381,7 @@ private: }; ReferenceCountedObjectPtr font; - void dupeInternalIfShared() throw(); + void dupeInternalIfShared(); }; #endif // __JUCE_FONT_JUCEHEADER__ diff --git a/src/io/files/juce_ZipFile.cpp b/src/io/files/juce_ZipFile.cpp index 7eea5e68bb..0b3c6e79e4 100644 --- a/src/io/files/juce_ZipFile.cpp +++ b/src/io/files/juce_ZipFile.cpp @@ -396,7 +396,7 @@ bool ZipFile::uncompressEntry (const int index, if (zei->entry.filename.endsWithChar ('/')) { - targetFile.createDirectory(); // (entry is a directory, not a file) + return targetFile.createDirectory(); // (entry is a directory, not a file) } else { diff --git a/src/native/common/juce_posix_SharedCode.h b/src/native/common/juce_posix_SharedCode.h index 9e31ee3faf..d3d175aac2 100644 --- a/src/native/common/juce_posix_SharedCode.h +++ b/src/native/common/juce_posix_SharedCode.h @@ -220,7 +220,7 @@ bool File::setAsCurrentWorkingDirectory() const } //============================================================================== -#if JUCE_IOS +#if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T typedef struct stat64 juce_statStruct; // (need to use the 64-bit version to work around a simulator bug) #else typedef struct stat juce_statStruct; @@ -229,11 +229,11 @@ bool File::setAsCurrentWorkingDirectory() const static bool juce_stat (const String& fileName, juce_statStruct& info) { return fileName.isNotEmpty() -#if JUCE_IOS + #if JUCE_IOS && ! __DARWIN_ONLY_64_BIT_INO_T && (stat64 (fileName.toUTF8(), &info) == 0); -#else + #else && (stat (fileName.toUTF8(), &info) == 0); -#endif + #endif } bool File::isDirectory() const diff --git a/src/text/juce_String.cpp b/src/text/juce_String.cpp index 697409f48e..360aea73c5 100644 --- a/src/text/juce_String.cpp +++ b/src/text/juce_String.cpp @@ -137,6 +137,7 @@ public: static void copyChars (juce_wchar* const dest, const juce_wchar* const src, const size_t numChars) throw() { + jassert (src != 0 & dest != 0); memcpy (dest, src, numChars * sizeof (juce_wchar)); dest [numChars] = 0; } @@ -2157,7 +2158,10 @@ int String::copyToCString (char* destBuffer, const int maxBufferSizeBytes) const //============================================================================== void String::copyToUnicode (juce_wchar* const destBuffer, const int maxCharsToCopy) const throw() { - StringHolder::copyChars (destBuffer, text, jmin (maxCharsToCopy, length())); + jassert (destBuffer != 0 && maxCharsToCopy >= 0); + + if (destBuffer != 0 && maxCharsToCopy >= 0) + StringHolder::copyChars (destBuffer, text, jmin (maxCharsToCopy, length())); } diff --git a/src/text/juce_String.h b/src/text/juce_String.h index a744b6ea04..b3e0b5a23c 100644 --- a/src/text/juce_String.h +++ b/src/text/juce_String.h @@ -984,7 +984,7 @@ public: @param destBuffer the place to copy it to @param maxCharsToCopy the maximum number of characters to copy to the buffer, - not including the tailing zero, so this shouldn't be + NOT including the trailing zero, so this shouldn't be larger than the size of your destination buffer - 1 */ void copyToUnicode (juce_wchar* destBuffer, int maxCharsToCopy) const throw();