2 * Implementation of CLSID_MemoryAllocator.
6 * hidenori@a2.ctktv.ne.jp
15 #include "wine/obj_base.h"
19 #include "debugtools.h"
20 DEFAULT_DEBUG_CHANNEL(quartz
);
22 #include "quartz_private.h"
27 IMemAllocator_fnQueryInterface(IMemAllocator
* iface
,REFIID riid
,void** ppobj
)
29 CMemoryAllocator_THIS(iface
,memalloc
);
31 TRACE("(%p)->()\n",This
);
33 return IUnknown_QueryInterface(This
->unk
.punkControl
,riid
,ppobj
);
37 IMemAllocator_fnAddRef(IMemAllocator
* iface
)
39 CMemoryAllocator_THIS(iface
,memalloc
);
41 TRACE("(%p)->()\n",This
);
43 return IUnknown_AddRef(This
->unk
.punkControl
);
47 IMemAllocator_fnRelease(IMemAllocator
* iface
)
49 CMemoryAllocator_THIS(iface
,memalloc
);
51 TRACE("(%p)->()\n",This
);
53 return IUnknown_Release(This
->unk
.punkControl
);
57 IMemAllocator_fnSetProperties(IMemAllocator
* iface
,ALLOCATOR_PROPERTIES
* pPropReq
,ALLOCATOR_PROPERTIES
* pPropActual
)
59 CMemoryAllocator_THIS(iface
,memalloc
);
62 TRACE( "(%p)->(%p,%p)\n", This
, pPropReq
, pPropActual
);
64 if ( pPropReq
== NULL
|| pPropActual
== NULL
)
66 if ( pPropReq
->cBuffers
< 0 ||
67 pPropReq
->cbBuffer
< 0 ||
68 pPropReq
->cbAlign
< 0 ||
69 pPropReq
->cbPrefix
< 0 )
72 if ( ( pPropReq
->cbAlign
& (pPropReq
->cbAlign
-1) ) != 0 )
75 EnterCriticalSection( &This
->csMem
);
77 This
->prop
.cBuffers
= pPropReq
->cBuffers
;
78 This
->prop
.cbBuffer
= pPropReq
->cbBuffer
;
79 This
->prop
.cbAlign
= pPropReq
->cbAlign
;
80 This
->prop
.cbPrefix
= pPropReq
->cbPrefix
;
82 if ( This
->prop
.cbAlign
== 0 )
83 This
->prop
.cbAlign
= 1;
84 padding
= This
->prop
.cbAlign
-
85 ( (This
->prop
.cbBuffer
+This
->prop
.cbPrefix
) % This
->prop
.cbAlign
);
87 This
->prop
.cbBuffer
+= padding
;
89 memcpy( pPropActual
, &This
->prop
, sizeof(ALLOCATOR_PROPERTIES
) );
91 LeaveCriticalSection( &This
->csMem
);
97 IMemAllocator_fnGetProperties(IMemAllocator
* iface
,ALLOCATOR_PROPERTIES
* pProp
)
99 CMemoryAllocator_THIS(iface
,memalloc
);
101 TRACE( "(%p)->(%p)\n", This
, pProp
);
106 EnterCriticalSection( &This
->csMem
);
108 memcpy( pProp
, &This
->prop
, sizeof(ALLOCATOR_PROPERTIES
) );
110 LeaveCriticalSection( &This
->csMem
);
115 static HRESULT WINAPI
116 IMemAllocator_fnCommit(IMemAllocator
* iface
)
118 CMemoryAllocator_THIS(iface
,memalloc
);
120 FIXME( "(%p)->() stub!\n", This
);
124 static HRESULT WINAPI
125 IMemAllocator_fnDecommit(IMemAllocator
* iface
)
127 CMemoryAllocator_THIS(iface
,memalloc
);
129 FIXME( "(%p)->() stub!\n", This
);
133 static HRESULT WINAPI
134 IMemAllocator_fnGetBuffer(IMemAllocator
* iface
,IMediaSample
** ppSample
,REFERENCE_TIME
* prtStart
,REFERENCE_TIME
* prtEnd
,DWORD dwFlags
)
136 CMemoryAllocator_THIS(iface
,memalloc
);
138 FIXME( "(%p)->() stub!\n", This
);
142 static HRESULT WINAPI
143 IMemAllocator_fnReleaseBuffer(IMemAllocator
* iface
,IMediaSample
* pSample
)
145 CMemoryAllocator_THIS(iface
,memalloc
);
147 FIXME( "(%p)->() stub!\n", This
);
153 static ICOM_VTABLE(IMemAllocator
) imemalloc
=
155 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
156 /* IUnknown fields */
157 IMemAllocator_fnQueryInterface
,
158 IMemAllocator_fnAddRef
,
159 IMemAllocator_fnRelease
,
160 /* IMemAllocator fields */
161 IMemAllocator_fnSetProperties
,
162 IMemAllocator_fnGetProperties
,
163 IMemAllocator_fnCommit
,
164 IMemAllocator_fnDecommit
,
165 IMemAllocator_fnGetBuffer
,
166 IMemAllocator_fnReleaseBuffer
,
170 HRESULT
CMemoryAllocator_InitIMemAllocator( CMemoryAllocator
* pma
)
174 ICOM_VTBL(&pma
->memalloc
) = &imemalloc
;
176 ZeroMemory( &pma
->prop
, sizeof(pma
->prop
) );
178 InitializeCriticalSection( &pma
->csMem
);
183 void CMemoryAllocator_UninitIMemAllocator( CMemoryAllocator
* pma
)
187 IMemAllocator_Decommit( (IMemAllocator
*)(&pma
->memalloc
) );
189 DeleteCriticalSection( &pma
->csMem
);