ReactOS 0.4.17-dev-966-gf06eace
memallocator.c
Go to the documentation of this file.
1/*
2 * Memory Allocator and Media Sample Implementation
3 *
4 * Copyright 2003 Robert Shearman
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include <assert.h>
22#include <limits.h>
23#include <stdarg.h>
24
25#include "windef.h"
26#include "winbase.h"
27#include "vfwmsgs.h"
28
29#include "quartz_private.h"
30#include "wine/debug.h"
31
33
34typedef struct StdMediaSample2
35{
45
46typedef struct BaseMemAllocator
47{
49
66
68{
69 return CONTAINING_RECORD(iface, BaseMemAllocator, IMemAllocator_iface);
70}
71
72static const IMemAllocatorVtbl BaseMemAllocator_VTable;
73static const IMediaSample2Vtbl StdMediaSample2_VTable;
75
76#define AM_SAMPLE2_PROP_SIZE_WRITABLE FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, pbBuffer)
77
79 HRESULT (* fnFree)(IMemAllocator *),
81 HRESULT (* fnBufferPrepare)(IMemAllocator *, StdMediaSample2 *, DWORD),
82 HRESULT (* fnBufferReleased)(IMemAllocator *, StdMediaSample2 *),
83 void (* fnDestroyed)(IMemAllocator *),
84 CRITICAL_SECTION *pCritSect,
85 BaseMemAllocator * pMemAlloc)
86{
87 assert(fnAlloc && fnFree && fnDestroyed);
88
90
91 pMemAlloc->ref = 1;
92 ZeroMemory(&pMemAlloc->props, sizeof(pMemAlloc->props));
93 list_init(&pMemAlloc->free_list);
94 list_init(&pMemAlloc->used_list);
95 pMemAlloc->fnAlloc = fnAlloc;
96 pMemAlloc->fnFree = fnFree;
97 pMemAlloc->fnVerify = fnVerify;
98 pMemAlloc->fnBufferPrepare = fnBufferPrepare;
99 pMemAlloc->fnBufferReleased = fnBufferReleased;
100 pMemAlloc->fnDestroyed = fnDestroyed;
101 pMemAlloc->bDecommitQueued = FALSE;
102 pMemAlloc->bCommitted = FALSE;
103 pMemAlloc->hSemWaiting = NULL;
104 pMemAlloc->lWaiting = 0;
105 pMemAlloc->pCritSect = pCritSect;
106
107 return S_OK;
108}
109
111{
113 TRACE("(%p)->(%s, %p)\n", This, qzdebugstr_guid(riid), ppv);
114
115 *ppv = NULL;
116
118 *ppv = &This->IMemAllocator_iface;
119 else if (IsEqualIID(riid, &IID_IMemAllocator))
120 *ppv = &This->IMemAllocator_iface;
121
122 if (*ppv)
123 {
124 IUnknown_AddRef((IUnknown *)(*ppv));
125 return S_OK;
126 }
127
128 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
129
130 return E_NOINTERFACE;
131}
132
134{
137
138 TRACE("%p increasing refcount to %lu.\n", This, ref);
139
140 return ref;
141}
142
144{
147
148 TRACE("%p decreasing refcount to %lu.\n", This, ref);
149
150 if (!ref)
151 {
152 CloseHandle(This->hSemWaiting);
153 if (This->bCommitted)
154 This->fnFree(iface);
155
156 This->fnDestroyed(iface);
157 return 0;
158 }
159 return ref;
160}
161
163{
165 HRESULT hr;
166
167 TRACE("(%p)->(%p, %p)\n", This, pRequest, pActual);
168
169 TRACE("Requested %ld buffers, size %ld, alignment %ld, prefix %ld.\n",
170 pRequest->cBuffers, pRequest->cbBuffer, pRequest->cbAlign, pRequest->cbPrefix);
171
172 EnterCriticalSection(This->pCritSect);
173 {
174 if (!list_empty(&This->used_list))
176 else if (This->bCommitted)
178 else if (pRequest->cbAlign == 0)
180 else
181 {
182 if (This->fnVerify)
183 hr = This->fnVerify(iface, pRequest);
184 else
185 hr = S_OK;
186
187 if (SUCCEEDED(hr))
188 This->props = *pRequest;
189
190 *pActual = This->props;
191 }
192 }
193 LeaveCriticalSection(This->pCritSect);
194
195 return hr;
196}
197
199{
201
202 TRACE("(%p)->(%p)\n", This, pProps);
203
204 EnterCriticalSection(This->pCritSect);
205 {
206 memcpy(pProps, &This->props, sizeof(*pProps));
207 }
208 LeaveCriticalSection(This->pCritSect);
209
210 return S_OK;
211}
212
214{
216 HRESULT hr;
217
218 TRACE("(%p)->()\n", This);
219
220 EnterCriticalSection(This->pCritSect);
221 {
222 if (!This->props.cbAlign)
224 else if (!This->props.cbBuffer)
226 else if (!This->props.cBuffers)
228 else if (This->bDecommitQueued && This->bCommitted)
229 {
230 This->bDecommitQueued = FALSE;
231 hr = S_OK;
232 }
233 else if (This->bCommitted)
234 hr = S_OK;
235 else
236 {
237 if (!(This->hSemWaiting = CreateSemaphoreW(NULL, This->props.cBuffers, This->props.cBuffers, NULL)))
238 {
239 ERR("Failed to create semaphore, error %lu.\n", GetLastError());
241 }
242 else
243 {
244 hr = This->fnAlloc(iface);
245 if (SUCCEEDED(hr))
246 This->bCommitted = TRUE;
247 else
248 ERR("Failed to allocate, hr %#lx.\n", hr);
249 }
250 }
251 }
252 LeaveCriticalSection(This->pCritSect);
253
254 return hr;
255}
256
258{
260 HRESULT hr;
261
262 TRACE("(%p)->()\n", This);
263
264 EnterCriticalSection(This->pCritSect);
265 {
266 if (!This->bCommitted)
267 hr = S_OK;
268 else
269 {
270 if (!list_empty(&This->used_list))
271 {
272 This->bDecommitQueued = TRUE;
273 /* notify ALL waiting threads that they cannot be allocated a buffer any more */
274 ReleaseSemaphore(This->hSemWaiting, This->lWaiting, NULL);
275
276 hr = S_OK;
277 }
278 else
279 {
280 if (This->lWaiting != 0)
281 ERR("Waiting: %ld\n", This->lWaiting);
282
283 This->bCommitted = FALSE;
284 CloseHandle(This->hSemWaiting);
285 This->hSemWaiting = NULL;
286
287 hr = This->fnFree(iface);
288 }
289 }
290 }
291 LeaveCriticalSection(This->pCritSect);
292
293 return hr;
294}
295
297{
299 HRESULT hr = S_OK;
300
301 /* NOTE: The pStartTime and pEndTime parameters are not applied to the sample.
302 * The allocator might use these values to determine which buffer it retrieves */
303
304 TRACE("allocator %p, sample %p, start_time %p, end_time %p, flags %#lx.\n",
305 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)
337 else
338 {
339 StdMediaSample2 *ms;
340 struct list * free = list_head(&This->free_list);
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("Returning hr %#lx.\n", hr);
354 return hr;
355}
356
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 if (This->lWaiting != 0)
382 ERR("Waiting: %ld\n", This->lWaiting);
383
384 This->bCommitted = FALSE;
385 This->bDecommitQueued = FALSE;
386
387 CloseHandle(This->hSemWaiting);
388 This->hSemWaiting = NULL;
389
390 This->fnFree(iface);
391 }
392 }
393 LeaveCriticalSection(This->pCritSect);
394
395 /* notify a waiting thread that there is now a free buffer */
396 if (This->hSemWaiting && !ReleaseSemaphore(This->hSemWaiting, 1, NULL))
397 {
398 ERR("Failed to release semaphore, error %lu.\n", GetLastError());
400 }
401
402 return hr;
403}
404
405static const IMemAllocatorVtbl BaseMemAllocator_VTable =
406{
416};
417
419{
420 assert(pbBuffer && pParent && (cbBuffer > 0));
421
422 if (!(*ppSample = CoTaskMemAlloc(sizeof(StdMediaSample2))))
423 return E_OUTOFMEMORY;
424
425 (*ppSample)->IMediaSample2_iface.lpVtbl = &StdMediaSample2_VTable;
426 (*ppSample)->ref = 0;
427 ZeroMemory(&(*ppSample)->props, sizeof((*ppSample)->props));
428
429 /* NOTE: no need to AddRef as the parent is guaranteed to be around
430 * at least as long as us and we don't want to create circular
431 * dependencies on the ref count */
432 (*ppSample)->pParent = pParent;
433 (*ppSample)->props.cbData = sizeof(AM_SAMPLE2_PROPERTIES);
434 (*ppSample)->props.cbBuffer = (*ppSample)->props.lActual = cbBuffer;
435 (*ppSample)->props.pbBuffer = pbBuffer;
436 (*ppSample)->media_time_valid = FALSE;
437
438 return S_OK;
439}
440
442{
443 if (This->props.pMediaType)
444 DeleteMediaType(This->props.pMediaType);
445
446 /* NOTE: does not remove itself from the list it belongs to */
448}
449
451{
452 return CONTAINING_RECORD(iface, StdMediaSample2, IMediaSample2_iface);
453}
454
456{
457 TRACE("(%s, %p)\n", qzdebugstr_guid(riid), ppv);
458
459 *ppv = NULL;
460
461 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IMediaSample) ||
462 IsEqualIID(riid, &IID_IMediaSample2))
463 {
464 *ppv = iface;
465 IMediaSample2_AddRef(iface);
466 return S_OK;
467 }
468
469 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
470 return E_NOINTERFACE;
471}
472
474{
477
478 TRACE("%p increasing refcount to %lu.\n", This, ref);
479
480 return ref;
481}
482
484{
487
488 TRACE("%p decreasing refcount to %lu.\n", This, ref);
489
490 if (!ref)
491 {
492 if (This->props.pMediaType)
493 DeleteMediaType(This->props.pMediaType);
494 This->props.pMediaType = NULL;
495 This->props.dwSampleFlags = 0;
496 This->media_time_valid = FALSE;
497
498 if (This->pParent)
499 IMemAllocator_ReleaseBuffer(This->pParent, (IMediaSample *)iface);
500 else
502 }
503 return ref;
504}
505
507{
509
510 TRACE("(%p)->(%p)\n", iface, ppBuffer);
511
512 *ppBuffer = This->props.pbBuffer;
513
514 if (!*ppBuffer)
515 {
516 ERR("Requested an unlocked surface and trying to lock regardless\n");
517 return E_FAIL;
518 }
519
520 return S_OK;
521}
522
524{
526
527 TRACE("StdMediaSample2_GetSize()\n");
528
529 return This->props.cbBuffer;
530}
531
533{
535 HRESULT hr;
536
537 TRACE("(%p)->(%p, %p)\n", iface, pStart, pEnd);
538
539 if (!(This->props.dwSampleFlags & AM_SAMPLE_TIMEVALID))
541 else if (!(This->props.dwSampleFlags & AM_SAMPLE_STOPVALID))
542 {
543 *pStart = This->props.tStart;
544 *pEnd = This->props.tStart + 1;
545
547 }
548 else
549 {
550 *pStart = This->props.tStart;
551 *pEnd = This->props.tStop;
552
553 hr = S_OK;
554 }
555
556 return hr;
557}
558
560{
562
563 TRACE("sample %p, start %s, end %s.\n", sample, start ? debugstr_time(*start) : "(null)",
564 end ? debugstr_time(*end) : "(null)");
565
566 if (start)
567 {
568 sample->props.tStart = *start;
569 sample->props.dwSampleFlags |= AM_SAMPLE_TIMEVALID;
570
571 if (end)
572 {
573 sample->props.tStop = *end;
574 sample->props.dwSampleFlags |= AM_SAMPLE_STOPVALID;
575 }
576 else
577 sample->props.dwSampleFlags &= ~AM_SAMPLE_STOPVALID;
578 }
579 else
580 sample->props.dwSampleFlags &= ~(AM_SAMPLE_TIMEVALID | AM_SAMPLE_STOPVALID);
581
582 return S_OK;
583}
584
586{
588
589 TRACE("(%p)->()\n", iface);
590
591 return (This->props.dwSampleFlags & AM_SAMPLE_SPLICEPOINT) ? S_OK : S_FALSE;
592}
593
595{
597
598 TRACE("(%p)->(%s)\n", iface, bIsSyncPoint ? "TRUE" : "FALSE");
599
600 if (bIsSyncPoint)
601 This->props.dwSampleFlags |= AM_SAMPLE_SPLICEPOINT;
602 else
603 This->props.dwSampleFlags &= ~AM_SAMPLE_SPLICEPOINT;
604
605 return S_OK;
606}
607
609{
611
612 TRACE("(%p)->()\n", iface);
613
614 return (This->props.dwSampleFlags & AM_SAMPLE_PREROLL) ? S_OK : S_FALSE;
615}
616
618{
620
621 TRACE("(%p)->(%s)\n", iface, bIsPreroll ? "TRUE" : "FALSE");
622
623 if (bIsPreroll)
624 This->props.dwSampleFlags |= AM_SAMPLE_PREROLL;
625 else
626 This->props.dwSampleFlags &= ~AM_SAMPLE_PREROLL;
627
628 return S_OK;
629}
630
632{
634
635 TRACE("(%p)->()\n", iface);
636
637 return This->props.lActual;
638}
639
641{
643
644 TRACE("sample %p, len %ld.\n", This, len);
645
646 if ((len > This->props.cbBuffer) || (len < 0))
647 {
648 ERR("Length %ld exceeds maximum %ld.\n", len, This->props.cbBuffer);
650 }
651 else
652 {
653 This->props.lActual = len;
654 return S_OK;
655 }
656}
657
659{
661
662 TRACE("(%p)->(%p)\n", iface, ppMediaType);
663
664 if (!This->props.pMediaType) {
665 /* Make sure we return a NULL pointer (required by native Quartz dll) */
666 if (ppMediaType)
667 *ppMediaType = NULL;
668 return S_FALSE;
669 }
670
671 if (!(*ppMediaType = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))))
672 return E_OUTOFMEMORY;
673
674 return CopyMediaType(*ppMediaType, This->props.pMediaType);
675}
676
678{
680
681 TRACE("(%p)->(%p)\n", iface, pMediaType);
682
683 if (This->props.pMediaType)
684 {
685 DeleteMediaType(This->props.pMediaType);
686 This->props.pMediaType = NULL;
687 }
688
689 if (!pMediaType)
690 {
691 This->props.dwSampleFlags &= ~AM_SAMPLE_TYPECHANGED;
692 return S_OK;
693 }
694
695 This->props.dwSampleFlags |= AM_SAMPLE_TYPECHANGED;
696
697 if (!(This->props.pMediaType = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))))
698 return E_OUTOFMEMORY;
699
700 return CopyMediaType(This->props.pMediaType, pMediaType);
701}
702
704{
706
707 TRACE("(%p)->()\n", iface);
708
709 return (This->props.dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY) ? S_OK : S_FALSE;
710}
711
713{
715
716 TRACE("(%p)->(%s)\n", iface, bIsDiscontinuity ? "TRUE" : "FALSE");
717
718 if (bIsDiscontinuity)
719 This->props.dwSampleFlags |= AM_SAMPLE_DATADISCONTINUITY;
720 else
721 This->props.dwSampleFlags &= ~AM_SAMPLE_DATADISCONTINUITY;
722
723 return S_OK;
724}
725
727{
729
730 TRACE("(%p)->(%p, %p)\n", iface, pStart, pEnd);
731
732 if (!This->media_time_valid)
734
735 *pStart = This->tMediaStart;
736 *pEnd = This->tMediaEnd;
737
738 return S_OK;
739}
740
742{
744
745 TRACE("sample %p, start %s, end %s.\n", sample, start ? debugstr_time(*start) : "(null)",
746 end ? debugstr_time(*end) : "(null)");
747
748 if (start)
749 {
750 if (!end) return E_POINTER;
751 sample->tMediaStart = *start;
752 sample->tMediaEnd = *end;
753 sample->media_time_valid = TRUE;
754 }
755 else
756 sample->media_time_valid = FALSE;
757
758 return S_OK;
759}
760
761static HRESULT WINAPI StdMediaSample2_GetProperties(IMediaSample2 * iface, DWORD cbProperties, BYTE * pbProperties)
762{
764
765 TRACE("sample %p, size %lu, properties %p.\n", This, cbProperties, pbProperties);
766
767 memcpy(pbProperties, &This->props, min(cbProperties, sizeof(This->props)));
768
769 return S_OK;
770}
771
772static HRESULT WINAPI StdMediaSample2_SetProperties(IMediaSample2 * iface, DWORD cbProperties, const BYTE * pbProperties)
773{
775
776 TRACE("sample %p, size %lu, properties %p.\n", This, cbProperties, pbProperties);
777
778 /* NOTE: pbBuffer and cbBuffer are read-only */
779 memcpy(&This->props, pbProperties, min(cbProperties, AM_SAMPLE2_PROP_SIZE_WRITABLE));
780
781 return S_OK;
782}
783
784static const IMediaSample2Vtbl StdMediaSample2_VTable =
785{
807};
808
810{
811 IMediaSample2 *iface2 = (IMediaSample2 *)iface;
812
813 if (!iface)
814 return NULL;
815 assert(iface2->lpVtbl == &StdMediaSample2_VTable);
816 return impl_from_IMediaSample2(iface2);
817}
818
819typedef struct StdMemAllocator
820{
825
827{
828 return CONTAINING_RECORD(iface, StdMemAllocator, base.IMemAllocator_iface);
829}
830
832{
834 StdMediaSample2 * pSample = NULL;
836 LONG i;
837
838 assert(list_empty(&This->base.free_list));
839
840 /* check alignment */
842
843 /* we do not allow a courser alignment than the OS page size */
844 if ((si.dwPageSize % This->base.props.cbAlign) != 0)
845 return VFW_E_BADALIGN;
846
847 /* FIXME: each sample has to have its buffer start on the right alignment.
848 * We don't do this at the moment */
849
850 /* allocate memory */
851 This->pMemory = VirtualAlloc(NULL, (This->base.props.cbBuffer + This->base.props.cbPrefix) * This->base.props.cBuffers, MEM_COMMIT, PAGE_READWRITE);
852
853 if (!This->pMemory)
854 return E_OUTOFMEMORY;
855
856 for (i = This->base.props.cBuffers - 1; i >= 0; i--)
857 {
858 /* pbBuffer does not start at the base address, it starts at base + cbPrefix */
859 BYTE * pbBuffer = (BYTE *)This->pMemory + i * (This->base.props.cbBuffer + This->base.props.cbPrefix) + This->base.props.cbPrefix;
860
861 StdMediaSample2_Construct(pbBuffer, This->base.props.cbBuffer, iface, &pSample);
862
863 list_add_head(&This->base.free_list, &pSample->listentry);
864 }
865
866 return S_OK;
867}
868
870{
872 struct list * cursor;
873
874 if (!list_empty(&This->base.used_list))
875 {
876 WARN("Freeing allocator with outstanding samples!\n");
877 while ((cursor = list_head(&This->base.used_list)) != NULL)
878 {
879 StdMediaSample2 *pSample;
881 pSample = LIST_ENTRY(cursor, StdMediaSample2, listentry);
882 pSample->pParent = NULL;
883 }
884 }
885
886 while ((cursor = list_head(&This->base.free_list)) != NULL)
887 {
890 }
891
892 /* free memory */
893 if (!VirtualFree(This->pMemory, 0, MEM_RELEASE))
894 {
895 ERR("Failed to free memory, error %lu.\n", GetLastError());
897 }
898
899 return S_OK;
900}
901
903{
905
906 This->csState.DebugInfo->Spare[0] = 0;
907 DeleteCriticalSection(&This->csState);
908
910}
911
913{
914 StdMemAllocator * pMemAlloc;
915 HRESULT hr;
916
917 if (lpUnkOuter)
919
920 if (!(pMemAlloc = CoTaskMemAlloc(sizeof(*pMemAlloc))))
921 return E_OUTOFMEMORY;
922
924 pMemAlloc->csState.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": StdMemAllocator.csState");
925
926 pMemAlloc->pMemory = NULL;
927
929 *out = (IUnknown *)&pMemAlloc->base.IMemAllocator_iface;
930 else
931 CoTaskMemFree(pMemAlloc);
932
933 return hr;
934}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
struct tagAM_SAMPLE2_PROPERTIES AM_SAMPLE2_PROPERTIES
@ AM_SAMPLE_TIMEVALID
Definition: axcore.idl:441
@ AM_SAMPLE_STOPVALID
Definition: axcore.idl:444
@ AM_SAMPLE_DATADISCONTINUITY
Definition: axcore.idl:439
@ AM_SAMPLE_TYPECHANGED
Definition: axcore.idl:440
@ AM_SAMPLE_PREROLL
Definition: axcore.idl:438
@ AM_SAMPLE_SPLICEPOINT
Definition: axcore.idl:437
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static int list_empty(struct list_entry *head)
Definition: list.h:58
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
static void list_init(struct list_entry *head)
Definition: list.h:51
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
Definition: list.h:39
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
const char * qzdebugstr_guid(const GUID *id)
Definition: main.c:671
static LONG WINAPI StdMediaSample2_GetActualDataLength(IMediaSample2 *iface)
Definition: memallocator.c:631
static HRESULT WINAPI StdMediaSample2_SetPreroll(IMediaSample2 *iface, BOOL bIsPreroll)
Definition: memallocator.c:617
static HRESULT WINAPI StdMediaSample2_SetDiscontinuity(IMediaSample2 *iface, BOOL bIsDiscontinuity)
Definition: memallocator.c:712
static HRESULT WINAPI StdMediaSample2_SetMediaType(IMediaSample2 *iface, AM_MEDIA_TYPE *pMediaType)
Definition: memallocator.c:677
static StdMemAllocator * StdMemAllocator_from_IMemAllocator(IMemAllocator *iface)
Definition: memallocator.c:826
static StdMediaSample2 * unsafe_impl_from_IMediaSample(IMediaSample *iface)
Definition: memallocator.c:809
static HRESULT StdMemAllocator_Alloc(IMemAllocator *iface)
Definition: memallocator.c:831
static LONG WINAPI StdMediaSample2_GetSize(IMediaSample2 *iface)
Definition: memallocator.c:523
static const IMemAllocatorVtbl BaseMemAllocator_VTable
Definition: memallocator.c:72
static HRESULT WINAPI StdMediaSample2_GetMediaTime(IMediaSample2 *iface, LONGLONG *pStart, LONGLONG *pEnd)
Definition: memallocator.c:726
#define AM_SAMPLE2_PROP_SIZE_WRITABLE
Definition: memallocator.c:76
HRESULT mem_allocator_create(IUnknown *lpUnkOuter, IUnknown **out)
Definition: memallocator.c:912
static HRESULT WINAPI StdMediaSample2_GetMediaType(IMediaSample2 *iface, AM_MEDIA_TYPE **ppMediaType)
Definition: memallocator.c:658
static HRESULT WINAPI StdMediaSample2_GetTime(IMediaSample2 *iface, REFERENCE_TIME *pStart, REFERENCE_TIME *pEnd)
Definition: memallocator.c:532
static HRESULT WINAPI StdMediaSample2_GetPointer(IMediaSample2 *iface, BYTE **ppBuffer)
Definition: memallocator.c:506
static HRESULT WINAPI StdMediaSample2_GetProperties(IMediaSample2 *iface, DWORD cbProperties, BYTE *pbProperties)
Definition: memallocator.c:761
static StdMediaSample2 * impl_from_IMediaSample2(IMediaSample2 *iface)
Definition: memallocator.c:450
static HRESULT WINAPI StdMediaSample2_SetSyncPoint(IMediaSample2 *iface, BOOL bIsSyncPoint)
Definition: memallocator.c:594
static ULONG WINAPI StdMediaSample2_Release(IMediaSample2 *iface)
Definition: memallocator.c:483
static HRESULT WINAPI BaseMemAllocator_QueryInterface(IMemAllocator *iface, REFIID riid, LPVOID *ppv)
Definition: memallocator.c:110
static HRESULT StdMediaSample2_Construct(BYTE *pbBuffer, LONG cbBuffer, IMemAllocator *pParent, StdMediaSample2 **ppSample)
Definition: memallocator.c:418
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:78
static HRESULT WINAPI StdMediaSample2_QueryInterface(IMediaSample2 *iface, REFIID riid, void **ppv)
Definition: memallocator.c:455
static BaseMemAllocator * impl_from_IMemAllocator(IMemAllocator *iface)
Definition: memallocator.c:67
static HRESULT StdMemAllocator_Free(IMemAllocator *iface)
Definition: memallocator.c:869
static ULONG WINAPI StdMediaSample2_AddRef(IMediaSample2 *iface)
Definition: memallocator.c:473
static HRESULT WINAPI BaseMemAllocator_Decommit(IMemAllocator *iface)
Definition: memallocator.c:257
static HRESULT WINAPI StdMediaSample2_IsDiscontinuity(IMediaSample2 *iface)
Definition: memallocator.c:703
static HRESULT WINAPI BaseMemAllocator_GetBuffer(IMemAllocator *iface, IMediaSample **pSample, REFERENCE_TIME *pStartTime, REFERENCE_TIME *pEndTime, DWORD dwFlags)
Definition: memallocator.c:296
static HRESULT WINAPI StdMediaSample2_SetProperties(IMediaSample2 *iface, DWORD cbProperties, const BYTE *pbProperties)
Definition: memallocator.c:772
static HRESULT WINAPI StdMediaSample2_IsPreroll(IMediaSample2 *iface)
Definition: memallocator.c:608
static void StdMemAllocator_Destroy(IMemAllocator *iface)
Definition: memallocator.c:902
static HRESULT WINAPI StdMediaSample2_IsSyncPoint(IMediaSample2 *iface)
Definition: memallocator.c:585
static HRESULT WINAPI BaseMemAllocator_SetProperties(IMemAllocator *iface, ALLOCATOR_PROPERTIES *pRequest, ALLOCATOR_PROPERTIES *pActual)
Definition: memallocator.c:162
static HRESULT WINAPI StdMediaSample2_SetMediaTime(IMediaSample2 *iface, LONGLONG *start, LONGLONG *end)
Definition: memallocator.c:741
static HRESULT WINAPI StdMediaSample2_SetActualDataLength(IMediaSample2 *iface, LONG len)
Definition: memallocator.c:640
static ULONG WINAPI BaseMemAllocator_AddRef(IMemAllocator *iface)
Definition: memallocator.c:133
static HRESULT WINAPI BaseMemAllocator_ReleaseBuffer(IMemAllocator *iface, IMediaSample *pSample)
Definition: memallocator.c:357
static HRESULT WINAPI BaseMemAllocator_GetProperties(IMemAllocator *iface, ALLOCATOR_PROPERTIES *pProps)
Definition: memallocator.c:198
static ULONG WINAPI BaseMemAllocator_Release(IMemAllocator *iface)
Definition: memallocator.c:143
static const IMediaSample2Vtbl StdMediaSample2_VTable
Definition: memallocator.c:73
static HRESULT WINAPI StdMediaSample2_SetTime(IMediaSample2 *iface, REFERENCE_TIME *start, REFERENCE_TIME *end)
Definition: memallocator.c:559
static void StdMediaSample2_Delete(StdMediaSample2 *This)
Definition: memallocator.c:441
static HRESULT WINAPI BaseMemAllocator_Commit(IMemAllocator *iface)
Definition: memallocator.c:213
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
#define CloseHandle
Definition: compat.h:739
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
BOOL WINAPI InitializeCriticalSectionEx(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount, IN DWORD flags)
Definition: sync.c:107
#define assert(_expr)
Definition: assert.h:32
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxRequest * pRequest
FxObject * pParent
Definition: fxdpcapi.cpp:86
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
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
const char cursor[]
Definition: icontest.c:13
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define ZeroMemory
Definition: minwinbase.h:31
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static SYSTEM_INFO si
Definition: virtual.c:39
#define min(a, b)
Definition: monoChain.cc:55
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define PAGE_READWRITE
Definition: nt_native.h:1307
#define MEM_RELEASE
Definition: nt_native.h:1319
#define MEM_COMMIT
Definition: nt_native.h:1316
long LONG
Definition: pedump.c:60
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define TRACE(s)
Definition: solgame.cpp:4
static const char * debugstr_time(REFERENCE_TIME time)
Definition: strmbase.h:32
HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE *pDest, const AM_MEDIA_TYPE *pSrc)
Definition: mediatype.c:150
void WINAPI DeleteMediaType(AM_MEDIA_TYPE *pMediaType)
Definition: mediatype.c:193
HRESULT(* fnVerify)(IMemAllocator *, ALLOCATOR_PROPERTIES *)
Definition: memallocator.c:54
HRESULT(* fnFree)(IMemAllocator *)
Definition: memallocator.c:53
void(* fnDestroyed)(IMemAllocator *)
Definition: memallocator.c:57
struct list used_list
Definition: memallocator.c:63
IMemAllocator IMemAllocator_iface
Definition: memallocator.c:48
struct list free_list
Definition: memallocator.c:62
CRITICAL_SECTION * pCritSect
Definition: memallocator.c:64
HRESULT(* fnAlloc)(IMemAllocator *)
Definition: memallocator.c:52
ALLOCATOR_PROPERTIES props
Definition: memallocator.c:51
HRESULT(* fnBufferPrepare)(IMemAllocator *, StdMediaSample2 *, DWORD flags)
Definition: memallocator.c:55
HRESULT(* fnBufferReleased)(IMemAllocator *, StdMediaSample2 *)
Definition: memallocator.c:56
AM_SAMPLE2_PROPERTIES props
Definition: memallocator.c:38
LONGLONG tMediaStart
Definition: memallocator.c:41
IMemAllocator * pParent
Definition: memallocator.c:39
struct list listentry
Definition: memallocator.c:40
IMediaSample2 IMediaSample2_iface
Definition: memallocator.c:36
LONGLONG tMediaEnd
Definition: memallocator.c:42
CRITICAL_SECTION csState
Definition: memallocator.c:822
BaseMemAllocator base
Definition: memallocator.c:821
PRTL_CRITICAL_SECTION_DEBUG DebugInfo
Definition: rtltypes.h:1478
DWORD dwPageSize
Definition: winbase.h:896
Definition: list.h:15
Definition: send.c:48
Definition: wave.c:25
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreW(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:406
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:491
#define LIST_ENTRY(type)
Definition: queue.h:175
#define DWORD_PTR
Definition: treelist.c:76
int64_t LONGLONG
Definition: typedefs.h:68
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define VFW_E_BADALIGN
Definition: vfwmsgs.h:53
#define VFW_E_SAMPLE_TIME_NOT_SET
Definition: vfwmsgs.h:104
#define VFW_E_MEDIA_TIME_NOT_SET
Definition: vfwmsgs.h:105
#define VFW_E_NOT_COMMITTED
Definition: vfwmsgs.h:56
#define VFW_E_BUFFERS_OUTSTANDING
Definition: vfwmsgs.h:55
#define VFW_S_NO_STOP_TIME
Definition: vfwmsgs.h:34
#define VFW_E_BUFFER_OVERFLOW
Definition: vfwmsgs.h:52
#define VFW_E_TIMEOUT
Definition: vfwmsgs.h:85
#define VFW_E_ALREADY_COMMITTED
Definition: vfwmsgs.h:54
#define VFW_E_SIZENOTSET
Definition: vfwmsgs.h:57
#define VFW_E_BUFFER_NOTSET
Definition: vfwmsgs.h:51
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
LPVOID NTAPI VirtualAlloc(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flAllocationType, IN DWORD flProtect)
Definition: virtmem.c:65
BOOL NTAPI VirtualFree(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD dwFreeType)
Definition: virtmem.c:119
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define WAIT_OBJECT_0
Definition: winbase.h:383
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:3451
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define E_NOINTERFACE
Definition: winerror.h:3479
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:3771
#define E_POINTER
Definition: winerror.h:3480
#define RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO
Definition: winnt_old.h:1156
unsigned char BYTE
Definition: xxhash.c:193