diff --git a/source/backend/engine/CarlaEngineJuce.cpp b/source/backend/engine/CarlaEngineJuce.cpp index 93d6f1e08..d4e46d888 100644 --- a/source/backend/engine/CarlaEngineJuce.cpp +++ b/source/backend/engine/CarlaEngineJuce.cpp @@ -140,11 +140,11 @@ public: return false; } - pData->bufferSize = fDevice->getCurrentBufferSizeSamples(); + pData->bufferSize = static_cast(fDevice->getCurrentBufferSizeSamples()); pData->sampleRate = fDevice->getCurrentSampleRate(); - pData->bufAudio.inCount = inputChannels.countNumberOfSetBits(); - pData->bufAudio.outCount = outputChannels.countNumberOfSetBits(); + pData->bufAudio.inCount = static_cast(inputChannels.countNumberOfSetBits()); + pData->bufAudio.outCount = static_cast(outputChannels.countNumberOfSetBits()); CARLA_ASSERT(pData->bufAudio.outCount > 0); @@ -250,14 +250,14 @@ public: for (uint i=0; i < pData->bufAudio.inCount; ++i) { - String inputName(inputNames[i]); + String inputName(inputNames[static_cast(i)]); if (inputName.trim().isNotEmpty()) std::snprintf(strBuf, STR_MAX, "%s", inputName.toRawUTF8()); else std::snprintf(strBuf, STR_MAX, "capture_%i", i+1); - callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_AUDIO_IN, RACK_PATCHBAY_GROUP_AUDIO_IN*1000 + i, PATCHBAY_PORT_TYPE_AUDIO, 0.0f, strBuf); + callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_AUDIO_IN, static_cast(RACK_PATCHBAY_GROUP_AUDIO_IN*1000 + i), PATCHBAY_PORT_TYPE_AUDIO, 0.0f, strBuf); } } @@ -275,14 +275,14 @@ public: for (uint i=0; i < pData->bufAudio.outCount; ++i) { - String outputName(outputNames[i]); + String outputName(outputNames[static_cast(i)]); if (outputName.trim().isNotEmpty()) std::snprintf(strBuf, STR_MAX, "%s", outputName.toRawUTF8()); else std::snprintf(strBuf, STR_MAX, "playback_%i", i+1); - callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_AUDIO_OUT, RACK_PATCHBAY_GROUP_AUDIO_OUT*1000 + i, PATCHBAY_PORT_TYPE_AUDIO|PATCHBAY_PORT_IS_INPUT, 0.0f, strBuf); + callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_AUDIO_OUT, static_cast(RACK_PATCHBAY_GROUP_AUDIO_OUT*1000 + i), PATCHBAY_PORT_TYPE_AUDIO|PATCHBAY_PORT_IS_INPUT, 0.0f, strBuf); } } @@ -448,7 +448,9 @@ protected: } else { - pData->processRackFull(const_cast(inputChannelData), numInputChannels, outputChannelData, numOutputChannels, numSamples, false); + pData->processRackFull(const_cast(inputChannelData), static_cast(numInputChannels), + outputChannelData, static_cast(numOutputChannels), + static_cast(numSamples), false); } // output events @@ -575,7 +577,7 @@ const char* CarlaEngine::getJuceApiName(const unsigned int index) if (static_cast(index) >= gJuceDeviceTypes.size()) return nullptr; - AudioIODeviceType* const deviceType(gJuceDeviceTypes[index]); + AudioIODeviceType* const deviceType(gJuceDeviceTypes[static_cast(index)]); if (deviceType == nullptr) return nullptr; @@ -590,7 +592,7 @@ const char* const* CarlaEngine::getJuceApiDeviceNames(const unsigned int index) if (static_cast(index) >= gJuceDeviceTypes.size()) return nullptr; - AudioIODeviceType* const deviceType(gJuceDeviceTypes[index]); + AudioIODeviceType* const deviceType(gJuceDeviceTypes[static_cast(index)]); if (deviceType == nullptr) return nullptr; @@ -630,7 +632,7 @@ const EngineDriverDeviceInfo* CarlaEngine::getJuceDeviceInfo(const unsigned int return nullptr; } - AudioIODeviceType* const deviceType(gJuceDeviceTypes[index]); + AudioIODeviceType* const deviceType(gJuceDeviceTypes[static_cast(index)]); if (deviceType == nullptr) return nullptr; @@ -670,7 +672,7 @@ const EngineDriverDeviceInfo* CarlaEngine::getJuceDeviceInfo(const unsigned int uint32_t* const bufferSizes(new uint32_t[bufferSizesCount+1]); for (int i=0; i < bufferSizesCount; ++i) - bufferSizes[i] = device->getBufferSizeSamples(i); + bufferSizes[i] = static_cast(device->getBufferSizeSamples(i)); bufferSizes[bufferSizesCount] = 0; devInfo.bufferSizes = bufferSizes; diff --git a/source/backend/plugin/Lv2Plugin.cpp b/source/backend/plugin/Lv2Plugin.cpp index 3e25a557f..e361fe0c0 100644 --- a/source/backend/plugin/Lv2Plugin.cpp +++ b/source/backend/plugin/Lv2Plugin.cpp @@ -20,6 +20,10 @@ #ifdef WANT_LV2 +#ifdef HAVE_JUCE +# include "juce_gui_basics.h" +#endif + #include "CarlaLv2Utils.hpp" #include "CarlaMathUtils.hpp" #include "Lv2AtomQueue.hpp" diff --git a/source/backend/standalone/CarlaStandalone.cpp b/source/backend/standalone/CarlaStandalone.cpp index c3e724585..6ace815cb 100644 --- a/source/backend/standalone/CarlaStandalone.cpp +++ b/source/backend/standalone/CarlaStandalone.cpp @@ -40,65 +40,6 @@ using juce::MessageManager; namespace CB = CarlaBackend; using CB::EngineOptions; -#ifdef HAVE_JUCE -// ----------------------------------------------------------------------- -// Juce Message Thread - -class JuceMessageThread : public CarlaThread -{ -public: - JuceMessageThread() - : CarlaThread("JuceMessageThread"), - fInitialised(false) - { - } - - ~JuceMessageThread() override - { - stop(); - } - - void start() - { - CARLA_SAFE_ASSERT_RETURN(! fInitialised,); - - fInitialised = false; - - CarlaThread::start(); - - while (! fInitialised) - carla_msleep(1); - } - - void stop() - { - if (! fInitialised) - return; - - CarlaThread::stop(-1); - } - -protected: - void run() override - { - fInitialised = true; - - if (MessageManager* const msgMgr = MessageManager::getInstance()) - { - msgMgr->setCurrentThreadAsMessageThread(); - - while ((! shouldExit()) && msgMgr->runDispatchLoopUntil(250)) - {} - } - - fInitialised = false; - } - -private: - volatile bool fInitialised; -}; -#endif - // ------------------------------------------------------------------------------------------------------------------- // Single, standalone engine @@ -113,10 +54,6 @@ struct CarlaBackendStandalone { CarlaString lastError; -#ifdef HAVE_JUCE - JuceMessageThread juceMsgThread; -#endif - CarlaBackendStandalone() : engine(nullptr), engineCallback(nullptr), @@ -145,17 +82,29 @@ struct CarlaBackendStandalone { void init() { JUCE_AUTORELEASEPOOL + { + initialiseJuce_GUI(); + if (MessageManager* const msgMgr = MessageManager::getInstance()) + msgMgr->setCurrentThreadAsMessageThread(); + } + } - initialiseJuce_GUI(); - juceMsgThread.start(); + void idle() + { + JUCE_AUTORELEASEPOOL + { + if (MessageManager* const msgMgr = MessageManager::getInstanceWithoutCreating()) + msgMgr->runDispatchLoopUntil(5); + } } void close() { JUCE_AUTORELEASEPOOL - - juceMsgThread.stop(); - shutdownJuce_GUI(); + { + MessageManager::deleteInstance(); + shutdownJuce_GUI(); + } } #endif @@ -580,6 +529,9 @@ void carla_engine_idle() { CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,); +#ifdef HAVE_JUCE + gStandalone.idle(); +#endif gStandalone.engine->idle(); } diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index 136cc8309..f5290deb4 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -15,6 +15,8 @@ * For a full copy of the GNU General Public License see the doc/GPL.txt file. */ +#undef HAVE_JUCE // FIXME + #include "CarlaBackendUtils.hpp" #include "CarlaLibUtils.hpp" #include "CarlaMathUtils.hpp"