ReactOS  0.4.14-dev-317-g96040ec
memallocator.c File Reference
#include <assert.h>
#include <limits.h>
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "vfwmsgs.h"
#include "quartz_private.h"
#include "wine/debug.h"
Include dependency graph for memallocator.c:

Go to the source code of this file.

Classes

struct  StdMediaSample2
 
struct  BaseMemAllocator
 
struct  StdMemAllocator
 

Macros

#define AM_SAMPLE2_PROP_SIZE_WRITABLE   FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, pbBuffer)
 
#define INVALID_MEDIA_TIME   (((ULONGLONG)0x7fffffff << 32) | 0xffffffff)
 

Typedefs

typedef struct StdMediaSample2 StdMediaSample2
 
typedef struct BaseMemAllocator BaseMemAllocator
 
typedef struct StdMemAllocator StdMemAllocator
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (quartz)
 
static BaseMemAllocatorimpl_from_IMemAllocator (IMemAllocator *iface)
 
static StdMediaSample2unsafe_impl_from_IMediaSample (IMediaSample *iface)
 
static HRESULT BaseMemAllocator_Init (HRESULT(*fnAlloc)(IMemAllocator *), HRESULT(*fnFree)(IMemAllocator *), HRESULT(*fnVerify)(IMemAllocator *, ALLOCATOR_PROPERTIES *), HRESULT(*fnBufferPrepare)(IMemAllocator *, StdMediaSample2 *, DWORD), HRESULT(*fnBufferReleased)(IMemAllocator *, StdMediaSample2 *), void(*fnDestroyed)(IMemAllocator *), CRITICAL_SECTION *pCritSect, BaseMemAllocator *pMemAlloc)
 
static HRESULT WINAPI BaseMemAllocator_QueryInterface (IMemAllocator *iface, REFIID riid, LPVOID *ppv)
 
static ULONG WINAPI BaseMemAllocator_AddRef (IMemAllocator *iface)
 
static ULONG WINAPI BaseMemAllocator_Release (IMemAllocator *iface)
 
static HRESULT WINAPI BaseMemAllocator_SetProperties (IMemAllocator *iface, ALLOCATOR_PROPERTIES *pRequest, ALLOCATOR_PROPERTIES *pActual)
 
static HRESULT WINAPI BaseMemAllocator_GetProperties (IMemAllocator *iface, ALLOCATOR_PROPERTIES *pProps)
 
static HRESULT WINAPI BaseMemAllocator_Commit (IMemAllocator *iface)
 
static HRESULT WINAPI BaseMemAllocator_Decommit (IMemAllocator *iface)
 
static HRESULT WINAPI BaseMemAllocator_GetBuffer (IMemAllocator *iface, IMediaSample **pSample, REFERENCE_TIME *pStartTime, REFERENCE_TIME *pEndTime, DWORD dwFlags)
 
static HRESULT WINAPI BaseMemAllocator_ReleaseBuffer (IMemAllocator *iface, IMediaSample *pSample)
 
static HRESULT StdMediaSample2_Construct (BYTE *pbBuffer, LONG cbBuffer, IMemAllocator *pParent, StdMediaSample2 **ppSample)
 
static void StdMediaSample2_Delete (StdMediaSample2 *This)
 
static StdMediaSample2impl_from_IMediaSample2 (IMediaSample2 *iface)
 
