Commit 0caef9e2 authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

amstream: Rewrite OpenFile flow in a more readable manner by using SUCCEEDED macro.

parent c0610daf
...@@ -303,11 +303,11 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream ...@@ -303,11 +303,11 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream
static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenFile(IAMMultiMediaStream* iface, LPCWSTR pszFileName, DWORD dwFlags) static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenFile(IAMMultiMediaStream* iface, LPCWSTR pszFileName, DWORD dwFlags)
{ {
HRESULT ret;
IAMMultiMediaStreamImpl *This = impl_from_IAMMultiMediaStream(iface); IAMMultiMediaStreamImpl *This = impl_from_IAMMultiMediaStream(iface);
IFileSourceFilter *SourceFilter; HRESULT ret = S_OK;
IBaseFilter *BaseFilter; IFileSourceFilter *SourceFilter = NULL;
IEnumPins *EnumPins; IBaseFilter *BaseFilter = NULL;
IEnumPins *EnumPins = NULL;
IPin *ipin; IPin *ipin;
PIN_DIRECTION pin_direction; PIN_DIRECTION pin_direction;
...@@ -315,56 +315,39 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenFile(IAMMultiMediaStream* ifac ...@@ -315,56 +315,39 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_OpenFile(IAMMultiMediaStream* ifac
/* If Initialize was not called before, we do it here */ /* If Initialize was not called before, we do it here */
if (!This->pFilterGraph) if (!This->pFilterGraph)
{
ret = IAMMultiMediaStream_Initialize(iface, STREAMTYPE_READ, 0, NULL); ret = IAMMultiMediaStream_Initialize(iface, STREAMTYPE_READ, 0, NULL);
if (FAILED(ret))
return ret;
}
ret = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, &IID_IFileSourceFilter, (void**)&SourceFilter); if (SUCCEEDED(ret))
if(ret != S_OK) ret = CoCreateInstance(&CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, &IID_IFileSourceFilter, (void**)&SourceFilter);
return ret;
ret = IGraphBuilder_AddSourceFilter(This->pFilterGraph, pszFileName, pszFileName, &BaseFilter); if (SUCCEEDED(ret))
if (FAILED(ret)) ret = IGraphBuilder_AddSourceFilter(This->pFilterGraph, pszFileName, pszFileName, &BaseFilter);
goto end;
ret = IFileSourceFilter_Load(SourceFilter, pszFileName, NULL); if (SUCCEEDED(ret))
if(ret != S_OK) ret = IFileSourceFilter_Load(SourceFilter, pszFileName, NULL);
{
IFileSourceFilter_Release(SourceFilter);
return ret;
}
ret = IFileSourceFilter_QueryInterface(SourceFilter, &IID_IBaseFilter, (void**)&BaseFilter); if (SUCCEEDED(ret))
if(ret != S_OK) ret = IFileSourceFilter_QueryInterface(SourceFilter, &IID_IBaseFilter, (void**)&BaseFilter);
{
IFileSourceFilter_Release(SourceFilter);
return ret;
}
ret = IBaseFilter_EnumPins(BaseFilter, &EnumPins); if (SUCCEEDED(ret))
if(ret != S_OK) ret = IBaseFilter_EnumPins(BaseFilter, &EnumPins);
{
goto end; if (SUCCEEDED(ret))
} ret = IEnumPins_Next(EnumPins, 1, &ipin, NULL);
ret = IEnumPins_Next(EnumPins, 1, &ipin, NULL); if (SUCCEEDED(ret))
if (ret == S_OK)
{ {
ret = IPin_QueryDirection(ipin, &pin_direction); ret = IPin_QueryDirection(ipin, &pin_direction);
IEnumPins_Release(EnumPins);
if (ret == S_OK && pin_direction == PINDIR_OUTPUT) if (ret == S_OK && pin_direction == PINDIR_OUTPUT)
This->ipin = ipin; This->ipin = ipin;
} }
else
{
IEnumPins_Release(EnumPins);
}
end: if (EnumPins)
IBaseFilter_Release(BaseFilter); IEnumPins_Release(EnumPins);
IFileSourceFilter_Release(SourceFilter); if (BaseFilter)
IBaseFilter_Release(BaseFilter);
if (SourceFilter)
IFileSourceFilter_Release(SourceFilter);
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment