| @@ -142,7 +142,8 @@ HAVE_JUCE = false | |||
| endif | |||
| ifeq ($(LINUX),true) | |||
| HAVE_JUCE = $(shell pkg-config --exists x11 xinerama xext xcursor freetype2 && echo true) | |||
| HAVE_JUCE = "false" | |||
| # $(shell pkg-config --exists x11 xinerama xext xcursor freetype2 && echo true) | |||
| endif | |||
| ifeq ($(MACOS),true) | |||
| @@ -639,6 +639,11 @@ bool CarlaEngine::close() | |||
| CARLA_SAFE_ASSERT_RETURN_ERR(pData->nextAction.opcode == kEnginePostActionNull, "Invalid engine internal data (err #9)"); | |||
| carla_debug("CarlaEngine::close()"); | |||
| pData->aboutToClose = true; | |||
| if (pData->curPluginCount != 0) | |||
| removeAllPlugins(); | |||
| pData->thread.stop(500); | |||
| pData->nextAction.ready(); | |||
| @@ -649,7 +654,6 @@ bool CarlaEngine::close() | |||
| pData->osc.close(); | |||
| pData->oscData = nullptr; | |||
| pData->aboutToClose = true; | |||
| pData->curPluginCount = 0; | |||
| pData->maxPluginNumber = 0; | |||
| pData->nextPluginId = 0; | |||
| @@ -1113,8 +1117,6 @@ CarlaPlugin* CarlaEngine::getPluginUnchecked(const unsigned int id) const noexce | |||
| const char* CarlaEngine::getUniquePluginName(const char* const name) const | |||
| { | |||
| CARLA_SAFE_ASSERT_RETURN(pData->plugins != nullptr, nullptr); | |||
| CARLA_SAFE_ASSERT_RETURN(pData->maxPluginNumber != 0, nullptr); | |||
| CARLA_SAFE_ASSERT_RETURN(pData->nextAction.opcode == kEnginePostActionNull, nullptr); | |||
| CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', nullptr); | |||
| carla_debug("CarlaEngine::getUniquePluginName(\"%s\")", name); | |||
| @@ -1128,7 +1130,12 @@ const char* CarlaEngine::getUniquePluginName(const char* const name) const | |||
| return sname.dup(); | |||
| } | |||
| sname.truncate(getMaxClientNameSize()-5-1); // 5 = strlen(" (10)") | |||
| const size_t maxNameSize(carla_min<uint>(getMaxClientNameSize(), 0xff, 6) - 6); // 6 = strlen(" (10)") + 1 | |||
| if (maxNameSize == 0 || ! isRunning()) | |||
| return sname.dup(); | |||
| sname.truncate(maxNameSize); | |||
| sname.replace(':', '.'); // ':' is used in JACK1 to split client/port names | |||
| for (unsigned short i=0; i < pData->curPluginCount; ++i) | |||
| @@ -1440,57 +1447,36 @@ bool CarlaEngine::saveProject(const char* const filename) | |||
| // ----------------------------------------------------------------------- | |||
| // Information (base) | |||
| /*! | |||
| * Get the current engine driver hints. | |||
| */ | |||
| unsigned int CarlaEngine::getHints() const noexcept | |||
| { | |||
| return pData->hints; | |||
| } | |||
| /*! | |||
| * Get the current buffer size. | |||
| */ | |||
| uint32_t CarlaEngine::getBufferSize() const noexcept | |||
| { | |||
| return pData->bufferSize; | |||
| } | |||
| /*! | |||
| * Get the current sample rate. | |||
| */ | |||
| double CarlaEngine::getSampleRate() const noexcept | |||
| { | |||
| return pData->sampleRate; | |||
| } | |||
| /*! | |||
| * Get the current engine name. | |||
| */ | |||
| const char* CarlaEngine::getName() const noexcept | |||
| { | |||
| return (const char*)pData->name; | |||
| return pData->name.getBuffer(); | |||
| } | |||
| /*! | |||
| * Get the current engine proccess mode. | |||
| */ | |||
| EngineProcessMode CarlaEngine::getProccessMode() const noexcept | |||
| { | |||
| return pData->options.processMode; | |||
| } | |||
| /*! | |||
| * Get the current engine options (read-only). | |||
| */ | |||
| const EngineOptions& CarlaEngine::getOptions() const noexcept | |||
| { | |||
| return pData->options; | |||
| } | |||
| /*! | |||
| * Get the current Time information (read-only). | |||
| */ | |||
| const EngineTimeInfo& CarlaEngine::getTimeInfo() const noexcept | |||
| { | |||
| return pData->timeInfo; | |||
| @@ -423,7 +423,7 @@ public: | |||
| char strBuf[STR_MAX+1]; | |||
| strBuf[STR_MAX] = '\0'; | |||
| //EngineRackBuffers* const rack(pData->bufAudio.rack); | |||
| EngineRackBuffers* const rack(pData->bufAudio.rack); | |||
| // Main | |||
| { | |||
| @@ -501,7 +501,6 @@ public: | |||
| } | |||
| #endif | |||
| #if 0 | |||
| // Connections | |||
| rack->connectLock.lock(); | |||
| @@ -600,7 +599,6 @@ public: | |||
| rack->usedConnections.append(connectionToId); | |||
| rack->lastConnectionId++; | |||
| } | |||
| #endif | |||
| return true; | |||
| } | |||
| @@ -1091,13 +1089,8 @@ const EngineDriverDeviceInfo* CarlaEngine::getRtAudioDeviceInfo(const unsigned i | |||
| { | |||
| initRtApis(); | |||
| carla_stderr("here 000"); | |||
| if (index >= gRtAudioApis.size()) | |||
| { | |||
| carla_stderr("here 001"); | |||
| return nullptr; | |||
| } | |||
| const RtAudio::Api& api(gRtAudioApis[index]); | |||
| @@ -1106,10 +1099,7 @@ const EngineDriverDeviceInfo* CarlaEngine::getRtAudioDeviceInfo(const unsigned i | |||
| const unsigned int devCount(rtAudio.getDeviceCount()); | |||
| if (devCount == 0) | |||
| { | |||
| carla_stderr("here 002"); | |||
| return nullptr; | |||
| } | |||
| unsigned int i; | |||
| RtAudio::DeviceInfo rtAudioDevInfo; | |||
| @@ -1123,10 +1113,7 @@ const EngineDriverDeviceInfo* CarlaEngine::getRtAudioDeviceInfo(const unsigned i | |||
| } | |||
| if (i == devCount) | |||
| { | |||
| carla_stderr("here 003"); | |||
| return nullptr; | |||
| } | |||
| static EngineDriverDeviceInfo devInfo = { 0x0, nullptr, nullptr }; | |||
| static uint32_t dummyBufferSizes[11] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 0 }; | |||
| @@ -1158,8 +1145,6 @@ const EngineDriverDeviceInfo* CarlaEngine::getRtAudioDeviceInfo(const unsigned i | |||
| devInfo.sampleRates = dummySampleRates; | |||
| } | |||
| carla_stderr("here 004"); | |||
| return &devInfo; | |||
| } | |||
| @@ -83,7 +83,7 @@ AuPlugin.cpp.o: AuPlugin.cpp $(CARLA_PLUGIN_HPP) $(CARLA_ENGINE_HPP) $(CARLA_UTI | |||
| $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
| CsoundPlugin.cpp.o: CsoundPlugin.cpp $(CARLA_PLUGIN_INTERNAL_HPP) $(CARLA_ENGINE_HPP) | |||
| $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
| $(CXX) $< $(BUILD_CXX_FLAGS) $(CSOUND_FLAGS) -c -o $@ | |||
| JucePlugin.cpp.o: JucePlugin.cpp $(CARLA_PLUGIN_INTERNAL_HPP) $(CARLA_ENGINE_HPP) | |||
| $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
| @@ -63,6 +63,10 @@ STATIC_LIBS += ../../modules/lilv.a | |||
| LINK_FLAGS += $(LILV_LIBS) | |||
| endif | |||
| ifeq ($(CARLA_CSOUND_SUPPORT),true) | |||
| LINK_FLAGS += $(CSOUND_LIBS) | |||
| endif | |||
| ifeq ($(CARLA_SAMPLERS_SUPPORT),true) | |||
| LINK_FLAGS += $(FLUIDSYNTH_LIBS) | |||
| LINK_FLAGS += $(LINUXSAMPLER_LIBS) | |||
| @@ -0,0 +1,191 @@ | |||
| /* | |||
| * Carla Tests | |||
| * Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * This program is free software; you can redistribute it and/or | |||
| * modify it under the terms of the GNU General Public License as | |||
| * published by the Free Software Foundation; either version 2 of | |||
| * the License, or any later version. | |||
| * | |||
| * This program is distributed in the hope that it will be useful, | |||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
| * GNU General Public License for more details. | |||
| * | |||
| * For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
| */ | |||
| #include "../backend/engine/CarlaEngineInternal.hpp" | |||
| #include "CarlaPlugin.hpp" | |||
| #include "CarlaHost.h" | |||
| #include "CarlaUtils.hpp" | |||
| // ----------------------------------------------------------------------- | |||
| CARLA_BACKEND_START_NAMESPACE | |||
| class CarlaEngineDummy : public CarlaEngine | |||
| { | |||
| public: | |||
| CarlaEngineDummy() | |||
| : CarlaEngine(), | |||
| fIsRunning(false) | |||
| { | |||
| } | |||
| bool init(const char* const clientName) override | |||
| { | |||
| fIsRunning = true; | |||
| pData->bufferSize = 512; | |||
| pData->sampleRate = 44100.0; | |||
| return CarlaEngine::init(clientName); | |||
| } | |||
| bool close() override | |||
| { | |||
| fIsRunning = false; | |||
| return CarlaEngine::close(); | |||
| } | |||
| bool isRunning() const noexcept override | |||
| { | |||
| return fIsRunning; | |||
| } | |||
| bool isOffline() const noexcept override | |||
| { | |||
| return false; | |||
| } | |||
| EngineType getType() const noexcept override | |||
| { | |||
| return kEngineTypePlugin; | |||
| } | |||
| const char* getCurrentDriverName() const noexcept override | |||
| { | |||
| return "Dummy"; | |||
| } | |||
| private: | |||
| bool fIsRunning; | |||
| }; | |||
| CARLA_BACKEND_END_NAMESPACE | |||
| // ----------------------------------------------------------------------- | |||
| CARLA_BACKEND_USE_NAMESPACE | |||
| #define TEST_NAME "TestName" | |||
| void testEngine(CarlaEngine* const eng) | |||
| { | |||
| assert(eng->getMaxClientNameSize() != 0); | |||
| assert(eng->getMaxPortNameSize() != 0); | |||
| assert(eng->getCurrentPluginCount() == 0); | |||
| assert(eng->getMaxPluginNumber() == 0); | |||
| assert(! eng->isRunning()); | |||
| assert(eng->getPlugin(0) == nullptr); | |||
| const char* name1 = eng->getUniquePluginName(TEST_NAME); | |||
| const char* name2 = eng->getUniquePluginName(TEST_NAME); | |||
| const char* name3 = eng->getUniquePluginName(TEST_NAME); | |||
| assert(name1 != nullptr); | |||
| assert(name2 != nullptr); | |||
| assert(name3 != nullptr); | |||
| assert(std::strcmp(name1, TEST_NAME) == 0); | |||
| assert(std::strcmp(name2, TEST_NAME) == 0); | |||
| assert(std::strcmp(name3, TEST_NAME) == 0); | |||
| delete[] name1; | |||
| delete[] name2; | |||
| delete[] name3; | |||
| eng->init("test"); | |||
| assert(eng->getCurrentPluginCount() == 0); | |||
| assert(eng->getMaxPluginNumber() != 0); | |||
| assert(eng->isRunning()); | |||
| assert(eng->getPlugin(0) == nullptr); | |||
| name1 = eng->getUniquePluginName(TEST_NAME); | |||
| name2 = eng->getUniquePluginName(TEST_NAME); | |||
| name3 = eng->getUniquePluginName(TEST_NAME); | |||
| assert(name1 != nullptr); | |||
| assert(name2 != nullptr); | |||
| assert(name3 != nullptr); | |||
| assert(std::strcmp(name1, TEST_NAME) == 0); | |||
| assert(std::strcmp(name2, TEST_NAME) == 0); | |||
| assert(std::strcmp(name3, TEST_NAME) == 0); | |||
| delete[] name1; | |||
| delete[] name2; | |||
| delete[] name3; | |||
| eng->close(); | |||
| // test quick init & close 3 times | |||
| eng->init("test1"); | |||
| eng->close(); | |||
| eng->init("test2"); | |||
| eng->close(); | |||
| eng->init("test3"); | |||
| eng->close(); | |||
| // leave it open | |||
| eng->init("test"); | |||
| // add as much plugins as possible | |||
| for (;;) | |||
| { | |||
| if (! eng->addPlugin(PLUGIN_INTERNAL, nullptr, TEST_NAME, "bypass")) | |||
| break; | |||
| } | |||
| assert(eng->getCurrentPluginCount() != 0); | |||
| assert(eng->getCurrentPluginCount() == eng->getMaxPluginNumber()); | |||
| assert(eng->getCurrentPluginCount() == MAX_DEFAULT_PLUGINS); | |||
| eng->close(); | |||
| } | |||
| int main() | |||
| { | |||
| assert(CarlaEngine::getDriverCount() != 0); | |||
| #if 0 | |||
| for (uint i=0, count=CarlaEngine::getDriverCount(); i < count && i < 4; ++i) | |||
| { | |||
| if (i == 1 || i == 2) continue; | |||
| carla_stdout("driver %i/%i: %s", i+1, count, CarlaEngine::getDriverName(i)); | |||
| if (const char* const* const devNames = CarlaEngine::getDriverDeviceNames(i)) | |||
| { | |||
| for (uint j=0; devNames[j] != nullptr; ++j) | |||
| { | |||
| CarlaEngine::getDriverDeviceInfo(i, devNames[j]); | |||
| } | |||
| } | |||
| } | |||
| #endif | |||
| assert(CarlaPlugin::getNativePluginCount() != 0); | |||
| for (size_t i=0, count=CarlaPlugin::getNativePluginCount(); i < count; ++i) | |||
| { | |||
| assert(CarlaPlugin::getNativePluginDescriptor(i) != nullptr); | |||
| } | |||
| CarlaEngineDummy e; | |||
| testEngine(&e); | |||
| // if (CarlaEngine* const eng = CarlaEngine::newDriverByName("PulseAudio")) | |||
| // { | |||
| // testEngine(eng); | |||
| // delete eng; | |||
| // } | |||
| return 0; | |||
| } | |||
| @@ -58,6 +58,17 @@ CarlaString: CarlaString.cpp ../utils/CarlaString.hpp | |||
| $(CXX) $< $(PEDANTIC_CXX_FLAGS) -o $@ | |||
| valgrind ./$@ | |||
| Engine: Engine.cpp | |||
| $(CXX) $< \ | |||
| ../backend/standalone/CarlaStandalone.cpp.o \ | |||
| -Wl,--start-group \ | |||
| ../backend/carla_engine.a ../backend/carla_plugin.a ../modules/carla_native.a \ | |||
| ../modules/dgl.a ../modules/jackbridge.a ../modules/lilv.a ../modules/rtmempool.a ../modules/rtaudio.a ../modules/rtmidi.a \ | |||
| -Wl,--end-group \ | |||
| $(PEDANTIC_CXX_FLAGS) $(shell pkg-config --libs alsa libpulse-simple liblo QtCore QtXml fluidsynth linuxsampler x11 gl smf fftw3 mxml zlib ntk_images ntk) -o $@ | |||
| env LD_LIBRARY_PATH=../backend valgrind --leak-check=full ./$@ | |||
| # ../modules/juce_audio_basics.a ../modules/juce_core.a \ | |||
| EngineEvents: EngineEvents.cpp | |||
| $(CXX) $< $(PEDANTIC_CXX_FLAGS) -L../backend -lcarla_standalone2 -o $@ | |||
| env LD_LIBRARY_PATH=../backend valgrind ./$@ | |||