From efbda8d90aa9713324226970bfd5166e28471fd4 Mon Sep 17 00:00:00 2001 From: Tim Haloun Date: Thu, 21 Nov 2019 16:10:18 -0800 Subject: [PATCH] Don't perform DataCallback if the input object has been stopped. Fix signed/unsigned mismatch. Protect against NumberOfEnumeratedDevices and Get[In|Out]putDeviceNames returning inconsistent results. It's possible for an device to be counted but getting its name fails, in which case the utility function returns true but would continue from its loop filling the AudioDeviceNames vector, leading to a smaller output than the later code expects. Bug: b/144382120 Change-Id: Iab008c28f03023c830011d229b1f1c7e3e7bb5ee Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160226 Commit-Queue: Henrik Andreassson Reviewed-by: Henrik Andreassson Cr-Commit-Position: refs/heads/master@{#29871} --- modules/audio_device/win/core_audio_input_win.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/audio_device/win/core_audio_input_win.cc b/modules/audio_device/win/core_audio_input_win.cc index 53500764bf..8c1b06e02f 100644 --- a/modules/audio_device/win/core_audio_input_win.cc +++ b/modules/audio_device/win/core_audio_input_win.cc @@ -261,6 +261,13 @@ void CoreAudioInput::ReleaseCOMObjects() { bool CoreAudioInput::OnDataCallback(uint64_t device_frequency) { RTC_DCHECK_RUN_ON(&thread_checker_audio_); + + if (!initialized_ || !is_active_) { + // This is concurrent examination of state across multiple threads so will + // be somewhat error prone, but we should still be defensive and not use + // audio_capture_client_ if we know it's not there. + return false; + } if (num_data_callbacks_ == 0) { RTC_LOG(INFO) << "--- Input audio stream is alive ---"; }