start virtmic with no target when audio capture is requested

This commit is contained in:
Malte Jürgens 2022-07-26 16:02:36 +02:00
parent a814d9cc1b
commit 6492cb9a35
No known key found for this signature in database
GPG Key ID: D29FBD5F93C0CFC3
2 changed files with 59 additions and 48 deletions

View File

@ -63,6 +63,15 @@ void DiscordPage::featurePermissionRequested(const QUrl &securityOrigin,
// Allow every permission asked // Allow every permission asked
setFeaturePermission(securityOrigin, feature, setFeaturePermission(securityOrigin, feature,
QWebEnginePage::PermissionGrantedByUser); QWebEnginePage::PermissionGrantedByUser);
if (feature == QWebEnginePage::Feature::MediaAudioCapture) {
if (m_virtmicProcess.state() == QProcess::NotRunning) {
qDebug() << "[virtmic] Starting Virtmic with no target to make sure "
"Discord can find all the audio devices";
m_virtmicProcess.start(QApplication::arguments()[0],
{"--virtmic", "None"});
}
}
} }
bool DiscordPage::acceptNavigationRequest(const QUrl &url, bool DiscordPage::acceptNavigationRequest(const QUrl &url,

View File

@ -90,6 +90,7 @@ void start(QString _target) {
{"audio.position", "FL,FR"}}, {"audio.position", "FL,FR"}},
pipewire::node::type, pipewire::node::version, false); pipewire::node::type, pipewire::node::version, false);
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) {
@ -142,6 +143,7 @@ void start(QString _target) {
links.erase(id); links.erase(id);
} }
}); });
}
while (true) { while (true) {
main_loop.run(); main_loop.run();