[PATCH 2/4] quartz: Cleanup PullPin_ReceiveConnection().
Eduard - Gabriel Munteanu
eduard.munteanu at linux360.ro
Thu Aug 27 14:13:53 CDT 2009
This cleans up PullPin_ReceiveConnection(), reducing indentation levels
and providing better error paths.
Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu at linux360.ro>
---
dlls/quartz/pin.c | 128 ++++++++++++++++++++++++++--------------------------
1 files changed, 64 insertions(+), 64 deletions(-)
diff --git a/dlls/quartz/pin.c b/dlls/quartz/pin.c
index 1947cc5..c40ccec 100644
--- a/dlls/quartz/pin.c
+++ b/dlls/quartz/pin.c
@@ -1121,88 +1121,88 @@ HRESULT WINAPI PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const
PIN_DIRECTION pindirReceive;
HRESULT hr = S_OK;
PullPin *This = (PullPin *)iface;
+ ALLOCATOR_PROPERTIES props;
IMemAllocator *prefAlloc;
TRACE("(%p/%p)->(%p, %p)\n", This, iface, pReceivePin, pmt);
dump_AM_MEDIA_TYPE(pmt);
EnterCriticalSection(This->pin.pCritSec);
- if (!This->pin.pConnectedTo)
- {
- ALLOCATOR_PROPERTIES props;
- props.cBuffers = 3;
- props.cbBuffer = 64 * 1024; /* 64k bytes */
- props.cbAlign = 1;
- props.cbPrefix = 0;
+ if (This->pin.pConnectedTo)
+ {
+ hr = VFW_E_ALREADY_CONNECTED;
+ goto out;
+ }
- if (SUCCEEDED(hr) && (This->pin.fnQueryAccept(This->pin.pUserData, pmt) != S_OK))
- hr = VFW_E_TYPE_NOT_ACCEPTED; /* FIXME: shouldn't we just map common errors onto
- * VFW_E_TYPE_NOT_ACCEPTED and pass the value on otherwise? */
+ props.cBuffers = 3;
+ props.cbBuffer = 64 * 1024; /* 64k bytes */
+ props.cbAlign = 1;
+ props.cbPrefix = 0;
- if (SUCCEEDED(hr))
- {
- IPin_QueryDirection(pReceivePin, &pindirReceive);
+ if (This->pin.fnQueryAccept(This->pin.pUserData, pmt) != S_OK)
+ {
+ hr = VFW_E_TYPE_NOT_ACCEPTED; /* FIXME: shouldn't we just map common errors onto
+ * VFW_E_TYPE_NOT_ACCEPTED and pass the value on otherwise? */
+ goto err;
+ }
- if (pindirReceive != PINDIR_OUTPUT)
- {
- ERR("Can't connect from non-output pin\n");
- hr = VFW_E_INVALID_DIRECTION;
- }
- }
+ IPin_QueryDirection(pReceivePin, &pindirReceive);
+ if (pindirReceive != PINDIR_OUTPUT)
+ {
+ ERR("Can't connect from non-output pin\n");
+ hr = VFW_E_INVALID_DIRECTION;
+ goto err;
+ }
- This->pReader = NULL;
- This->pAlloc = NULL;
- if (SUCCEEDED(hr))
- {
- hr = IPin_QueryInterface(pReceivePin, &IID_IAsyncReader, (LPVOID *)&This->pReader);
- }
+ This->pReader = NULL;
+ This->pAlloc = NULL;
+ hr = IPin_QueryInterface(pReceivePin, &IID_IAsyncReader, (LPVOID *)&This->pReader);
+ if (FAILED(hr))
+ goto err;
- if (SUCCEEDED(hr) && This->fnPreConnect)
- {
- hr = This->fnPreConnect(iface, pReceivePin, &props);
- }
+ if (This->fnPreConnect)
+ hr = This->fnPreConnect(iface, pReceivePin, &props);
+ if (FAILED(hr))
+ goto err;
- if (SUCCEEDED(hr))
- {
- hr = StdMemAllocator_create(NULL, (LPVOID *) &prefAlloc);
- }
+ hr = StdMemAllocator_create(NULL, (LPVOID *) &prefAlloc);
+ if (FAILED(hr))
+ goto err;
- if (SUCCEEDED(hr))
- {
- /*
- * Some applications (e.g. Fallout 3) erroneously
- * expect a non-NULL preferred allocator, so we'll pass one.
- */
- hr = IAsyncReader_RequestAllocator(This->pReader, prefAlloc, &props, &This->pAlloc);
- IMemAllocator_Release(prefAlloc);
- }
+ /*
+ * Some applications (e.g. Fallout 3) erroneously
+ * expect a non-NULL preferred allocator, so we'll pass one.
+ */
+ hr = IAsyncReader_RequestAllocator(This->pReader, prefAlloc, &props, &This->pAlloc);
+ IMemAllocator_Release(prefAlloc);
+ if (FAILED(hr))
+ goto err;
- if (SUCCEEDED(hr))
- {
- CopyMediaType(&This->pin.mtCurrent, pmt);
- This->pin.pConnectedTo = pReceivePin;
- IPin_AddRef(pReceivePin);
- hr = IMemAllocator_Commit(This->pAlloc);
- }
+ CopyMediaType(&This->pin.mtCurrent, pmt);
+ This->pin.pConnectedTo = pReceivePin;
+ IPin_AddRef(pReceivePin);
+ hr = IMemAllocator_Commit(This->pAlloc);
+ if (FAILED(hr))
+ goto err;
- if (SUCCEEDED(hr))
- hr = PullPin_InitProcessing(This);
+ hr = PullPin_InitProcessing(This);
+ if (FAILED(hr))
+ goto err;
- if (FAILED(hr))
- {
- if (This->pReader)
- IAsyncReader_Release(This->pReader);
- This->pReader = NULL;
- if (This->pAlloc)
- IMemAllocator_Release(This->pAlloc);
- This->pAlloc = NULL;
- }
- }
- else
- hr = VFW_E_ALREADY_CONNECTED;
+out:
LeaveCriticalSection(This->pin.pCritSec);
return hr;
+
+err:
+ if (This->pReader)
+ IAsyncReader_Release(This->pReader);
+ This->pReader = NULL;
+ if (This->pAlloc)
+ IMemAllocator_Release(This->pAlloc);
+ This->pAlloc = NULL;
+
+ goto out;
}
HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv)
--
1.6.0.6
More information about the wine-patches
mailing list