Merge pull request #7843 from chacha21:fix-capture-msmf

This commit is contained in:
Alexander Alekhin 2016-12-14 02:47:19 +00:00
commit c977af8ee8

View File

@ -1986,13 +1986,17 @@ long videoDevice::resetDevice(IMFActivate *pActivate)
&vd_pFriendlyName, &vd_pFriendlyName,
NULL NULL
); );
hr = pActivate->ActivateObject( if (SUCCEEDED(hr))
__uuidof(IMFMediaSource), hr = pActivate->ActivateObject(
(void**)&pSource __uuidof(IMFMediaSource),
); (void**)&pSource
enumerateCaptureFormats(pSource); );
buildLibraryofTypes(); if (SUCCEEDED(hr) && pSource)
SafeRelease(&pSource); {
enumerateCaptureFormats(pSource);
buildLibraryofTypes();
SafeRelease(&pSource);
}//end if (SUCCEEDED(hr) && pSource)
if(FAILED(hr)) if(FAILED(hr))
{ {
vd_pFriendlyName = NULL; vd_pFriendlyName = NULL;
@ -2638,7 +2642,12 @@ HRESULT videoDevice::enumerateCaptureFormats(IMFMediaSource *pSource)
_ComPtr<IMFStreamDescriptor> pSD = NULL; _ComPtr<IMFStreamDescriptor> pSD = NULL;
_ComPtr<IMFMediaTypeHandler> pHandler = NULL; _ComPtr<IMFMediaTypeHandler> pHandler = NULL;
_ComPtr<IMFMediaType> pType = NULL; _ComPtr<IMFMediaType> pType = NULL;
HRESULT hr = pSource->CreatePresentationDescriptor(pPD.GetAddressOf()); HRESULT hr = !pSource ? E_POINTER : S_OK;
if (FAILED(hr))
{
goto done;
}
hr = pSource->CreatePresentationDescriptor(pPD.GetAddressOf());
if (FAILED(hr)) if (FAILED(hr))
{ {
goto done; goto done;
@ -3815,7 +3824,12 @@ HRESULT CvCaptureFile_MSMF::enumerateCaptureFormats(IMFMediaSource *pSource)
_ComPtr<IMFStreamDescriptor> pSD = NULL; _ComPtr<IMFStreamDescriptor> pSD = NULL;
_ComPtr<IMFMediaTypeHandler> pHandler = NULL; _ComPtr<IMFMediaTypeHandler> pHandler = NULL;
_ComPtr<IMFMediaType> pType = NULL; _ComPtr<IMFMediaType> pType = NULL;
HRESULT hr = pSource->CreatePresentationDescriptor(pPD.GetAddressOf()); HRESULT hr = !pSource ? E_POINTER : S_OK;
if (FAILED(hr))
{
goto done;
}
hr = pSource->CreatePresentationDescriptor(pPD.GetAddressOf());
if (FAILED(hr)) if (FAILED(hr))
{ {
goto done; goto done;