Add lock to prevent possible rare race condition in Win coreAudio capture implementation.

BUG = 
TEST = voe_auto_test

Review URL: https://webrtc-codereview.appspot.com/1320011

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3868 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
braveyao@webrtc.org
2013-04-18 09:32:07 +00:00
parent ceaedc0014
commit c14b728b71

View File

@@ -3677,8 +3677,8 @@ Exit:
if (FAILED(hr)) if (FAILED(hr))
{ {
_UnLock();
_ptrClientOut->Stop(); _ptrClientOut->Stop();
_UnLock();
_TraceCOMError(hr); _TraceCOMError(hr);
} }
@@ -3690,19 +3690,23 @@ Exit:
} }
} }
_Lock();
if (keepPlaying) if (keepPlaying)
{ {
hr = _ptrClientOut->Stop(); if (_ptrClientOut != NULL)
if (FAILED(hr))
{ {
_TraceCOMError(hr); hr = _ptrClientOut->Stop();
if (FAILED(hr))
{
_TraceCOMError(hr);
}
hr = _ptrClientOut->Reset();
if (FAILED(hr))
{
_TraceCOMError(hr);
}
} }
hr = _ptrClientOut->Reset();
if (FAILED(hr))
{
_TraceCOMError(hr);
}
// Trigger callback from module process thread // Trigger callback from module process thread
_playError = 1; _playError = 1;
WEBRTC_TRACE(kTraceError, kTraceUtility, _id, "kPlayoutError message posted: rendering thread has ended pre-maturely"); WEBRTC_TRACE(kTraceError, kTraceUtility, _id, "kPlayoutError message posted: rendering thread has ended pre-maturely");
@@ -3712,6 +3716,8 @@ Exit:
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_Rendering thread is now terminated properly"); WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_Rendering thread is now terminated properly");
} }
_UnLock();
return (DWORD)hr; return (DWORD)hr;
} }
@@ -4177,13 +4183,15 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread()
Exit: Exit:
if (FAILED(hr)) if (FAILED(hr))
{ {
_UnLock();
_ptrClientIn->Stop(); _ptrClientIn->Stop();
_UnLock();
_TraceCOMError(hr); _TraceCOMError(hr);
} }
RevertCaptureThreadPriority(); RevertCaptureThreadPriority();
_Lock();
if (keepRecording) if (keepRecording)
{ {
if (_ptrClientIn != NULL) if (_ptrClientIn != NULL)
@@ -4212,6 +4220,8 @@ Exit:
SAFE_RELEASE(_ptrClientIn); SAFE_RELEASE(_ptrClientIn);
SAFE_RELEASE(_ptrCaptureClient); SAFE_RELEASE(_ptrCaptureClient);
_UnLock();
if (syncBuffer) if (syncBuffer)
{ {
delete [] syncBuffer; delete [] syncBuffer;