1 | /*
|
---|
2 | * Implementation of CLSID_MemoryAllocator.
|
---|
3 | *
|
---|
4 | * FIXME - stub.
|
---|
5 | *
|
---|
6 | * hidenori@a2.ctktv.ne.jp
|
---|
7 | */
|
---|
8 |
|
---|
9 | #include "config.h"
|
---|
10 |
|
---|
11 | #include "windef.h"
|
---|
12 | #include "winbase.h"
|
---|
13 | #include "wingdi.h"
|
---|
14 | #include "winerror.h"
|
---|
15 | #include "wine/obj_base.h"
|
---|
16 | #include "strmif.h"
|
---|
17 | #include "uuids.h"
|
---|
18 |
|
---|
19 | #include "debugtools.h"
|
---|
20 | DEFAULT_DEBUG_CHANNEL(quartz);
|
---|
21 |
|
---|
22 | #include "quartz_private.h"
|
---|
23 | #include "memalloc.h"
|
---|
24 |
|
---|
25 |
|
---|
26 | static HRESULT WINAPI
|
---|
27 | IMemAllocator_fnQueryInterface(IMemAllocator* iface,REFIID riid,void** ppobj)
|
---|
28 | {
|
---|
29 | CMemoryAllocator_THIS(iface,memalloc);
|
---|
30 |
|
---|
31 | TRACE("(%p)->()\n",This);
|
---|
32 |
|
---|
33 | return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
|
---|
34 | }
|
---|
35 |
|
---|
36 | static ULONG WINAPI
|
---|
37 | IMemAllocator_fnAddRef(IMemAllocator* iface)
|
---|
38 | {
|
---|
39 | CMemoryAllocator_THIS(iface,memalloc);
|
---|
40 |
|
---|
41 | TRACE("(%p)->()\n",This);
|
---|
42 |
|
---|
43 | return IUnknown_AddRef(This->unk.punkControl);
|
---|
44 | }
|
---|
45 |
|
---|
46 | static ULONG WINAPI
|
---|
47 | IMemAllocator_fnRelease(IMemAllocator* iface)
|
---|
48 | {
|
---|
49 | CMemoryAllocator_THIS(iface,memalloc);
|
---|
50 |
|
---|
51 | TRACE("(%p)->()\n",This);
|
---|
52 |
|
---|
53 | return IUnknown_Release(This->unk.punkControl);
|
---|
54 | }
|
---|
55 |
|
---|
56 | static HRESULT WINAPI
|
---|
57 | IMemAllocator_fnSetProperties(IMemAllocator* iface,ALLOCATOR_PROPERTIES* pPropReq,ALLOCATOR_PROPERTIES* pPropActual)
|
---|
58 | {
|
---|
59 | CMemoryAllocator_THIS(iface,memalloc);
|
---|
60 | long padding;
|
---|
61 |
|
---|
62 | TRACE( "(%p)->(%p,%p)\n", This, pPropReq, pPropActual );
|
---|
63 |
|
---|
64 | if ( pPropReq == NULL || pPropActual == NULL )
|
---|
65 | return E_POINTER;
|
---|
66 | if ( pPropReq->cBuffers < 0 ||
|
---|
67 | pPropReq->cbBuffer < 0 ||
|
---|
68 | pPropReq->cbAlign < 0 ||
|
---|
69 | pPropReq->cbPrefix < 0 )
|
---|
70 | return E_INVALIDARG;
|
---|
71 |
|
---|
72 | if ( ( pPropReq->cbAlign & (pPropReq->cbAlign-1) ) != 0 )
|
---|
73 | return E_INVALIDARG;
|
---|
74 |
|
---|
75 | EnterCriticalSection( &This->csMem );
|
---|
76 |
|
---|
77 | This->prop.cBuffers = pPropReq->cBuffers;
|
---|
78 | This->prop.cbBuffer = pPropReq->cbBuffer;
|
---|
79 | This->prop.cbAlign = pPropReq->cbAlign;
|
---|
80 | This->prop.cbPrefix = pPropReq->cbPrefix;
|
---|
81 |
|
---|
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 );
|
---|
86 |
|
---|
87 | This->prop.cbBuffer += padding;
|
---|
88 |
|
---|
89 | memcpy( pPropActual, &This->prop, sizeof(ALLOCATOR_PROPERTIES) );
|
---|
90 |
|
---|
91 | LeaveCriticalSection( &This->csMem );
|
---|
92 |
|
---|
93 | return NOERROR;
|
---|
94 | }
|
---|
95 |
|
---|
96 | static HRESULT WINAPI
|
---|
97 | IMemAllocator_fnGetProperties(IMemAllocator* iface,ALLOCATOR_PROPERTIES* pProp)
|
---|
98 | {
|
---|
99 | CMemoryAllocator_THIS(iface,memalloc);
|
---|
100 |
|
---|
101 | TRACE( "(%p)->(%p)\n", This, pProp );
|
---|
102 |
|
---|
103 | if ( pProp == NULL )
|
---|
104 | return E_POINTER;
|
---|
105 |
|
---|
106 | EnterCriticalSection( &This->csMem );
|
---|
107 |
|
---|
108 | memcpy( pProp, &This->prop, sizeof(ALLOCATOR_PROPERTIES) );
|
---|
109 |
|
---|
110 | LeaveCriticalSection( &This->csMem );
|
---|
111 |
|
---|
112 | return NOERROR;
|
---|
113 | }
|
---|
114 |
|
---|
115 | static HRESULT WINAPI
|
---|
116 | IMemAllocator_fnCommit(IMemAllocator* iface)
|
---|
117 | {
|
---|
118 | CMemoryAllocator_THIS(iface,memalloc);
|
---|
119 |
|
---|
120 | FIXME( "(%p)->() stub!\n", This );
|
---|
121 | return E_NOTIMPL;
|
---|
122 | }
|
---|
123 |
|
---|
124 | static HRESULT WINAPI
|
---|
125 | IMemAllocator_fnDecommit(IMemAllocator* iface)
|
---|
126 | {
|
---|
127 | CMemoryAllocator_THIS(iface,memalloc);
|
---|
128 |
|
---|
129 | FIXME( "(%p)->() stub!\n", This );
|
---|
130 | return E_NOTIMPL;
|
---|
131 | }
|
---|
132 |
|
---|
133 | static HRESULT WINAPI
|
---|
134 | IMemAllocator_fnGetBuffer(IMemAllocator* iface,IMediaSample** ppSample,REFERENCE_TIME* prtStart,REFERENCE_TIME* prtEnd,DWORD dwFlags)
|
---|
135 | {
|
---|
136 | CMemoryAllocator_THIS(iface,memalloc);
|
---|
137 |
|
---|
138 | FIXME( "(%p)->() stub!\n", This );
|
---|
139 | return E_NOTIMPL;
|
---|
140 | }
|
---|
141 |
|
---|
142 | static HRESULT WINAPI
|
---|
143 | IMemAllocator_fnReleaseBuffer(IMemAllocator* iface,IMediaSample* pSample)
|
---|
144 | {
|
---|
145 | CMemoryAllocator_THIS(iface,memalloc);
|
---|
146 |
|
---|
147 | FIXME( "(%p)->() stub!\n", This );
|
---|
148 | return E_NOTIMPL;
|
---|
149 | }
|
---|
150 |
|
---|
151 |
|
---|
152 |
|
---|
153 | static ICOM_VTABLE(IMemAllocator) imemalloc =
|
---|
154 | {
|
---|
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,
|
---|
167 | };
|
---|
168 |
|
---|
169 |
|
---|
170 | HRESULT CMemoryAllocator_InitIMemAllocator( CMemoryAllocator* pma )
|
---|
171 | {
|
---|
172 | TRACE("(%p)\n",pma);
|
---|
173 |
|
---|
174 | ICOM_VTBL(&pma->memalloc) = &imemalloc;
|
---|
175 |
|
---|
176 | ZeroMemory( &pma->prop, sizeof(pma->prop) );
|
---|
177 |
|
---|
178 | InitializeCriticalSection( &pma->csMem );
|
---|
179 |
|
---|
180 | return NOERROR;
|
---|
181 | }
|
---|
182 |
|
---|
183 | void CMemoryAllocator_UninitIMemAllocator( CMemoryAllocator* pma )
|
---|
184 | {
|
---|
185 | TRACE("(%p)\n",pma);
|
---|
186 |
|
---|
187 | IMemAllocator_Decommit( (IMemAllocator*)(&pma->memalloc) );
|
---|
188 |
|
---|
189 | DeleteCriticalSection( &pma->csMem );
|
---|
190 | }
|
---|