Commit 703d0a33 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

qedit: COM cleanup for the IPin iface (SampleGrabber).

parent 023f79a8
...@@ -351,13 +351,18 @@ static IEnumMediaTypes *mediaenum_create(const AM_MEDIA_TYPE *mtype) ...@@ -351,13 +351,18 @@ static IEnumMediaTypes *mediaenum_create(const AM_MEDIA_TYPE *mtype)
/* Sample Grabber pin implementation */ /* Sample Grabber pin implementation */
typedef struct _SG_Pin { typedef struct _SG_Pin {
const IPinVtbl* lpVtbl; IPin IPin_iface;
PIN_DIRECTION dir; PIN_DIRECTION dir;
WCHAR const *name; WCHAR const *name;
struct _SG_Impl *sg; struct _SG_Impl *sg;
IPin *pair; IPin *pair;
} SG_Pin; } SG_Pin;
static inline SG_Pin *impl_from_IPin(IPin *iface)
{
return CONTAINING_RECORD(iface, SG_Pin, IPin_iface);
}
/* Sample Grabber filter implementation */ /* Sample Grabber filter implementation */
typedef struct _SG_Impl { typedef struct _SG_Impl {
IBaseFilter IBaseFilter_iface; IBaseFilter IBaseFilter_iface;
...@@ -661,8 +666,8 @@ SampleGrabber_IBaseFilter_EnumPins(IBaseFilter *iface, IEnumPins **pins) ...@@ -661,8 +666,8 @@ SampleGrabber_IBaseFilter_EnumPins(IBaseFilter *iface, IEnumPins **pins)
TRACE("(%p)->(%p)\n", This, pins); TRACE("(%p)->(%p)\n", This, pins);
if (!pins) if (!pins)
return E_POINTER; return E_POINTER;
pin[0] = (IPin*)&This->pin_in.lpVtbl; pin[0] = &This->pin_in.IPin_iface;
pin[1] = (IPin*)&This->pin_out.lpVtbl; pin[1] = &This->pin_out.IPin_iface;
*pins = pinsenum_create(iface, pin, 2); *pins = pinsenum_create(iface, pin, 2);
return *pins ? S_OK : E_OUTOFMEMORY; return *pins ? S_OK : E_OUTOFMEMORY;
} }
...@@ -677,14 +682,14 @@ SampleGrabber_IBaseFilter_FindPin(IBaseFilter *iface, LPCWSTR id, IPin **pin) ...@@ -677,14 +682,14 @@ SampleGrabber_IBaseFilter_FindPin(IBaseFilter *iface, LPCWSTR id, IPin **pin)
return E_POINTER; return E_POINTER;
if (!lstrcmpiW(id,pin_in_name)) if (!lstrcmpiW(id,pin_in_name))
{ {
SampleGrabber_addref(This); *pin = &This->pin_in.IPin_iface;
*pin = (IPin*)&(This->pin_in.lpVtbl); IPin_AddRef(*pin);
return S_OK; return S_OK;
} }
else if (!lstrcmpiW(id,pin_out_name)) else if (!lstrcmpiW(id,pin_out_name))
{ {
SampleGrabber_addref(This); *pin = &This->pin_out.IPin_iface;
*pin = (IPin*)&(This->pin_out.lpVtbl); IPin_AddRef(*pin);
return S_OK; return S_OK;
} }
*pin = NULL; *pin = NULL;
...@@ -1003,37 +1008,37 @@ SampleGrabber_IMemInputPin_ReceiveCanBlock(IMemInputPin *iface) ...@@ -1003,37 +1008,37 @@ SampleGrabber_IMemInputPin_ReceiveCanBlock(IMemInputPin *iface)
static ULONG WINAPI static ULONG WINAPI
SampleGrabber_IPin_AddRef(IPin *iface) SampleGrabber_IPin_AddRef(IPin *iface)
{ {
return SampleGrabber_addref(((SG_Pin *)iface)->sg); SG_Pin *This = impl_from_IPin(iface);
return ISampleGrabber_AddRef(&This->sg->ISampleGrabber_iface);
} }
/* IUnknown */ /* IUnknown */
static ULONG WINAPI static ULONG WINAPI
SampleGrabber_IPin_Release(IPin *iface) SampleGrabber_IPin_Release(IPin *iface)
{ {
return SampleGrabber_release(((SG_Pin *)iface)->sg); SG_Pin *This = impl_from_IPin(iface);
return ISampleGrabber_Release(&This->sg->ISampleGrabber_iface);
} }
/* IUnknown */ /* IUnknown */
static HRESULT WINAPI static HRESULT WINAPI
SampleGrabber_IPin_QueryInterface(IPin *iface, REFIID riid, void **ppvObject) SampleGrabber_IPin_QueryInterface(IPin *iface, REFIID riid, void **ppv)
{ {
SG_Pin *This = (SG_Pin *)iface; SG_Pin *This = impl_from_IPin(iface);
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject); TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
if (IsEqualIID(riid, &IID_IUnknown) || *ppv = NULL;
IsEqualIID(riid, &IID_IPin)) { if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IPin))
SampleGrabber_addref(This->sg); *ppv = iface;
*ppvObject = This; else if (IsEqualIID(riid, &IID_IMemInputPin))
return S_OK; *ppv = &This->sg->IMemInputPin_iface;
} else {
else if (IsEqualIID(riid, &IID_IMemInputPin)) { WARN("(%p, %s,%p): not found\n", This, debugstr_guid(riid), ppv);
SampleGrabber_addref(This->sg); return E_NOINTERFACE;
*ppvObject = &This->sg->IMemInputPin_iface;
return S_OK;
} }
*ppvObject = NULL;
WARN("(%p, %s,%p): not found\n", This, debugstr_guid(riid), ppvObject); IUnknown_AddRef((IUnknown*)*ppv);
return E_NOINTERFACE; return S_OK;
} }
/* IPin - input pin */ /* IPin - input pin */
...@@ -1048,8 +1053,9 @@ SampleGrabber_In_IPin_Connect(IPin *iface, IPin *receiver, const AM_MEDIA_TYPE * ...@@ -1048,8 +1053,9 @@ SampleGrabber_In_IPin_Connect(IPin *iface, IPin *receiver, const AM_MEDIA_TYPE *
static HRESULT WINAPI static HRESULT WINAPI
SampleGrabber_Out_IPin_Connect(IPin *iface, IPin *receiver, const AM_MEDIA_TYPE *type) SampleGrabber_Out_IPin_Connect(IPin *iface, IPin *receiver, const AM_MEDIA_TYPE *type)
{ {
SG_Pin *This = (SG_Pin *)iface; SG_Pin *This = impl_from_IPin(iface);
HRESULT hr; HRESULT hr;
TRACE("(%p)->(%p, %p)\n", This, receiver, type); TRACE("(%p)->(%p, %p)\n", This, receiver, type);
if (!receiver) if (!receiver)
return E_POINTER; return E_POINTER;
...@@ -1079,7 +1085,7 @@ SampleGrabber_Out_IPin_Connect(IPin *iface, IPin *receiver, const AM_MEDIA_TYPE ...@@ -1079,7 +1085,7 @@ SampleGrabber_Out_IPin_Connect(IPin *iface, IPin *receiver, const AM_MEDIA_TYPE
!IsEqualGUID(&type->formattype, &GUID_NULL) && !IsEqualGUID(&type->formattype, &GUID_NULL) &&
!type->pbFormat) !type->pbFormat)
return VFW_E_TYPE_NOT_ACCEPTED; return VFW_E_TYPE_NOT_ACCEPTED;
hr = IPin_ReceiveConnection(receiver,(IPin*)&This->lpVtbl,type); hr = IPin_ReceiveConnection(receiver, &This->IPin_iface, type);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
This->pair = receiver; This->pair = receiver;
...@@ -1096,7 +1102,8 @@ SampleGrabber_Out_IPin_Connect(IPin *iface, IPin *receiver, const AM_MEDIA_TYPE ...@@ -1096,7 +1102,8 @@ SampleGrabber_Out_IPin_Connect(IPin *iface, IPin *receiver, const AM_MEDIA_TYPE
static HRESULT WINAPI static HRESULT WINAPI
SampleGrabber_In_IPin_ReceiveConnection(IPin *iface, IPin *connector, const AM_MEDIA_TYPE *type) SampleGrabber_In_IPin_ReceiveConnection(IPin *iface, IPin *connector, const AM_MEDIA_TYPE *type)
{ {
SG_Pin *This = (SG_Pin *)iface; SG_Pin *This = impl_from_IPin(iface);
TRACE("(%p)->(%p, %p)\n", This, connector, type); TRACE("(%p)->(%p, %p)\n", This, connector, type);
if (!connector) if (!connector)
return E_POINTER; return E_POINTER;
...@@ -1151,7 +1158,8 @@ SampleGrabber_Out_IPin_ReceiveConnection(IPin *iface, IPin *connector, const AM_ ...@@ -1151,7 +1158,8 @@ SampleGrabber_Out_IPin_ReceiveConnection(IPin *iface, IPin *connector, const AM_
static HRESULT WINAPI static HRESULT WINAPI
SampleGrabber_In_IPin_Disconnect(IPin *iface) SampleGrabber_In_IPin_Disconnect(IPin *iface)
{ {
SG_Pin *This = (SG_Pin *)iface; SG_Pin *This = impl_from_IPin(iface);
TRACE("(%p)->() pair = %p\n", This, This->pair); TRACE("(%p)->() pair = %p\n", This, This->pair);
if (This->sg->state != State_Stopped) if (This->sg->state != State_Stopped)
return VFW_E_NOT_STOPPED; return VFW_E_NOT_STOPPED;
...@@ -1166,7 +1174,8 @@ SampleGrabber_In_IPin_Disconnect(IPin *iface) ...@@ -1166,7 +1174,8 @@ SampleGrabber_In_IPin_Disconnect(IPin *iface)
static HRESULT WINAPI static HRESULT WINAPI
SampleGrabber_Out_IPin_Disconnect(IPin *iface) SampleGrabber_Out_IPin_Disconnect(IPin *iface)
{ {
SG_Pin *This = (SG_Pin *)iface; SG_Pin *This = impl_from_IPin(iface);
TRACE("(%p)->() pair = %p\n", This, This->pair); TRACE("(%p)->() pair = %p\n", This, This->pair);
if (This->sg->state != State_Stopped) if (This->sg->state != State_Stopped)
return VFW_E_NOT_STOPPED; return VFW_E_NOT_STOPPED;
...@@ -1185,7 +1194,8 @@ SampleGrabber_Out_IPin_Disconnect(IPin *iface) ...@@ -1185,7 +1194,8 @@ SampleGrabber_Out_IPin_Disconnect(IPin *iface)
static HRESULT WINAPI static HRESULT WINAPI
SampleGrabber_IPin_ConnectedTo(IPin *iface, IPin **pin) SampleGrabber_IPin_ConnectedTo(IPin *iface, IPin **pin)
{ {
SG_Pin *This = (SG_Pin *)iface; SG_Pin *This = impl_from_IPin(iface);
TRACE("(%p)->(%p) pair = %p\n", This, pin, This->pair); TRACE("(%p)->(%p) pair = %p\n", This, pin, This->pair);
if (!pin) if (!pin)
return E_POINTER; return E_POINTER;
...@@ -1201,7 +1211,8 @@ SampleGrabber_IPin_ConnectedTo(IPin *iface, IPin **pin) ...@@ -1201,7 +1211,8 @@ SampleGrabber_IPin_ConnectedTo(IPin *iface, IPin **pin)
static HRESULT WINAPI static HRESULT WINAPI
SampleGrabber_IPin_ConnectionMediaType(IPin *iface, AM_MEDIA_TYPE *mtype) SampleGrabber_IPin_ConnectionMediaType(IPin *iface, AM_MEDIA_TYPE *mtype)
{ {
SG_Pin *This = (SG_Pin *)iface; SG_Pin *This = impl_from_IPin(iface);
TRACE("(%p)->(%p)\n", This, mtype); TRACE("(%p)->(%p)\n", This, mtype);
if (!mtype) if (!mtype)
return E_POINTER; return E_POINTER;
...@@ -1219,7 +1230,8 @@ SampleGrabber_IPin_ConnectionMediaType(IPin *iface, AM_MEDIA_TYPE *mtype) ...@@ -1219,7 +1230,8 @@ SampleGrabber_IPin_ConnectionMediaType(IPin *iface, AM_MEDIA_TYPE *mtype)
static HRESULT WINAPI static HRESULT WINAPI
SampleGrabber_IPin_QueryPinInfo(IPin *iface, PIN_INFO *info) SampleGrabber_IPin_QueryPinInfo(IPin *iface, PIN_INFO *info)
{ {
SG_Pin *This = (SG_Pin *)iface; SG_Pin *This = impl_from_IPin(iface);
TRACE("(%p)->(%p)\n", This, info); TRACE("(%p)->(%p)\n", This, info);
if (!info) if (!info)
return E_POINTER; return E_POINTER;
...@@ -1234,7 +1246,8 @@ SampleGrabber_IPin_QueryPinInfo(IPin *iface, PIN_INFO *info) ...@@ -1234,7 +1246,8 @@ SampleGrabber_IPin_QueryPinInfo(IPin *iface, PIN_INFO *info)
static HRESULT WINAPI static HRESULT WINAPI
SampleGrabber_IPin_QueryDirection(IPin *iface, PIN_DIRECTION *dir) SampleGrabber_IPin_QueryDirection(IPin *iface, PIN_DIRECTION *dir)
{ {
SG_Pin *This = (SG_Pin *)iface; SG_Pin *This = impl_from_IPin(iface);
TRACE("(%p)->(%p)\n", This, dir); TRACE("(%p)->(%p)\n", This, dir);
if (!dir) if (!dir)
return E_POINTER; return E_POINTER;
...@@ -1246,7 +1259,8 @@ SampleGrabber_IPin_QueryDirection(IPin *iface, PIN_DIRECTION *dir) ...@@ -1246,7 +1259,8 @@ SampleGrabber_IPin_QueryDirection(IPin *iface, PIN_DIRECTION *dir)
static HRESULT WINAPI static HRESULT WINAPI
SampleGrabber_IPin_QueryId(IPin *iface, LPWSTR *id) SampleGrabber_IPin_QueryId(IPin *iface, LPWSTR *id)
{ {
SG_Pin *This = (SG_Pin *)iface; SG_Pin *This = impl_from_IPin(iface);
int len; int len;
TRACE("(%p)->(%p)\n", This, id); TRACE("(%p)->(%p)\n", This, id);
if (!id) if (!id)
...@@ -1269,7 +1283,8 @@ SampleGrabber_IPin_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *mtype) ...@@ -1269,7 +1283,8 @@ SampleGrabber_IPin_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *mtype)
static HRESULT WINAPI static HRESULT WINAPI
SampleGrabber_IPin_EnumMediaTypes(IPin *iface, IEnumMediaTypes **mtypes) SampleGrabber_IPin_EnumMediaTypes(IPin *iface, IEnumMediaTypes **mtypes)
{ {
SG_Pin *This = (SG_Pin *)iface; SG_Pin *This = impl_from_IPin(iface);
TRACE("(%p)->(%p)\n", This, mtypes); TRACE("(%p)->(%p)\n", This, mtypes);
if (!mtypes) if (!mtypes)
return E_POINTER; return E_POINTER;
...@@ -1281,15 +1296,16 @@ SampleGrabber_IPin_EnumMediaTypes(IPin *iface, IEnumMediaTypes **mtypes) ...@@ -1281,15 +1296,16 @@ SampleGrabber_IPin_EnumMediaTypes(IPin *iface, IEnumMediaTypes **mtypes)
static HRESULT WINAPI static HRESULT WINAPI
SampleGrabber_In_IPin_QueryInternalConnections(IPin *iface, IPin **pins, ULONG *nPins) SampleGrabber_In_IPin_QueryInternalConnections(IPin *iface, IPin **pins, ULONG *nPins)
{ {
SG_Pin *This = (SG_Pin *)iface; SG_Pin *This = impl_from_IPin(iface);
TRACE("(%p)->(%p, %p) size = %u\n", This, pins, nPins, (nPins ? *nPins : 0)); TRACE("(%p)->(%p, %p) size = %u\n", This, pins, nPins, (nPins ? *nPins : 0));
if (!nPins) if (!nPins)
return E_POINTER; return E_POINTER;
if (*nPins) { if (*nPins) {
if (!pins) if (!pins)
return E_POINTER; return E_POINTER;
IPin_AddRef((IPin*)&This->sg->pin_out.lpVtbl); IPin_AddRef(&This->sg->pin_out.IPin_iface);
*pins = (IPin*)&This->sg->pin_out.lpVtbl; *pins = &This->sg->pin_out.IPin_iface;
*nPins = 1; *nPins = 1;
return S_OK; return S_OK;
} }
...@@ -1452,12 +1468,12 @@ HRESULT SampleGrabber_create(IUnknown *pUnkOuter, LPVOID *ppv) ...@@ -1452,12 +1468,12 @@ HRESULT SampleGrabber_create(IUnknown *pUnkOuter, LPVOID *ppv)
obj->IBaseFilter_iface.lpVtbl = &IBaseFilter_VTable; obj->IBaseFilter_iface.lpVtbl = &IBaseFilter_VTable;
obj->ISampleGrabber_iface.lpVtbl = &ISampleGrabber_VTable; obj->ISampleGrabber_iface.lpVtbl = &ISampleGrabber_VTable;
obj->IMemInputPin_iface.lpVtbl = &IMemInputPin_VTable; obj->IMemInputPin_iface.lpVtbl = &IMemInputPin_VTable;
obj->pin_in.lpVtbl = &IPin_In_VTable; obj->pin_in.IPin_iface.lpVtbl = &IPin_In_VTable;
obj->pin_in.dir = PINDIR_INPUT; obj->pin_in.dir = PINDIR_INPUT;
obj->pin_in.name = pin_in_name; obj->pin_in.name = pin_in_name;
obj->pin_in.sg = obj; obj->pin_in.sg = obj;
obj->pin_in.pair = NULL; obj->pin_in.pair = NULL;
obj->pin_out.lpVtbl = &IPin_Out_VTable; obj->pin_out.IPin_iface.lpVtbl = &IPin_Out_VTable;
obj->pin_out.dir = PINDIR_OUTPUT; obj->pin_out.dir = PINDIR_OUTPUT;
obj->pin_out.name = pin_out_name; obj->pin_out.name = pin_out_name;
obj->pin_out.sg = obj; obj->pin_out.sg = obj;
......
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