Browse Source

Exclude retiring capture sessions from new subscriptions

master
evgeny 4 days ago
parent
commit
543c9decba
  1. 5
      tools/chatgui/src/audio_capture.cpp

5
tools/chatgui/src/audio_capture.cpp

@ -16,7 +16,7 @@ struct AudioCapture::Session {
AudioDevice device; AudioDevice device;
QString key; QString key;
std::array<Slot, 2> consumers; std::array<Slot, 2> consumers;
bool streamProfile = false; bool streamProfile = false, retiring = false;
int requestedChannels = 1, channels = 1; int requestedChannels = 1, channels = 1;
uint64_t tag = 0; uint64_t tag = 0;
QElapsedTimer clock; 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();) { for (auto it = sessions.begin(); it != sessions.end();) {
auto session = it->lock(); auto session = it->lock();
if (!session) { it = sessions.erase(it); continue; } if (!session) { it = sessions.erase(it); continue; }
if (session->key == key) m_session = session; if (!session->retiring && session->key == key) m_session = session;
++it; ++it;
} }
if (!m_session) { m_session = std::make_shared<Session>(key); sessions.push_back(m_session); } if (!m_session) { m_session = std::make_shared<Session>(key); sessions.push_back(m_session); }
@ -151,6 +151,7 @@ void AudioCapture::closeAsync() {
if (m_closeThread.joinable()) m_closeThread.join(); if (m_closeThread.joinable()) m_closeThread.join();
auto session = detach(); auto session = detach();
if (!session) return; if (!session) return;
if (session.use_count() == 1) session->retiring = true;
m_closeDone.store(false, std::memory_order_release); m_closeDone.store(false, std::memory_order_release);
DEBUG_INFO(DEBUG_CATEGORY_CALL, "capture: asynchronous close started shared=%d", session.use_count() > 1); DEBUG_INFO(DEBUG_CATEGORY_CALL, "capture: asynchronous close started shared=%d", session.use_count() > 1);
try { try {

Loading…
Cancel
Save