4 * Copyright 2003 Robert Shearman
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.
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.
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
21 #define NONAMELESSUNION
22 #define NONAMELESSSTRUCT
24 #include "quartz_private.h"
26 #include "wine/debug.h"
27 #include "wine/unicode.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
38 static const WCHAR wszOutputPinName
[] = { 'O','u','t','p','u','t',0 };
40 typedef struct AsyncReader
43 IFileSourceFilter IFileSourceFilter_iface
;
44 IAMFilterMiscFlags IAMFilterMiscFlags_iface
;
51 static inline AsyncReader
*impl_from_BaseFilter(BaseFilter
*iface
)
53 return CONTAINING_RECORD(iface
, AsyncReader
, filter
);
56 static inline AsyncReader
*impl_from_IBaseFilter(IBaseFilter
*iface
)
58 return CONTAINING_RECORD(iface
, AsyncReader
, filter
.IBaseFilter_iface
);
61 static inline AsyncReader
*impl_from_IFileSourceFilter(IFileSourceFilter
*iface
)
63 return CONTAINING_RECORD(iface
, AsyncReader
, IFileSourceFilter_iface
);
66 static inline AsyncReader
*impl_from_IAMFilterMiscFlags(IAMFilterMiscFlags
*iface
)
68 return CONTAINING_RECORD(iface
, AsyncReader
, IAMFilterMiscFlags_iface
);
71 static const IBaseFilterVtbl AsyncReader_Vtbl
;
72 static const IFileSourceFilterVtbl FileSource_Vtbl
;
73 static const IAsyncReaderVtbl FileAsyncReader_Vtbl
;
74 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl
;
76 static HRESULT
FileAsyncReader_Construct(HANDLE hFile
, IBaseFilter
* pBaseFilter
, LPCRITICAL_SECTION pCritSec
, IPin
** ppPin
);
78 static const WCHAR mediatype_name
[] = {
79 'M', 'e', 'd', 'i', 'a', ' ', 'T', 'y', 'p', 'e', 0 };
80 static const WCHAR subtype_name
[] = {
81 'S', 'u', 'b', 't', 'y', 'p', 'e', 0 };
82 static const WCHAR source_filter_name
[] = {
83 'S','o','u','r','c','e',' ','F','i','l','t','e','r',0};
85 static HRESULT
process_extensions(HKEY hkeyExtensions
, LPCOLESTR pszFileName
, GUID
* majorType
, GUID
* minorType
, GUID
* sourceFilter
)
96 /* Get the part of the name that matters */
97 extension
= PathFindExtensionW(pszFileName
);
98 if (*extension
!= '.')
101 l
= RegOpenKeyExW(hkeyExtensions
, extension
, 0, KEY_READ
, &hsub
);
107 size
= sizeof(keying
);
108 l
= RegQueryValueExW(hsub
, mediatype_name
, NULL
, NULL
, (LPBYTE
)keying
, &size
);
110 CLSIDFromString(keying
, majorType
);
115 size
= sizeof(keying
);
117 l
= RegQueryValueExW(hsub
, subtype_name
, NULL
, NULL
, (LPBYTE
)keying
, &size
);
119 CLSIDFromString(keying
, minorType
);
124 size
= sizeof(keying
);
126 l
= RegQueryValueExW(hsub
, source_filter_name
, NULL
, NULL
, (LPBYTE
)keying
, &size
);
128 CLSIDFromString(keying
, sourceFilter
);
138 static unsigned char byte_from_hex_char(WCHAR wHex
)
140 switch (tolowerW(wHex
))
152 return (wHex
- '0') & 0xf;
159 return (wHex
- 'a' + 10) & 0xf;
165 static HRESULT
process_pattern_string(LPCWSTR wszPatternString
, IAsyncReader
* pReader
)
175 TRACE("\t\tPattern string: %s\n", debugstr_w(wszPatternString
));
177 /* format: "offset, bytestocompare, mask, value" */
179 ulOffset
= strtolW(wszPatternString
, NULL
, 10);
181 if (!(wszPatternString
= strchrW(wszPatternString
, ',')))
184 wszPatternString
++; /* skip ',' */
186 ulBytes
= strtolW(wszPatternString
, NULL
, 10);
188 pbMask
= HeapAlloc(GetProcessHeap(), 0, ulBytes
);
189 pbValue
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, ulBytes
);
190 pbFile
= HeapAlloc(GetProcessHeap(), 0, ulBytes
);
192 /* default mask is match everything */
193 memset(pbMask
, 0xFF, ulBytes
);
195 if (!(wszPatternString
= strchrW(wszPatternString
, ',')))
200 wszPatternString
++; /* skip ',' */
201 while (!isxdigitW(*wszPatternString
) && (*wszPatternString
!= ',')) wszPatternString
++;
203 for (strpos
= 0; isxdigitW(*wszPatternString
) && (strpos
/2 < ulBytes
); wszPatternString
++, strpos
++)
205 if ((strpos
% 2) == 1) /* odd numbered position */
206 pbMask
[strpos
/ 2] |= byte_from_hex_char(*wszPatternString
);
208 pbMask
[strpos
/ 2] = byte_from_hex_char(*wszPatternString
) << 4;
211 if (!(wszPatternString
= strchrW(wszPatternString
, ',')))
214 wszPatternString
++; /* skip ',' */
219 for ( ; !isxdigitW(*wszPatternString
) && (*wszPatternString
!= ','); wszPatternString
++)
222 for (strpos
= 0; isxdigitW(*wszPatternString
) && (strpos
/2 < ulBytes
); wszPatternString
++, strpos
++)
224 if ((strpos
% 2) == 1) /* odd numbered position */
225 pbValue
[strpos
/ 2] |= byte_from_hex_char(*wszPatternString
);
227 pbValue
[strpos
/ 2] = byte_from_hex_char(*wszPatternString
) << 4;
232 hr
= IAsyncReader_SyncRead(pReader
, ulOffset
, ulBytes
, pbFile
);
237 for (i
= 0; i
< ulBytes
; i
++)
238 if ((pbFile
[i
] & pbMask
[i
]) != pbValue
[i
])
245 HeapFree(GetProcessHeap(), 0, pbMask
);
246 HeapFree(GetProcessHeap(), 0, pbValue
);
247 HeapFree(GetProcessHeap(), 0, pbFile
);
249 /* if we encountered no errors with this string, and there is a following tuple, then we
250 * have to match that as well to succeed */
251 if ((hr
== S_OK
) && (wszPatternString
= strchrW(wszPatternString
, ',')))
252 return process_pattern_string(wszPatternString
+ 1, pReader
);
257 HRESULT
GetClassMediaFile(IAsyncReader
* pReader
, LPCOLESTR pszFileName
, GUID
* majorType
, GUID
* minorType
, GUID
* sourceFilter
)
259 HKEY hkeyMediaType
= NULL
;
263 static const WCHAR wszMediaType
[] = {'M','e','d','i','a',' ','T','y','p','e',0};
265 TRACE("(%p, %s, %p, %p)\n", pReader
, debugstr_w(pszFileName
), majorType
, minorType
);
268 *majorType
= GUID_NULL
;
270 *minorType
= GUID_NULL
;
272 *sourceFilter
= GUID_NULL
;
274 lRet
= RegOpenKeyExW(HKEY_CLASSES_ROOT
, wszMediaType
, 0, KEY_READ
, &hkeyMediaType
);
275 hr
= HRESULT_FROM_WIN32(lRet
);
281 for (indexMajor
= 0; !bFound
; indexMajor
++)
284 WCHAR wszMajorKeyName
[CHARS_IN_GUID
];
285 DWORD dwKeyNameLength
= sizeof(wszMajorKeyName
) / sizeof(wszMajorKeyName
[0]);
286 static const WCHAR wszExtensions
[] = {'E','x','t','e','n','s','i','o','n','s',0};
288 if (RegEnumKeyExW(hkeyMediaType
, indexMajor
, wszMajorKeyName
, &dwKeyNameLength
, NULL
, NULL
, NULL
, NULL
) != ERROR_SUCCESS
)
290 if (RegOpenKeyExW(hkeyMediaType
, wszMajorKeyName
, 0, KEY_READ
, &hkeyMajor
) != ERROR_SUCCESS
)
292 TRACE("%s\n", debugstr_w(wszMajorKeyName
));
293 if (!strcmpW(wszExtensions
, wszMajorKeyName
))
295 if (process_extensions(hkeyMajor
, pszFileName
, majorType
, minorType
, sourceFilter
) == S_OK
)
298 /* We need a reader interface to check bytes */
303 for (indexMinor
= 0; !bFound
; indexMinor
++)
306 WCHAR wszMinorKeyName
[CHARS_IN_GUID
];
307 DWORD dwMinorKeyNameLen
= sizeof(wszMinorKeyName
) / sizeof(wszMinorKeyName
[0]);
308 WCHAR wszSourceFilterKeyName
[CHARS_IN_GUID
];
309 DWORD dwSourceFilterKeyNameLen
= sizeof(wszSourceFilterKeyName
);
313 if (RegEnumKeyExW(hkeyMajor
, indexMinor
, wszMinorKeyName
, &dwMinorKeyNameLen
, NULL
, NULL
, NULL
, NULL
) != ERROR_SUCCESS
)
316 if (RegOpenKeyExW(hkeyMajor
, wszMinorKeyName
, 0, KEY_READ
, &hkeyMinor
) != ERROR_SUCCESS
)
319 TRACE("\t%s\n", debugstr_w(wszMinorKeyName
));
321 if (RegQueryInfoKeyW(hkeyMinor
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, &maxValueLen
, NULL
, NULL
) != ERROR_SUCCESS
)
324 for (indexValue
= 0; !bFound
; indexValue
++)
327 WCHAR wszValueName
[14]; /* longest name we should encounter will be "Source Filter" */
328 LPWSTR wszPatternString
= HeapAlloc(GetProcessHeap(), 0, maxValueLen
);
329 DWORD dwValueNameLen
= sizeof(wszValueName
) / sizeof(wszValueName
[0]); /* remember this is in chars */
330 DWORD dwDataLen
= maxValueLen
; /* remember this is in bytes */
332 if (RegEnumValueW(hkeyMinor
, indexValue
, wszValueName
, &dwValueNameLen
, NULL
, &dwType
, (LPBYTE
)wszPatternString
, &dwDataLen
) != ERROR_SUCCESS
)
334 HeapFree(GetProcessHeap(), 0, wszPatternString
);
338 if (strcmpW(wszValueName
, source_filter_name
)==0) {
339 HeapFree(GetProcessHeap(), 0, wszPatternString
);
343 /* if it is not the source filter value */
344 if (process_pattern_string(wszPatternString
, pReader
) == S_OK
)
346 HeapFree(GetProcessHeap(), 0, wszPatternString
);
347 if (majorType
&& FAILED(CLSIDFromString(wszMajorKeyName
, majorType
)))
349 if (minorType
&& FAILED(CLSIDFromString(wszMinorKeyName
, minorType
)))
353 /* Look up the source filter key */
354 if (RegQueryValueExW(hkeyMinor
, source_filter_name
, NULL
, NULL
, (LPBYTE
)wszSourceFilterKeyName
, &dwSourceFilterKeyNameLen
))
356 if (FAILED(CLSIDFromString(wszSourceFilterKeyName
, sourceFilter
)))
361 HeapFree(GetProcessHeap(), 0, wszPatternString
);
363 CloseHandle(hkeyMinor
);
366 CloseHandle(hkeyMajor
);
369 CloseHandle(hkeyMediaType
);
371 if (SUCCEEDED(hr
) && !bFound
)
373 ERR("Media class not found\n");
378 TRACE("Found file's class:\n");
380 TRACE("\tmajor = %s\n", qzdebugstr_guid(majorType
));
382 TRACE("\tsubtype = %s\n", qzdebugstr_guid(minorType
));
384 TRACE("\tsource filter = %s\n", qzdebugstr_guid(sourceFilter
));
390 static IPin
* WINAPI
AsyncReader_GetPin(BaseFilter
*iface
, int pos
)
392 AsyncReader
*This
= impl_from_BaseFilter(iface
);
394 TRACE("%p->(%d)\n", This
, pos
);
396 if (pos
>= 1 || !This
->pOutputPin
)
399 IPin_AddRef(This
->pOutputPin
);
400 return This
->pOutputPin
;
403 static LONG WINAPI
AsyncReader_GetPinCount(BaseFilter
*iface
)
405 AsyncReader
*This
= impl_from_BaseFilter(iface
);
407 TRACE("%p->()\n", This
);
409 if (!This
->pOutputPin
)
415 static const BaseFilterFuncTable BaseFuncTable
= {
417 AsyncReader_GetPinCount
420 HRESULT
AsyncReader_create(IUnknown
* pUnkOuter
, LPVOID
* ppv
)
422 AsyncReader
*pAsyncRead
;
425 return CLASS_E_NOAGGREGATION
;
427 pAsyncRead
= CoTaskMemAlloc(sizeof(AsyncReader
));
430 return E_OUTOFMEMORY
;
432 BaseFilter_Init(&pAsyncRead
->filter
, &AsyncReader_Vtbl
, &CLSID_AsyncReader
, (DWORD_PTR
)(__FILE__
": AsyncReader.csFilter"), &BaseFuncTable
);
434 pAsyncRead
->IFileSourceFilter_iface
.lpVtbl
= &FileSource_Vtbl
;
435 pAsyncRead
->IAMFilterMiscFlags_iface
.lpVtbl
= &IAMFilterMiscFlags_Vtbl
;
436 pAsyncRead
->pOutputPin
= NULL
;
438 pAsyncRead
->pszFileName
= NULL
;
439 pAsyncRead
->pmt
= NULL
;
443 TRACE("-- created at %p\n", pAsyncRead
);
448 /** IUnknown methods **/
450 static HRESULT WINAPI
AsyncReader_QueryInterface(IBaseFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
452 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
454 TRACE("%p->(%s, %p)\n", This
, qzdebugstr_guid(riid
), ppv
);
458 if (IsEqualIID(riid
, &IID_IUnknown
))
459 *ppv
= &This
->filter
.IBaseFilter_iface
;
460 else if (IsEqualIID(riid
, &IID_IPersist
))
461 *ppv
= &This
->filter
.IBaseFilter_iface
;
462 else if (IsEqualIID(riid
, &IID_IMediaFilter
))
463 *ppv
= &This
->filter
.IBaseFilter_iface
;
464 else if (IsEqualIID(riid
, &IID_IBaseFilter
))
465 *ppv
= &This
->filter
.IBaseFilter_iface
;
466 else if (IsEqualIID(riid
, &IID_IFileSourceFilter
))
467 *ppv
= &This
->IFileSourceFilter_iface
;
468 else if (IsEqualIID(riid
, &IID_IAMFilterMiscFlags
))
469 *ppv
= &This
->IAMFilterMiscFlags_iface
;
473 IUnknown_AddRef((IUnknown
*)(*ppv
));
477 if (!IsEqualIID(riid
, &IID_IPin
) && !IsEqualIID(riid
, &IID_IMediaSeeking
) &&
478 !IsEqualIID(riid
, &IID_IVideoWindow
) && !IsEqualIID(riid
, &IID_IBasicAudio
))
479 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
481 return E_NOINTERFACE
;
484 static ULONG WINAPI
AsyncReader_Release(IBaseFilter
* iface
)
486 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
487 ULONG refCount
= InterlockedDecrement(&This
->filter
.refCount
);
489 TRACE("%p->() Release from %d\n", This
, refCount
+ 1);
493 if (This
->pOutputPin
)
496 if(SUCCEEDED(IPin_ConnectedTo(This
->pOutputPin
, &pConnectedTo
)))
498 IPin_Disconnect(pConnectedTo
);
499 IPin_Release(pConnectedTo
);
501 IPin_Disconnect(This
->pOutputPin
);
502 IPin_Release(This
->pOutputPin
);
504 CoTaskMemFree(This
->pszFileName
);
506 FreeMediaType(This
->pmt
);
507 BaseFilter_Destroy(&This
->filter
);
515 /** IMediaFilter methods **/
517 static HRESULT WINAPI
AsyncReader_Stop(IBaseFilter
* iface
)
519 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
521 TRACE("%p->()\n", This
);
523 This
->filter
.state
= State_Stopped
;
528 static HRESULT WINAPI
AsyncReader_Pause(IBaseFilter
* iface
)
530 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
532 TRACE("%p->()\n", This
);
534 This
->filter
.state
= State_Paused
;
539 static HRESULT WINAPI
AsyncReader_Run(IBaseFilter
* iface
, REFERENCE_TIME tStart
)
541 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
543 TRACE("%p->(%s)\n", This
, wine_dbgstr_longlong(tStart
));
545 This
->filter
.state
= State_Running
;
550 /** IBaseFilter methods **/
552 static HRESULT WINAPI
AsyncReader_FindPin(IBaseFilter
* iface
, LPCWSTR Id
, IPin
**ppPin
)
554 AsyncReader
*This
= impl_from_IBaseFilter(iface
);
555 TRACE("%p->(%s, %p)\n", This
, debugstr_w(Id
), ppPin
);
560 if (strcmpW(Id
, wszOutputPinName
))
563 return VFW_E_NOT_FOUND
;
566 *ppPin
= This
->pOutputPin
;
571 static const IBaseFilterVtbl AsyncReader_Vtbl
=
573 AsyncReader_QueryInterface
,
574 BaseFilterImpl_AddRef
,
576 BaseFilterImpl_GetClassID
,
580 BaseFilterImpl_GetState
,
581 BaseFilterImpl_SetSyncSource
,
582 BaseFilterImpl_GetSyncSource
,
583 BaseFilterImpl_EnumPins
,
585 BaseFilterImpl_QueryFilterInfo
,
586 BaseFilterImpl_JoinFilterGraph
,
587 BaseFilterImpl_QueryVendorInfo
590 static HRESULT WINAPI
FileSource_QueryInterface(IFileSourceFilter
* iface
, REFIID riid
, LPVOID
* ppv
)
592 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
594 return IBaseFilter_QueryInterface(&This
->filter
.IBaseFilter_iface
, riid
, ppv
);
597 static ULONG WINAPI
FileSource_AddRef(IFileSourceFilter
* iface
)
599 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
601 return IBaseFilter_AddRef(&This
->filter
.IBaseFilter_iface
);
604 static ULONG WINAPI
FileSource_Release(IFileSourceFilter
* iface
)
606 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
608 return IBaseFilter_Release(&This
->filter
.IBaseFilter_iface
);
611 static HRESULT WINAPI
FileSource_Load(IFileSourceFilter
* iface
, LPCOLESTR pszFileName
, const AM_MEDIA_TYPE
* pmt
)
615 IAsyncReader
* pReader
= NULL
;
616 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
618 TRACE("%p->(%s, %p)\n", This
, debugstr_w(pszFileName
), pmt
);
624 /* FIXME: check the sharing values that native uses */
625 hFile
= CreateFileW(pszFileName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, FILE_FLAG_OVERLAPPED
, NULL
);
627 if (hFile
== INVALID_HANDLE_VALUE
)
629 return HRESULT_FROM_WIN32(GetLastError());
633 hr
= FileAsyncReader_Construct(hFile
, &This
->filter
.IBaseFilter_iface
, &This
->filter
.csFilter
, &This
->pOutputPin
);
634 BaseFilterImpl_IncrementPinVersion(&This
->filter
);
637 hr
= IPin_QueryInterface(This
->pOutputPin
, &IID_IAsyncReader
, (LPVOID
*)&pReader
);
639 /* store file name & media type */
642 CoTaskMemFree(This
->pszFileName
);
644 FreeMediaType(This
->pmt
);
646 This
->pszFileName
= CoTaskMemAlloc((strlenW(pszFileName
) + 1) * sizeof(WCHAR
));
647 strcpyW(This
->pszFileName
, pszFileName
);
649 This
->pmt
= CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE
));
652 This
->pmt
->bFixedSizeSamples
= TRUE
;
653 This
->pmt
->bTemporalCompression
= FALSE
;
654 This
->pmt
->cbFormat
= 0;
655 This
->pmt
->pbFormat
= NULL
;
656 This
->pmt
->pUnk
= NULL
;
657 This
->pmt
->lSampleSize
= 0;
658 This
->pmt
->formattype
= FORMAT_None
;
659 hr
= GetClassMediaFile(pReader
, pszFileName
, &This
->pmt
->majortype
, &This
->pmt
->subtype
, NULL
);
662 This
->pmt
->majortype
= MEDIATYPE_Stream
;
663 This
->pmt
->subtype
= MEDIASUBTYPE_NULL
;
668 CopyMediaType(This
->pmt
, pmt
);
672 IAsyncReader_Release(pReader
);
676 if (This
->pOutputPin
)
678 IPin_Release(This
->pOutputPin
);
679 This
->pOutputPin
= NULL
;
682 CoTaskMemFree(This
->pszFileName
);
684 FreeMediaType(This
->pmt
);
685 This
->pszFileName
= NULL
;
691 /* FIXME: check return codes */
695 static HRESULT WINAPI
FileSource_GetCurFile(IFileSourceFilter
* iface
, LPOLESTR
* ppszFileName
, AM_MEDIA_TYPE
* pmt
)
697 AsyncReader
*This
= impl_from_IFileSourceFilter(iface
);
699 TRACE("%p->(%p, %p)\n", This
, ppszFileName
, pmt
);
704 /* copy file name & media type if available, otherwise clear the outputs */
705 if (This
->pszFileName
)
707 *ppszFileName
= CoTaskMemAlloc((strlenW(This
->pszFileName
) + 1) * sizeof(WCHAR
));
708 strcpyW(*ppszFileName
, This
->pszFileName
);
711 *ppszFileName
= NULL
;
716 CopyMediaType(pmt
, This
->pmt
);
718 ZeroMemory(pmt
, sizeof(*pmt
));
724 static const IFileSourceFilterVtbl FileSource_Vtbl
=
726 FileSource_QueryInterface
,
730 FileSource_GetCurFile
734 /* the dwUserData passed back to user */
735 typedef struct DATAREQUEST
737 IMediaSample
* pSample
; /* sample passed to us by user */
738 DWORD_PTR dwUserData
; /* user data passed to us */
739 OVERLAPPED ovl
; /* our overlapped structure */
742 typedef struct FileAsyncReader
745 IAsyncReader IAsyncReader_iface
;
747 ALLOCATOR_PROPERTIES allocProps
;
750 /* Why would you need more? Every sample has its own handle */
754 CRITICAL_SECTION csList
; /* critical section to prevent concurrency issues */
755 DATAREQUEST
*sample_list
;
757 /* Have a handle for every sample, and then one more as flushing handle */
761 static inline FileAsyncReader
*impl_from_IPin(IPin
*iface
)
763 return CONTAINING_RECORD(iface
, FileAsyncReader
, pin
.pin
.IPin_iface
);
766 static inline FileAsyncReader
*impl_from_BasePin(BasePin
*iface
)
768 return CONTAINING_RECORD(iface
, FileAsyncReader
, pin
.pin
);
771 static inline FileAsyncReader
*impl_from_BaseOutputPin(BaseOutputPin
*iface
)
773 return CONTAINING_RECORD(iface
, FileAsyncReader
, pin
);
776 static inline BaseOutputPin
*impl_BaseOutputPin_from_BasePin(BasePin
*iface
)
778 return CONTAINING_RECORD(iface
, BaseOutputPin
, pin
);
781 static inline FileAsyncReader
*impl_from_IAsyncReader(IAsyncReader
*iface
)
783 return CONTAINING_RECORD(iface
, FileAsyncReader
, IAsyncReader_iface
);
786 static HRESULT WINAPI
FileAsyncReaderPin_QueryAccept(IPin
*iface
, const AM_MEDIA_TYPE
*pmt
)
788 FileAsyncReader
*This
= impl_from_IPin(iface
);
789 AM_MEDIA_TYPE
*pmt_filter
= impl_from_IBaseFilter(This
->pin
.pin
.pinInfo
.pFilter
)->pmt
;
791 FIXME("(%p, %p)\n", iface
, pmt
);
793 if (IsEqualGUID(&pmt
->majortype
, &pmt_filter
->majortype
) &&
794 IsEqualGUID(&pmt
->subtype
, &pmt_filter
->subtype
) &&
795 IsEqualGUID(&pmt
->formattype
, &FORMAT_None
))
801 static HRESULT WINAPI
FileAsyncReaderPin_GetMediaType(BasePin
*iface
, int iPosition
, AM_MEDIA_TYPE
*pmt
)
803 FileAsyncReader
*This
= impl_from_BasePin(iface
);
807 return VFW_S_NO_MORE_ITEMS
;
808 CopyMediaType(pmt
, impl_from_IBaseFilter(This
->pin
.pin
.pinInfo
.pFilter
)->pmt
);
812 /* overridden pin functions */
814 static HRESULT WINAPI
FileAsyncReaderPin_QueryInterface(IPin
* iface
, REFIID riid
, LPVOID
* ppv
)
816 FileAsyncReader
*This
= impl_from_IPin(iface
);
817 TRACE("(%s, %p)\n", qzdebugstr_guid(riid
), ppv
);
821 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IPin
))
822 *ppv
= &This
->pin
.pin
.IPin_iface
;
823 else if (IsEqualIID(riid
, &IID_IAsyncReader
))
824 *ppv
= &This
->IAsyncReader_iface
;
828 IUnknown_AddRef((IUnknown
*)*ppv
);
832 if (!IsEqualIID(riid
, &IID_IMediaSeeking
))
833 FIXME("No interface for %s!\n", qzdebugstr_guid(riid
));
835 return E_NOINTERFACE
;
838 static ULONG WINAPI
FileAsyncReaderPin_Release(IPin
* iface
)
840 FileAsyncReader
*This
= impl_from_IPin(iface
);
841 ULONG refCount
= InterlockedDecrement(&This
->pin
.pin
.refCount
);
844 TRACE("(%p)->() Release from %d\n", This
, refCount
+ 1);
848 CoTaskMemFree(This
->sample_list
);
849 if (This
->handle_list
)
851 for (x
= 0; x
<= This
->samples
; ++x
)
852 CloseHandle(This
->handle_list
[x
]);
853 CoTaskMemFree(This
->handle_list
);
855 CloseHandle(This
->hFile
);
856 This
->csList
.DebugInfo
->Spare
[0] = 0;
857 DeleteCriticalSection(&This
->csList
);
858 BaseOutputPin_Destroy(&This
->pin
);
864 static const IPinVtbl FileAsyncReaderPin_Vtbl
=
866 FileAsyncReaderPin_QueryInterface
,
868 FileAsyncReaderPin_Release
,
869 BaseOutputPinImpl_Connect
,
870 BaseOutputPinImpl_ReceiveConnection
,
871 BasePinImpl_Disconnect
,
872 BasePinImpl_ConnectedTo
,
873 BasePinImpl_ConnectionMediaType
,
874 BasePinImpl_QueryPinInfo
,
875 BasePinImpl_QueryDirection
,
877 FileAsyncReaderPin_QueryAccept
,
878 BasePinImpl_EnumMediaTypes
,
879 BasePinImpl_QueryInternalConnections
,
880 BaseOutputPinImpl_EndOfStream
,
881 BaseOutputPinImpl_BeginFlush
,
882 BaseOutputPinImpl_EndFlush
,
883 BasePinImpl_NewSegment
886 /* Function called as a helper to IPin_Connect */
887 /* specific AM_MEDIA_TYPE - it cannot be NULL */
888 /* this differs from standard OutputPin_AttemptConnection only in that it
889 * doesn't need the IMemInputPin interface on the receiving pin */
890 static HRESULT WINAPI
FileAsyncReaderPin_AttemptConnection(BasePin
* iface
, IPin
* pReceivePin
, const AM_MEDIA_TYPE
* pmt
)
892 BaseOutputPin
*This
= impl_BaseOutputPin_from_BasePin(iface
);
895 TRACE("%p->(%p, %p)\n", This
, pReceivePin
, pmt
);
896 dump_AM_MEDIA_TYPE(pmt
);
898 /* FIXME: call queryacceptproc */
900 This
->pin
.pConnectedTo
= pReceivePin
;
901 IPin_AddRef(pReceivePin
);
902 CopyMediaType(&This
->pin
.mtCurrent
, pmt
);
904 hr
= IPin_ReceiveConnection(pReceivePin
, &iface
->IPin_iface
, pmt
);
908 IPin_Release(This
->pin
.pConnectedTo
);
909 This
->pin
.pConnectedTo
= NULL
;
910 FreeMediaType(&This
->pin
.mtCurrent
);
913 TRACE(" -- %x\n", hr
);
917 static HRESULT WINAPI
FileAsyncReaderPin_DecideBufferSize(BaseOutputPin
*iface
, IMemAllocator
*pAlloc
, ALLOCATOR_PROPERTIES
*ppropInputRequest
)
919 FileAsyncReader
*This
= impl_from_BaseOutputPin(iface
);
920 ALLOCATOR_PROPERTIES actual
;
922 if (ppropInputRequest
->cbAlign
&& ppropInputRequest
->cbAlign
!= This
->allocProps
.cbAlign
)
923 FIXME("Requested Buffer cbAlign mismatch %i,%i\n",This
->allocProps
.cbAlign
, ppropInputRequest
->cbAlign
);
924 if (ppropInputRequest
->cbPrefix
)
925 FIXME("Requested Buffer cbPrefix mismatch %i,%i\n",This
->allocProps
.cbPrefix
, ppropInputRequest
->cbPrefix
);
926 if (ppropInputRequest
->cbBuffer
)
927 FIXME("Requested Buffer cbBuffer mismatch %i,%i\n",This
->allocProps
.cbBuffer
, ppropInputRequest
->cbBuffer
);
928 if (ppropInputRequest
->cBuffers
)
929 FIXME("Requested Buffer cBuffers mismatch %i,%i\n",This
->allocProps
.cBuffers
, ppropInputRequest
->cBuffers
);
931 return IMemAllocator_SetProperties(pAlloc
, &This
->allocProps
, &actual
);
934 static const BaseOutputPinFuncTable output_BaseOutputFuncTable
= {
937 FileAsyncReaderPin_AttemptConnection
,
938 BasePinImpl_GetMediaTypeVersion
,
939 FileAsyncReaderPin_GetMediaType
941 FileAsyncReaderPin_DecideBufferSize
,
942 BaseOutputPinImpl_DecideAllocator
,
943 BaseOutputPinImpl_BreakConnect
946 static HRESULT
FileAsyncReader_Construct(HANDLE hFile
, IBaseFilter
* pBaseFilter
, LPCRITICAL_SECTION pCritSec
, IPin
** ppPin
)
952 piOutput
.dir
= PINDIR_OUTPUT
;
953 piOutput
.pFilter
= pBaseFilter
;
954 strcpyW(piOutput
.achName
, wszOutputPinName
);
955 hr
= BaseOutputPin_Construct(&FileAsyncReaderPin_Vtbl
, sizeof(FileAsyncReader
), &piOutput
, &output_BaseOutputFuncTable
, pCritSec
, ppPin
);
959 FileAsyncReader
*pPinImpl
= (FileAsyncReader
*)*ppPin
;
960 pPinImpl
->IAsyncReader_iface
.lpVtbl
= &FileAsyncReader_Vtbl
;
961 pPinImpl
->hFile
= hFile
;
962 pPinImpl
->bFlushing
= FALSE
;
963 pPinImpl
->sample_list
= NULL
;
964 pPinImpl
->handle_list
= NULL
;
965 pPinImpl
->queued_number
= 0;
966 InitializeCriticalSection(&pPinImpl
->csList
);
967 pPinImpl
->csList
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": FileAsyncReader.csList");
974 static HRESULT WINAPI
FileAsyncReader_QueryInterface(IAsyncReader
* iface
, REFIID riid
, LPVOID
* ppv
)
976 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
978 return IPin_QueryInterface(&This
->pin
.pin
.IPin_iface
, riid
, ppv
);
981 static ULONG WINAPI
FileAsyncReader_AddRef(IAsyncReader
* iface
)
983 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
985 return IPin_AddRef(&This
->pin
.pin
.IPin_iface
);
988 static ULONG WINAPI
FileAsyncReader_Release(IAsyncReader
* iface
)
990 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
992 return IPin_Release(&This
->pin
.pin
.IPin_iface
);
995 #define DEF_ALIGNMENT 1
997 static HRESULT WINAPI
FileAsyncReader_RequestAllocator(IAsyncReader
* iface
, IMemAllocator
* pPreferred
, ALLOCATOR_PROPERTIES
* pProps
, IMemAllocator
** ppActual
)
999 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1003 TRACE("%p->(%p, %p, %p)\n", This
, pPreferred
, pProps
, ppActual
);
1005 if (!pProps
->cbAlign
|| (pProps
->cbAlign
% DEF_ALIGNMENT
) != 0)
1006 pProps
->cbAlign
= DEF_ALIGNMENT
;
1010 hr
= IMemAllocator_SetProperties(pPreferred
, pProps
, pProps
);
1011 /* FIXME: check we are still aligned */
1014 IMemAllocator_AddRef(pPreferred
);
1015 *ppActual
= pPreferred
;
1016 TRACE("FileAsyncReader_RequestAllocator -- %x\n", hr
);
1023 hr
= CoCreateInstance(&CLSID_MemoryAllocator
, NULL
, CLSCTX_INPROC
, &IID_IMemAllocator
, (LPVOID
*)&pPreferred
);
1027 hr
= IMemAllocator_SetProperties(pPreferred
, pProps
, pProps
);
1028 /* FIXME: check we are still aligned */
1031 *ppActual
= pPreferred
;
1032 TRACE("FileAsyncReader_RequestAllocator -- %x\n", hr
);
1039 CoTaskMemFree(This
->sample_list
);
1040 if (This
->handle_list
)
1043 for (x
= 0; x
<= This
->samples
; ++x
)
1044 CloseHandle(This
->handle_list
[x
]);
1045 CoTaskMemFree(This
->handle_list
);
1048 This
->samples
= pProps
->cBuffers
;
1049 This
->oldest_sample
= 0;
1050 TRACE("Samples: %u\n", This
->samples
);
1051 This
->sample_list
= CoTaskMemAlloc(sizeof(This
->sample_list
[0]) * pProps
->cBuffers
);
1052 This
->handle_list
= CoTaskMemAlloc(sizeof(HANDLE
) * pProps
->cBuffers
* 2);
1054 if (This
->sample_list
&& This
->handle_list
)
1057 ZeroMemory(This
->sample_list
, sizeof(This
->sample_list
[0]) * pProps
->cBuffers
);
1058 for (x
= 0; x
< This
->samples
; ++x
)
1060 This
->sample_list
[x
].ovl
.hEvent
= This
->handle_list
[x
] = CreateEventW(NULL
, 0, 0, NULL
);
1061 if (x
+ 1 < This
->samples
)
1062 This
->handle_list
[This
->samples
+ 1 + x
] = This
->handle_list
[x
];
1064 This
->handle_list
[This
->samples
] = CreateEventW(NULL
, 1, 0, NULL
);
1065 This
->allocProps
= *pProps
;
1070 CoTaskMemFree(This
->sample_list
);
1071 CoTaskMemFree(This
->handle_list
);
1073 This
->sample_list
= NULL
;
1074 This
->handle_list
= NULL
;
1082 IMemAllocator_Release(pPreferred
);
1085 TRACE("-- %x\n", hr
);
1089 /* we could improve the Request/WaitForNext mechanism by allowing out of order samples.
1090 * however, this would be quite complicated to do and may be a bit error prone */
1091 static HRESULT WINAPI
FileAsyncReader_Request(IAsyncReader
* iface
, IMediaSample
* pSample
, DWORD_PTR dwUser
)
1094 REFERENCE_TIME Start
;
1095 REFERENCE_TIME Stop
;
1096 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1097 LPBYTE pBuffer
= NULL
;
1099 TRACE("%p->(%p, %lx)\n", This
, pSample
, dwUser
);
1104 /* get start and stop positions in bytes */
1106 hr
= IMediaSample_GetTime(pSample
, &Start
, &Stop
);
1109 hr
= IMediaSample_GetPointer(pSample
, &pBuffer
);
1111 EnterCriticalSection(&This
->csList
);
1112 if (This
->bFlushing
)
1114 LeaveCriticalSection(&This
->csList
);
1115 return VFW_E_WRONG_STATE
;
1120 DWORD dwLength
= (DWORD
) BYTES_FROM_MEDIATIME(Stop
- Start
);
1121 DATAREQUEST
*pDataRq
;
1124 /* Try to insert above the waiting sample if possible */
1125 for (x
= This
->oldest_sample
; x
< This
->samples
; ++x
)
1127 if (!This
->sample_list
[x
].pSample
)
1131 if (x
>= This
->samples
)
1132 for (x
= 0; x
< This
->oldest_sample
; ++x
)
1134 if (!This
->sample_list
[x
].pSample
)
1138 /* There must be a sample we have found */
1139 assert(x
< This
->samples
);
1140 ++This
->queued_number
;
1142 pDataRq
= This
->sample_list
+ x
;
1144 pDataRq
->ovl
.u
.s
.Offset
= (DWORD
) BYTES_FROM_MEDIATIME(Start
);
1145 pDataRq
->ovl
.u
.s
.OffsetHigh
= (DWORD
)(BYTES_FROM_MEDIATIME(Start
) >> (sizeof(DWORD
) * 8));
1146 pDataRq
->dwUserData
= dwUser
;
1148 /* we violate traditional COM rules here by maintaining
1149 * a reference to the sample, but not calling AddRef, but
1150 * that's what MSDN says to do */
1151 pDataRq
->pSample
= pSample
;
1153 /* this is definitely not how it is implemented on Win9x
1154 * as they do not support async reads on files, but it is
1155 * sooo much easier to use this than messing around with threads!
1157 if (!ReadFile(This
->hFile
, pBuffer
, dwLength
, NULL
, &pDataRq
->ovl
))
1158 hr
= HRESULT_FROM_WIN32(GetLastError());
1160 /* ERROR_IO_PENDING is not actually an error since this is what we want! */
1161 if (hr
== HRESULT_FROM_WIN32(ERROR_IO_PENDING
))
1165 LeaveCriticalSection(&This
->csList
);
1167 TRACE("-- %x\n", hr
);
1171 static HRESULT WINAPI
FileAsyncReader_WaitForNext(IAsyncReader
* iface
, DWORD dwTimeout
, IMediaSample
** ppSample
, DWORD_PTR
* pdwUser
)
1174 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1177 TRACE("%p->(%u, %p, %p)\n", This
, dwTimeout
, ppSample
, pdwUser
);
1182 EnterCriticalSection(&This
->csList
);
1183 if (!This
->bFlushing
)
1185 LONG oldest
= This
->oldest_sample
;
1187 if (!This
->queued_number
)
1189 /* It could be that nothing is queued right now, but that can be fixed */
1190 WARN("Called without samples in queue and not flushing!!\n");
1192 LeaveCriticalSection(&This
->csList
);
1194 /* wait for an object to read, or time out */
1195 buffer
= WaitForMultipleObjectsEx(This
->samples
+1, This
->handle_list
+ oldest
, FALSE
, dwTimeout
, TRUE
);
1197 EnterCriticalSection(&This
->csList
);
1198 if (buffer
<= This
->samples
)
1200 /* Re-scale the buffer back to normal */
1203 /* Uh oh, we overshot the flusher handle, renormalize it back to 0..Samples-1 */
1204 if (buffer
> This
->samples
)
1205 buffer
-= This
->samples
+ 1;
1206 assert(buffer
<= This
->samples
);
1209 if (buffer
>= This
->samples
)
1211 if (buffer
!= This
->samples
)
1213 FIXME("Returned: %u (%08x)\n", buffer
, GetLastError());
1217 hr
= VFW_E_WRONG_STATE
;
1221 --This
->queued_number
;
1224 if (This
->bFlushing
&& buffer
== ~0)
1226 for (buffer
= 0; buffer
< This
->samples
; ++buffer
)
1228 if (This
->sample_list
[buffer
].pSample
)
1230 ResetEvent(This
->handle_list
[buffer
]);
1234 if (buffer
== This
->samples
)
1236 assert(!This
->queued_number
);
1241 --This
->queued_number
;
1248 REFERENCE_TIME rtStart
, rtStop
;
1249 REFERENCE_TIME rtSampleStart
, rtSampleStop
;
1250 DATAREQUEST
*pDataRq
= This
->sample_list
+ buffer
;
1253 /* get any errors */
1254 if (!This
->bFlushing
&& !GetOverlappedResult(This
->hFile
, &pDataRq
->ovl
, &dwBytes
, FALSE
))
1255 hr
= HRESULT_FROM_WIN32(GetLastError());
1257 /* Return the sample no matter what so it can be destroyed */
1258 *ppSample
= pDataRq
->pSample
;
1259 *pdwUser
= pDataRq
->dwUserData
;
1261 if (This
->bFlushing
)
1262 hr
= VFW_E_WRONG_STATE
;
1267 /* Set the time on the sample */
1268 IMediaSample_SetActualDataLength(pDataRq
->pSample
, dwBytes
);
1270 rtStart
= (DWORD64
)pDataRq
->ovl
.u
.s
.Offset
+ ((DWORD64
)pDataRq
->ovl
.u
.s
.OffsetHigh
<< 32);
1271 rtStart
= MEDIATIME_FROM_BYTES(rtStart
);
1272 rtStop
= rtStart
+ MEDIATIME_FROM_BYTES(dwBytes
);
1274 IMediaSample_GetTime(pDataRq
->pSample
, &rtSampleStart
, &rtSampleStop
);
1275 assert(rtStart
== rtSampleStart
);
1276 assert(rtStop
<= rtSampleStop
);
1278 IMediaSample_SetTime(pDataRq
->pSample
, &rtStart
, &rtStop
);
1279 assert(rtStart
== rtSampleStart
);
1281 assert(rtStop
== rtSampleStop
);
1283 assert(rtStop
== rtStart
);
1285 This
->sample_list
[buffer
].pSample
= NULL
;
1286 assert(This
->oldest_sample
< This
->samples
);
1288 if (buffer
== This
->oldest_sample
)
1291 for (x
= This
->oldest_sample
+ 1; x
< This
->samples
; ++x
)
1292 if (This
->sample_list
[x
].pSample
)
1294 if (x
>= This
->samples
)
1295 for (x
= 0; x
< This
->oldest_sample
; ++x
)
1296 if (This
->sample_list
[x
].pSample
)
1298 if (This
->oldest_sample
== x
)
1299 /* No samples found, reset to 0 */
1301 This
->oldest_sample
= x
;
1304 LeaveCriticalSection(&This
->csList
);
1306 TRACE("-- %x\n", hr
);
1310 static HRESULT WINAPI
FileAsyncReader_SyncRead(IAsyncReader
* iface
, LONGLONG llPosition
, LONG lLength
, BYTE
* pBuffer
);
1312 static HRESULT WINAPI
FileAsyncReader_SyncReadAligned(IAsyncReader
* iface
, IMediaSample
* pSample
)
1315 REFERENCE_TIME tStart
;
1316 REFERENCE_TIME tStop
;
1319 TRACE("(%p)\n", pSample
);
1321 hr
= IMediaSample_GetTime(pSample
, &tStart
, &tStop
);
1324 hr
= IMediaSample_GetPointer(pSample
, &pBuffer
);
1327 hr
= FileAsyncReader_SyncRead(iface
,
1328 BYTES_FROM_MEDIATIME(tStart
),
1329 (LONG
) BYTES_FROM_MEDIATIME(tStop
- tStart
),
1332 TRACE("-- %x\n", hr
);
1336 static HRESULT WINAPI
FileAsyncReader_SyncRead(IAsyncReader
* iface
, LONGLONG llPosition
, LONG lLength
, BYTE
* pBuffer
)
1340 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1342 TRACE("%p->(%s, %d, %p)\n", This
, wine_dbgstr_longlong(llPosition
), lLength
, pBuffer
);
1344 ZeroMemory(&ovl
, sizeof(ovl
));
1346 ovl
.hEvent
= CreateEventW(NULL
, 0, 0, NULL
);
1347 /* NOTE: llPosition is the actual byte position to start reading from */
1348 ovl
.u
.s
.Offset
= (DWORD
) llPosition
;
1349 ovl
.u
.s
.OffsetHigh
= (DWORD
) (llPosition
>> (sizeof(DWORD
) * 8));
1351 if (!ReadFile(This
->hFile
, pBuffer
, lLength
, NULL
, &ovl
))
1352 hr
= HRESULT_FROM_WIN32(GetLastError());
1354 if (hr
== HRESULT_FROM_WIN32(ERROR_IO_PENDING
))
1361 if (!GetOverlappedResult(This
->hFile
, &ovl
, &dwBytesRead
, TRUE
))
1362 hr
= HRESULT_FROM_WIN32(GetLastError());
1365 CloseHandle(ovl
.hEvent
);
1367 TRACE("-- %x\n", hr
);
1371 static HRESULT WINAPI
FileAsyncReader_Length(IAsyncReader
* iface
, LONGLONG
* pTotal
, LONGLONG
* pAvailable
)
1375 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1377 TRACE("%p->(%p, %p)\n", This
, pTotal
, pAvailable
);
1379 if (((dwSizeLow
= GetFileSize(This
->hFile
, &dwSizeHigh
)) == -1) &&
1380 (GetLastError() != NO_ERROR
))
1381 return HRESULT_FROM_WIN32(GetLastError());
1383 *pTotal
= (LONGLONG
)dwSizeLow
| (LONGLONG
)dwSizeHigh
<< (sizeof(DWORD
) * 8);
1385 *pAvailable
= *pTotal
;
1390 static HRESULT WINAPI
FileAsyncReader_BeginFlush(IAsyncReader
* iface
)
1392 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1394 TRACE("%p->()\n", This
);
1396 EnterCriticalSection(&This
->csList
);
1397 This
->bFlushing
= TRUE
;
1398 CancelIo(This
->hFile
);
1399 SetEvent(This
->handle_list
[This
->samples
]);
1400 LeaveCriticalSection(&This
->csList
);
1405 static HRESULT WINAPI
FileAsyncReader_EndFlush(IAsyncReader
* iface
)
1407 FileAsyncReader
*This
= impl_from_IAsyncReader(iface
);
1410 TRACE("%p->()\n", This
);
1412 EnterCriticalSection(&This
->csList
);
1413 ResetEvent(This
->handle_list
[This
->samples
]);
1414 This
->bFlushing
= FALSE
;
1415 for (x
= 0; x
< This
->samples
; ++x
)
1416 assert(!This
->sample_list
[x
].pSample
);
1418 LeaveCriticalSection(&This
->csList
);
1423 static const IAsyncReaderVtbl FileAsyncReader_Vtbl
=
1425 FileAsyncReader_QueryInterface
,
1426 FileAsyncReader_AddRef
,
1427 FileAsyncReader_Release
,
1428 FileAsyncReader_RequestAllocator
,
1429 FileAsyncReader_Request
,
1430 FileAsyncReader_WaitForNext
,
1431 FileAsyncReader_SyncReadAligned
,
1432 FileAsyncReader_SyncRead
,
1433 FileAsyncReader_Length
,
1434 FileAsyncReader_BeginFlush
,
1435 FileAsyncReader_EndFlush
,
1439 static HRESULT WINAPI
AMFilterMiscFlags_QueryInterface(IAMFilterMiscFlags
*iface
, REFIID riid
, void **ppv
) {
1440 AsyncReader
*This
= impl_from_IAMFilterMiscFlags(iface
);
1441 return IBaseFilter_QueryInterface(&This
->filter
.IBaseFilter_iface
, riid
, ppv
);
1444 static ULONG WINAPI
AMFilterMiscFlags_AddRef(IAMFilterMiscFlags
*iface
) {
1445 AsyncReader
*This
= impl_from_IAMFilterMiscFlags(iface
);
1446 return IBaseFilter_AddRef(&This
->filter
.IBaseFilter_iface
);
1449 static ULONG WINAPI
AMFilterMiscFlags_Release(IAMFilterMiscFlags
*iface
) {
1450 AsyncReader
*This
= impl_from_IAMFilterMiscFlags(iface
);
1451 return IBaseFilter_Release(&This
->filter
.IBaseFilter_iface
);
1454 static ULONG WINAPI
AMFilterMiscFlags_GetMiscFlags(IAMFilterMiscFlags
*iface
) {
1455 return AM_FILTER_MISC_FLAGS_IS_SOURCE
;
1458 static const IAMFilterMiscFlagsVtbl IAMFilterMiscFlags_Vtbl
= {
1459 AMFilterMiscFlags_QueryInterface
,
1460 AMFilterMiscFlags_AddRef
,
1461 AMFilterMiscFlags_Release
,
1462 AMFilterMiscFlags_GetMiscFlags