From c4d51065631a560cfcc628392988a3b4c2552c2a Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 26 Oct 2017 20:51:19 +0200 Subject: [PATCH] Remove a few more juce related code --- source/backend/engine/CarlaEngineBridge.cpp | 3 + source/backend/engine/CarlaEngineGraph.cpp | 3 + source/backend/engine/CarlaEngineJack.cpp | 27 +++--- source/backend/engine/CarlaEngineNative.cpp | 1 + source/utils/CarlaBinaryUtils.hpp | 9 +- source/utils/CarlaEngineUtils.hpp | 93 --------------------- source/utils/CarlaJuceUtils.hpp | 6 -- source/utils/CarlaPatchbayUtils.hpp | 2 +- source/utils/CarlaStringList.hpp | 23 ++++- 9 files changed, 47 insertions(+), 120 deletions(-) diff --git a/source/backend/engine/CarlaEngineBridge.cpp b/source/backend/engine/CarlaEngineBridge.cpp index cf0e6ed3e..b0988fdce 100644 --- a/source/backend/engine/CarlaEngineBridge.cpp +++ b/source/backend/engine/CarlaEngineBridge.cpp @@ -31,6 +31,9 @@ # include #endif +#include "AppConfig.h" +#include "juce_core/juce_core.h" + // must be last #include "jackbridge/JackBridge.hpp" diff --git a/source/backend/engine/CarlaEngineGraph.cpp b/source/backend/engine/CarlaEngineGraph.cpp index 94cba098a..d17c4130f 100644 --- a/source/backend/engine/CarlaEngineGraph.cpp +++ b/source/backend/engine/CarlaEngineGraph.cpp @@ -22,6 +22,9 @@ #include "CarlaMathUtils.hpp" #include "CarlaMIDI.h" +#include "AppConfig.h" +#include "juce_audio_basics/juce_audio_basics.h" + using juce::AudioBuffer; using juce::FloatVectorOperations; using juce::MemoryBlock; diff --git a/source/backend/engine/CarlaEngineJack.cpp b/source/backend/engine/CarlaEngineJack.cpp index f599c8fb3..baa2951ce 100644 --- a/source/backend/engine/CarlaEngineJack.cpp +++ b/source/backend/engine/CarlaEngineJack.cpp @@ -26,7 +26,6 @@ #include "CarlaStringList.hpp" #include "jackey.h" -#include "juce_audio_basics/juce_audio_basics.h" #ifdef __SSE2_MATH__ # include @@ -37,10 +36,6 @@ #define URI_CANVAS_ICON "http://kxstudio.sf.net/ns/canvas/icon" -using juce::FloatVectorOperations; -using juce::String; -using juce::StringArray; - CARLA_BACKEND_START_NAMESPACE class CarlaEngineJack; @@ -137,7 +132,7 @@ public: } if (! kIsInput) - FloatVectorOperations::clear(fBuffer, static_cast(bufferSize)); + carla_zeroFloats(fBuffer, static_cast(bufferSize)); } void invalidate() noexcept @@ -229,7 +224,7 @@ public: } if (! kIsInput) - FloatVectorOperations::clear(fBuffer, static_cast(bufferSize)); + carla_zeroFloats(fBuffer, static_cast(bufferSize)); } void invalidate() noexcept @@ -1560,10 +1555,10 @@ protected: if (pData->aboutToClose) { if (float* const audioOut1 = (float*)jackbridge_port_get_buffer(fRackPorts[kRackPortAudioOut1], nframes)) - FloatVectorOperations::clear(audioOut1, static_cast(nframes)); + carla_zeroFloats(audioOut1, nframes); if (float* const audioOut2 = (float*)jackbridge_port_get_buffer(fRackPorts[kRackPortAudioOut2], nframes)) - FloatVectorOperations::clear(audioOut2, static_cast(nframes)); + carla_zeroFloats(audioOut2, nframes); } else if (pData->curPluginCount == 0) { @@ -1579,8 +1574,8 @@ protected: CARLA_SAFE_ASSERT_RETURN(audioOut2 != nullptr,); // pass-through - FloatVectorOperations::copy(audioOut1, audioIn1, static_cast(nframes)); - FloatVectorOperations::copy(audioOut2, audioIn2, static_cast(nframes)); + carla_copyFloats(audioOut1, audioIn1, nframes); + carla_copyFloats(audioOut2, audioIn2, nframes); // TODO pass-through MIDI as well if (void* const eventOut = jackbridge_port_get_buffer(fRackPorts[kRackPortEventOut], nframes)) @@ -2024,11 +2019,11 @@ private: { CARLA_SAFE_ASSERT_RETURN(ourName != nullptr && ourName[0] != '\0',); - StringArray parsedGroups; + CarlaStringList parsedGroups; // add our client first { - parsedGroups.add(String(ourName)); + parsedGroups.append(ourName); GroupNameToId groupNameToId; groupNameToId.setData(++fUsedGroups.lastId, ourName); @@ -2061,9 +2056,7 @@ private: CARLA_SAFE_ASSERT_CONTINUE(found); - String jGroupName(groupName.buffer()); - - if (parsedGroups.contains(jGroupName)) + if (parsedGroups.contains(groupName)) { groupId = fUsedGroups.getGroupId(groupName); CARLA_SAFE_ASSERT_CONTINUE(groupId > 0); @@ -2071,7 +2064,7 @@ private: else { groupId = ++fUsedGroups.lastId; - parsedGroups.add(jGroupName); + parsedGroups.append(groupName); int pluginId = -1; PatchbayIcon icon = (jackPortFlags & JackPortIsPhysical) ? PATCHBAY_ICON_HARDWARE : PATCHBAY_ICON_APPLICATION; diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index 7e077c649..46a70e315 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -34,6 +34,7 @@ #include "CarlaHost.h" #include "CarlaNative.hpp" +#include "AppConfig.h" #include "juce_audio_basics/juce_audio_basics.h" using juce::File; diff --git a/source/utils/CarlaBinaryUtils.hpp b/source/utils/CarlaBinaryUtils.hpp index 91c185c52..d854bf8bc 100644 --- a/source/utils/CarlaBinaryUtils.hpp +++ b/source/utils/CarlaBinaryUtils.hpp @@ -22,6 +22,7 @@ #include "CarlaUtils.hpp" #if defined(CARLA_OS_WIN) +# include "AppConfig.h" # include "juce_core/juce_core.h" #elif defined(HAVE_LIBMAGIC) # include @@ -129,10 +130,14 @@ BinaryType getBinaryTypeFromFile(const char* const filename) if (std::strstr(output, "MS Windows") != nullptr) if (std::strstr(output, "PE32 executable") != nullptr || std::strstr(output, "PE32+ executable") != nullptr) - return (std::strstr(output, "x86-64") != nullptr) ? BINARY_WIN64 : BINARY_WIN32; + return (std::strstr(output, "x86-64") != nullptr) + ? BINARY_WIN64 + : BINARY_WIN32; if (std::strstr(output, "ELF") != nullptr) - return (std::strstr(output, "x86-64") != nullptr || std::strstr(output, "aarch64") != nullptr) ? BINARY_POSIX64 : BINARY_POSIX32; + return (std::strstr(output, "x86-64") != nullptr || std::strstr(output, "aarch64") != nullptr) + ? BINARY_POSIX64 + : BINARY_POSIX32; #endif return BINARY_NATIVE; diff --git a/source/utils/CarlaEngineUtils.hpp b/source/utils/CarlaEngineUtils.hpp index a767c6bbf..e555182c0 100644 --- a/source/utils/CarlaEngineUtils.hpp +++ b/source/utils/CarlaEngineUtils.hpp @@ -21,11 +21,6 @@ #include "CarlaEngine.hpp" #include "CarlaUtils.hpp" -#include "CarlaMIDI.h" - -#include "AppConfig.h" -#include "juce_audio_basics/juce_audio_basics.h" - CARLA_BACKEND_START_NAMESPACE // ----------------------------------------------------------------------- @@ -115,94 +110,6 @@ const char* EngineControlEventType2Str(const EngineControlEventType type) noexce return nullptr; } -// ----------------------------------------------------------------------- - -static inline -void fillEngineEventsFromJuceMidiBuffer(EngineEvent engineEvents[kMaxEngineEventInternalCount], const juce::MidiBuffer& midiBuffer) -{ - const uint8_t* midiData; - int numBytes, sampleNumber; - ushort engineEventIndex = 0; - - for (ushort i=0; i < kMaxEngineEventInternalCount; ++i) - { - const EngineEvent& engineEvent(engineEvents[i]); - - if (engineEvent.type != kEngineEventTypeNull) - continue; - - engineEventIndex = i; - break; - } - - for (juce::MidiBuffer::Iterator midiBufferIterator(midiBuffer); midiBufferIterator.getNextEvent(midiData, numBytes, sampleNumber) && engineEventIndex < kMaxEngineEventInternalCount;) - { - CARLA_SAFE_ASSERT_CONTINUE(numBytes > 0); - CARLA_SAFE_ASSERT_CONTINUE(sampleNumber >= 0); - CARLA_SAFE_ASSERT_CONTINUE(numBytes < 0xFF /* uint8_t max */); - - EngineEvent& engineEvent(engineEvents[engineEventIndex++]); - - engineEvent.time = static_cast(sampleNumber); - engineEvent.fillFromMidiData(static_cast(numBytes), midiData, 0); - } -} - -// ----------------------------------------------------------------------- - -static inline -void fillJuceMidiBufferFromEngineEvents(juce::MidiBuffer& midiBuffer, const EngineEvent engineEvents[kMaxEngineEventInternalCount]) -{ - uint8_t size = 0; - uint8_t mdata[3] = { 0, 0, 0 }; - const uint8_t* mdataPtr = mdata; - uint8_t mdataTmp[EngineMidiEvent::kDataSize]; - - for (ushort i=0; i < kMaxEngineEventInternalCount; ++i) - { - const EngineEvent& engineEvent(engineEvents[i]); - - if (engineEvent.type == kEngineEventTypeNull) - { - break; - } - else if (engineEvent.type == kEngineEventTypeControl) - { - const EngineControlEvent& ctrlEvent(engineEvent.ctrl); - - ctrlEvent.convertToMidiData(engineEvent.channel, size, mdata); - mdataPtr = mdata; - } - else if (engineEvent.type == kEngineEventTypeMidi) - { - const EngineMidiEvent& midiEvent(engineEvent.midi); - - size = midiEvent.size; - - if (size > EngineMidiEvent::kDataSize && midiEvent.dataExt != nullptr) - { - mdataPtr = midiEvent.dataExt; - } - else - { - // copy - carla_copy(mdataTmp, midiEvent.data, size); - // add channel - mdataTmp[0] = static_cast(mdataTmp[0] | (engineEvent.channel & MIDI_CHANNEL_BIT)); - // done - mdataPtr = mdataTmp; - } - } - else - { - continue; - } - - if (size > 0) - midiBuffer.addEvent(mdataPtr, static_cast(size), static_cast(engineEvent.time)); - } -} - // ------------------------------------------------------------------- // Helper classes diff --git a/source/utils/CarlaJuceUtils.hpp b/source/utils/CarlaJuceUtils.hpp index 257f7815d..5085ff906 100644 --- a/source/utils/CarlaJuceUtils.hpp +++ b/source/utils/CarlaJuceUtils.hpp @@ -202,12 +202,6 @@ private: CARLA_PREVENT_HEAP_ALLOCATION }; -#ifdef CARLA_OS_WIN -namespace juce { -extern bool juce_isRunningInWine(); -} -#endif - //===================================================================================================================== #endif // CARLA_JUCE_UTILS_HPP_INCLUDED diff --git a/source/utils/CarlaPatchbayUtils.hpp b/source/utils/CarlaPatchbayUtils.hpp index 50934288e..e72674118 100644 --- a/source/utils/CarlaPatchbayUtils.hpp +++ b/source/utils/CarlaPatchbayUtils.hpp @@ -1,6 +1,6 @@ /* * Carla patchbay utils - * Copyright (C) 2011-2014 Filipe Coelho + * Copyright (C) 2011-2017 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/source/utils/CarlaStringList.hpp b/source/utils/CarlaStringList.hpp index 6844e00be..1df1472a2 100644 --- a/source/utils/CarlaStringList.hpp +++ b/source/utils/CarlaStringList.hpp @@ -1,6 +1,6 @@ /* * Carla String List - * Copyright (C) 2014 Filipe Coelho + * Copyright (C) 2014-2017 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -261,6 +261,27 @@ public: // ------------------------------------------------------------------- + bool contains(const char* const string) noexcept + { + CARLA_SAFE_ASSERT_RETURN(string != nullptr, false); + + if (fCount == 0) + return false; + + for (Itenerator it = begin2(); it.valid(); it.next()) + { + const char* const stringComp(it.getValue(nullptr)); + CARLA_SAFE_ASSERT_CONTINUE(stringComp != nullptr); + + if (std::strcmp(string, stringComp) == 0) + return true; + } + + return false; + } + + // ------------------------------------------------------------------- + void remove(Itenerator& it) noexcept { if (const char* const string = it.getValue(nullptr))