From 543c9decbaaa8a9e13293b4d3e79e478eea124a9 Mon Sep 17 00:00:00 2001 From: evgeny Date: Fri, 16 Oct 2026 16:15:20 +0200 Subject: [PATCH] Exclude retiring capture sessions from new subscriptions --- tools/chatgui/src/audio_capture.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/chatgui/src/audio_capture.cpp b/tools/chatgui/src/audio_capture.cpp index 83063377..132133d1 100644 --- a/tools/chatgui/src/audio_capture.cpp +++ b/tools/chatgui/src/audio_capture.cpp @@ -16,7 +16,7 @@ struct AudioCapture::Session { AudioDevice device; QString key; std::array consumers; - bool streamProfile = false; + bool streamProfile = false, retiring = false; int requestedChannels = 1, channels = 1; uint64_t tag = 0; QElapsedTimer clock; @@ -108,7 +108,7 @@ bool AudioCapture::open(const QString& input, Role role, int channels, uint64_t for (auto it = sessions.begin(); it != sessions.end();) { auto session = it->lock(); if (!session) { it = sessions.erase(it); continue; } - if (session->key == key) m_session = session; + if (!session->retiring && session->key == key) m_session = session; ++it; } if (!m_session) { m_session = std::make_shared(key); sessions.push_back(m_session); } @@ -151,6 +151,7 @@ void AudioCapture::closeAsync() { if (m_closeThread.joinable()) m_closeThread.join(); auto session = detach(); if (!session) return; + if (session.use_count() == 1) session->retiring = true; m_closeDone.store(false, std::memory_order_release); DEBUG_INFO(DEBUG_CATEGORY_CALL, "capture: asynchronous close started shared=%d", session.use_count() > 1); try {