static HRESULT WINAPI StdMediaSample2_QueryInterface (IMediaSample2 *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI StdMediaSample2_AddRef (IMediaSample2 *iface)
 
static ULONG WINAPI StdMediaSample2_Release (IMediaSample2 *iface)
 
static HRESULT WINAPI StdMediaSample2_GetPointer (IMediaSample2 *iface, BYTE **ppBuffer)
 
static LONG WINAPI StdMediaSample2_GetSize (IMediaSample2 *iface)
 
static HRESULT WINAPI StdMediaSample2_GetTime (IMediaSample2 *iface, REFERENCE_TIME *pStart, REFERENCE_TIME *pEnd)
 
static HRESULT WINAPI StdMediaSample2_SetTime (IMediaSample2 *iface, REFERENCE_TIME *pStart, REFERENCE_TIME *pEnd)
 
static HRESULT WINAPI StdMediaSample2_IsSyncPoint (IMediaSample2 *iface)
 
static HRESULT WINAPI StdMediaSample2_SetSyncPoint (IMediaSample2 *iface, BOOL bIsSyncPoint)
 
static HRESULT WINAPI StdMediaSample2_IsPreroll (IMediaSample2 *iface)
 
static HRESULT WINAPI StdMediaSample2_SetPreroll (IMediaSample2 *iface, BOOL bIsPreroll)
 
static LONG WINAPI StdMediaSample2_GetActualDataLength (IMediaSample2 *iface)
 
static HRESULT WINAPI StdMediaSample2_SetActualDataLength (IMediaSample2 *iface, LONG len)
 
static HRESULT WINAPI StdMediaSample2_GetMediaType (IMediaSample2 *iface, AM_MEDIA_TYPE **ppMediaType)
 
static HRESULT WINAPI StdMediaSample2_SetMediaType (IMediaSample2 *iface, AM_MEDIA_TYPE *pMediaType)
 
static HRESULT WINAPI StdMediaSample2_IsDiscontinuity (IMediaSample2 *iface)
 
static HRESULT WINAPI StdMediaSample2_SetDiscontinuity (IMediaSample2 *iface, BOOL bIsDiscontinuity)
 
static HRESULT WINAPI StdMediaSample2_GetMediaTime (IMediaSample2 *iface, LONGLONG *pStart, LONGLONG *pEnd)
 
static HRESULT WINAPI StdMediaSample2_SetMediaTime (IMediaSample2 *iface, LONGLONG *pStart, LONGLONG *pEnd)
 
static HRESULT WINAPI StdMediaSample2_GetProperties (IMediaSample2 *iface, DWORD cbProperties, BYTE *pbProperties)
 
static HRESULT WINAPI StdMediaSample2_SetProperties (IMediaSample2 *iface, DWORD cbProperties, const BYTE *pbProperties)
 
static StdMemAllocatorStdMemAllocator_from_IMemAllocator (IMemAllocator *iface)
 
static HRESULT StdMemAllocator_Alloc (IMemAllocator *iface)
 
static HRESULT StdMemAllocator_Free (IMemAllocator *iface)
 
static void StdMemAllocator_Destroy (IMemAllocator *iface)
 
HRESULT StdMemAllocator_create (LPUNKNOWN lpUnkOuter, LPVOID *ppv)
 

Variables

static const IMemAllocatorVtbl BaseMemAllocator_VTable
 
static const IMediaSample2Vtbl StdMediaSample2_VTable
 

Macro Definition Documentation

◆ AM_SAMPLE2_PROP_SIZE_WRITABLE

#define AM_SAMPLE2_PROP_SIZE_WRITABLE   FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, pbBuffer)

Definition at line 75 of file memallocator.c.

◆ INVALID_MEDIA_TIME

#define INVALID_MEDIA_TIME   (((ULONGLONG)0x7fffffff << 32) | 0xffffffff)

Definition at line 77 of file memallocator.c.

Typedef Documentation

◆ BaseMemAllocator

◆ StdMediaSample2

◆ StdMemAllocator

Function Documentation

◆ BaseMemAllocator_AddRef()

static ULONG WINAPI BaseMemAllocator_AddRef ( IMemAllocator iface)
static

Definition at line 134 of file memallocator.c.

135 {
138 
139  TRACE("(%p)->() AddRef from %d\n", iface, ref - 1);
140 
141  return ref;
142 }
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
static BaseMemAllocator * impl_from_IMemAllocator(IMemAllocator *iface)
Definition: memallocator.c:66
unsigned int ULONG
Definition: retypes.h:1

◆ BaseMemAllocator_Commit()

static HRESULT WINAPI BaseMemAllocator_Commit ( IMemAllocator iface)
static

Definition at line 212 of file memallocator.c.

213 {
215  HRESULT hr;
216 
217  TRACE("(%p)->()\n", This);
218 
219  EnterCriticalSection(This->pCritSect);
220  {
221  if (!This->props.cbAlign)
222  hr = VFW_E_BADALIGN;
223  else if (!This->props.cbBuffer)
225  else if (!This->props.cBuffers)
227  else if (This->bDecommitQueued && This->bCommitted)
228  {
229  This->bDecommitQueued = FALSE;
230  hr = S_OK;
231  }
232  else if (This->bCommitted)
233  hr = S_OK;
234  else
235  {
236  if (!(This->hSemWaiting = CreateSemaphoreW(NULL, This->props.cBuffers, This->props.cBuffers, NULL)))
237  {
238  ERR("Couldn't create semaphore (error was %u)\n", GetLastError());
240  }
241  else
242  {
243  hr = This->fnAlloc(iface);
244  if (SUCCEEDED(hr))
245  This->bCommitted = TRUE;
246  else
247  ERR("fnAlloc failed with error 0x%x\n", hr);
248  }
249  }
250  }
251  LeaveCriticalSection(This->pCritSect);
252 
253  return hr;
254 }
#define VFW_E_BADALIGN
Definition: vfwmsgs.h:53
#define TRUE
Definition: types.h:120
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:444
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
#define VFW_E_SIZENOTSET
Definition: vfwmsgs.h:57
#define VFW_E_BUFFER_NOTSET
Definition: vfwmsgs.h:51
static BaseMemAllocator * impl_from_IMemAllocator(IMemAllocator *iface)
Definition: memallocator.c:66
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ BaseMemAllocator_Decommit()

static HRESULT WINAPI BaseMemAllocator_Decommit ( IMemAllocator iface)
static

Definition at line 256 of file memallocator.c.

257 {
259  HRESULT hr;
260 
261  TRACE("(%p)->()\n", This);
262 
263  EnterCriticalSection(This->pCritSect);
264  {
265  if (!This->bCommitted)
266  hr = S_OK;
267  else
268  {
269  if (!list_empty(&This->used_list))
270  {
271  This->bDecommitQueued = TRUE;
272  /* notify ALL waiting threads that they cannot be allocated a buffer any more */
273  ReleaseSemaphore(This->hSemWaiting, This->lWaiting, NULL);
274 
275  hr = S_OK;
276  }
277  else
278  {
279  if (This->lWaiting != 0)
280  ERR("Waiting: %d\n", This->lWaiting);
281 
282  This->bCommitted = FALSE;
283  CloseHandle(This->hSemWaiting);
284  This->hSemWaiting = NULL;
285 
286  hr = This->fnFree(iface);
287  if (FAILED(hr))
288  ERR("fnFree failed with error 0x%x\n", hr);
289  }
290  }
291  }
292  LeaveCriticalSection(This->pCritSect);
293 
294  return hr;
295 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
HRESULT hr
Definition: shlfolder.c:183
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define ERR(fmt,...)
Definition: debug.h:109
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
Definition: list.h:143
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542
static BaseMemAllocator * impl_from_IMemAllocator(IMemAllocator *iface)
Definition: memallocator.c:66
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ BaseMemAllocator_GetBuffer()

static HRESULT WINAPI BaseMemAllocator_GetBuffer ( IMemAllocator iface,
IMediaSample **  pSample,
REFERENCE_TIME pStartTime,
REFERENCE_TIME pEndTime,
DWORD  dwFlags 
)
static

Definition at line 297 of file memallocator.c.

298 {
300  HRESULT hr = S_OK;
301 
302  /* NOTE: The pStartTime and pEndTime parameters are not applied to the sample.
303  * The allocator might use these values to determine which buffer it retrieves */
304 
305  TRACE("(%p)->(%p, %p, %p, %x)\n", This, pSample, pStartTime, pEndTime, dwFlags);
306 
307  *pSample = NULL;
308 
309  EnterCriticalSection(This->pCritSect);
310  if (!This->bCommitted || This->bDecommitQueued)
311  {
312  WARN("Not committed\n");
314  }
315  else
316  ++This->lWaiting;
317  LeaveCriticalSection(This->pCritSect);
318  if (FAILED(hr))
319  return hr;
320 
321  if (WaitForSingleObject(This->hSemWaiting, (dwFlags & AM_GBF_NOWAIT) ? 0 : INFINITE) != WAIT_OBJECT_0)
322  {
323  EnterCriticalSection(This->pCritSect);
324  --This->lWaiting;
325  LeaveCriticalSection(This->pCritSect);
326  WARN("Timed out\n");
327  return VFW_E_TIMEOUT;
328  }
329 
330  EnterCriticalSection(This->pCritSect);
331  {
332  --This->lWaiting;
333  if (!This->bCommitted)
335  else if (This->bDecommitQueued)
336  hr = VFW_E_TIMEOUT;
337  else
338  {
339  StdMediaSample2 *ms;
340  struct list * free = list_head(&This->free_list);
341  list_remove(free);
342  list_add_head(&This->used_list, free);
343 
344  ms = LIST_ENTRY(free, StdMediaSample2, listentry);
345  assert(ms->ref == 0);
346  *pSample = (IMediaSample *)&ms->IMediaSample2_iface;
347  IMediaSample_AddRef(*pSample);
348  }
349  }
350  LeaveCriticalSection(This->pCritSect);
351 
352  if (hr != S_OK)
353  WARN("%08x\n", hr);
354  return hr;
355 }
HRESULT hr
Definition: shlfolder.c:183
#define free
Definition: debug_ros.c:5
#define WARN(fmt,...)
Definition: debug.h:111
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
#define assert(x)
Definition: debug.h:53
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
#define WAIT_OBJECT_0
Definition: winbase.h:387
#define VFW_E_TIMEOUT
Definition: vfwmsgs.h:85
LONG HRESULT
Definition: typedefs.h:77
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: _list.h:228
#define S_OK
Definition: intsafe.h:59
#define VFW_E_NOT_COMMITTED
Definition: vfwmsgs.h:56
static BaseMemAllocator * impl_from_IMemAllocator(IMemAllocator *iface)
Definition: memallocator.c:66
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define LIST_ENTRY(type)
Definition: queue.h:175
#define INFINITE
Definition: serial.h:102
IMediaSample2 IMediaSample2_iface
Definition: memallocator.c:36

◆ BaseMemAllocator_GetProperties()

static HRESULT WINAPI BaseMemAllocator_GetProperties ( IMemAllocator iface,
ALLOCATOR_PROPERTIES pProps 
)
static

Definition at line 196 of file memallocator.c.

197 {
199  HRESULT hr = S_OK;
200 
201  TRACE("(%p)->(%p)\n", This, pProps);
202 
203  EnterCriticalSection(This->pCritSect);
204  {
205  memcpy(pProps, &This->props, sizeof(*pProps));
206  }
207  LeaveCriticalSection(This->pCritSect);
208 
209  return hr;
210 }
HRESULT hr
Definition: shlfolder.c:183
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59
static BaseMemAllocator * impl_from_IMemAllocator(IMemAllocator *iface)
Definition: memallocator.c:66
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ BaseMemAllocator_Init()

static HRESULT BaseMemAllocator_Init ( HRESULT(*)(IMemAllocator *)  fnAlloc,
HRESULT(*)(IMemAllocator *)  fnFree,
HRESULT(*)(IMemAllocator *, ALLOCATOR_PROPERTIES *)  fnVerify,
HRESULT(*)(IMemAllocator *, StdMediaSample2 *, DWORD fnBufferPrepare,
HRESULT(*)(IMemAllocator *, StdMediaSample2 *)  fnBufferReleased,
void(*)(IMemAllocator *)  fnDestroyed,
CRITICAL_SECTION pCritSect,
BaseMemAllocator pMemAlloc 
)
static

Definition at line 79 of file memallocator.c.

87 {
88  assert(fnAlloc && fnFree && fnDestroyed);
89 
90  pMemAlloc->IMemAllocator_iface.lpVtbl = &BaseMemAllocator_VTable;
91 
92  pMemAlloc->ref = 1;
93  ZeroMemory(&pMemAlloc->props, sizeof(pMemAlloc->props));
94  list_init(&pMemAlloc->free_list);
95  list_init(&pMemAlloc->used_list);
96  pMemAlloc->fnAlloc = fnAlloc;
97  pMemAlloc->fnFree = fnFree;
98  pMemAlloc->fnVerify = fnVerify;
99  pMemAlloc->fnBufferPrepare = fnBufferPrepare;
100  pMemAlloc->fnBufferReleased = fnBufferReleased;
101  pMemAlloc->fnDestroyed = fnDestroyed;
102  pMemAlloc->bDecommitQueued = FALSE;
103  pMemAlloc->bCommitted = FALSE;
104  pMemAlloc->hSemWaiting = NULL;
105  pMemAlloc->lWaiting = 0;
106  pMemAlloc->pCritSect = pCritSect;
107 
108  return S_OK;
109 }
HRESULT(* fnBufferPrepare)(IMemAllocator *, StdMediaSample2 *, DWORD flags)
Definition: memallocator.c:54
HRESULT(* fnBufferReleased)(IMemAllocator *, StdMediaSample2 *)
Definition: memallocator.c:55
#define assert(x)
Definition: debug.h:53
#define ZeroMemory
Definition: winbase.h:1642
HRESULT(* fnVerify)(IMemAllocator *, ALLOCATOR_PROPERTIES *)
Definition: memallocator.c:53
IMemAllocator IMemAllocator_iface
Definition: memallocator.c:47
struct list free_list
Definition: memallocator.c:61
smooth NULL
Definition: ftsmooth.c:416
static const IMemAllocatorVtbl BaseMemAllocator_VTable
Definition: memallocator.c:71
HRESULT(* fnFree)(IMemAllocator *)
Definition: memallocator.c:52
ALLOCATOR_PROPERTIES props
Definition: memallocator.c:50
CRITICAL_SECTION * pCritSect
Definition: memallocator.c:63
#define S_OK
Definition: intsafe.h:59
void(* fnDestroyed)(IMemAllocator *)
Definition: memallocator.c:56
struct list used_list
Definition: memallocator.c:62
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
HRESULT(* fnAlloc)(IMemAllocator *)
Definition: memallocator.c:51

Referenced by StdMemAllocator_create().

◆ BaseMemAllocator_QueryInterface()

static HRESULT WINAPI BaseMemAllocator_QueryInterface ( IMemAllocator iface,
REFIID  riid,
LPVOID ppv 
)
static

Definition at line 111 of file memallocator.c.

112 {
114  TRACE("(%p)->(%s, %p)\n", This, qzdebugstr_guid(riid), ppv);
115 
116  *ppv = NULL;
117 
119  *ppv = &This->IMemAllocator_iface;
120  else if (IsEqualIID(riid, &IID_IMemAllocator))
121  *ppv = &This->IMemAllocator_iface;
122 
123  if (*ppv)
124  {
125  IUnknown_AddRef((IUnknown *)(*ppv));
126  return S_OK;
127  }
128 
129  FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
130 
131  return E_NOINTERFACE;
132 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
const char * qzdebugstr_guid(const GUID *id)
Definition: main.c:279
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
static BaseMemAllocator * impl_from_IMemAllocator(IMemAllocator *iface)
Definition: memallocator.c:66
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ BaseMemAllocator_Release()

static ULONG WINAPI BaseMemAllocator_Release ( IMemAllocator iface)
static

Definition at line 144 of file memallocator.c.

145 {
148 
149  TRACE("(%p)->() Release from %d\n", iface, ref + 1);
150 
151  if (!ref)
152  {
153  CloseHandle(This->hSemWaiting);
154  if (This->bCommitted)
155  This->fnFree(iface);
156 
157  This->fnDestroyed(iface);
158  return 0;
159  }
160  return ref;
161 }
#define CloseHandle
Definition: compat.h:398
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedDecrement
Definition: armddk.h:52
static BaseMemAllocator * impl_from_IMemAllocator(IMemAllocator *iface)
Definition: memallocator.c:66
unsigned int ULONG
Definition: retypes.h:1

◆ BaseMemAllocator_ReleaseBuffer()

static HRESULT WINAPI BaseMemAllocator_ReleaseBuffer ( IMemAllocator iface,
IMediaSample pSample 
)
static

Definition at line 357 of file memallocator.c.

358 {
360  StdMediaSample2 * pStdSample = unsafe_impl_from_IMediaSample(pSample);
361  HRESULT hr = S_OK;
362 
363  TRACE("(%p)->(%p)\n", This, pSample);
364 
365  /* FIXME: make sure that sample is currently on the used list */
366 
367  /* FIXME: we should probably check the ref count on the sample before freeing
368  * it to make sure that it is not still in use */
369  EnterCriticalSection(This->pCritSect);
370  {
371  if (!This->bCommitted)
372  ERR("Releasing a buffer when the allocator is not committed?!?\n");
373 
374  /* remove from used_list */
375  list_remove(&pStdSample->listentry);
376 
377  list_add_head(&This->free_list, &pStdSample->listentry);
378 
379  if (list_empty(&This->used_list) && This->bDecommitQueued && This->bCommitted)
380  {
381  HRESULT hrfree;
382 
383  if (This->lWaiting != 0)
384  ERR("Waiting: %d\n", This->lWaiting);
385 
386  This->bCommitted = FALSE;
387  This->bDecommitQueued = FALSE;
388 
389  CloseHandle(This->hSemWaiting);
390  This->hSemWaiting = NULL;
391 
392  if (FAILED(hrfree = This->fnFree(iface)))
393  ERR("fnFree failed with error 0x%x\n", hrfree);
394  }
395  }
396  LeaveCriticalSection(This->pCritSect);
397 
398  /* notify a waiting thread that there is now a free buffer */
399  if (This->hSemWaiting && !ReleaseSemaphore(This->hSemWaiting, 1, NULL))
400  {
401  ERR("ReleaseSemaphore failed with error %u\n", GetLastError());
403  }
404 
405  return hr;
406 }
#define CloseHandle
Definition: compat.h:398
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static StdMediaSample2 * unsafe_impl_from_IMediaSample(IMediaSample *iface)
Definition: memallocator.c:795
smooth NULL
Definition: ftsmooth.c:416
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
struct list listentry
Definition: memallocator.c:40
#define ERR(fmt,...)
Definition: debug.h:109
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
Definition: list.h:143
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542
static BaseMemAllocator * impl_from_IMemAllocator(IMemAllocator *iface)
Definition: memallocator.c:66
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ BaseMemAllocator_SetProperties()

static HRESULT WINAPI BaseMemAllocator_SetProperties ( IMemAllocator iface,
ALLOCATOR_PROPERTIES pRequest,
ALLOCATOR_PROPERTIES pActual 
)
static

Definition at line 163 of file memallocator.c.

164 {
166  HRESULT hr;
167 
168  TRACE("(%p)->(%p, %p)\n", This, pRequest, pActual);
169 
170  EnterCriticalSection(This->pCritSect);
171  {
172  if (!list_empty(&This->used_list))
174  else if (This->bCommitted)
176  else if (pRequest->cbAlign == 0)
177  hr = VFW_E_BADALIGN;
178  else
179  {
180  if (This->fnVerify)
181  hr = This->fnVerify(iface, pRequest);
182  else
183  hr = S_OK;
184 
185  if (SUCCEEDED(hr))
186  This->props = *pRequest;
187 
188  *pActual = This->props;
189  }
190  }
191  LeaveCriticalSection(This->pCritSect);
192 
193  return hr;
194 }
#define VFW_E_BADALIGN
Definition: vfwmsgs.h:53
HRESULT hr
Definition: shlfolder.c:183
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define VFW_E_ALREADY_COMMITTED
Definition: vfwmsgs.h:54
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
Definition: list.h:143
#define S_OK
Definition: intsafe.h:59
#define VFW_E_BUFFERS_OUTSTANDING
Definition: vfwmsgs.h:55
static BaseMemAllocator * impl_from_IMemAllocator(IMemAllocator *iface)
Definition: memallocator.c:66
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ impl_from_IMediaSample2()

◆ impl_from_IMemAllocator()

static BaseMemAllocator* impl_from_IMemAllocator ( IMemAllocator iface)
inlinestatic

Definition at line 66 of file memallocator.c.

67 {
68  return CONTAINING_RECORD(iface, BaseMemAllocator, IMemAllocator_iface);
69 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by BaseMemAllocator_AddRef(), BaseMemAllocator_Commit(), BaseMemAllocator_Decommit(), BaseMemAllocator_GetBuffer(), BaseMemAllocator_GetProperties(), BaseMemAllocator_QueryInterface(), BaseMemAllocator_Release(), BaseMemAllocator_ReleaseBuffer(), and BaseMemAllocator_SetProperties().

◆ StdMediaSample2_AddRef()

static ULONG WINAPI StdMediaSample2_AddRef ( IMediaSample2 iface)
static

Definition at line 474 of file memallocator.c.

475 {
478 
479  TRACE("(%p)->(): new ref = %d\n", This, ref);
480 
481  return ref;
482 }
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ StdMediaSample2_Construct()

static HRESULT StdMediaSample2_Construct ( BYTE pbBuffer,
LONG  cbBuffer,
IMemAllocator pParent,
StdMediaSample2 **  ppSample 
)
static

Definition at line 421 of file memallocator.c.

422 {
423  assert(pbBuffer && pParent && (cbBuffer > 0));
424 
425  if (!(*ppSample = CoTaskMemAlloc(sizeof(StdMediaSample2))))
426  return E_OUTOFMEMORY;
427 
428  (*ppSample)->IMediaSample2_iface.lpVtbl = &StdMediaSample2_VTable;
429  (*ppSample)->ref = 0;
430  ZeroMemory(&(*ppSample)->props, sizeof((*ppSample)->props));
431 
432  /* NOTE: no need to AddRef as the parent is guaranteed to be around
433  * at least as long as us and we don't want to create circular
434  * dependencies on the ref count */
435  (*ppSample)->pParent = pParent;
436  (*ppSample)->props.cbData = sizeof(AM_SAMPLE2_PROPERTIES);
437  (*ppSample)->props.cbBuffer = (*ppSample)->props.lActual = cbBuffer;
438  (*ppSample)->props.pbBuffer = pbBuffer;
439  (*ppSample)->tMediaStart = INVALID_MEDIA_TIME;
440  (*ppSample)->tMediaEnd = 0;
441 
442  return S_OK;
443 }
#define INVALID_MEDIA_TIME
Definition: memallocator.c:77
#define assert(x)
Definition: debug.h:53
#define ZeroMemory
Definition: winbase.h:1642
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define S_OK
Definition: intsafe.h:59
static const IMediaSample2Vtbl StdMediaSample2_VTable
Definition: memallocator.c:72
struct tagAM_SAMPLE2_PROPERTIES AM_SAMPLE2_PROPERTIES
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404

Referenced by StdMemAllocator_Alloc().

◆ StdMediaSample2_Delete()

static void StdMediaSample2_Delete ( StdMediaSample2 This)
static

Definition at line 445 of file memallocator.c.

446 {
447  /* NOTE: does not remove itself from the list it belongs to */
449 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420

Referenced by StdMediaSample2_Release(), and StdMemAllocator_Free().

◆ StdMediaSample2_GetActualDataLength()

static LONG WINAPI StdMediaSample2_GetActualDataLength ( IMediaSample2 iface)
static

Definition at line 625 of file memallocator.c.

626 {
628 
629  TRACE("(%p)->()\n", iface);
630 
631  return This->props.lActual;
632 }
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4

◆ StdMediaSample2_GetMediaTime()

static HRESULT WINAPI StdMediaSample2_GetMediaTime ( IMediaSample2 iface,
LONGLONG pStart,
LONGLONG pEnd 
)
static

Definition at line 713 of file memallocator.c.

714 {
716 
717  TRACE("(%p)->(%p, %p)\n", iface, pStart, pEnd);
718 
719  if (This->tMediaStart == INVALID_MEDIA_TIME)
721 
722  *pStart = This->tMediaStart;
723  *pEnd = This->tMediaEnd;
724 
725  return S_OK;
726 }
#define INVALID_MEDIA_TIME
Definition: memallocator.c:77
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
#define VFW_E_MEDIA_TIME_NOT_SET
Definition: vfwmsgs.h:105
#define S_OK
Definition: intsafe.h:59

◆ StdMediaSample2_GetMediaType()

static HRESULT WINAPI StdMediaSample2_GetMediaType ( IMediaSample2 iface,
AM_MEDIA_TYPE **  ppMediaType 
)
static

Definition at line 652 of file memallocator.c.

653 {
655 
656  TRACE("(%p)->(%p)\n", iface, ppMediaType);
657 
658  if (!This->props.pMediaType) {
659  /* Make sure we return a NULL pointer (required by native Quartz dll) */
660  if (ppMediaType)
661  *ppMediaType = NULL;
662  return S_FALSE;
663  }
664 
665  if (!(*ppMediaType = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))))
666  return E_OUTOFMEMORY;
667 
668  return CopyMediaType(*ppMediaType, This->props.pMediaType);
669 }
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define S_FALSE
Definition: winerror.h:2357
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT CopyMediaType(AM_MEDIA_TYPE *pDest, const AM_MEDIA_TYPE *pSrc)
Definition: filtergraph.c:706
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404

◆ StdMediaSample2_GetPointer()

static HRESULT WINAPI StdMediaSample2_GetPointer ( IMediaSample2 iface,
BYTE **  ppBuffer 
)
static

Definition at line 501 of file memallocator.c.

502 {
504 
505  TRACE("(%p)->(%p)\n", iface, ppBuffer);
506 
507  *ppBuffer = This->props.pbBuffer;
508 
509  if (!*ppBuffer)
510  {
511  ERR("Requested an unlocked surface and trying to lock regardless\n");
512  return E_FAIL;
513  }
514 
515  return S_OK;
516 }
#define E_FAIL
Definition: ddrawi.h:102
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59

◆ StdMediaSample2_GetProperties()

static HRESULT WINAPI StdMediaSample2_GetProperties ( IMediaSample2 iface,
DWORD  cbProperties,
BYTE pbProperties 
)
static

Definition at line 747 of file memallocator.c.

748 {
750 
751  TRACE("(%p)->(%d, %p)\n", iface, cbProperties, pbProperties);
752 
753  memcpy(pbProperties, &This->props, min(cbProperties, sizeof(This->props)));
754 
755  return S_OK;
756 }
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59
#define min(a, b)
Definition: monoChain.cc:55

◆ StdMediaSample2_GetSize()

static LONG WINAPI StdMediaSample2_GetSize ( IMediaSample2 iface)
static

Definition at line 518 of file memallocator.c.

519 {
521 
522  TRACE("StdMediaSample2_GetSize()\n");
523 
524  return This->props.cbBuffer;
525 }
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4

◆ StdMediaSample2_GetTime()

static HRESULT WINAPI StdMediaSample2_GetTime ( IMediaSample2 iface,
REFERENCE_TIME pStart,
REFERENCE_TIME pEnd 
)
static

Definition at line 527 of file memallocator.c.

528 {
530  HRESULT hr;
531 
532  TRACE("(%p)->(%p, %p)\n", iface, pStart, pEnd);
533 
534  if (!(This->props.dwSampleFlags & AM_SAMPLE_TIMEVALID))
536  else if (!(This->props.dwSampleFlags & AM_SAMPLE_STOPVALID))
537  {
538  *pStart = This->props.tStart;
539  *pEnd = This->props.tStart + 1;
540 
542  }
543  else
544  {
545  *pStart = This->props.tStart;
546  *pEnd = This->props.tStop;
547 
548  hr = S_OK;
549  }
550 
551  return hr;
552 }
HRESULT hr
Definition: shlfolder.c:183
#define VFW_E_SAMPLE_TIME_NOT_SET
Definition: vfwmsgs.h:104
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
#define VFW_S_NO_STOP_TIME
Definition: vfwmsgs.h:34

◆ StdMediaSample2_IsDiscontinuity()

static HRESULT WINAPI StdMediaSample2_IsDiscontinuity ( IMediaSample2 iface)
static

Definition at line 690 of file memallocator.c.

691 {
693 
694  TRACE("(%p)->()\n", iface);
695 
696  return (This->props.dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY) ? S_OK : S_FALSE;
697 }
#define S_FALSE
Definition: winerror.h:2357
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ StdMediaSample2_IsPreroll()

static HRESULT WINAPI StdMediaSample2_IsPreroll ( IMediaSample2 iface)
static

Definition at line 602 of file memallocator.c.

603 {
605 
606  TRACE("(%p)->()\n", iface);
607 
608  return (This->props.dwSampleFlags & AM_SAMPLE_PREROLL) ? S_OK : S_FALSE;
609 }
#define S_FALSE
Definition: winerror.h:2357
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ StdMediaSample2_IsSyncPoint()

static HRESULT WINAPI StdMediaSample2_IsSyncPoint ( IMediaSample2 iface)
static

Definition at line 579 of file memallocator.c.

580 {
582 
583  TRACE("(%p)->()\n", iface);
584 
585  return (This->props.dwSampleFlags & AM_SAMPLE_SPLICEPOINT) ? S_OK : S_FALSE;
586 }
#define S_FALSE
Definition: winerror.h:2357
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ StdMediaSample2_QueryInterface()

static HRESULT WINAPI StdMediaSample2_QueryInterface ( IMediaSample2 iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 456 of file memallocator.c.

457 {
458  TRACE("(%s, %p)\n", qzdebugstr_guid(riid), ppv);
459 
460  *ppv = NULL;
461 
462  if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IMediaSample) ||
463  IsEqualIID(riid, &IID_IMediaSample2))
464  {
465  *ppv = iface;
466  IMediaSample2_AddRef(iface);
467  return S_OK;
468  }
469 
470  FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
471  return E_NOINTERFACE;
472 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
const char * qzdebugstr_guid(const GUID *id)
Definition: main.c:279
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ StdMediaSample2_Release()

static ULONG WINAPI StdMediaSample2_Release ( IMediaSample2 iface)
static

Definition at line 484 of file memallocator.c.

485 {
488 
489  TRACE("(%p)->(): new ref = %d\n", This, ref);
490 
491  if (!ref)
492  {
493  if (This->pParent)
494  IMemAllocator_ReleaseBuffer(This->pParent, (IMediaSample *)iface);
495  else
497  }
498  return ref;
499 }
Definition: send.c:47
GLenum GLint ref
Definition: glext.h:6028
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
static void StdMediaSample2_Delete(StdMediaSample2 *This)
Definition: memallocator.c:445
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1

◆ StdMediaSample2_SetActualDataLength()

static HRESULT WINAPI StdMediaSample2_SetActualDataLength ( IMediaSample2 iface,
LONG  len 
)
static

Definition at line 634 of file memallocator.c.

635 {
637 
638  TRACE("(%p)->(%d)\n", iface, len);
639 
640  if ((len > This->props.cbBuffer) || (len < 0))
641  {
642  WARN("Tried to set length to %d, while max is %d\n", len, This->props.cbBuffer);
643  return VFW_E_BUFFER_OVERFLOW;
644  }
645  else
646  {
647  This->props.lActual = len;
648  return S_OK;
649  }
650 }
#define WARN(fmt,...)
Definition: debug.h:111
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
#define VFW_E_BUFFER_OVERFLOW
Definition: vfwmsgs.h:52
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:59

◆ StdMediaSample2_SetDiscontinuity()

static HRESULT WINAPI StdMediaSample2_SetDiscontinuity ( IMediaSample2 iface,
BOOL  bIsDiscontinuity 
)
static

Definition at line 699 of file memallocator.c.

700 {
702 
703  TRACE("(%p)->(%s)\n", iface, bIsDiscontinuity ? "TRUE" : "FALSE");
704 
705  if (bIsDiscontinuity)
706  This->props.dwSampleFlags |= AM_SAMPLE_DATADISCONTINUITY;
707  else
708  This->props.dwSampleFlags &= ~AM_SAMPLE_DATADISCONTINUITY;
709 
710  return S_OK;
711 }
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ StdMediaSample2_SetMediaTime()

static HRESULT WINAPI StdMediaSample2_SetMediaTime ( IMediaSample2 iface,
LONGLONG pStart,
LONGLONG pEnd 
)
static

Definition at line 728 of file memallocator.c.

729 {
731 
732  TRACE("(%p)->(%p, %p)\n", iface, pStart, pEnd);
733 
734  if (pStart)
735  This->tMediaStart = *pStart;
736  else
737  This->tMediaStart = INVALID_MEDIA_TIME;
738 
739  if (pEnd)
740  This->tMediaEnd = *pEnd;
741  else
742  This->tMediaEnd = 0;
743 
744  return S_OK;
745 }
#define INVALID_MEDIA_TIME
Definition: memallocator.c:77
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ StdMediaSample2_SetMediaType()

static HRESULT WINAPI StdMediaSample2_SetMediaType ( IMediaSample2 iface,
AM_MEDIA_TYPE pMediaType 
)
static

Definition at line 671 of file memallocator.c.

672 {
674 
675  TRACE("(%p)->(%p)\n", iface, pMediaType);
676 
677  if (This->props.pMediaType)
678  {
679  FreeMediaType(This->props.pMediaType);
680  This->props.pMediaType = NULL;
681  }
682  if (!pMediaType)
683  return S_FALSE;
684  if (!(This->props.pMediaType = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))))
685  return E_OUTOFMEMORY;
686 
687  return CopyMediaType(This->props.pMediaType, pMediaType);
688 }
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static void FreeMediaType(AM_MEDIA_TYPE *pMediaType)
Definition: filtergraph.c:692
#define S_FALSE
Definition: winerror.h:2357
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT CopyMediaType(AM_MEDIA_TYPE *pDest, const AM_MEDIA_TYPE *pSrc)
Definition: filtergraph.c:706
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404

◆ StdMediaSample2_SetPreroll()

static HRESULT WINAPI StdMediaSample2_SetPreroll ( IMediaSample2 iface,
BOOL  bIsPreroll 
)
static

Definition at line 611 of file memallocator.c.

612 {
614 
615  TRACE("(%p)->(%s)\n", iface, bIsPreroll ? "TRUE" : "FALSE");
616 
617  if (bIsPreroll)
618  This->props.dwSampleFlags |= AM_SAMPLE_PREROLL;
619  else
620  This->props.dwSampleFlags &= ~AM_SAMPLE_PREROLL;
621 
622  return S_OK;
623 }
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ StdMediaSample2_SetProperties()

static HRESULT WINAPI StdMediaSample2_SetProperties ( IMediaSample2 iface,
DWORD  cbProperties,
const BYTE pbProperties 
)
static

Definition at line 758 of file memallocator.c.

759 {
761 
762  TRACE("(%p)->(%d, %p)\n", iface, cbProperties, pbProperties);
763 
764  /* NOTE: pbBuffer and cbBuffer are read-only */
765  memcpy(&This->props, pbProperties, min(cbProperties, AM_SAMPLE2_PROP_SIZE_WRITABLE));
766 
767  return S_OK;
768 }
#define AM_SAMPLE2_PROP_SIZE_WRITABLE
Definition: memallocator.c:75
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59
#define min(a, b)
Definition: monoChain.cc:55

◆ StdMediaSample2_SetSyncPoint()

static HRESULT WINAPI StdMediaSample2_SetSyncPoint ( IMediaSample2 iface,
BOOL  bIsSyncPoint 
)
static

Definition at line 588 of file memallocator.c.

589 {
591 
592  TRACE("(%p)->(%s)\n", iface, bIsSyncPoint ? "TRUE" : "FALSE");
593 
594  if (bIsSyncPoint)
595  This->props.dwSampleFlags |= AM_SAMPLE_SPLICEPOINT;
596  else
597  This->props.dwSampleFlags &= ~AM_SAMPLE_SPLICEPOINT;
598 
599  return S_OK;
600 }
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ StdMediaSample2_SetTime()

static HRESULT WINAPI StdMediaSample2_SetTime ( IMediaSample2 iface,
REFERENCE_TIME pStart,
REFERENCE_TIME pEnd 
)
static

Definition at line 554 of file memallocator.c.

555 {
557 
558  TRACE("(%p)->(%p, %p)\n", iface, pStart, pEnd);
559 
560  if (pStart)
561  {
562  This->props.tStart = *pStart;
563  This->props.dwSampleFlags |= AM_SAMPLE_TIMEVALID;
564  }
565  else
566  This->props.dwSampleFlags &= ~AM_SAMPLE_TIMEVALID;
567 
568  if (pEnd)
569  {
570  This->props.tStop = *pEnd;
571  This->props.dwSampleFlags |= AM_SAMPLE_STOPVALID;
572  }
573  else
574  This->props.dwSampleFlags &= ~AM_SAMPLE_STOPVALID;
575 
576  return S_OK;
577 }
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ StdMemAllocator_Alloc()

static HRESULT StdMemAllocator_Alloc ( IMemAllocator iface)
static

Definition at line 817 of file memallocator.c.

818 {
820  StdMediaSample2 * pSample = NULL;
821  SYSTEM_INFO si;
822  LONG i;
823 
824  assert(list_empty(&This->base.free_list));
825 
826  /* check alignment */
827  GetSystemInfo(&si);
828 
829  /* we do not allow a courser alignment than the OS page size */
830  if ((si.dwPageSize % This->base.props.cbAlign) != 0)
831  return VFW_E_BADALIGN;
832 
833  /* FIXME: each sample has to have its buffer start on the right alignment.
834  * We don't do this at the moment */
835 
836  /* allocate memory */
837  This->pMemory = VirtualAlloc(NULL, (This->base.props.cbBuffer + This->base.props.cbPrefix) * This->base.props.cBuffers, MEM_COMMIT, PAGE_READWRITE);
838 
839  if (!This->pMemory)
840  return E_OUTOFMEMORY;
841 
842  for (i = This->base.props.cBuffers - 1; i >= 0; i--)
843  {
844  /* pbBuffer does not start at the base address, it starts at base + cbPrefix */
845  BYTE * pbBuffer = (BYTE *)This->pMemory + i * (This->base.props.cbBuffer + This->base.props.cbPrefix) + This->base.props.cbPrefix;
846 
847  StdMediaSample2_Construct(pbBuffer, This->base.props.cbBuffer, iface, &pSample);
848 
849  list_add_head(&This->base.free_list, &pSample->listentry);
850  }
851 
852  return S_OK;
853 }
#define VFW_E_BADALIGN
Definition: vfwmsgs.h:53
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
#define assert(x)
Definition: debug.h:53
#define MEM_COMMIT
Definition: nt_native.h:1313
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LPVOID NTAPI VirtualAlloc(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flAllocationType, IN DWORD flProtect)
Definition: virtmem.c:74
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
long LONG
Definition: pedump.c:60
static StdMemAllocator * StdMemAllocator_from_IMemAllocator(IMemAllocator *iface)
Definition: memallocator.c:812
smooth NULL
Definition: ftsmooth.c:416
unsigned char BYTE
Definition: mem.h:68
struct list listentry
Definition: memallocator.c:40
static HRESULT StdMediaSample2_Construct(BYTE *pbBuffer, LONG cbBuffer, IMemAllocator *pParent, StdMediaSample2 **ppSample)
Definition: memallocator.c:421
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
Definition: list.h:143
#define S_OK
Definition: intsafe.h:59
DWORD dwPageSize
Definition: winbase.h:1133
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:142
#define PAGE_READWRITE
Definition: nt_native.h:1304

Referenced by StdMemAllocator_create().

◆ StdMemAllocator_create()

HRESULT StdMemAllocator_create ( LPUNKNOWN  lpUnkOuter,
LPVOID ppv 
)

Definition at line 898 of file memallocator.c.

899 {
900  StdMemAllocator * pMemAlloc;
901  HRESULT hr;
902 
903  *ppv = NULL;
904 
905  if (lpUnkOuter)
906  return CLASS_E_NOAGGREGATION;
907 
908  if (!(pMemAlloc = CoTaskMemAlloc(sizeof(*pMemAlloc))))
909  return E_OUTOFMEMORY;
910 
911  InitializeCriticalSection(&pMemAlloc->csState);
912  pMemAlloc->csState.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": StdMemAllocator.csState");
913 
914  pMemAlloc->pMemory = NULL;
915 
917  *ppv = pMemAlloc;
918  else
919  CoTaskMemFree(pMemAlloc);
920 
921  return hr;
922 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
#define DWORD_PTR
Definition: treelist.c:76
HRESULT hr
Definition: shlfolder.c:183
REFIID LPVOID * ppv
Definition: atlbase.h:39
BaseMemAllocator base
Definition: memallocator.c:807
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static void StdMemAllocator_Destroy(IMemAllocator *iface)
Definition: memallocator.c:888
static HRESULT BaseMemAllocator_Init(HRESULT(*fnAlloc)(IMemAllocator *), HRESULT(*fnFree)(IMemAllocator *), HRESULT(*fnVerify)(IMemAllocator *, ALLOCATOR_PROPERTIES *), HRESULT(*fnBufferPrepare)(IMemAllocator *, StdMediaSample2 *, DWORD), HRESULT(*fnBufferReleased)(IMemAllocator *, StdMediaSample2 *), void(*fnDestroyed)(IMemAllocator *), CRITICAL_SECTION *pCritSect, BaseMemAllocator *pMemAlloc)
Definition: memallocator.c:79
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
PCRITICAL_SECTION_DEBUG DebugInfo
Definition: winbase.h:866
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
CRITICAL_SECTION csState
Definition: memallocator.c:808
static HRESULT StdMemAllocator_Alloc(IMemAllocator *iface)
Definition: memallocator.c:817
static HRESULT StdMemAllocator_Free(IMemAllocator *iface)
Definition: memallocator.c:855
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404
#define SUCCEEDED(hr)
Definition: intsafe.h:57
DWORD_PTR Spare[8/sizeof(DWORD_PTR)]
Definition: winbase.h:859

Referenced by PullPin_ReceiveConnection().

◆ StdMemAllocator_Destroy()

static void StdMemAllocator_Destroy ( IMemAllocator iface)
static

Definition at line 888 of file memallocator.c.

889 {
891 
892  This->csState.DebugInfo->Spare[0] = 0;
893  DeleteCriticalSection(&This->csState);
894 
896 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
static StdMemAllocator * StdMemAllocator_from_IMemAllocator(IMemAllocator *iface)
Definition: memallocator.c:812
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by StdMemAllocator_create().

◆ StdMemAllocator_Free()

static HRESULT StdMemAllocator_Free ( IMemAllocator iface)
static

Definition at line 855 of file memallocator.c.

856 {
858  struct list * cursor;
859 
860  if (!list_empty(&This->base.used_list))
861  {
862  WARN("Freeing allocator with outstanding samples!\n");
863  while ((cursor = list_head(&This->base.used_list)) != NULL)
864  {
865  StdMediaSample2 *pSample;
867  pSample = LIST_ENTRY(cursor, StdMediaSample2, listentry);
868  pSample->pParent = NULL;
869  }
870  }
871 
872  while ((cursor = list_head(&This->base.free_list)) != NULL)
873  {
876  }
877 
878  /* free memory */
879  if (!VirtualFree(This->pMemory, 0, MEM_RELEASE))
880  {
881  ERR("Couldn't free memory. Error: %u\n", GetLastError());
883  }
884 
885  return S_OK;
886 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define WARN(fmt,...)
Definition: debug.h:111
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
IMemAllocator * pParent
Definition: memallocator.c:39
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
Definition: list.h:131
static StdMemAllocator * StdMemAllocator_from_IMemAllocator(IMemAllocator *iface)
Definition: memallocator.c:812
smooth NULL
Definition: ftsmooth.c:416
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
static void StdMediaSample2_Delete(StdMediaSample2 *This)
Definition: memallocator.c:445
Definition: _list.h:228
#define ERR(fmt,...)
Definition: debug.h:109
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
Definition: list.h:143
#define S_OK
Definition: intsafe.h:59
const char cursor[]
Definition: icontest.c:13
#define MEM_RELEASE
Definition: nt_native.h:1316
BOOL NTAPI VirtualFree(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD dwFreeType)
Definition: virtmem.c:128
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by StdMemAllocator_create().

◆ StdMemAllocator_from_IMemAllocator()

static StdMemAllocator* StdMemAllocator_from_IMemAllocator ( IMemAllocator iface)
inlinestatic

Definition at line 812 of file memallocator.c.

813 {
814  return CONTAINING_RECORD(iface, StdMemAllocator, base.IMemAllocator_iface);
815 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by StdMemAllocator_Alloc(), StdMemAllocator_Destroy(), and StdMemAllocator_Free().

◆ unsafe_impl_from_IMediaSample()

static StdMediaSample2 * unsafe_impl_from_IMediaSample ( IMediaSample iface)
inlinestatic

Definition at line 795 of file memallocator.c.

796 {
797  IMediaSample2 *iface2 = (IMediaSample2 *)iface;
798 
799  if (!iface)
800  return NULL;
801  assert(iface2->lpVtbl == &StdMediaSample2_VTable);
802  return impl_from_IMediaSample2(iface2);
803 }
#define assert(x)
Definition: debug.h:53
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:451
smooth NULL
Definition: ftsmooth.c:416
static const IMediaSample2Vtbl StdMediaSample2_VTable
Definition: memallocator.c:72

Referenced by BaseMemAllocator_ReleaseBuffer().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( quartz  )

Variable Documentation

◆ BaseMemAllocator_VTable

static const IMemAllocatorVtbl BaseMemAllocator_VTable
static
Initial value:
=
{
}
static HRESULT WINAPI BaseMemAllocator_SetProperties(IMemAllocator *iface, ALLOCATOR_PROPERTIES *pRequest, ALLOCATOR_PROPERTIES *pActual)
Definition: memallocator.c:163
static HRESULT WINAPI BaseMemAllocator_QueryInterface(IMemAllocator *iface, REFIID riid, LPVOID *ppv)
Definition: memallocator.c:111
static HRESULT WINAPI BaseMemAllocator_GetBuffer(IMemAllocator *iface, IMediaSample **pSample, REFERENCE_TIME *pStartTime, REFERENCE_TIME *pEndTime, DWORD dwFlags)
Definition: memallocator.c:297
static HRESULT WINAPI BaseMemAllocator_GetProperties(IMemAllocator *iface, ALLOCATOR_PROPERTIES *pProps)
Definition: memallocator.c:196
static HRESULT WINAPI BaseMemAllocator_Commit(IMemAllocator *iface)
Definition: memallocator.c:212
static HRESULT WINAPI BaseMemAllocator_ReleaseBuffer(IMemAllocator *iface, IMediaSample *pSample)
Definition: memallocator.c:357
static ULONG WINAPI BaseMemAllocator_AddRef(IMemAllocator *iface)
Definition: memallocator.c:134
static ULONG WINAPI BaseMemAllocator_Release(IMemAllocator *iface)
Definition: memallocator.c:144
static HRESULT WINAPI BaseMemAllocator_Decommit(IMemAllocator *iface)
Definition: memallocator.c:256

Definition at line 71 of file memallocator.c.

Referenced by BaseMemAllocator_Init().

◆ StdMediaSample2_VTable

static const IMediaSample2Vtbl StdMediaSample2_VTable
static
Initial value:
=
{
}
static HRESULT WINAPI StdMediaSample2_GetPointer(IMediaSample2 *iface, BYTE **ppBuffer)
Definition: memallocator.c:501
static HRESULT WINAPI StdMediaSample2_SetSyncPoint(IMediaSample2 *iface, BOOL bIsSyncPoint)
Definition: memallocator.c:588
static LONG WINAPI StdMediaSample2_GetSize(IMediaSample2 *iface)
Definition: memallocator.c:518
static HRESULT WINAPI StdMediaSample2_IsDiscontinuity(IMediaSample2 *iface)
Definition: memallocator.c:690
static HRESULT WINAPI StdMediaSample2_GetMediaTime(IMediaSample2 *iface, LONGLONG *pStart, LONGLONG *pEnd)
Definition: memallocator.c:713
static HRESULT WINAPI StdMediaSample2_SetActualDataLength(IMediaSample2 *iface, LONG len)
Definition: memallocator.c:634
static HRESULT WINAPI StdMediaSample2_SetProperties(IMediaSample2 *iface, DWORD cbProperties, const BYTE *pbProperties)
Definition: memallocator.c:758
static ULONG WINAPI StdMediaSample2_AddRef(IMediaSample2 *iface)
Definition: memallocator.c:474
static HRESULT WINAPI StdMediaSample2_GetTime(IMediaSample2 *iface, REFERENCE_TIME *pStart, REFERENCE_TIME *pEnd)
Definition: memallocator.c:527
static HRESULT WINAPI StdMediaSample2_QueryInterface(IMediaSample2 *iface, REFIID riid, void **ppv)
Definition: memallocator.c:456
static HRESULT WINAPI StdMediaSample2_GetMediaType(IMediaSample2 *iface, AM_MEDIA_TYPE **ppMediaType)
Definition: memallocator.c:652
static HRESULT WINAPI StdMediaSample2_SetTime(IMediaSample2 *iface, REFERENCE_TIME *pStart, REFERENCE_TIME *pEnd)
Definition: memallocator.c:554
static HRESULT WINAPI StdMediaSample2_SetDiscontinuity(IMediaSample2 *iface, BOOL bIsDiscontinuity)
Definition: memallocator.c:699
static HRESULT WINAPI StdMediaSample2_SetPreroll(IMediaSample2 *iface, BOOL bIsPreroll)
Definition: memallocator.c:611
static LONG WINAPI StdMediaSample2_GetActualDataLength(IMediaSample2 *iface)
Definition: memallocator.c:625
static ULONG WINAPI StdMediaSample2_Release(IMediaSample2 *iface)
Definition: memallocator.c:484
static HRESULT WINAPI StdMediaSample2_SetMediaTime(IMediaSample2 *iface, LONGLONG *pStart, LONGLONG *pEnd)
Definition: memallocator.c:728
static HRESULT WINAPI StdMediaSample2_SetMediaType(IMediaSample2 *iface, AM_MEDIA_TYPE *pMediaType)
Definition: memallocator.c:671
static HRESULT WINAPI StdMediaSample2_GetProperties(IMediaSample2 *iface, DWORD cbProperties, BYTE *pbProperties)
Definition: memallocator.c:747
static HRESULT WINAPI StdMediaSample2_IsPreroll(IMediaSample2 *iface)
Definition: memallocator.c:602
static HRESULT WINAPI StdMediaSample2_IsSyncPoint(IMediaSample2 *iface)
Definition: memallocator.c:579

Definition at line 72 of file memallocator.c.

Referenced by StdMediaSample2_Construct(), and unsafe_impl_from_IMediaSample().