From 3f801a5c8fc2457aebe269264b6bb1cacf002b3f Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 30 Aug 2018 14:57:48 +0200 Subject: [PATCH] Auto-connect option for JACK and JACK/RtAudio now implemented --- source/backend/engine/CarlaEngineJack.cpp | 43 +++++++++++++++++++++-- source/modules/rtaudio/RtAudio.cpp | 6 ++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/source/backend/engine/CarlaEngineJack.cpp b/source/backend/engine/CarlaEngineJack.cpp index 99f33d0c9..eddc971bd 100644 --- a/source/backend/engine/CarlaEngineJack.cpp +++ b/source/backend/engine/CarlaEngineJack.cpp @@ -989,6 +989,45 @@ public: if (jackbridge_activate(fClient)) { + if (opts.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || + opts.processMode == ENGINE_PROCESS_MODE_PATCHBAY) + { + if (pData->options.audioDevice != nullptr && + std::strcmp(pData->options.audioDevice, "Auto-Connect ON") == 0 && + std::getenv("LADISH_APP_NAME") == nullptr && + std::getenv("NSM_URL") == nullptr) + { + char strBuf[STR_MAX]; + strBuf[STR_MAX-1] = '\0'; + + if (jackbridge_port_by_name(fClient, "system:capture_1") != nullptr) + { + std::snprintf(strBuf, STR_MAX-2, "%s:audio-in1", jackClientName); + jackbridge_connect(fClient, "system:capture_1", strBuf); + + std::snprintf(strBuf, STR_MAX-2, "%s:audio-in2", jackClientName); + + if (jackbridge_port_by_name(fClient, "system:capture_2") != nullptr) + jackbridge_connect(fClient, "system:capture_2", strBuf); + else + jackbridge_connect(fClient, "system:capture_1", strBuf); + } + + if (jackbridge_port_by_name(fClient, "system:capture_1") != nullptr) + { + std::snprintf(strBuf, STR_MAX-2, "%s:audio-out1", jackClientName); + jackbridge_connect(fClient, strBuf, "system:playback_1"); + + std::snprintf(strBuf, STR_MAX-2, "%s:audio-out2", jackClientName); + + if (jackbridge_port_by_name(fClient, "system:playback_2") != nullptr) + jackbridge_connect(fClient, strBuf, "system:playback_2"); + else + jackbridge_connect(fClient, strBuf, "system:playback_1"); + } + } + } + startThread(); callback(ENGINE_CALLBACK_ENGINE_STARTED, 0, opts.processMode, opts.transportMode, @@ -997,7 +1036,8 @@ public: return true; } - if (opts.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || opts.processMode == ENGINE_PROCESS_MODE_PATCHBAY) + if (opts.processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK || + opts.processMode == ENGINE_PROCESS_MODE_PATCHBAY) { pData->graph.destroy(); } @@ -1798,7 +1838,6 @@ protected: if (fTimebaseRolling != playing) { - carla_stdout("state changed SAVE %i", playing); fTimebaseRolling = playing; pData->timeInfo.playing = playing; } diff --git a/source/modules/rtaudio/RtAudio.cpp b/source/modules/rtaudio/RtAudio.cpp index d06e03b41..9810557ec 100644 --- a/source/modules/rtaudio/RtAudio.cpp +++ b/source/modules/rtaudio/RtAudio.cpp @@ -2218,8 +2218,10 @@ bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne } } - // auto-connect "device" is #1 - shouldAutoconnect_ = device == 0; + // auto-connect-off "device" is at index 1 + shouldAutoconnect_ = (device != 1 && + std::getenv("LADISH_APP_NAME") == nullptr && + std::getenv("NSM_URL") == nullptr); // Setup the buffer conversion information structure. We don't use // buffers to do channel offsets, so we override that parameter