Skip to content

Commit

Permalink
Auto-connect Cardinal jack ports
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Apr 4, 2022
1 parent 7988ef3 commit d37a559
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 9 deletions.
2 changes: 1 addition & 1 deletion archiso/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN pacman pacman -Syuu --noconfirm && pacman -Scc

# install packages for archiso and live-welcome
RUN pacman -Syu --noconfirm arch-install-scripts dosfstools e2fsprogs libisoburn mtools squashfs-tools && \
pacman -Syu --noconfirm gcc git kparts make patch pkg-config qt5-webengine && \
pacman -Syu --noconfirm gcc git jack2 kparts make patch pkg-config qt5-webengine && \
pacman -Scc

# misc setup
Expand Down
7 changes: 5 additions & 2 deletions live-welcome/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ KF5_LIBS += -lKF5Parts -lKF5Service -lKF5CoreAddons
ALSA_CFLAGS = $(shell pkg-config --cflags alsa)
ALSA_LIBS = $(shell pkg-config --libs alsa)

JACK_CFLAGS = $(shell pkg-config --cflags jack)
JACK_LIBS = $(shell pkg-config --libs jack)

QT5_CFLAGS = $(shell pkg-config --cflags Qt5Network Qt5Widgets Qt5WebEngineWidgets Qt5X11Extras)
QT5_LIBS = $(shell pkg-config --libs Qt5Network Qt5Widgets Qt5WebEngineWidgets Qt5X11Extras)

Expand Down Expand Up @@ -65,12 +68,12 @@ TARGETS = mod-live-usb-welcome
all: $(TARGETS)

mod-live-usb-welcome: $(OBJECTS)
$(CXX) $^ $(X11_LIBS) $(KF5_LIBS) $(QT5_LIBS) $(ALSA_LIBS) -ldl -lrt $(LDFLAGS) -o $@
$(CXX) $^ $(X11_LIBS) $(KF5_LIBS) $(QT5_LIBS) $(JACK_LIBS) $(ALSA_LIBS) -ldl -lrt $(LDFLAGS) -o $@

src/KioskTabs.cpp.o: resources/watermark.txt

%.cpp.o: %.cpp
$(CXX) $< -c $(X11_CFLAGS) $(KF5_CFLAGS) $(QT5_CFLAGS) $(ALSA_CFLAGS) $(CXXFLAGS) -o $@
$(CXX) $< -c $(X11_CFLAGS) $(KF5_CFLAGS) $(QT5_CFLAGS) $(JACK_CFLAGS) $(ALSA_CFLAGS) $(CXXFLAGS) -o $@

src/moc_%.cpp: src/%.hpp
$(MOC) $< > $@
Expand Down
53 changes: 47 additions & 6 deletions live-welcome/src/KioskTabs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@

#include "KioskTabs.hpp"

#include "KioskAbout.hpp"
#include "KioskForeignWidget.hpp"
#include "Utils.hpp"

#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QThread>
#include <QtCore/QTimer>
#include <QtWidgets/QInputDialog>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QTabBar>
#include <QtWebEngineWidgets/QWebEngineView>
// #include <QtWebEngineWidgets/QWebEngineSettings>

// #include <KParts/BrowserExtension>
#include <KParts/ReadWritePart>
#include <KService/KService>

#include "KioskAbout.hpp"
#include "KioskForeignWidget.hpp"
#include "Utils.hpp"
#include <jack/jack.h>

static const char* const initial_html = "<html><body><style>body { background: black url(data:image/png;base64,"
#include "../resources/watermark.txt"
Expand Down Expand Up @@ -144,15 +145,55 @@ void KioskTabs::addNewClicked()
KioskForeignWidget* const w = new KioskForeignWidget(this);
setCurrentIndex(addTab(w, "Cardinal"));

if (! w->startForeignTool("Cardinal"))
if (w->startForeignTool("Cardinal"))
{
if (jack_client_t* const client = jack_client_open("CardinalHelper", JackNoStartServer, nullptr))
{
// wait max 5s for Cardinal to appear
for (int i=0; i<50; ++i)
{
if (jack_port_by_name(client, "Cardinal:events-in") == nullptr)
{
QThread::msleep(100);
continue;
}

jack_connect(client, "mod-midi-merger:out", "Cardinal:events-in");
jack_connect(client, "system:capture_1", "Cardinal:audio_in_1");
jack_connect(client, "system:capture_2", "Cardinal:audio_in_2");
jack_connect(client, "system:capture_3", "Cardinal:audio_in_3");
jack_connect(client, "system:capture_4", "Cardinal:audio_in_4");
jack_connect(client, "system:capture_5", "Cardinal:audio_in_5");
jack_connect(client, "system:capture_6", "Cardinal:audio_in_6");
jack_connect(client, "system:capture_7", "Cardinal:audio_in_7");
jack_connect(client, "system:capture_8", "Cardinal:audio_in_8");
jack_connect(client, "Cardinal:midi-out", "mod-midi-broadcaster:in");
jack_connect(client, "Cardinal:audio_out_1", "mod-monitor:in_1");
jack_connect(client, "Cardinal:audio_out_2", "mod-monitor:in_2");
jack_connect(client, "Cardinal:audio_out_3", "system:playback_3");
jack_connect(client, "Cardinal:audio_out_4", "system:playback_4");
jack_connect(client, "Cardinal:audio_out_5", "system:playback_5");
jack_connect(client, "Cardinal:audio_out_6", "system:playback_6");
jack_connect(client, "Cardinal:audio_out_7", "system:playback_7");
jack_connect(client, "Cardinal:audio_out_8", "system:playback_8");
break;
}

jack_client_close(client);
}
}
else
{
tabClosed(oldIndex);
}
}
else if (ret == "Terminal")
{
openTerminal();
}

updatePlusButtonPosition();
return;
}

QTimer::singleShot(0, this, SLOT(tabCancel()));
Expand Down

0 comments on commit d37a559

Please sign in to comment.