From e47ff579b37b8b6f13cb37cc5836ce7dcdd8fdf8 Mon Sep 17 00:00:00 2001 From: evgeny Date: Fri, 16 Oct 2026 01:48:39 +0200 Subject: [PATCH] Keep desktop stream mute controls synchronized with publication --- tools/chatgui/src/stream_publish_engine.cpp | 13 ++++++++++++- tools/chatgui/src/stream_publish_engine.h | 1 + tools/chatgui/src/stream_publish_window.cpp | 6 ++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tools/chatgui/src/stream_publish_engine.cpp b/tools/chatgui/src/stream_publish_engine.cpp index 1a75666b..6bdd1000 100644 --- a/tools/chatgui/src/stream_publish_engine.cpp +++ b/tools/chatgui/src/stream_publish_engine.cpp @@ -108,7 +108,18 @@ bool StreamPublishEngine::running() const { return m->running.load(); } uint64_t StreamPublishEngine::group() const { return m->group; } StreamPublishConfig StreamPublishEngine::config() const { std::lock_guard guard(m->lock); return m->wanted; } QList StreamPublishEngine::codecs() const { std::lock_guard guard(m->lock); return m->codecs; } -void StreamPublishEngine::setMuted(bool muted) { m->muted = muted; } +bool StreamPublishEngine::muted() const { return m->muted.load(); } +void StreamPublishEngine::setMuted(bool muted) { + if (!m->running || !config().audio) { + DEBUG_WARN(DEBUG_CATEGORY_STREAM, "desktop stream mute without active audio"); return; + } + bool previous = m->muted.exchange(muted); + if (!gui_stream_publish_audio(m->id, !muted)) { + m->muted = previous; publicationFailed(m->id, text("Could not change stream audio")); return; + } + DEBUG_INFO(DEBUG_CATEGORY_STREAM, "desktop stream audio id=%llu muted=%d", (unsigned long long)m->id, muted); + emit configurationChanged(); +} QList StreamPublishEngine::sources() { QList sources; diff --git a/tools/chatgui/src/stream_publish_engine.h b/tools/chatgui/src/stream_publish_engine.h index 14677371..ef4a0c0f 100644 --- a/tools/chatgui/src/stream_publish_engine.h +++ b/tools/chatgui/src/stream_publish_engine.h @@ -42,6 +42,7 @@ public: static QList sources(); static bool supported(); void setMuted(bool muted); + bool muted() const; signals: void codecsChanged(); void stateChanged(const QString& state); diff --git a/tools/chatgui/src/stream_publish_window.cpp b/tools/chatgui/src/stream_publish_window.cpp index fe830086..cbcd7a33 100644 --- a/tools/chatgui/src/stream_publish_window.cpp +++ b/tools/chatgui/src/stream_publish_window.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef HAVE_STREAM_CAPTURE #include #include @@ -74,7 +75,7 @@ StreamPublishWindow::StreamPublishWindow(StreamPublishEngine* engine, uint64_t g for (const auto& device : SoundManager::enumerateCaptureDevices()) m_microphone->addItem(device.name, device.id); form->addRow(text("Microphone"), m_microphone); m_inputChannels = new QLabel(settings); form->addRow(text("Audio input"), m_inputChannels); - m_mute = new QCheckBox(text("Mute microphone"), settings); form->addRow(m_mute); + m_mute = new QCheckBox(text("Mute stream audio"), settings); form->addRow(m_mute); connect(m_mute, &QCheckBox::toggled, engine, &StreamPublishEngine::setMuted); m_status = new QLabel(this); m_status->setWordWrap(true); layout->addWidget(m_status); m_stats = new QLabel(this); m_stats->setWordWrap(true); m_stats->setMinimumHeight(46); layout->addWidget(m_stats); @@ -140,7 +141,8 @@ void StreamPublishWindow::synchronize() { m_start->setText(active ? text("Stop stream") : text("Start stream")); m_start->setEnabled((active && m_engine->running()) || (!active && StreamPublishEngine::supported() && m_source->count() && m_codec->count())); for (auto* box : {m_source, m_mode, m_codec, m_bitrate}) box->setEnabled(!active || m_engine->running()); - m_audio->setEnabled(!active); m_microphone->setEnabled(!active); m_mute->setEnabled(active && m_engine->config().audio); + m_audio->setEnabled(!active); m_microphone->setEnabled(!active); m_mute->setEnabled(m_engine->running() && m_engine->config().audio); + { QSignalBlocker blocked(m_mute); m_mute->setChecked(m_engine->muted()); } if (active) { auto config = m_engine->config(); for (int i = 0; i < m_sources.size(); i++) if (m_sources[i].kind == config.source.kind