| @@ -934,7 +934,7 @@ public: | |||||
| /*! | /*! | ||||
| * Set last error. | * Set last error. | ||||
| */ | */ | ||||
| void setLastError(const char* const error) const; | |||||
| void setLastError(const char* const error) const noexcept; | |||||
| // ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
| // Misc | // Misc | ||||
| @@ -1005,6 +1005,16 @@ public: | |||||
| */ | */ | ||||
| void registerEnginePlugin(const unsigned int id, CarlaPlugin* const plugin) noexcept; | void registerEnginePlugin(const unsigned int id, CarlaPlugin* const plugin) noexcept; | ||||
| #ifndef BUILD_BRIDGE | |||||
| /*! | |||||
| * Virtual functions for handling MIDI ports in the rack patchbay. | |||||
| */ | |||||
| virtual bool connectRackMidiInPort(const int) { return false; } | |||||
| virtual bool connectRackMidiOutPort(const int) { return false; } | |||||
| virtual bool disconnectRackMidiInPort(const int) { return false; } | |||||
| virtual bool disconnectRackMidiOutPort(const int) { return false; } | |||||
| #endif | |||||
| // ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
| protected: | protected: | ||||
| @@ -1050,14 +1060,6 @@ protected: | |||||
| // ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
| // Patchbay stuff | // Patchbay stuff | ||||
| /*! | |||||
| * Virtual functions for handling MIDI ports in the rack patchbay. | |||||
| */ | |||||
| virtual bool connectRackMidiInPort(const int) { return false; } | |||||
| virtual bool connectRackMidiOutPort(const int) { return false; } | |||||
| virtual bool disconnectRackMidiInPort(const int) { return false; } | |||||
| virtual bool disconnectRackMidiOutPort(const int) { return false; } | |||||
| /*! | /*! | ||||
| * Virtual functions for handling patchbay state. | * Virtual functions for handling patchbay state. | ||||
| */ | */ | ||||
| @@ -1491,7 +1491,7 @@ bool CarlaEngine::saveProject(const char* const filename) | |||||
| bool firstPlugin = true; | bool firstPlugin = true; | ||||
| char strBuf[STR_MAX+1]; | char strBuf[STR_MAX+1]; | ||||
| for (unsigned int i=0; i < pData->curPluginCount; ++i) | |||||
| for (uint i=0; i < pData->curPluginCount; ++i) | |||||
| { | { | ||||
| CarlaPlugin* const plugin(pData->plugins[i].plugin); | CarlaPlugin* const plugin(pData->plugins[i].plugin); | ||||
| @@ -1654,6 +1654,7 @@ const char* CarlaEngine::runFileCallback(const FileCallbackOpcode action, const | |||||
| void CarlaEngine::setFileCallback(const FileCallbackFunc func, void* const ptr) noexcept | void CarlaEngine::setFileCallback(const FileCallbackFunc func, void* const ptr) noexcept | ||||
| { | { | ||||
| carla_debug("CarlaEngine::setFileCallback(%p, %p)", func, ptr); | |||||
| pData->fileCallback = func; | pData->fileCallback = func; | ||||
| pData->fileCallbackPtr = ptr; | pData->fileCallbackPtr = ptr; | ||||
| @@ -1663,107 +1664,19 @@ void CarlaEngine::setFileCallback(const FileCallbackFunc func, void* const ptr) | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // Patchbay | // Patchbay | ||||
| bool CarlaEngine::patchbayConnect(const int /*groupA*/, const int portA, const int /*groupB*/, const int portB) | |||||
| bool CarlaEngine::patchbayConnect(const int groupA, const int portA, const int groupB, const int portB) | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT_RETURN(pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY, false); | CARLA_SAFE_ASSERT_RETURN(pData->options.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || pData->options.processMode == ENGINE_PROCESS_MODE_PATCHBAY, false); | ||||
| CARLA_SAFE_ASSERT_RETURN(pData->bufAudio.isReady, false); | CARLA_SAFE_ASSERT_RETURN(pData->bufAudio.isReady, false); | ||||
| carla_debug("CarlaEngineRtAudio::patchbayConnect(%i, %i)", portA, portB); | |||||
| if (pData->bufAudio.usePatchbay) | |||||
| { | |||||
| // not implemented yet | |||||
| return false; | |||||
| } | |||||
| carla_debug("CarlaEngine::patchbayConnect(%i, %i)", portA, portB); | |||||
| EngineRackBuffers* const rack(pData->bufAudio.rack); | |||||
| CARLA_SAFE_ASSERT_RETURN_ERR(portA > RACK_PATCHBAY_PORT_MAX, "Invalid output port"); | |||||
| CARLA_SAFE_ASSERT_RETURN_ERR(portB > RACK_PATCHBAY_PORT_MAX, "Invalid input port"); | |||||
| // only allow connections between Carla and other ports | |||||
| if (portA < 0 && portB < 0) | |||||
| if (portA < 0 || portB < 0) | |||||
| { | { | ||||
| setLastError("Invalid connection (1)"); | |||||
| setLastError("Invalid connection"); | |||||
| return false; | return false; | ||||
| } | } | ||||
| if (portA >= 0 && portB >= 0) | |||||
| { | |||||
| setLastError("Invalid connection (2)"); | |||||
| return false; | |||||
| } | |||||
| const int carlaPort = (portA < 0) ? portA : portB; | |||||
| const int targetPort = (carlaPort == portA) ? portB : portA; | |||||
| bool makeConnection = false; | |||||
| switch (carlaPort) | |||||
| { | |||||
| case RACK_PATCHBAY_PORT_AUDIO_IN1: | |||||
| CARLA_SAFE_ASSERT_BREAK(targetPort >= RACK_PATCHBAY_GROUP_AUDIO_IN*1000); | |||||
| CARLA_SAFE_ASSERT_BREAK(targetPort <= RACK_PATCHBAY_GROUP_AUDIO_IN*1000+999); | |||||
| rack->connectLock.enter(); | |||||
| rack->connectedIn1.append(targetPort - RACK_PATCHBAY_GROUP_AUDIO_IN*1000); | |||||
| rack->connectLock.leave(); | |||||
| makeConnection = true; | |||||
| break; | |||||
| case RACK_PATCHBAY_PORT_AUDIO_IN2: | |||||
| CARLA_SAFE_ASSERT_BREAK(targetPort >= RACK_PATCHBAY_GROUP_AUDIO_IN*1000); | |||||
| CARLA_SAFE_ASSERT_BREAK(targetPort <= RACK_PATCHBAY_GROUP_AUDIO_IN*1000+999); | |||||
| rack->connectLock.enter(); | |||||
| rack->connectedIn2.append(targetPort - RACK_PATCHBAY_GROUP_AUDIO_IN*1000); | |||||
| rack->connectLock.leave(); | |||||
| makeConnection = true; | |||||
| break; | |||||
| case RACK_PATCHBAY_PORT_AUDIO_OUT1: | |||||
| CARLA_SAFE_ASSERT_BREAK(targetPort >= RACK_PATCHBAY_GROUP_AUDIO_OUT*1000); | |||||
| CARLA_SAFE_ASSERT_BREAK(targetPort <= RACK_PATCHBAY_GROUP_AUDIO_OUT*1000+999); | |||||
| rack->connectLock.enter(); | |||||
| rack->connectedOut1.append(targetPort - RACK_PATCHBAY_GROUP_AUDIO_OUT*1000); | |||||
| rack->connectLock.leave(); | |||||
| makeConnection = true; | |||||
| break; | |||||
| case RACK_PATCHBAY_PORT_AUDIO_OUT2: | |||||
| CARLA_SAFE_ASSERT_BREAK(targetPort >= RACK_PATCHBAY_GROUP_AUDIO_OUT*1000); | |||||
| CARLA_SAFE_ASSERT_BREAK(targetPort <= RACK_PATCHBAY_GROUP_AUDIO_OUT*1000+999); | |||||
| rack->connectLock.enter(); | |||||
| rack->connectedOut2.append(targetPort - RACK_PATCHBAY_GROUP_AUDIO_OUT*1000); | |||||
| rack->connectLock.leave(); | |||||
| makeConnection = true; | |||||
| break; | |||||
| case RACK_PATCHBAY_PORT_MIDI_IN: | |||||
| CARLA_SAFE_ASSERT_BREAK(targetPort >= RACK_PATCHBAY_GROUP_MIDI_IN*1000); | |||||
| CARLA_SAFE_ASSERT_BREAK(targetPort <= RACK_PATCHBAY_GROUP_MIDI_IN*1000+999); | |||||
| makeConnection = connectRackMidiInPort(targetPort - RACK_PATCHBAY_GROUP_MIDI_IN*1000); | |||||
| break; | |||||
| case RACK_PATCHBAY_PORT_MIDI_OUT: | |||||
| CARLA_SAFE_ASSERT_BREAK(targetPort >= RACK_PATCHBAY_GROUP_MIDI_OUT*1000); | |||||
| CARLA_SAFE_ASSERT_BREAK(targetPort <= RACK_PATCHBAY_GROUP_MIDI_OUT*1000+999); | |||||
| makeConnection = connectRackMidiOutPort(targetPort - RACK_PATCHBAY_GROUP_MIDI_OUT*1000); | |||||
| break; | |||||
| } | |||||
| if (! makeConnection) | |||||
| { | |||||
| setLastError("Invalid connection (3)"); | |||||
| return false; | |||||
| } | |||||
| ConnectionToId connectionToId; | |||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.portOut = portA; | |||||
| connectionToId.portIn = portB; | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, portA, portB, 0.0f, nullptr); | |||||
| rack->usedConnections.append(connectionToId); | |||||
| rack->lastConnectionId++; | |||||
| return true; | |||||
| return pData->bufAudio.connect(this, groupA, portA, groupB, portB); | |||||
| } | } | ||||
| bool CarlaEngine::patchbayDisconnect(const uint connectionId) | bool CarlaEngine::patchbayDisconnect(const uint connectionId) | ||||
| @@ -1778,6 +1691,7 @@ bool CarlaEngine::patchbayDisconnect(const uint connectionId) | |||||
| return false; | return false; | ||||
| } | } | ||||
| #if 0 | |||||
| EngineRackBuffers* const rack(pData->bufAudio.rack); | EngineRackBuffers* const rack(pData->bufAudio.rack); | ||||
| CARLA_SAFE_ASSERT_RETURN_ERR(rack->usedConnections.count() > 0, "No connections available"); | CARLA_SAFE_ASSERT_RETURN_ERR(rack->usedConnections.count() > 0, "No connections available"); | ||||
| @@ -1846,6 +1760,7 @@ bool CarlaEngine::patchbayDisconnect(const uint connectionId) | |||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| #endif | |||||
| setLastError("Failed to find connection"); | setLastError("Failed to find connection"); | ||||
| return false; | return false; | ||||
| @@ -1884,9 +1799,8 @@ const char* CarlaEngine::getLastError() const noexcept | |||||
| return pData->lastError; | return pData->lastError; | ||||
| } | } | ||||
| void CarlaEngine::setLastError(const char* const error) const | |||||
| void CarlaEngine::setLastError(const char* const error) const noexcept | |||||
| { | { | ||||
| pData->lastError = error; | pData->lastError = error; | ||||
| } | } | ||||
| @@ -2067,7 +1981,7 @@ void CarlaEngine::bufferSizeChanged(const uint32_t newBufferSize) | |||||
| { | { | ||||
| carla_debug("CarlaEngine::bufferSizeChanged(%i)", newBufferSize); | carla_debug("CarlaEngine::bufferSizeChanged(%i)", newBufferSize); | ||||
| for (unsigned int i=0; i < pData->curPluginCount; ++i) | |||||
| for (uint i=0; i < pData->curPluginCount; ++i) | |||||
| { | { | ||||
| CarlaPlugin* const plugin(pData->plugins[i].plugin); | CarlaPlugin* const plugin(pData->plugins[i].plugin); | ||||
| @@ -2082,7 +1996,7 @@ void CarlaEngine::sampleRateChanged(const double newSampleRate) | |||||
| { | { | ||||
| carla_debug("CarlaEngine::sampleRateChanged(%g)", newSampleRate); | carla_debug("CarlaEngine::sampleRateChanged(%g)", newSampleRate); | ||||
| for (unsigned int i=0; i < pData->curPluginCount; ++i) | |||||
| for (uint i=0; i < pData->curPluginCount; ++i) | |||||
| { | { | ||||
| CarlaPlugin* const plugin(pData->plugins[i].plugin); | CarlaPlugin* const plugin(pData->plugins[i].plugin); | ||||
| @@ -2097,7 +2011,7 @@ void CarlaEngine::offlineModeChanged(const bool isOfflineNow) | |||||
| { | { | ||||
| carla_debug("CarlaEngine::offlineModeChanged(%s)", bool2str(isOfflineNow)); | carla_debug("CarlaEngine::offlineModeChanged(%s)", bool2str(isOfflineNow)); | ||||
| for (unsigned int i=0; i < pData->curPluginCount; ++i) | |||||
| for (uint i=0; i < pData->curPluginCount; ++i) | |||||
| { | { | ||||
| CarlaPlugin* const plugin(pData->plugins[i].plugin); | CarlaPlugin* const plugin(pData->plugins[i].plugin); | ||||
| @@ -2138,33 +2052,7 @@ const char* const* CarlaEngine::getPatchbayConnections() const | |||||
| { | { | ||||
| carla_debug("CarlaEngine::getPatchbayConnections()"); | carla_debug("CarlaEngine::getPatchbayConnections()"); | ||||
| if (pData->bufAudio.usePatchbay) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->bufAudio.patchbay != nullptr, nullptr); | |||||
| return pData->bufAudio.patchbay->getConnections(); | |||||
| } | |||||
| else | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(pData->bufAudio.rack != nullptr, nullptr); | |||||
| return pData->bufAudio.rack->getConnections(); | |||||
| } | |||||
| } | |||||
| static int getCarlaPortIdFromName(const char* const shortname) noexcept | |||||
| { | |||||
| if (std::strcmp(shortname, "AudioIn1") == 0) | |||||
| return RACK_PATCHBAY_PORT_AUDIO_IN1; | |||||
| if (std::strcmp(shortname, "AudioIn2") == 0) | |||||
| return RACK_PATCHBAY_PORT_AUDIO_IN2; | |||||
| if (std::strcmp(shortname, "AudioOut1") == 0) | |||||
| return RACK_PATCHBAY_PORT_AUDIO_OUT1; | |||||
| if (std::strcmp(shortname, "AudioOut2") == 0) | |||||
| return RACK_PATCHBAY_PORT_AUDIO_OUT2; | |||||
| if (std::strcmp(shortname, "MidiIn") == 0) | |||||
| return RACK_PATCHBAY_PORT_MIDI_IN; | |||||
| if (std::strcmp(shortname, "MidiOut") == 0) | |||||
| return RACK_PATCHBAY_PORT_MIDI_OUT; | |||||
| return RACK_PATCHBAY_PORT_MAX; | |||||
| return pData->bufAudio.getConnections(); | |||||
| } | } | ||||
| void CarlaEngine::restorePatchbayConnection(const char* const connSource, const char* const connTarget) | void CarlaEngine::restorePatchbayConnection(const char* const connSource, const char* const connTarget) | ||||
| @@ -2173,6 +2061,7 @@ void CarlaEngine::restorePatchbayConnection(const char* const connSource, const | |||||
| CARLA_SAFE_ASSERT_RETURN(connTarget != nullptr && connTarget[0] != '\0',); | CARLA_SAFE_ASSERT_RETURN(connTarget != nullptr && connTarget[0] != '\0',); | ||||
| carla_debug("CarlaEngine::restorePatchbayConnection(\"%s\", \"%s\")", connSource, connTarget); | carla_debug("CarlaEngine::restorePatchbayConnection(\"%s\", \"%s\")", connSource, connTarget); | ||||
| #if 0 | |||||
| if (pData->bufAudio.usePatchbay) | if (pData->bufAudio.usePatchbay) | ||||
| { | { | ||||
| // TODO | // TODO | ||||
| @@ -2249,6 +2138,7 @@ void CarlaEngine::restorePatchbayConnection(const char* const connSource, const | |||||
| patchbayConnect(targetGroup, targetPort, sourceGroup, sourcePort); | patchbayConnect(targetGroup, targetPort, sourceGroup, sourcePort); | ||||
| } | } | ||||
| #endif | |||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -290,12 +290,12 @@ EngineRackBuffers::EngineRackBuffers(const uint32_t bufferSize) | |||||
| resize(bufferSize); | resize(bufferSize); | ||||
| } | } | ||||
| EngineRackBuffers::~EngineRackBuffers() | |||||
| EngineRackBuffers::~EngineRackBuffers() noexcept | |||||
| { | { | ||||
| clear(); | clear(); | ||||
| } | } | ||||
| void EngineRackBuffers::clear() | |||||
| void EngineRackBuffers::clear() noexcept | |||||
| { | { | ||||
| lastConnectionId = 0; | lastConnectionId = 0; | ||||
| @@ -348,6 +348,96 @@ void EngineRackBuffers::resize(const uint32_t bufferSize) | |||||
| } | } | ||||
| } | } | ||||
| bool EngineRackBuffers::connect(CarlaEngine* const engine, const int groupA, const int portA, const int groupB, const int portB) noexcept | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(engine != nullptr, false); | |||||
| CARLA_SAFE_ASSERT_RETURN(groupA != groupB, false); | |||||
| CARLA_SAFE_ASSERT_RETURN(groupA >= RACK_PATCHBAY_GROUP_CARLA && groupA < RACK_PATCHBAY_GROUP_MAX, false); | |||||
| CARLA_SAFE_ASSERT_RETURN(groupB >= RACK_PATCHBAY_GROUP_CARLA && groupB < RACK_PATCHBAY_GROUP_MAX, false); | |||||
| CARLA_SAFE_ASSERT_RETURN(portA >= 0, false); | |||||
| CARLA_SAFE_ASSERT_RETURN(portB >= 0, false); | |||||
| int carlaPort, otherPort; | |||||
| if (groupA == RACK_PATCHBAY_GROUP_CARLA) | |||||
| { | |||||
| carlaPort = portA; | |||||
| otherPort = portB; | |||||
| } | |||||
| else | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(groupB == RACK_PATCHBAY_GROUP_CARLA, false); | |||||
| carlaPort = portB; | |||||
| otherPort = portA; | |||||
| } | |||||
| bool makeConnection = false; | |||||
| switch (carlaPort) | |||||
| { | |||||
| case RACK_PATCHBAY_CARLA_PORT_AUDIO_IN1: | |||||
| connectLock.enter(); | |||||
| connectedIn1.append(otherPort); | |||||
| connectLock.leave(); | |||||
| makeConnection = true; | |||||
| break; | |||||
| case RACK_PATCHBAY_CARLA_PORT_AUDIO_IN2: | |||||
| connectLock.enter(); | |||||
| connectedIn2.append(otherPort); | |||||
| connectLock.leave(); | |||||
| makeConnection = true; | |||||
| break; | |||||
| case RACK_PATCHBAY_CARLA_PORT_AUDIO_OUT1: | |||||
| connectLock.enter(); | |||||
| connectedOut1.append(otherPort); | |||||
| connectLock.leave(); | |||||
| makeConnection = true; | |||||
| break; | |||||
| case RACK_PATCHBAY_CARLA_PORT_AUDIO_OUT2: | |||||
| connectLock.enter(); | |||||
| connectedOut2.append(otherPort); | |||||
| connectLock.leave(); | |||||
| makeConnection = true; | |||||
| break; | |||||
| case RACK_PATCHBAY_CARLA_PORT_MIDI_IN: | |||||
| makeConnection = engine->connectRackMidiInPort(otherPort); | |||||
| break; | |||||
| case RACK_PATCHBAY_CARLA_PORT_MIDI_OUT: | |||||
| makeConnection = engine->connectRackMidiOutPort(otherPort); | |||||
| break; | |||||
| } | |||||
| if (! makeConnection) | |||||
| { | |||||
| engine->setLastError("Invalid rack connection"); | |||||
| return false; | |||||
| } | |||||
| ConnectionToId connectionToId; | |||||
| connectionToId.id = lastConnectionId; | |||||
| connectionToId.groupA = groupA; | |||||
| connectionToId.portA = portA; | |||||
| connectionToId.groupB = groupB; | |||||
| connectionToId.portB = portB; | |||||
| char strBuf[STR_MAX+1]; | |||||
| strBuf[STR_MAX] = '\0'; | |||||
| std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", groupA, portA, groupB, portB); | |||||
| engine->callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, lastConnectionId, 0, 0, 0.0f, strBuf); | |||||
| usedConnections.append(connectionToId); | |||||
| ++lastConnectionId; | |||||
| return true; | |||||
| } | |||||
| const char* const* EngineRackBuffers::getConnections() const | const char* const* EngineRackBuffers::getConnections() const | ||||
| { | { | ||||
| if (usedConnections.count() == 0) | if (usedConnections.count() == 0) | ||||
| @@ -360,56 +450,54 @@ const char* const* EngineRackBuffers::getConnections() const | |||||
| { | { | ||||
| const ConnectionToId& connection(it.getValue()); | const ConnectionToId& connection(it.getValue()); | ||||
| const int otherPort((connection.portOut >= 0) ? connection.portOut : connection.portIn); | |||||
| const int carlaPort((otherPort == connection.portOut) ? connection.portIn : connection.portOut); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(connection.groupA != connection.groupB); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(connection.groupA >= RACK_PATCHBAY_GROUP_CARLA && connection.groupA < RACK_PATCHBAY_GROUP_MAX); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(connection.groupB >= RACK_PATCHBAY_GROUP_CARLA && connection.groupB < RACK_PATCHBAY_GROUP_MAX); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(connection.portA >= 0); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(connection.portB >= 0); | |||||
| if (otherPort >= RACK_PATCHBAY_GROUP_MIDI_OUT*1000) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_CONTINUE(carlaPort == RACK_PATCHBAY_PORT_MIDI_IN); | |||||
| const int portId(otherPort-RACK_PATCHBAY_GROUP_MIDI_OUT*1000); | |||||
| int carlaPort, otherPort; | |||||
| std::sprintf(strBuf, "MidiOut:%i", portId+1); | |||||
| connList.append(carla_strdup(strBuf)); | |||||
| connList.append(carla_strdup("Carla:MidiOut")); | |||||
| } | |||||
| else if (otherPort >= RACK_PATCHBAY_GROUP_MIDI_IN*1000) | |||||
| if (connection.groupA == RACK_PATCHBAY_GROUP_CARLA) | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT_CONTINUE(carlaPort == RACK_PATCHBAY_PORT_MIDI_OUT); | |||||
| const int portId(otherPort-RACK_PATCHBAY_GROUP_MIDI_IN*1000); | |||||
| connList.append(carla_strdup("Carla:MidiIn")); | |||||
| std::sprintf(strBuf, "MidiIn:%i", portId+1); | |||||
| connList.append(carla_strdup(strBuf)); | |||||
| carlaPort = connection.portA; | |||||
| otherPort = connection.portB; | |||||
| } | } | ||||
| else if (otherPort >= RACK_PATCHBAY_GROUP_AUDIO_OUT*1000) | |||||
| else | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT_CONTINUE(carlaPort == RACK_PATCHBAY_PORT_AUDIO_OUT1 || carlaPort == RACK_PATCHBAY_PORT_AUDIO_OUT2); | |||||
| const int portId(otherPort-RACK_PATCHBAY_GROUP_AUDIO_OUT*1000); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(connection.groupB == RACK_PATCHBAY_GROUP_CARLA); | |||||
| std::sprintf(strBuf, "AudioOut:%i", portId+1); | |||||
| connList.append(carla_strdup(strBuf)); | |||||
| connList.append(carla_strdup((carlaPort == RACK_PATCHBAY_PORT_AUDIO_OUT1) ? "Carla:AudioOut1" : "Carla:AudioOut2")); | |||||
| carlaPort = connection.portB; | |||||
| otherPort = connection.portA; | |||||
| } | } | ||||
| else if (otherPort >= RACK_PATCHBAY_GROUP_AUDIO_IN*1000) | |||||
| switch (carlaPort) | |||||
| { | { | ||||
| CARLA_SAFE_ASSERT_CONTINUE(carlaPort == RACK_PATCHBAY_PORT_AUDIO_IN1 || carlaPort == RACK_PATCHBAY_PORT_AUDIO_IN2); | |||||
| case RACK_PATCHBAY_CARLA_PORT_AUDIO_IN1: | |||||
| case RACK_PATCHBAY_CARLA_PORT_AUDIO_IN2: | |||||
| std::sprintf(strBuf, "AudioIn:%i", otherPort+1); | |||||
| connList.append(carla_strdup(strBuf)); | |||||
| connList.append(carla_strdup((carlaPort == RACK_PATCHBAY_CARLA_PORT_AUDIO_IN1) ? "Carla:AudioIn1" : "Carla:AudioIn2")); | |||||
| break; | |||||
| const int portId(otherPort-RACK_PATCHBAY_GROUP_AUDIO_IN*1000); | |||||
| case RACK_PATCHBAY_CARLA_PORT_AUDIO_OUT1: | |||||
| case RACK_PATCHBAY_CARLA_PORT_AUDIO_OUT2: | |||||
| connList.append(carla_strdup((carlaPort == RACK_PATCHBAY_CARLA_PORT_AUDIO_OUT1) ? "Carla:AudioOut1" : "Carla:AudioOut2")); | |||||
| std::sprintf(strBuf, "AudioOut:%i", otherPort+1); | |||||
| connList.append(carla_strdup(strBuf)); | |||||
| break; | |||||
| connList.append(carla_strdup((carlaPort == RACK_PATCHBAY_PORT_AUDIO_IN1) ? "Carla:AudioIn1" : "Carla:AudioIn2")); | |||||
| case RACK_PATCHBAY_CARLA_PORT_MIDI_IN: | |||||
| std::sprintf(strBuf, "MidiIn:%i", otherPort+1); | |||||
| connList.append(carla_strdup(strBuf)); | |||||
| connList.append(carla_strdup("Carla:MidiIn")); | |||||
| break; | |||||
| std::sprintf(strBuf, "AudioIn:%i", portId+1); | |||||
| case RACK_PATCHBAY_CARLA_PORT_MIDI_OUT: | |||||
| connList.append(carla_strdup("Carla:MidiOut")); | |||||
| std::sprintf(strBuf, "MidiOut:%i", otherPort+1); | |||||
| connList.append(carla_strdup(strBuf)); | connList.append(carla_strdup(strBuf)); | ||||
| } | |||||
| else | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(false, nullptr); | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| @@ -437,12 +525,12 @@ EnginePatchbayBuffers::EnginePatchbayBuffers(const uint32_t bufferSize) | |||||
| resize(bufferSize); | resize(bufferSize); | ||||
| } | } | ||||
| EnginePatchbayBuffers::~EnginePatchbayBuffers() | |||||
| EnginePatchbayBuffers::~EnginePatchbayBuffers() noexcept | |||||
| { | { | ||||
| clear(); | clear(); | ||||
| } | } | ||||
| void EnginePatchbayBuffers::clear() | |||||
| void EnginePatchbayBuffers::clear() noexcept | |||||
| { | { | ||||
| } | } | ||||
| @@ -450,6 +538,13 @@ void EnginePatchbayBuffers::resize(const uint32_t /*bufferSize*/) | |||||
| { | { | ||||
| } | } | ||||
| bool EnginePatchbayBuffers::connect(CarlaEngine* const engine, const int, const int, const int, const int) noexcept | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(engine != nullptr, false); | |||||
| return false; | |||||
| } | |||||
| const char* const* EnginePatchbayBuffers::getConnections() const | const char* const* EnginePatchbayBuffers::getConnections() const | ||||
| { | { | ||||
| return nullptr; | return nullptr; | ||||
| @@ -490,7 +585,7 @@ void EngineInternalAudio::initPatchbay() noexcept | |||||
| } | } | ||||
| } | } | ||||
| void EngineInternalAudio::clear() | |||||
| void EngineInternalAudio::clear() noexcept | |||||
| { | { | ||||
| isReady = false; | isReady = false; | ||||
| inCount = 0; | inCount = 0; | ||||
| @@ -540,6 +635,34 @@ void EngineInternalAudio::resize(const uint32_t bufferSize) | |||||
| } | } | ||||
| } | } | ||||
| bool EngineInternalAudio::connect(CarlaEngine* const engine, const int groupA, const int portA, const int groupB, const int portB) noexcept | |||||
| { | |||||
| if (usePatchbay) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(patchbay != nullptr, nullptr); | |||||
| return patchbay->connect(engine, groupA, portA, groupB, portB); | |||||
| } | |||||
| else | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(rack != nullptr, nullptr); | |||||
| return rack->connect(engine, groupA, portA, groupB, portB); | |||||
| } | |||||
| } | |||||
| const char* const* EngineInternalAudio::getConnections() const | |||||
| { | |||||
| if (usePatchbay) | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(patchbay != nullptr, nullptr); | |||||
| return patchbay->getConnections(); | |||||
| } | |||||
| else | |||||
| { | |||||
| CARLA_SAFE_ASSERT_RETURN(rack != nullptr, nullptr); | |||||
| return rack->getConnections(); | |||||
| } | |||||
| } | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // InternalEvents | // InternalEvents | ||||
| @@ -48,22 +48,21 @@ const unsigned short kMaxEngineEventInternalCount = 512; | |||||
| // Rack Patchbay stuff | // Rack Patchbay stuff | ||||
| enum RackPatchbayGroupIds { | enum RackPatchbayGroupIds { | ||||
| RACK_PATCHBAY_GROUP_CARLA = 0, | |||||
| RACK_PATCHBAY_GROUP_AUDIO_IN = 1, | |||||
| RACK_PATCHBAY_GROUP_AUDIO_OUT = 2, | |||||
| RACK_PATCHBAY_GROUP_MIDI_IN = 3, | |||||
| RACK_PATCHBAY_GROUP_MIDI_OUT = 4, | |||||
| RACK_PATCHBAY_GROUP_MAX = 5 | |||||
| RACK_PATCHBAY_GROUP_CARLA = 0, | |||||
| RACK_PATCHBAY_GROUP_AUDIO = 1, | |||||
| RACK_PATCHBAY_GROUP_MIDI = 2, | |||||
| RACK_PATCHBAY_GROUP_MAX = 3 | |||||
| }; | }; | ||||
| enum RackPatchbayPortIds { | |||||
| RACK_PATCHBAY_PORT_AUDIO_IN1 = -1, | |||||
| RACK_PATCHBAY_PORT_AUDIO_IN2 = -2, | |||||
| RACK_PATCHBAY_PORT_AUDIO_OUT1 = -3, | |||||
| RACK_PATCHBAY_PORT_AUDIO_OUT2 = -4, | |||||
| RACK_PATCHBAY_PORT_MIDI_IN = -5, | |||||
| RACK_PATCHBAY_PORT_MIDI_OUT = -6, | |||||
| RACK_PATCHBAY_PORT_MAX = -7 | |||||
| enum RackPatchbayCarlaPortIds { | |||||
| RACK_PATCHBAY_CARLA_PORT_NULL = 0, | |||||
| RACK_PATCHBAY_CARLA_PORT_AUDIO_IN1 = 1, | |||||
| RACK_PATCHBAY_CARLA_PORT_AUDIO_IN2 = 2, | |||||
| RACK_PATCHBAY_CARLA_PORT_AUDIO_OUT1 = 3, | |||||
| RACK_PATCHBAY_CARLA_PORT_AUDIO_OUT2 = 4, | |||||
| RACK_PATCHBAY_CARLA_PORT_MIDI_IN = 5, | |||||
| RACK_PATCHBAY_CARLA_PORT_MIDI_OUT = 6, | |||||
| RACK_PATCHBAY_CARLA_PORT_MAX = 7 | |||||
| }; | }; | ||||
| struct PortNameToId { | struct PortNameToId { | ||||
| @@ -73,10 +72,30 @@ struct PortNameToId { | |||||
| struct ConnectionToId { | struct ConnectionToId { | ||||
| uint id; | uint id; | ||||
| int portOut; | |||||
| int portIn; | |||||
| int groupA; | |||||
| int portA; | |||||
| int groupB; | |||||
| int portB; | |||||
| }; | }; | ||||
| static inline | |||||
| int getCarlaRackPortIdFromName(const char* const shortname) noexcept | |||||
| { | |||||
| if (std::strcmp(shortname, "AudioIn1") == 0) | |||||
| return RACK_PATCHBAY_CARLA_PORT_AUDIO_IN1; | |||||
| if (std::strcmp(shortname, "AudioIn2") == 0) | |||||
| return RACK_PATCHBAY_CARLA_PORT_AUDIO_IN2; | |||||
| if (std::strcmp(shortname, "AudioOut1") == 0) | |||||
| return RACK_PATCHBAY_CARLA_PORT_AUDIO_OUT1; | |||||
| if (std::strcmp(shortname, "AudioOut2") == 0) | |||||
| return RACK_PATCHBAY_CARLA_PORT_AUDIO_OUT2; | |||||
| if (std::strcmp(shortname, "MidiIn") == 0) | |||||
| return RACK_PATCHBAY_CARLA_PORT_MIDI_IN; | |||||
| if (std::strcmp(shortname, "MidiOut") == 0) | |||||
| return RACK_PATCHBAY_CARLA_PORT_MIDI_OUT; | |||||
| return RACK_PATCHBAY_CARLA_PORT_NULL; | |||||
| } | |||||
| // ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
| // EngineRackBuffers | // EngineRackBuffers | ||||
| @@ -95,9 +114,11 @@ struct EngineRackBuffers { | |||||
| LinkedList<ConnectionToId> usedConnections; | LinkedList<ConnectionToId> usedConnections; | ||||
| EngineRackBuffers(const uint32_t bufferSize); | EngineRackBuffers(const uint32_t bufferSize); | ||||
| ~EngineRackBuffers(); | |||||
| void clear(); | |||||
| ~EngineRackBuffers() noexcept; | |||||
| void clear() noexcept; | |||||
| void resize(const uint32_t bufferSize); | void resize(const uint32_t bufferSize); | ||||
| bool connect(CarlaEngine* const engine, const int groupA, const int portA, const int groupB, const int port) noexcept; | |||||
| const char* const* getConnections() const; | const char* const* getConnections() const; | ||||
| CARLA_DECLARE_NON_COPY_STRUCT(EngineRackBuffers) | CARLA_DECLARE_NON_COPY_STRUCT(EngineRackBuffers) | ||||
| @@ -109,9 +130,11 @@ struct EngineRackBuffers { | |||||
| struct EnginePatchbayBuffers { | struct EnginePatchbayBuffers { | ||||
| // TODO | // TODO | ||||
| EnginePatchbayBuffers(const uint32_t bufferSize); | EnginePatchbayBuffers(const uint32_t bufferSize); | ||||
| ~EnginePatchbayBuffers(); | |||||
| void clear(); | |||||
| ~EnginePatchbayBuffers() noexcept; | |||||
| void clear() noexcept; | |||||
| void resize(const uint32_t bufferSize); | void resize(const uint32_t bufferSize); | ||||
| bool connect(CarlaEngine* const engine, const int groupA, const int portA, const int groupB, const int port) noexcept; | |||||
| const char* const* getConnections() const; | const char* const* getConnections() const; | ||||
| CARLA_DECLARE_NON_COPY_STRUCT(EnginePatchbayBuffers) | CARLA_DECLARE_NON_COPY_STRUCT(EnginePatchbayBuffers) | ||||
| @@ -135,10 +158,13 @@ struct EngineInternalAudio { | |||||
| EngineInternalAudio() noexcept; | EngineInternalAudio() noexcept; | ||||
| ~EngineInternalAudio() noexcept; | ~EngineInternalAudio() noexcept; | ||||
| void initPatchbay() noexcept; | void initPatchbay() noexcept; | ||||
| void clear(); | |||||
| void clear() noexcept; | |||||
| void create(const uint32_t bufferSize); | void create(const uint32_t bufferSize); | ||||
| void resize(const uint32_t bufferSize); | void resize(const uint32_t bufferSize); | ||||
| bool connect(CarlaEngine* const engine, const int groupA, const int portA, const int groupB, const int port) noexcept; | |||||
| const char* const* getConnections() const; | |||||
| CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalAudio) | CARLA_DECLARE_NON_COPY_STRUCT(EngineInternalAudio) | ||||
| }; | }; | ||||
| @@ -968,6 +968,7 @@ public: | |||||
| fUsedConnections.append(connectionToId); | fUsedConnections.append(connectionToId); | ||||
| char strBuf[STR_MAX+1]; | char strBuf[STR_MAX+1]; | ||||
| strBuf[STR_MAX] = '\0'; | |||||
| std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", groupA, portA, groupB, portB); | std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", groupA, portA, groupB, portB); | ||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, connectionToId.id, 0, 0, 0.0f, strBuf); | callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, connectionToId.id, 0, 0, 0.0f, strBuf); | ||||
| @@ -266,7 +266,7 @@ public: | |||||
| else | else | ||||
| std::snprintf(strBuf, STR_MAX, "capture_%i", i+1); | std::snprintf(strBuf, STR_MAX, "capture_%i", i+1); | ||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_AUDIO_IN, static_cast<int>(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<int>(i), PATCHBAY_PORT_TYPE_AUDIO, 0.0f, strBuf); | |||||
| } | } | ||||
| } | } | ||||
| @@ -291,144 +291,15 @@ public: | |||||
| else | else | ||||
| std::snprintf(strBuf, STR_MAX, "playback_%i", i+1); | std::snprintf(strBuf, STR_MAX, "playback_%i", i+1); | ||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_AUDIO_OUT, static_cast<int>(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<int>(i), static_cast<int>(PATCHBAY_PORT_TYPE_AUDIO|PATCHBAY_PORT_IS_INPUT), 0.0f, strBuf); | |||||
| } | } | ||||
| } | } | ||||
| #if 0 // midi implemented yet | |||||
| // MIDI In | // MIDI In | ||||
| { | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED, RACK_PATCHBAY_GROUP_MIDI_IN, PATCHBAY_ICON_HARDWARE, -1, 0.0f, "Readable MIDI ports"); | |||||
| for (unsigned int i=0, count=fDummyMidiIn.getPortCount(); i < count; ++i) | |||||
| { | |||||
| PortNameToId portNameToId; | |||||
| portNameToId.portId = RACK_PATCHBAY_GROUP_MIDI_IN*1000 + i; | |||||
| std::strncpy(portNameToId.name, fDummyMidiIn.getPortName(i).c_str(), STR_MAX); | |||||
| fUsedMidiIns.append(portNameToId); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_MIDI_IN, portNameToId.portId, PATCHBAY_PORT_TYPE_MIDI, 0.0f, portNameToId.name); | |||||
| } | |||||
| } | |||||
| // MIDI Out | // MIDI Out | ||||
| { | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED, RACK_PATCHBAY_GROUP_MIDI_OUT, PATCHBAY_ICON_HARDWARE, -1, 0.0f, "Writable MIDI ports"); | |||||
| for (unsigned int i=0, count=fDummyMidiOut.getPortCount(); i < count; ++i) | |||||
| { | |||||
| PortNameToId portNameToId; | |||||
| portNameToId.portId = RACK_PATCHBAY_GROUP_MIDI_OUT*1000 + i; | |||||
| std::strncpy(portNameToId.name, fDummyMidiOut.getPortName(i).c_str(), STR_MAX); | |||||
| fUsedMidiOuts.append(portNameToId); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, 0, RACK_PATCHBAY_GROUP_MIDI_OUT, portNameToId.portId, PATCHBAY_PORT_TYPE_MIDI|PATCHBAY_PORT_IS_INPUT, portNameToId.name); | |||||
| } | |||||
| } | |||||
| #endif | |||||
| #if 0 | |||||
| // Connections | // Connections | ||||
| rack->connectLock.lock(); | |||||
| for (LinkedList<uint>::Itenerator it = rack->connectedIns[0].begin(); it.valid(); it.next()) | |||||
| { | |||||
| const uint& port(it.getValue()); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(port < pData->bufAudio.inCount); | |||||
| ConnectionToId connectionToId; | |||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.portOut = RACK_PATCHBAY_GROUP_AUDIO_IN*1000 + port; | |||||
| connectionToId.portIn = RACK_PATCHBAY_PORT_AUDIO_IN1; | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr); | |||||
| rack->usedConnections.append(connectionToId); | |||||
| rack->lastConnectionId++; | |||||
| } | |||||
| for (LinkedList<uint>::Itenerator it = rack->connectedIns[1].begin(); it.valid(); it.next()) | |||||
| { | |||||
| const uint& port(it.getValue()); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(port < pData->bufAudio.inCount); | |||||
| ConnectionToId connectionToId; | |||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.portOut = RACK_PATCHBAY_GROUP_AUDIO_IN*1000 + port; | |||||
| connectionToId.portIn = RACK_PATCHBAY_PORT_AUDIO_IN2; | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr); | |||||
| rack->usedConnections.append(connectionToId); | |||||
| rack->lastConnectionId++; | |||||
| } | |||||
| for (LinkedList<uint>::Itenerator it = rack->connectedOuts[0].begin(); it.valid(); it.next()) | |||||
| { | |||||
| const uint& port(it.getValue()); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(port < pData->bufAudio.outCount); | |||||
| ConnectionToId connectionToId; | |||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.portOut = RACK_PATCHBAY_PORT_AUDIO_OUT1; | |||||
| connectionToId.portIn = RACK_PATCHBAY_GROUP_AUDIO_OUT*1000 + port; | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr); | |||||
| rack->usedConnections.append(connectionToId); | |||||
| rack->lastConnectionId++; | |||||
| } | |||||
| for (LinkedList<uint>::Itenerator it = rack->connectedOuts[1].begin(); it.valid(); it.next()) | |||||
| { | |||||
| const uint& port(it.getValue()); | |||||
| CARLA_SAFE_ASSERT_CONTINUE(port < pData->bufAudio.outCount); | |||||
| ConnectionToId connectionToId; | |||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.portOut = RACK_PATCHBAY_PORT_AUDIO_OUT2; | |||||
| connectionToId.portIn = RACK_PATCHBAY_GROUP_AUDIO_OUT*1000 + port; | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr); | |||||
| rack->usedConnections.append(connectionToId); | |||||
| rack->lastConnectionId++; | |||||
| } | |||||
| pData->bufAudio.rack->connectLock.unlock(); | |||||
| #if 0 | |||||
| for (LinkedList<MidiPort>::Itenerator it=fMidiIns.begin(); it.valid(); it.next()) | |||||
| { | |||||
| const MidiPort& midiPort(it.getValue()); | |||||
| ConnectionToId connectionToId; | |||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.portOut = RACK_PATCHBAY_GROUP_MIDI_IN*1000 + midiPort.portId; | |||||
| connectionToId.portIn = RACK_PATCHBAY_PORT_MIDI_IN; | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr); | |||||
| rack->usedConnections.append(connectionToId); | |||||
| rack->lastConnectionId++; | |||||
| } | |||||
| for (LinkedList<MidiPort>::Itenerator it=fMidiOuts.begin(); it.valid(); it.next()) | |||||
| { | |||||
| const MidiPort& midiPort(it.getValue()); | |||||
| ConnectionToId connectionToId; | |||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.portOut = RACK_PATCHBAY_PORT_MIDI_OUT; | |||||
| connectionToId.portIn = RACK_PATCHBAY_GROUP_MIDI_OUT*1000 + midiPort.portId; | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr); | |||||
| rack->usedConnections.append(connectionToId); | |||||
| rack->lastConnectionId++; | |||||
| } | |||||
| #endif | |||||
| #endif | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -434,12 +434,12 @@ public: | |||||
| { | { | ||||
| callback(ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED, RACK_PATCHBAY_GROUP_CARLA, PATCHBAY_ICON_CARLA, -1, 0.0f, getName()); | callback(ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED, RACK_PATCHBAY_GROUP_CARLA, PATCHBAY_ICON_CARLA, -1, 0.0f, getName()); | ||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_CARLA, RACK_PATCHBAY_PORT_AUDIO_IN1, PATCHBAY_PORT_TYPE_AUDIO|PATCHBAY_PORT_IS_INPUT, 0.0f, "audio-in1"); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_CARLA, RACK_PATCHBAY_PORT_AUDIO_IN2, PATCHBAY_PORT_TYPE_AUDIO|PATCHBAY_PORT_IS_INPUT, 0.0f, "audio-in2"); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_CARLA, RACK_PATCHBAY_PORT_AUDIO_OUT1, PATCHBAY_PORT_TYPE_AUDIO, 0.0f, "audio-out1"); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_CARLA, RACK_PATCHBAY_PORT_AUDIO_OUT2, PATCHBAY_PORT_TYPE_AUDIO, 0.0f, "audio-out2"); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_CARLA, RACK_PATCHBAY_PORT_MIDI_IN, PATCHBAY_PORT_TYPE_MIDI|PATCHBAY_PORT_IS_INPUT, 0.0f, "midi-in"); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_CARLA, RACK_PATCHBAY_PORT_MIDI_OUT, PATCHBAY_PORT_TYPE_MIDI, 0.0f, "midi-out"); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_CARLA, RACK_PATCHBAY_CARLA_PORT_AUDIO_IN1, PATCHBAY_PORT_TYPE_AUDIO|PATCHBAY_PORT_IS_INPUT, 0.0f, "audio-in1"); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_CARLA, RACK_PATCHBAY_CARLA_PORT_AUDIO_IN2, PATCHBAY_PORT_TYPE_AUDIO|PATCHBAY_PORT_IS_INPUT, 0.0f, "audio-in2"); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_CARLA, RACK_PATCHBAY_CARLA_PORT_AUDIO_OUT1, PATCHBAY_PORT_TYPE_AUDIO, 0.0f, "audio-out1"); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_CARLA, RACK_PATCHBAY_CARLA_PORT_AUDIO_OUT2, PATCHBAY_PORT_TYPE_AUDIO, 0.0f, "audio-out2"); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_CARLA, RACK_PATCHBAY_CARLA_PORT_MIDI_IN, PATCHBAY_PORT_TYPE_MIDI|PATCHBAY_PORT_IS_INPUT, 0.0f, "midi-in"); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_CARLA, RACK_PATCHBAY_CARLA_PORT_MIDI_OUT, PATCHBAY_PORT_TYPE_MIDI, 0.0f, "midi-out"); | |||||
| } | } | ||||
| // Audio In | // Audio In | ||||
| @@ -454,7 +454,7 @@ public: | |||||
| for (uint i=0; i < pData->bufAudio.inCount; ++i) | for (uint i=0; i < pData->bufAudio.inCount; ++i) | ||||
| { | { | ||||
| std::snprintf(strBuf, STR_MAX, "capture_%i", i+1); | std::snprintf(strBuf, STR_MAX, "capture_%i", i+1); | ||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_AUDIO_IN, int(RACK_PATCHBAY_GROUP_AUDIO_IN*1000 + i), int(PATCHBAY_PORT_TYPE_AUDIO), 0.0f, strBuf); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_AUDIO_IN, static_cast<int>(i), PATCHBAY_PORT_TYPE_AUDIO, 0.0f, strBuf); | |||||
| } | } | ||||
| } | } | ||||
| @@ -470,7 +470,7 @@ public: | |||||
| for (uint i=0; i < pData->bufAudio.outCount; ++i) | for (uint i=0; i < pData->bufAudio.outCount; ++i) | ||||
| { | { | ||||
| std::snprintf(strBuf, STR_MAX, "playback_%i", i+1); | std::snprintf(strBuf, STR_MAX, "playback_%i", i+1); | ||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_AUDIO_OUT, int(RACK_PATCHBAY_GROUP_AUDIO_OUT*1000 + i), int(PATCHBAY_PORT_TYPE_AUDIO|PATCHBAY_PORT_IS_INPUT), 0.0f, strBuf); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_AUDIO_OUT, static_cast<int>(i), PATCHBAY_PORT_TYPE_AUDIO|PATCHBAY_PORT_IS_INPUT, 0.0f, strBuf); | |||||
| } | } | ||||
| } | } | ||||
| @@ -481,7 +481,7 @@ public: | |||||
| for (uint i=0, count=fDummyMidiIn.getPortCount(); i < count; ++i) | for (uint i=0, count=fDummyMidiIn.getPortCount(); i < count; ++i) | ||||
| { | { | ||||
| PortNameToId portNameToId; | PortNameToId portNameToId; | ||||
| portNameToId.portId = int(RACK_PATCHBAY_GROUP_MIDI_IN*1000 + i); | |||||
| portNameToId.portId = static_cast<int>(i); | |||||
| std::strncpy(portNameToId.name, fDummyMidiIn.getPortName(i).c_str(), STR_MAX); | std::strncpy(portNameToId.name, fDummyMidiIn.getPortName(i).c_str(), STR_MAX); | ||||
| portNameToId.name[STR_MAX] = '\0'; | portNameToId.name[STR_MAX] = '\0'; | ||||
| fUsedMidiIns.append(portNameToId); | fUsedMidiIns.append(portNameToId); | ||||
| @@ -490,23 +490,21 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| #if 0 // midi-out not implemented yet | |||||
| // MIDI Out | // MIDI Out | ||||
| { | { | ||||
| callback(ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED, RACK_PATCHBAY_GROUP_MIDI_OUT, PATCHBAY_ICON_HARDWARE, -1, 0.0f, "Writable MIDI ports"); | callback(ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED, RACK_PATCHBAY_GROUP_MIDI_OUT, PATCHBAY_ICON_HARDWARE, -1, 0.0f, "Writable MIDI ports"); | ||||
| for (unsigned int i=0, count=fDummyMidiOut.getPortCount(); i < count; ++i) | |||||
| for (uint i=0, count=fDummyMidiOut.getPortCount(); i < count; ++i) | |||||
| { | { | ||||
| PortNameToId portNameToId; | PortNameToId portNameToId; | ||||
| portNameToId.portId = int(RACK_PATCHBAY_GROUP_MIDI_OUT*1000 + i); | |||||
| portNameToId.portId = static_cast<int>(i); | |||||
| std::strncpy(portNameToId.name, fDummyMidiOut.getPortName(i).c_str(), STR_MAX); | std::strncpy(portNameToId.name, fDummyMidiOut.getPortName(i).c_str(), STR_MAX); | ||||
| portNameToId.name[STR_MAX] = '\0'; | portNameToId.name[STR_MAX] = '\0'; | ||||
| fUsedMidiOuts.append(portNameToId); | fUsedMidiOuts.append(portNameToId); | ||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, 0, RACK_PATCHBAY_GROUP_MIDI_OUT, portNameToId.portId, PATCHBAY_PORT_TYPE_MIDI|PATCHBAY_PORT_IS_INPUT, portNameToId.name); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_PORT_ADDED, RACK_PATCHBAY_GROUP_MIDI_OUT, portNameToId.portId, PATCHBAY_PORT_TYPE_MIDI|PATCHBAY_PORT_IS_INPUT, 0.0f, portNameToId.name); | |||||
| } | } | ||||
| } | } | ||||
| #endif | |||||
| // Connections | // Connections | ||||
| rack->connectLock.enter(); | rack->connectLock.enter(); | ||||
| @@ -517,14 +515,17 @@ public: | |||||
| CARLA_SAFE_ASSERT_CONTINUE(port >= 0 && port < static_cast<int>(pData->bufAudio.inCount)); | CARLA_SAFE_ASSERT_CONTINUE(port >= 0 && port < static_cast<int>(pData->bufAudio.inCount)); | ||||
| ConnectionToId connectionToId; | ConnectionToId connectionToId; | ||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.portOut = RACK_PATCHBAY_GROUP_AUDIO_IN*1000 + port; | |||||
| connectionToId.portIn = RACK_PATCHBAY_PORT_AUDIO_IN1; | |||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.groupOut = RACK_PATCHBAY_GROUP_AUDIO_IN; | |||||
| connectionToId.portOut = port; | |||||
| connectionToId.groupIn = RACK_PATCHBAY_GROUP_CARLA; | |||||
| connectionToId.portIn = RACK_PATCHBAY_CARLA_PORT_AUDIO_IN1; | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr); | |||||
| std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", connectionToId.groupOut, connectionToId.portOut, connectionToId.groupIn, connectionToId.portIn); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, 0, 0, 0.0f, strBuf); | |||||
| rack->usedConnections.append(connectionToId); | rack->usedConnections.append(connectionToId); | ||||
| rack->lastConnectionId++; | |||||
| ++rack->lastConnectionId; | |||||
| } | } | ||||
| for (LinkedList<int>::Itenerator it = rack->connectedIn2.begin(); it.valid(); it.next()) | for (LinkedList<int>::Itenerator it = rack->connectedIn2.begin(); it.valid(); it.next()) | ||||
| @@ -533,14 +534,17 @@ public: | |||||
| CARLA_SAFE_ASSERT_CONTINUE(port >= 0 && port < static_cast<int>(pData->bufAudio.inCount)); | CARLA_SAFE_ASSERT_CONTINUE(port >= 0 && port < static_cast<int>(pData->bufAudio.inCount)); | ||||
| ConnectionToId connectionToId; | ConnectionToId connectionToId; | ||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.portOut = RACK_PATCHBAY_GROUP_AUDIO_IN*1000 + port; | |||||
| connectionToId.portIn = RACK_PATCHBAY_PORT_AUDIO_IN2; | |||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.groupOut = RACK_PATCHBAY_GROUP_AUDIO_IN; | |||||
| connectionToId.portOut = port; | |||||
| connectionToId.groupIn = RACK_PATCHBAY_GROUP_CARLA; | |||||
| connectionToId.portIn = RACK_PATCHBAY_CARLA_PORT_AUDIO_IN2; | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr); | |||||
| std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", connectionToId.groupOut, connectionToId.portOut, connectionToId.groupIn, connectionToId.portIn); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, 0, 0, 0.0f, strBuf); | |||||
| rack->usedConnections.append(connectionToId); | rack->usedConnections.append(connectionToId); | ||||
| rack->lastConnectionId++; | |||||
| ++rack->lastConnectionId; | |||||
| } | } | ||||
| for (LinkedList<int>::Itenerator it = rack->connectedOut1.begin(); it.valid(); it.next()) | for (LinkedList<int>::Itenerator it = rack->connectedOut1.begin(); it.valid(); it.next()) | ||||
| @@ -549,14 +553,17 @@ public: | |||||
| CARLA_SAFE_ASSERT_CONTINUE(port >= 0 && port < static_cast<int>(pData->bufAudio.outCount)); | CARLA_SAFE_ASSERT_CONTINUE(port >= 0 && port < static_cast<int>(pData->bufAudio.outCount)); | ||||
| ConnectionToId connectionToId; | ConnectionToId connectionToId; | ||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.portOut = RACK_PATCHBAY_PORT_AUDIO_OUT1; | |||||
| connectionToId.portIn = RACK_PATCHBAY_GROUP_AUDIO_OUT*1000 + port; | |||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.groupOut = RACK_PATCHBAY_GROUP_CARLA; | |||||
| connectionToId.portOut = RACK_PATCHBAY_CARLA_PORT_AUDIO_OUT1; | |||||
| connectionToId.groupIn = RACK_PATCHBAY_GROUP_AUDIO_OUT; | |||||
| connectionToId.portIn = port; | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr); | |||||
| std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", connectionToId.groupOut, connectionToId.portOut, connectionToId.groupIn, connectionToId.portIn); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, 0, 0, 0.0f, strBuf); | |||||
| rack->usedConnections.append(connectionToId); | rack->usedConnections.append(connectionToId); | ||||
| rack->lastConnectionId++; | |||||
| ++rack->lastConnectionId; | |||||
| } | } | ||||
| for (LinkedList<int>::Itenerator it = rack->connectedOut2.begin(); it.valid(); it.next()) | for (LinkedList<int>::Itenerator it = rack->connectedOut2.begin(); it.valid(); it.next()) | ||||
| @@ -565,14 +572,17 @@ public: | |||||
| CARLA_SAFE_ASSERT_CONTINUE(port >= 0 && port < static_cast<int>(pData->bufAudio.outCount)); | CARLA_SAFE_ASSERT_CONTINUE(port >= 0 && port < static_cast<int>(pData->bufAudio.outCount)); | ||||
| ConnectionToId connectionToId; | ConnectionToId connectionToId; | ||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.portOut = RACK_PATCHBAY_PORT_AUDIO_OUT2; | |||||
| connectionToId.portIn = RACK_PATCHBAY_GROUP_AUDIO_OUT*1000 + port; | |||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.groupOut = RACK_PATCHBAY_GROUP_CARLA; | |||||
| connectionToId.portOut = RACK_PATCHBAY_CARLA_PORT_AUDIO_OUT2; | |||||
| connectionToId.groupIn = RACK_PATCHBAY_GROUP_AUDIO_OUT; | |||||
| connectionToId.portIn = port; | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr); | |||||
| std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", connectionToId.groupOut, connectionToId.portOut, connectionToId.groupIn, connectionToId.portIn); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, 0, 0, 0.0f, strBuf); | |||||
| rack->usedConnections.append(connectionToId); | rack->usedConnections.append(connectionToId); | ||||
| rack->lastConnectionId++; | |||||
| ++rack->lastConnectionId; | |||||
| } | } | ||||
| pData->bufAudio.rack->connectLock.leave(); | pData->bufAudio.rack->connectLock.leave(); | ||||
| @@ -582,14 +592,17 @@ public: | |||||
| const MidiPort& midiPort(it.getValue()); | const MidiPort& midiPort(it.getValue()); | ||||
| ConnectionToId connectionToId; | ConnectionToId connectionToId; | ||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.portOut = RACK_PATCHBAY_GROUP_MIDI_IN*1000 + midiPort.portId; | |||||
| connectionToId.portIn = RACK_PATCHBAY_PORT_MIDI_IN; | |||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.groupOut = RACK_PATCHBAY_GROUP_MIDI_IN; | |||||
| connectionToId.portOut = midiPort.portId; | |||||
| connectionToId.groupIn = RACK_PATCHBAY_GROUP_CARLA; | |||||
| connectionToId.portIn = RACK_PATCHBAY_CARLA_PORT_MIDI_IN; | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr); | |||||
| std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", connectionToId.groupOut, connectionToId.portOut, connectionToId.groupIn, connectionToId.portIn); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, 0, 0, 0.0f, strBuf); | |||||
| rack->usedConnections.append(connectionToId); | rack->usedConnections.append(connectionToId); | ||||
| rack->lastConnectionId++; | |||||
| ++rack->lastConnectionId; | |||||
| } | } | ||||
| for (LinkedList<MidiPort>::Itenerator it=fMidiOuts.begin(); it.valid(); it.next()) | for (LinkedList<MidiPort>::Itenerator it=fMidiOuts.begin(); it.valid(); it.next()) | ||||
| @@ -597,14 +610,17 @@ public: | |||||
| const MidiPort& midiPort(it.getValue()); | const MidiPort& midiPort(it.getValue()); | ||||
| ConnectionToId connectionToId; | ConnectionToId connectionToId; | ||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.portOut = RACK_PATCHBAY_PORT_MIDI_OUT; | |||||
| connectionToId.portIn = RACK_PATCHBAY_GROUP_MIDI_OUT*1000 + midiPort.portId; | |||||
| connectionToId.id = rack->lastConnectionId; | |||||
| connectionToId.groupOut = RACK_PATCHBAY_GROUP_CARLA; | |||||
| connectionToId.portOut = RACK_PATCHBAY_CARLA_PORT_MIDI_OUT; | |||||
| connectionToId.groupIn = RACK_PATCHBAY_GROUP_MIDI_OUT; | |||||
| connectionToId.portIn = midiPort.portId; | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, connectionToId.portOut, connectionToId.portIn, 0.0f, nullptr); | |||||
| std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i", connectionToId.groupOut, connectionToId.portOut, connectionToId.groupIn, connectionToId.portIn); | |||||
| callback(ENGINE_CALLBACK_PATCHBAY_CONNECTION_ADDED, rack->lastConnectionId, 0, 0, 0.0f, strBuf); | |||||
| rack->usedConnections.append(connectionToId); | rack->usedConnections.append(connectionToId); | ||||
| rack->lastConnectionId++; | |||||
| ++rack->lastConnectionId; | |||||
| } | } | ||||
| return true; | return true; | ||||
| @@ -448,7 +448,7 @@ template<typename T> | |||||
| class LinkedList : public AbstractLinkedList<T> | class LinkedList : public AbstractLinkedList<T> | ||||
| { | { | ||||
| public: | public: | ||||
| LinkedList() {} | |||||
| LinkedList() noexcept {} | |||||
| private: | private: | ||||
| typename AbstractLinkedList<T>::Data* _allocate() noexcept override | typename AbstractLinkedList<T>::Data* _allocate() noexcept override | ||||
| @@ -98,7 +98,7 @@ public: | |||||
| // ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
| // Now the actual rt-linkedlist code | // Now the actual rt-linkedlist code | ||||
| RtLinkedList(Pool& memPool) | |||||
| RtLinkedList(Pool& memPool) noexcept | |||||
| : fMemPool(memPool) {} | : fMemPool(memPool) {} | ||||
| bool append_sleepy(const T& value) noexcept | bool append_sleepy(const T& value) noexcept | ||||