From bf09976e86aa15bb2f117510da2d33905180f458 Mon Sep 17 00:00:00 2001 From: "braveyao@webrtc.org" Date: Mon, 3 Nov 2014 09:58:40 +0000 Subject: [PATCH] Add more sanity checks to workaround the unidentified problem that CaptureThread is still running while related resouces are destroyed already. BUG= TEST=auto test R=henrika@webrtc.org Review URL: https://webrtc-codereview.appspot.com/28859004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7590 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../modules/audio_device/win/audio_device_core_win.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/webrtc/modules/audio_device/win/audio_device_core_win.cc b/webrtc/modules/audio_device/win/audio_device_core_win.cc index 3708c5403..bcf1c1bb2 100644 --- a/webrtc/modules/audio_device/win/audio_device_core_win.cc +++ b/webrtc/modules/audio_device/win/audio_device_core_win.cc @@ -3893,6 +3893,12 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() // This value is fixed during the capturing session. // UINT32 bufferLength = 0; + if (_ptrClientIn == NULL) + { + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, + "input state has been modified before capture loop starts."); + return 1; + } hr = _ptrClientIn->GetBufferSize(&bufferLength); EXIT_ON_ERROR(hr); WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "[CAPT] size of buffer : %u", bufferLength); @@ -4113,7 +4119,10 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() // ---------------------------- THREAD LOOP ---------------------------- << - hr = _ptrClientIn->Stop(); + if (_ptrClientIn) + { + hr = _ptrClientIn->Stop(); + } Exit: if (FAILED(hr))