Browse Source

Keep normal capture lifecycle synchronous after healthy input

master
evgeny 2 days ago
parent
commit
110af9b0c5
  1. 9
      tools/chatgui/src/call_audio_engine.cpp
  2. 5
      tools/chatgui/src/radio_audio_engine.cpp

9
tools/chatgui/src/call_audio_engine.cpp

@ -129,7 +129,8 @@ void CallAudioEngine::setPlaybackDevice(const QString& id) {
void CallAudioEngine::setCaptureDevice(const QString& id) {
if (id == m_captureId) return;
m_captureId = id;
m_capture.closeAsync(); m_voice.stopCapture(); m_capture.retryNow();
if (!m_capture.closing()) m_capture.close();
m_voice.stopCapture(); m_capture.retryNow();
m_captureError.clear(); emit captureErrorChanged();
if (m_active) { call_audio_reset_io(m_callId.load(), 0); recoverDevices(); }
}
@ -137,7 +138,8 @@ void CallAudioEngine::setCaptureDevice(const QString& id) {
void CallAudioEngine::beginEnd(quint64 callId) {
if (!m_active || m_callId != callId || m_ending) return;
m_ending = true;
m_capture.closeAsync(); m_voice.stopCapture();
if (!m_capture.closing()) m_capture.close();
m_voice.stopCapture();
call_audio_begin_end(callId);
uint64_t generation = m_generation;
QTimer::singleShot(500, this, [this, generation]() { if (m_generation == generation) stop(); });
@ -146,7 +148,8 @@ void CallAudioEngine::beginEnd(quint64 callId) {
void CallAudioEngine::stop() {
++m_generation;
m_active = false;
m_capture.closeAsync(); m_voice.stopCapture();
if (!m_capture.closing()) m_capture.close();
m_voice.stopCapture();
SoundManager::instance()->detachVoice(&m_voice); m_outputAttached = false;
m_voice.stop();
if (m_capture.closing()) m_recoveryTimer.start();

5
tools/chatgui/src/radio_audio_engine.cpp

@ -48,7 +48,8 @@ RadioAudioEngine::RadioAudioEngine() {
auto* manager = SoundManager::instance();
if (m_captureId != manager->captureDevice()) {
m_captureId = manager->captureDevice();
m_capture.closeAsync(); m_captureError.clear();
if (!m_capture.closing()) m_capture.close();
m_captureError.clear();
emit stateChanged();
}
if (m_playbackId != manager->playbackDevice()) {
@ -290,7 +291,7 @@ void RadioAudioEngine::pauseDevices() {
void RadioAudioEngine::stop() {
m_recoveryTimer.stop();
m_capture.closeAsync();
if (!m_capture.closing()) m_capture.close();
SoundManager::instance()->detachVoice(&m_voice); m_outputAttached = false;
m_voice.stop();
m_microphone.release();

Loading…
Cancel
Save