Browse Source

Keep microphone buffer resizing outside the GUI close path

master
evgeny 2 days ago
parent
commit
3c73c7d645
  1. 8
      tools/chatgui/src/audio_capture.cpp
  2. 1
      tools/chatgui/src/audio_device.h
  3. 3
      tools/chatgui/src/call_audio_engine.cpp

8
tools/chatgui/src/audio_capture.cpp

@ -60,7 +60,13 @@ struct AudioCapture::Session {
}
}
void recover() {
if (device.needsRecovery()) { stop(); device.retryLater(); }
if (device.needsRecovery()) {
if (device.resizingBuffer()) {
for (auto& slot : consumers) if (slot.client) detach(slot);
device.closeAsync();
} else stop();
device.retryLater();
}
if (device.initialized()) { prepare(); return; }
auto* context = SoundManager::instance()->context();
if (!context || !device.retryReady()) return;

1
tools/chatgui/src/audio_device.h

@ -25,6 +25,7 @@ public:
bool closing() const { return !m_closeDone.load(std::memory_order_acquire); }
bool captureTimedOut() const; // Секунда без корректного PCM; нулевые сэмплы считаются данными.
bool needsRecovery();
bool resizingBuffer() const { return m_resizePending; } // После needsRecovery(): переоткрытие с увеличенным буфером.
bool retryReady() const;
void retryLater();
void retryNow();

3
tools/chatgui/src/call_audio_engine.cpp

@ -100,7 +100,8 @@ void CallAudioEngine::recoverDevices() {
}
if (!m_captureError.isEmpty() || m_capture.closing()) return;
if (!m_ending && ((m_capture.initialized() && !m_voice.captureRunning()) || m_capture.needsRecovery())) {
m_capture.close(); m_voice.stopCapture();
if (m_capture.resizingBuffer()) m_capture.closeAsync(); else m_capture.close();
m_voice.stopCapture();
call_audio_reset_io(m_callId.load(), 0); m_capture.retryLater();
}
if (!m_ending && m_capture.retryReady()) openCapture();

Loading…
Cancel
Save