Make DMO init safe when not supported.
BUG=issue133 TEST=voe_auto_test Review URL: http://webrtc-codereview.appspot.com/284001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@990 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
91617ff948
commit
5a529395aa
@ -359,6 +359,8 @@ AudioDeviceWindowsCore::AudioDeviceWindowsCore(const WebRtc_Word32 id) :
|
||||
_ptrCaptureClient(NULL),
|
||||
_ptrCaptureVolume(NULL),
|
||||
_ptrRenderSimpleVolume(NULL),
|
||||
_dmo(NULL),
|
||||
_mediaBuffer(NULL),
|
||||
_builtInAecEnabled(false),
|
||||
_playAudioFrameSize(0),
|
||||
_playSampleRate(0),
|
||||
@ -491,15 +493,16 @@ AudioDeviceWindowsCore::AudioDeviceWindowsCore(const WebRtc_Word32 id) :
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_IMediaObject,
|
||||
reinterpret_cast<void**>(&ptrDMO));
|
||||
_dmo = ptrDMO;
|
||||
ptrDMO->Release();
|
||||
}
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr) || ptrDMO == NULL)
|
||||
{
|
||||
// Since we check that _dmo is non-NULL in EnableBuiltInAEC(), the
|
||||
// feature is prevented from being enabled.
|
||||
_builtInAecEnabled = false;
|
||||
_TraceCOMError(hr);
|
||||
assert(false);
|
||||
}
|
||||
assert(_dmo != NULL);
|
||||
_dmo = ptrDMO;
|
||||
SAFE_RELEASE(ptrDMO);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -3778,7 +3781,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO()
|
||||
// copy available data to |dmoBuffer|, and should only return
|
||||
// 10 ms frames. The value of |dwStatus| should be ignored.
|
||||
hr = _dmo->ProcessOutput(0, 1, &dmoBuffer, &dwStatus);
|
||||
dmoBuffer.pBuffer->Release();
|
||||
SAFE_RELEASE(dmoBuffer.pBuffer);
|
||||
dwStatus = dmoBuffer.dwStatus;
|
||||
}
|
||||
if (FAILED(hr))
|
||||
@ -4052,7 +4055,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread()
|
||||
clock->GetPosition(&pos, NULL);
|
||||
clock->GetFrequency(&freq);
|
||||
_sndCardPlayDelay = ROUND((double(_writtenSamples) / _devicePlaySampleRate - double(pos) / freq) * 1000.0);
|
||||
clock->Release();
|
||||
SAFE_RELEASE(clock);
|
||||
}
|
||||
|
||||
// Send the captured data to the registered consumer
|
||||
@ -4217,15 +4220,14 @@ int AudioDeviceWindowsCore::SetDMOProperties()
|
||||
IPropertyStore* ptrPS = NULL;
|
||||
hr = _dmo->QueryInterface(IID_IPropertyStore,
|
||||
reinterpret_cast<void**>(&ptrPS));
|
||||
ps = ptrPS;
|
||||
ptrPS->Release();
|
||||
}
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr) || ptrPS == NULL)
|
||||
{
|
||||
_TraceCOMError(hr);
|
||||
return -1;
|
||||
}
|
||||
assert(ps != NULL);
|
||||
ps = ptrPS;
|
||||
SAFE_RELEASE(ptrPS);
|
||||
}
|
||||
|
||||
// Set the AEC system mode.
|
||||
// SINGLE_CHANNEL_AEC - AEC processing only.
|
||||
@ -4650,14 +4652,14 @@ WebRtc_Word32 AudioDeviceWindowsCore::_GetDefaultDeviceIndex(EDataFlow dir,
|
||||
{
|
||||
IMMDevice* ptrDevice = NULL;
|
||||
hr = collection->Item(i, &ptrDevice);
|
||||
device = ptrDevice;
|
||||
ptrDevice->Release();
|
||||
}
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr) || ptrDevice == NULL)
|
||||
{
|
||||
_TraceCOMError(hr);
|
||||
return -1;
|
||||
}
|
||||
device = ptrDevice;
|
||||
SAFE_RELEASE(ptrDevice);
|
||||
}
|
||||
|
||||
if (_GetDeviceID(device, szDeviceID, kDeviceIDLength) == -1)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user