diff --git a/data/copy-juce-carla b/data/copy-juce-carla index 76f4efb8f..df6dba3f6 100755 --- a/data/copy-juce-carla +++ b/data/copy-juce-carla @@ -2,8 +2,8 @@ set -e -JUCE_MODULES_DIR="/home/falktx/Personal/FOSS/GIT/distrho/DISTRHO/libs/juce/source/modules/" -CARLA_MODULES_DIR="/home/falktx/Personal/FOSS/GIT/falktx/Carla/source/modules/" +JUCE_MODULES_DIR="/home/falktx/FOSS/GIT-mine/DISTRHO/libs/juce/source/modules/" +CARLA_MODULES_DIR="/home/falktx/FOSS/GIT-mine/Carla/source/modules/" MODULES=("juce_audio_basics juce_audio_devices juce_audio_formats juce_audio_processors juce_core juce_data_structures juce_events juce_graphics juce_gui_basics juce_gui_extra") diff --git a/source/modules/juce_audio_devices/native/juce_android_Midi.cpp b/source/modules/juce_audio_devices/native/juce_android_Midi.cpp index f84fc7177..88eeae6ed 100644 --- a/source/modules/juce_audio_devices/native/juce_android_Midi.cpp +++ b/source/modules/juce_audio_devices/native/juce_android_Midi.cpp @@ -41,6 +41,7 @@ MidiOutput* MidiOutput::openDevice (int index) MidiOutput::~MidiOutput() { + stopBackgroundThread(); } void MidiOutput::sendMessageNow (const MidiMessage&) diff --git a/source/modules/juce_audio_devices/native/juce_linux_Midi.cpp b/source/modules/juce_audio_devices/native/juce_linux_Midi.cpp index 9aa658680..a6799f3d5 100644 --- a/source/modules/juce_audio_devices/native/juce_linux_Midi.cpp +++ b/source/modules/juce_audio_devices/native/juce_linux_Midi.cpp @@ -512,12 +512,14 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName) MidiOutput::~MidiOutput() { - delete static_cast (internal); + stopBackgroundThread(); + + delete static_cast (internal); } void MidiOutput::sendMessageNow (const MidiMessage& message) { - static_cast (internal)->sendMessageNow (message); + static_cast (internal)->sendMessageNow (message); } //============================================================================== @@ -529,7 +531,7 @@ MidiInput::MidiInput (const String& nm) MidiInput::~MidiInput() { stop(); - delete static_cast (internal); + delete static_cast (internal); } void MidiInput::start() diff --git a/source/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp b/source/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp index 7e4fb2cd1..5f8b3d5a6 100644 --- a/source/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp +++ b/source/modules/juce_audio_devices/native/juce_mac_CoreMidi.cpp @@ -357,6 +357,8 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName) MidiOutput::~MidiOutput() { + stopBackgroundThread(); + delete static_cast (internal); } diff --git a/source/modules/juce_audio_devices/native/juce_win32_Midi.cpp b/source/modules/juce_audio_devices/native/juce_win32_Midi.cpp index fd5e60c53..2737b1e66 100644 --- a/source/modules/juce_audio_devices/native/juce_win32_Midi.cpp +++ b/source/modules/juce_audio_devices/native/juce_win32_Midi.cpp @@ -297,11 +297,11 @@ MidiInput::MidiInput (const String& name_) MidiInput::~MidiInput() { - delete static_cast (internal); + delete static_cast (internal); } -void MidiInput::start() { static_cast (internal)->start(); } -void MidiInput::stop() { static_cast (internal)->stop(); } +void MidiInput::start() { static_cast (internal)->start(); } +void MidiInput::stop() { static_cast (internal)->stop(); } //============================================================================== @@ -432,7 +432,7 @@ MidiOutput::~MidiOutput() { stopBackgroundThread(); - MidiOutHandle* const h = static_cast (internal); + MidiOutHandle* const h = static_cast (internal); if (MidiOutHandle::activeHandles.contains (h) && --(h->refCount) == 0) { @@ -444,7 +444,7 @@ MidiOutput::~MidiOutput() void MidiOutput::sendMessageNow (const MidiMessage& message) { - const MidiOutHandle* const handle = static_cast (internal); + const MidiOutHandle* const handle = static_cast (internal); if (message.getRawDataSize() > 3 || message.isSysEx()) { diff --git a/source/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp b/source/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp index 11eec0fcb..f5f566483 100644 --- a/source/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp +++ b/source/modules/juce_audio_formats/codecs/juce_WindowsMediaAudioFormat.cpp @@ -127,9 +127,7 @@ class WMAudioReader : public AudioFormatReader public: WMAudioReader (InputStream* const input_) : AudioFormatReader (input_, TRANS (wmFormatName)), - wmvCoreLib ("Wmvcore.dll"), - currentPosition (0), - bufferStart (0), bufferEnd (0) + wmvCoreLib ("Wmvcore.dll") { JUCE_LOAD_WINAPI_FUNCTION (wmvCoreLib, WMCreateSyncReader, wmCreateSyncReader, HRESULT, (IUnknown*, DWORD, IWMSyncReader**)) @@ -168,30 +166,24 @@ public: checkCoInitialiseCalled(); - if (startSampleInFile != currentPosition) - { - currentPosition = startSampleInFile; - wmSyncReader->SetRange (((QWORD) startSampleInFile * 10000000) / (int) sampleRate, 0); - bufferStart = bufferEnd = 0; - } - const int stride = numChannels * sizeof (int16); - bool firstLoop = true; while (numSamples > 0) { - if (bufferEnd <= bufferStart) + if (! bufferedRange.contains (startSampleInFile)) { + const bool hasJumped = (startSampleInFile != bufferedRange.getEnd()); + + if (hasJumped) + wmSyncReader->SetRange ((QWORD) (startSampleInFile * 10000000 / (int64) sampleRate), 0); + ComSmartPtr sampleBuffer; QWORD sampleTime, duration; DWORD flags, outputNum; WORD streamNum; - int64 readBufferStart; - HRESULT hr = wmSyncReader->GetNextSample (1, sampleBuffer.resetAndGetPointerAddress(), &sampleTime, - &duration, &flags, &outputNum, &streamNum); - - readBufferStart = (int64)floor((sampleTime * sampleRate) * 0.0000001); + HRESULT hr = wmSyncReader->GetNextSample (1, sampleBuffer.resetAndGetPointerAddress(), + &sampleTime, &duration, &flags, &outputNum, &streamNum); if (sampleBuffer != nullptr) { @@ -199,41 +191,35 @@ public: DWORD dataLength = 0; hr = sampleBuffer->GetBufferAndLength (&rawData, &dataLength); - bufferStart = 0; - bufferEnd = (int) dataLength; - - if (bufferEnd <= 0) - { - sampleBuffer->Release(); + if (dataLength == 0) return false; - } - buffer.ensureSize (bufferEnd); - memcpy (buffer.getData(), rawData, bufferEnd); + if (hasJumped) + bufferedRange.setStart ((int64) ((sampleTime * (int64) sampleRate) / 10000000)); + else + bufferedRange.setStart (bufferedRange.getEnd()); // (because the positions returned often aren't continguous) - if (firstLoop && readBufferStart < startSampleInFile) - { - bufferStart += stride * (int) (startSampleInFile - readBufferStart); - - if (bufferStart > bufferEnd) - bufferStart = bufferEnd; - } + bufferedRange.setLength ((int64) (dataLength / stride)); + buffer.ensureSize ((int) dataLength); + memcpy (buffer.getData(), rawData, (size_t) dataLength); } - else + else if (hr == NS_E_NO_MORE_SAMPLES) { - bufferStart = 0; - bufferEnd = 512; - buffer.ensureSize (bufferEnd); + bufferedRange.setStart (startSampleInFile); + bufferedRange.setLength (256); + buffer.ensureSize (256 * stride); buffer.fillWith (0); } - - firstLoop = false; + else + { + return false; + } } - - const int16* const rawData = static_cast (addBytesToPointer (buffer.getData(), bufferStart)); - const int numToDo = jmin (numSamples, (bufferEnd - bufferStart) / stride); + const int offsetInBuffer = (int) (startSampleInFile - bufferedRange.getStart()); + const int16* const rawData = static_cast (addBytesToPointer (buffer.getData(), offsetInBuffer * stride)); + const int numToDo = jmin (numSamples, (int) (bufferedRange.getLength() - offsetInBuffer)); for (int i = 0; i < numDestChannels; ++i) { @@ -250,13 +236,9 @@ public: } } - bufferStart += numToDo * stride; - if (bufferEnd - bufferStart < stride) - bufferStart = bufferEnd; - + startSampleInFile += numToDo; startOffsetInDestBuffer += numToDo; numSamples -= numToDo; - currentPosition += numToDo; } return true; @@ -265,9 +247,8 @@ public: private: DynamicLibrary wmvCoreLib; ComSmartPtr wmSyncReader; - int64 currentPosition; MemoryBlock buffer; - int bufferStart, bufferEnd; + Range bufferedRange; void checkCoInitialiseCalled() { diff --git a/source/modules/juce_core/files/juce_FileOutputStream.cpp b/source/modules/juce_core/files/juce_FileOutputStream.cpp index c4dd84aeb..961a8d19e 100644 --- a/source/modules/juce_core/files/juce_FileOutputStream.cpp +++ b/source/modules/juce_core/files/juce_FileOutputStream.cpp @@ -44,7 +44,6 @@ FileOutputStream::FileOutputStream (const File& f, const size_t bufferSizeToUse) FileOutputStream::~FileOutputStream() { flushBuffer(); - flushInternal(); closeHandle(); } diff --git a/source/modules/juce_core/native/juce_win32_ComSmartPtr.h b/source/modules/juce_core/native/juce_win32_ComSmartPtr.h index 8d7c912f9..0dc0efc20 100644 --- a/source/modules/juce_core/native/juce_win32_ComSmartPtr.h +++ b/source/modules/juce_core/native/juce_win32_ComSmartPtr.h @@ -29,7 +29,7 @@ #ifndef JUCE_WIN32_COMSMARTPTR_H_INCLUDED #define JUCE_WIN32_COMSMARTPTR_H_INCLUDED -#ifndef _MSC_VER +#if ! (defined (_MSC_VER) || defined (__uuidof)) template struct UUIDGetter { static CLSID get() { jassertfalse; return CLSID(); } }; #define __uuidof(x) UUIDGetter::get() #endif diff --git a/source/modules/juce_core/native/juce_win32_Threads.cpp b/source/modules/juce_core/native/juce_win32_Threads.cpp index bbc907f75..4eb24e2c0 100644 --- a/source/modules/juce_core/native/juce_win32_Threads.cpp +++ b/source/modules/juce_core/native/juce_win32_Threads.cpp @@ -558,8 +558,16 @@ bool ChildProcess::start (const StringArray& args, int streamFlags) String escaped; for (int i = 0; i < args.size(); ++i) - escaped << args[i].replace ("\"", "\\\"") - .replace (" ", "\\ ") << ' '; + { + String arg (args[i]); + + // If there are spaces, surround it with quotes. If there are quotes, + // replace them with \" so that CommandLineToArgv will correctly parse them. + if (arg.containsAnyOf ("\" ")) + arg = arg.replace ("\"", "\\\"").quoted(); + + escaped << arg << ' '; + } return start (escaped.trim(), streamFlags); } diff --git a/source/modules/juce_graphics/colour/juce_Colour.cpp b/source/modules/juce_graphics/colour/juce_Colour.cpp index 0646287eb..aaf946865 100644 --- a/source/modules/juce_graphics/colour/juce_Colour.cpp +++ b/source/modules/juce_graphics/colour/juce_Colour.cpp @@ -29,19 +29,6 @@ namespace ColourHelpers return n <= 0.0f ? 0 : (n >= 1.0f ? 255 : static_cast (n * 255.996f)); } - // This is an adjusted brightness value, based on the way the human - // eye responds to different colour channels.. - static float getPerceivedBrightness (Colour c) noexcept - { - const float r = c.getFloatRed(); - const float g = c.getFloatGreen(); - const float b = c.getFloatBlue(); - - return std::sqrt (r * r * 0.241f - + g * g * 0.691f - + b * b * 0.068f); - } - //============================================================================== struct HSB { @@ -333,6 +320,13 @@ Colour Colour::withHue (float h) const noexcept { ColourHelpers::HSB hs Colour Colour::withSaturation (float s) const noexcept { ColourHelpers::HSB hsb (*this); hsb.saturation = s; return hsb.toColour (*this); } Colour Colour::withBrightness (float v) const noexcept { ColourHelpers::HSB hsb (*this); hsb.brightness = v; return hsb.toColour (*this); } +float Colour::getPerceivedBrightness() const noexcept +{ + return std::sqrt (0.241f * square (getFloatRed()) + + 0.691f * square (getFloatGreen()) + + 0.068f * square (getFloatBlue())); +} + //============================================================================== Colour Colour::withRotatedHue (const float amountToRotate) const noexcept { @@ -386,9 +380,9 @@ Colour Colour::greyLevel (const float brightness) noexcept //============================================================================== Colour Colour::contrasting (const float amount) const noexcept { - return overlaidWith ((ColourHelpers::getPerceivedBrightness (*this) >= 0.5f - ? Colours::black - : Colours::white).withAlpha (amount)); + return overlaidWith ((getPerceivedBrightness() >= 0.5f + ? Colours::black + : Colours::white).withAlpha (amount)); } Colour Colour::contrasting (Colour target, float minContrast) const noexcept @@ -409,8 +403,8 @@ Colour Colour::contrasting (Colour target, float minContrast) const noexcept Colour Colour::contrasting (Colour colour1, Colour colour2) noexcept { - const float b1 = ColourHelpers::getPerceivedBrightness (colour1); - const float b2 = ColourHelpers::getPerceivedBrightness (colour2); + const float b1 = colour1.getPerceivedBrightness(); + const float b2 = colour2.getPerceivedBrightness(); float best = 0.0f; float bestDist = 0.0f; diff --git a/source/modules/juce_graphics/colour/juce_Colour.h b/source/modules/juce_graphics/colour/juce_Colour.h index 3e2b222b7..4d845048f 100644 --- a/source/modules/juce_graphics/colour/juce_Colour.h +++ b/source/modules/juce_graphics/colour/juce_Colour.h @@ -243,6 +243,12 @@ public: */ float getBrightness() const noexcept; + /** Returns a skewed brightness value, adjusted to better reflect the way the human + eye responds to different colour channels. This makes it better than getBrightness() + for comparing differences in brightness. + */ + float getPerceivedBrightness() const noexcept; + /** Returns the colour's hue, saturation and brightness components all at once. The values returned are in the range 0.0 to 1.0 */ diff --git a/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp b/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp index 200725283..926307234 100644 --- a/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp +++ b/source/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cpp @@ -225,10 +225,13 @@ void LookAndFeel_V3::drawTabButton (TabBarButton& button, Graphics& g, bool isMo if (TabbedButtonBar* bar = button.findParentComponentOfClass()) { - if (button.isFrontTab() && bar->isColourSpecified (TabbedButtonBar::frontTextColourId)) - col = bar->findColour (TabbedButtonBar::frontTextColourId); - else if (bar->isColourSpecified (TabbedButtonBar::tabTextColourId)) - col = bar->findColour (TabbedButtonBar::tabTextColourId); + TabbedButtonBar::ColourIds colID = button.isFrontTab() ? TabbedButtonBar::frontTextColourId + : TabbedButtonBar::tabTextColourId; + + if (bar->isColourSpecified (colID)) + col = bar->findColour (colID); + else if (isColourSpecified (colID)) + col = findColour (colID); } const Rectangle area (button.getTextArea().toFloat()); diff --git a/source/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp b/source/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp index 0d49dfb73..fb5a4113d 100644 --- a/source/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp +++ b/source/modules/juce_gui_basics/native/juce_linux_FileChooser.cpp @@ -102,7 +102,6 @@ void FileChooser::showPlatformDialog (Array& results, args.add (startPath); args.add (filters.replaceCharacter (';', ' ')); - args.add ("2>/dev/null"); } else { @@ -136,6 +135,8 @@ void FileChooser::showPlatformDialog (Array& results, args.add ("--filename=" + file.getFileName()); } + args.add ("2>/dev/null"); // (to avoid logging info ending up in the results) + ChildProcess child; if (child.start (args, ChildProcess::wantStdOut)) diff --git a/source/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp b/source/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp index b4b9a9f76..a52a20d78 100644 --- a/source/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp +++ b/source/modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp @@ -165,18 +165,20 @@ juce_wchar CodeDocument::Iterator::nextChar() noexcept return 0; } - const juce_wchar result = charPointer.getAndAdvance(); - - if (result == 0) - { - ++line; - charPointer = nullptr; - } - else + if (const juce_wchar result = charPointer.getAndAdvance()) { + if (charPointer.isEmpty()) + { + ++line; + charPointer = nullptr; + } + ++position; return result; } + + ++line; + charPointer = nullptr; } } @@ -212,9 +214,7 @@ juce_wchar CodeDocument::Iterator::peekNextChar() const noexcept return 0; } - const juce_wchar c = *charPointer; - - if (c != 0) + if (const juce_wchar c = *charPointer) return c; if (const CodeDocumentLine* const l = document->lines [line + 1]) diff --git a/source/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp b/source/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp index bfded7a68..98311536b 100644 --- a/source/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp +++ b/source/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.cpp @@ -116,7 +116,7 @@ public: if (previousCommand != 0) message << "\n\n(" << TRANS("Currently assigned to \"CMDN\"") - .replace ("CMDN", owner.getCommandManager().getNameOfCommand (previousCommand)) + .replace ("CMDN", TRANS (owner.getCommandManager().getNameOfCommand (previousCommand))) << ')'; setMessage (message);