use rohrkabel as submodule and update it to v1.2

This commit is contained in:
Malte Jürgens 2022-07-26 16:33:34 +02:00
parent 6492cb9a35
commit bc59458e19
No known key found for this signature in database
GPG Key ID: D29FBD5F93C0CFC3
6 changed files with 98 additions and 74 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "submodules/rohrkabel"]
path = submodules/rohrkabel
url = https://github.com/Soundux/rohrkabel

View File

@ -22,14 +22,26 @@ set(discord-screenaudio_SRC
resources.qrc resources.qrc
) )
include(FetchContent) # Adapted from https://cliutils.gitlab.io/modern-cmake/chapters/projects/submodule.html
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Updating submodules")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "`git submodule update --init --recursive` failed with ${GIT_SUBMOD_RESULT}, please provide the submodules manually")
endif()
endif()
endif()
FetchContent_Declare( if(NOT EXISTS "${PROJECT_SOURCE_DIR}/submodules/rohrkabel/CMakeLists.txt")
rohrkabel message(FATAL_ERROR "Rohrkabel was not found since you are not in a Git checkout or have GIT_SUBMODULE disabled. Please provide rohrkabel manually to `./submodules/rohrkabel`.")
GIT_REPOSITORY "https://github.com/Soundux/rohrkabel" endif()
GIT_TAG "d87403f48d3a95aa4bcf4cd60112d9e4bb090d5d"
) add_subdirectory(submodules/rohrkabel)
FetchContent_MakeAvailable(rohrkabel)
add_executable(discord-screenaudio ${discord-screenaudio_SRC}) add_executable(discord-screenaudio ${discord-screenaudio_SRC})

View File

@ -89,6 +89,7 @@ void DiscordPage::stopVirtmic() {
if (m_virtmicProcess.state() == QProcess::Running) { if (m_virtmicProcess.state() == QProcess::Running) {
qDebug() << "[virtmic] Stopping Virtmic"; qDebug() << "[virtmic] Stopping Virtmic";
m_virtmicProcess.kill(); m_virtmicProcess.kill();
m_virtmicProcess.waitForFinished();
} }
} }

View File

@ -1,5 +1,8 @@
#include "virtmic.h" #include "virtmic.h"
#include <rohrkabel/loop/main.hpp>
#include <rohrkabel/registry/registry.hpp>
namespace Virtmic { namespace Virtmic {
QVector<QString> getTargets() { QVector<QString> getTargets() {
@ -24,7 +27,7 @@ QVector<QString> getTargets() {
} }
} }
}); });
core.sync(); core.update();
return targets; return targets;
} }
@ -67,12 +70,12 @@ void start(QString _target) {
<< "Link : " << target << ":" << port_id << " -> "; << "Link : " << target << ":" << port_id << " -> ";
if (port.info().props["audio.channel"] == "FL") { if (port.info().props["audio.channel"] == "FL") {
links.emplace(port_id, core.create<pipewire::link_factory>( links.emplace(port_id, core.create_simple<pipewire::link_factory>(
{virt_fl->info().id, port_id})); virt_fl->info().id, port_id));
std::cout << "[virtmic] " << virt_fl->info().id << std::endl; std::cout << "[virtmic] " << virt_fl->info().id << std::endl;
} else { } else {
links.emplace(port_id, core.create<pipewire::link_factory>( links.emplace(port_id, core.create_simple<pipewire::link_factory>(
{virt_fr->info().id, port_id})); virt_fr->info().id, port_id));
std::cout << "[virtmic] " << virt_fr->info().id << std::endl; std::cout << "[virtmic] " << virt_fr->info().id << std::endl;
} }
} }
@ -81,16 +84,22 @@ void start(QString _target) {
std::string target = _target.toLatin1().toStdString(); std::string target = _target.toLatin1().toStdString();
auto virtual_mic = auto virtual_mic = core.create("adapter",
core.create("adapter",
{{"node.name", "discord-screenaudio-virtmic"}, {{"node.name", "discord-screenaudio-virtmic"},
{"media.class", "Audio/Source/Virtual"}, {"media.class", "Audio/Source/Virtual"},
{"factory.name", "support.null-audio-sink"}, {"factory.name", "support.null-audio-sink"},
{"audio.channels", "2"}, {"audio.channels", "2"},
{"audio.position", "FL,FR"}}, {"audio.position", "FL,FR"}},
pipewire::node::type, pipewire::node::version, false); pipewire::node::type, pipewire::node::version,
pipewire::update_strategy::none);
if (target == "None") {
while (true) {
main_loop.run();
}
return;
}
if (target != "None") {
auto reg_events = reg.listen<pipewire::registry_listener>(); auto reg_events = reg.listen<pipewire::registry_listener>();
reg_events.on<pipewire::registry_event::global>( reg_events.on<pipewire::registry_event::global>(
[&](const pipewire::global &global) { [&](const pipewire::global &global) {
@ -143,7 +152,6 @@ void start(QString _target) {
links.erase(id); links.erase(id);
} }
}); });
}
while (true) { while (true) {
main_loop.run(); main_loop.run();

View File

@ -3,7 +3,6 @@
#include <QString> #include <QString>
#include <QVector> #include <QVector>
#include <iostream> #include <iostream>
#include <rohrkabel/registry/registry.hpp>
namespace Virtmic { namespace Virtmic {

1
submodules/rohrkabel Submodule

@ -0,0 +1 @@
Subproject commit a2d04d1e27a7b0aa2c2fe4de28b60ada22c7c348