ReactOS 0.4.16-dev-297-gc569aee
pin.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PullPin
 

Macros

#define ALIGNDOWN(value, boundary)   ((value)/(boundary)*(boundary))
 
#define ALIGNUP(value, boundary)   (ALIGNDOWN((value)+(boundary)-1, (boundary)))
 
#define Req_Sleepy   0
 
#define Req_Die   1
 
#define Req_Run   2
 
#define Req_Pause   3
 

Typedefs

typedef HRESULT(* SAMPLEPROC_PULL) (LPVOID userdata, IMediaSample *pSample, DWORD_PTR cookie)
 
typedef HRESULT(* QUERYACCEPTPROC) (LPVOID userdata, const AM_MEDIA_TYPE *pmt)
 
typedef HRESULT(* PRECONNECTPROC) (IPin *iface, IPin *pConnectPin, ALLOCATOR_PROPERTIES *props)
 
typedef HRESULT(* CLEANUPPROC) (LPVOID userdata)
 
typedef HRESULT(* REQUESTPROC) (LPVOID userdata)
 
typedef HRESULT(* STOPPROCESSPROC) (LPVOID userdata)
 
typedef struct PullPin PullPin
 

Functions

HRESULT PullPin_Construct (const IPinVtbl *PullPin_Vtbl, const PIN_INFO *pPinInfo, SAMPLEPROC_PULL pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, REQUESTPROC pCustomRequest, STOPPROCESSPROC pDone, LPCRITICAL_SECTION pCritSec, IPin **ppPin)
 
HRESULT WINAPI PullPin_ReceiveConnection (IPin *iface, IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
 
HRESULT WINAPI PullPin_Disconnect (IPin *iface)
 
HRESULT WINAPI PullPin_QueryInterface (IPin *iface, REFIID riid, LPVOID *ppv)
 
ULONG WINAPI PullPin_Release (IPin *iface)
 
HRESULT WINAPI PullPin_EndOfStream (IPin *iface)
 
HRESULT WINAPI PullPin_QueryAccept (IPin *iface, const AM_MEDIA_TYPE *pmt)
 
HRESULT WINAPI PullPin_BeginFlush (IPin *iface)
 
HRESULT WINAPI PullPin_EndFlush (IPin *iface)
 
HRESULT WINAPI PullPin_NewSegment (IPin *iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
 
HRESULT PullPin_StartProcessing (PullPin *This)
 
HRESULT PullPin_PauseProcessing (PullPin *This)
 
HRESULT PullPin_WaitForStateChange (PullPin *This, DWORD dwMilliseconds)
 
static PullPinimpl_PullPin_from_IPin (IPin *iface)
 

Macro Definition Documentation

◆ ALIGNDOWN

#define ALIGNDOWN (   value,
  boundary 
)    ((value)/(boundary)*(boundary))

Definition at line 67 of file pin.h.

◆ ALIGNUP

#define ALIGNUP (   value,
  boundary 
)    (ALIGNDOWN((value)+(boundary)-1, (boundary)))

Definition at line 68 of file pin.h.

◆ Req_Die

#define Req_Die   1

Definition at line 102 of file pin.h.

◆ Req_Pause

#define Req_Pause   3

Definition at line 104 of file pin.h.

◆ Req_Run

#define Req_Run   2

Definition at line 103 of file pin.h.

◆ Req_Sleepy

#define Req_Sleepy   0

Definition at line 101 of file pin.h.

Typedef Documentation

◆ CLEANUPPROC

typedef HRESULT(* CLEANUPPROC) (LPVOID userdata)

Definition at line 50 of file pin.h.

◆ PRECONNECTPROC

typedef HRESULT(* PRECONNECTPROC) (IPin *iface, IPin *pConnectPin, ALLOCATOR_PROPERTIES *props)

Definition at line 43 of file pin.h.

◆ PullPin

◆ QUERYACCEPTPROC

typedef HRESULT(* QUERYACCEPTPROC) (LPVOID userdata, const AM_MEDIA_TYPE *pmt)

Definition at line 35 of file pin.h.

◆ REQUESTPROC

typedef HRESULT(* REQUESTPROC) (LPVOID userdata)

Definition at line 60 of file pin.h.

◆ SAMPLEPROC_PULL

typedef HRESULT(* SAMPLEPROC_PULL) (LPVOID userdata, IMediaSample *pSample, DWORD_PTR cookie)

Definition at line 29 of file pin.h.

◆ STOPPROCESSPROC

typedef HRESULT(* STOPPROCESSPROC) (LPVOID userdata)

Definition at line 65 of file pin.h.

Function Documentation

◆ impl_PullPin_from_IPin()

◆ PullPin_BeginFlush()

HRESULT WINAPI PullPin_BeginFlush ( IPin iface)

Definition at line 739 of file pin.c.

740{
742 TRACE("(%p)->()\n", This);
743
744 EnterCriticalSection(This->pin.pCritSec);
745 {
747 }
748 LeaveCriticalSection(This->pin.pCritSec);
749
750 EnterCriticalSection(&This->thread_lock);
751 {
752 if (This->pReader)
753 IAsyncReader_BeginFlush(This->pReader);
755
756 if (This->hThread && This->state == Req_Run)
757 {
760 }
761 }
762 LeaveCriticalSection(&This->thread_lock);
763
764 EnterCriticalSection(This->pin.pCritSec);
765 {
766 This->fnCleanProc(This->pUserData);
767 }
768 LeaveCriticalSection(This->pin.pCritSec);
769
770 return S_OK;
771}
#define NULL
Definition: types.h:112
static HRESULT deliver_beginflush(IPin *pin, LPVOID unused)
Definition: pin.c:158
static HRESULT SendFurther(IPin *from, SendPinFunc fnMiddle, LPVOID arg, SendPinFunc fnEnd)
Definition: pin.c:61
HRESULT PullPin_WaitForStateChange(PullPin *This, DWORD dwMilliseconds)
Definition: pin.c:708
HRESULT PullPin_PauseProcessing(PullPin *This)
Definition: pin.c:646
#define INFINITE
Definition: serial.h:102
#define S_OK
Definition: intsafe.h:52
#define Req_Run
Definition: pin.h:103
static PullPin * impl_PullPin_from_IPin(IPin *iface)
Definition: pin.h:132
#define TRACE(s)
Definition: solgame.cpp:4
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

◆ PullPin_Construct()

HRESULT PullPin_Construct ( const IPinVtbl *  PullPin_Vtbl,
const PIN_INFO pPinInfo,
SAMPLEPROC_PULL  pSampleProc,
LPVOID  pUserData,
QUERYACCEPTPROC  pQueryAccept,
CLEANUPPROC  pCleanUp,
REQUESTPROC  pCustomRequest,
STOPPROCESSPROC  pDone,
LPCRITICAL_SECTION  pCritSec,
IPin **  ppPin 
)

Definition at line 221 of file pin.c.

225{
226 PullPin * pPinImpl;
227
228 *ppPin = NULL;
229
230 if (pPinInfo->dir != PINDIR_INPUT)
231 {
232 ERR("Pin direction(%x) != PINDIR_INPUT\n", pPinInfo->dir);
233 return E_INVALIDARG;
234 }
235
236 pPinImpl = CoTaskMemAlloc(sizeof(*pPinImpl));
237
238 if (!pPinImpl)
239 return E_OUTOFMEMORY;
240
241 if (SUCCEEDED(PullPin_Init(PullPin_Vtbl, pPinInfo, pSampleProc, pUserData, pQueryAccept, pCleanUp, pCustomRequest, pDone, pCritSec, pPinImpl)))
242 {
243 *ppPin = &pPinImpl->pin.IPin_iface;
244 return S_OK;
245 }
246
247 CoTaskMemFree(pPinImpl);
248 return E_FAIL;
249}
@ PINDIR_INPUT
Definition: axcore.idl:41
#define ERR(fmt,...)
Definition: precomp.h:57
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
static HRESULT PullPin_Init(const IPinVtbl *PullPin_Vtbl, const PIN_INFO *pPinInfo, SAMPLEPROC_PULL pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, REQUESTPROC pCustomRequest, STOPPROCESSPROC pDone, LPCRITICAL_SECTION pCritSec, PullPin *pPinImpl)
Definition: pin.c:182
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
#define SUCCEEDED(hr)
Definition: intsafe.h:50
IPin IPin_iface
Definition: strmbase.h:35
BasePin pin
Definition: pin.h:73

Referenced by Parser_Create().

◆ PullPin_Disconnect()

HRESULT WINAPI PullPin_Disconnect ( IPin iface)

Definition at line 803 of file pin.c.

804{
805 HRESULT hr;
807
808 TRACE("()\n");
809
810 EnterCriticalSection(This->pin.pCritSec);
811 {
812 if (FAILED(hr = IMemAllocator_Decommit(This->pAlloc)))
813 ERR("Allocator decommit failed with error %x. Possible memory leak\n", hr);
814
815 if (This->pin.pConnectedTo)
816 {
817 IPin_Release(This->pin.pConnectedTo);
818 This->pin.pConnectedTo = NULL;
820
821 FreeMediaType(&This->pin.mtCurrent);
822 ZeroMemory(&This->pin.mtCurrent, sizeof(This->pin.mtCurrent));
823 hr = S_OK;
824 }
825 else
826 hr = S_FALSE;
827 }
828 LeaveCriticalSection(This->pin.pCritSec);
829
831 CloseHandle(This->hThread);
832 This->hThread = NULL;
833
834 return hr;
835}
static HRESULT PullPin_StopProcessing(PullPin *This)
Definition: pin.c:689
#define CloseHandle
Definition: compat.h:739
#define FAILED(hr)
Definition: intsafe.h:51
static void FreeMediaType(AM_MEDIA_TYPE *pMediaType)
Definition: filtergraph.c:692
HRESULT hr
Definition: shlfolder.c:183
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define ZeroMemory
Definition: winbase.h:1737
#define S_FALSE
Definition: winerror.h:2357

Referenced by Parser_PullPin_Disconnect().

◆ PullPin_EndFlush()

HRESULT WINAPI PullPin_EndFlush ( IPin iface)

Definition at line 773 of file pin.c.

774{
776
777 TRACE("(%p)->()\n", iface);
778
779 /* Send further first: Else a race condition might terminate processing early */
780 EnterCriticalSection(This->pin.pCritSec);
782 LeaveCriticalSection(This->pin.pCritSec);
783
784 EnterCriticalSection(&This->thread_lock);
785 {
786 FILTER_STATE state;
787
788 if (This->pReader)
789 IAsyncReader_EndFlush(This->pReader);
790
791 IBaseFilter_GetState(This->pin.pinInfo.pFilter, INFINITE, &state);
792
793 if (state != State_Stopped)
795
797 }
798 LeaveCriticalSection(&This->thread_lock);
799
800 return S_OK;
801}
static int state
Definition: maze.c:121
HRESULT PullPin_StartProcessing(PullPin *This)
Definition: pin.c:623
static HRESULT deliver_endflush(IPin *pin, LPVOID unused)
Definition: pin.c:163

◆ PullPin_EndOfStream()

HRESULT WINAPI PullPin_EndOfStream ( IPin iface)

Definition at line 724 of file pin.c.

725{
728
729 TRACE("(%p)->()\n", iface);
730
731 EnterCriticalSection(This->pin.pCritSec);
733 SetEvent(This->hEventStateChanged);
734 LeaveCriticalSection(This->pin.pCritSec);
735
736 return hr;
737}
static HRESULT deliver_endofstream(IPin *pin, LPVOID unused)
Definition: pin.c:153
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733

◆ PullPin_NewSegment()

HRESULT WINAPI PullPin_NewSegment ( IPin iface,
REFERENCE_TIME  tStart,
REFERENCE_TIME  tStop,
double  dRate 
)

Definition at line 837 of file pin.c.

838{
840 FIXME("(%p)->(%s, %s, %g) stub\n", iface, wine_dbgstr_longlong(tStart), wine_dbgstr_longlong(tStop), dRate);
841
842 args.tStart = tStart;
843 args.tStop = tStop;
844 args.rate = dRate;
845
846 return SendFurther( iface, deliver_newsegment, &args, NULL );
847}
#define FIXME(fmt,...)
Definition: precomp.h:53
static HRESULT deliver_newsegment(IPin *pin, LPVOID data)
Definition: pin.c:174
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define args
Definition: format.c:66
Definition: match.c:390

◆ PullPin_PauseProcessing()

HRESULT PullPin_PauseProcessing ( PullPin This)

Definition at line 646 of file pin.c.

647{
648 /* if we are connected */
649 TRACE("(%p)->()\n", This);
650 if(This->pAlloc)
651 {
652 assert(This->hThread);
653
655
656 EnterCriticalSection(This->pin.pCritSec);
657
658 assert(!This->stop_playback);
659 assert(This->state == Req_Run|| This->state == Req_Sleepy);
660
661 assert(WaitForSingleObject(This->thread_sleepy, 0) == WAIT_TIMEOUT);
662
663 This->state = Req_Pause;
664 This->stop_playback = TRUE;
665 ResetEvent(This->hEventStateChanged);
666 SetEvent(This->thread_sleepy);
667
668 /* Release any outstanding samples */
669 if (This->pReader)
670 {
671 IMediaSample *pSample;
672 DWORD_PTR dwUser;
673
674 do
675 {
676 pSample = NULL;
677 IAsyncReader_WaitForNext(This->pReader, 0, &pSample, &dwUser);
678 if (pSample)
679 IMediaSample_Release(pSample);
680 } while(pSample);
681 }
682
683 LeaveCriticalSection(This->pin.pCritSec);
684 }
685
686 return S_OK;
687}
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define TRUE
Definition: types.h:120
#define assert(x)
Definition: debug.h:53
#define Req_Pause
Definition: pin.h:104
#define Req_Sleepy
Definition: pin.h:101
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
uint32_t DWORD_PTR
Definition: typedefs.h:65

Referenced by Parser_Stop(), and PullPin_BeginFlush().

◆ PullPin_QueryAccept()

HRESULT WINAPI PullPin_QueryAccept ( IPin iface,
const AM_MEDIA_TYPE pmt 
)

Definition at line 715 of file pin.c.

716{
718
719 TRACE("(%p/%p)->(%p)\n", This, iface, pmt);
720
721 return (This->fnQueryAccept(This->pUserData, pmt) == S_OK ? S_OK : S_FALSE);
722}

◆ PullPin_QueryInterface()

HRESULT WINAPI PullPin_QueryInterface ( IPin iface,
REFIID  riid,
LPVOID ppv 
)

Definition at line 345 of file pin.c.

346{
348
349 TRACE("(%p/%p)->(%s, %p)\n", This, iface, qzdebugstr_guid(riid), ppv);
350
351 *ppv = NULL;
352
354 *ppv = iface;
355 else if (IsEqualIID(riid, &IID_IPin))
356 *ppv = iface;
357 else if (IsEqualIID(riid, &IID_IMediaSeeking) ||
358 IsEqualIID(riid, &IID_IQualityControl))
359 {
360 return IBaseFilter_QueryInterface(This->pin.pinInfo.pFilter, riid, ppv);
361 }
362
363 if (*ppv)
364 {
365 IUnknown_AddRef((IUnknown *)(*ppv));
366 return S_OK;
367 }
368
369 FIXME("No interface for %s!\n", qzdebugstr_guid(riid));
370
371 return E_NOINTERFACE;
372}
const GUID IID_IUnknown
const char * qzdebugstr_guid(const GUID *id)
Definition: main.c:279
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
const GUID IID_IPin
Definition: pincontrol.cpp:15
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

Referenced by Parser_PullPin_QueryInterface().

◆ PullPin_ReceiveConnection()

HRESULT WINAPI PullPin_ReceiveConnection ( IPin iface,
IPin pReceivePin,
const AM_MEDIA_TYPE pmt 
)

Definition at line 253 of file pin.c.

254{
255 PIN_DIRECTION pindirReceive;
256 HRESULT hr = S_OK;
258
259 TRACE("(%p/%p)->(%p, %p)\n", This, iface, pReceivePin, pmt);
261
262 EnterCriticalSection(This->pin.pCritSec);
263 if (!This->pin.pConnectedTo)
264 {
266
267 props.cBuffers = 3;
268 props.cbBuffer = 64 * 1024; /* 64 KB */
269 props.cbAlign = 1;
270 props.cbPrefix = 0;
271
272 if (This->fnQueryAccept(This->pUserData, pmt) != S_OK)
273 hr = VFW_E_TYPE_NOT_ACCEPTED; /* FIXME: shouldn't we just map common errors onto
274 * VFW_E_TYPE_NOT_ACCEPTED and pass the value on otherwise? */
275
276 if (SUCCEEDED(hr))
277 {
278 IPin_QueryDirection(pReceivePin, &pindirReceive);
279
280 if (pindirReceive != PINDIR_OUTPUT)
281 {
282 ERR("Can't connect from non-output pin\n");
284 }
285 }
286
287 This->pReader = NULL;
288 This->pAlloc = NULL;
289 This->prefAlloc = NULL;
290 if (SUCCEEDED(hr))
291 {
292 hr = IPin_QueryInterface(pReceivePin, &IID_IAsyncReader, (LPVOID *)&This->pReader);
293 }
294
295 if (SUCCEEDED(hr) && This->fnPreConnect)
296 {
297 hr = This->fnPreConnect(iface, pReceivePin, &props);
298 }
299
300 /*
301 * Some custom filters (such as the one used by Fallout 3
302 * and Fallout: New Vegas) expect to be passed a non-NULL
303 * preferred allocator.
304 */
305 if (SUCCEEDED(hr))
306 {
307 hr = StdMemAllocator_create(NULL, (LPVOID *) &This->prefAlloc);
308 }
309
310 if (SUCCEEDED(hr))
311 {
312 hr = IAsyncReader_RequestAllocator(This->pReader, This->prefAlloc, &props, &This->pAlloc);
313 }
314
315 if (SUCCEEDED(hr))
316 {
317 CopyMediaType(&This->pin.mtCurrent, pmt);
318 This->pin.pConnectedTo = pReceivePin;
319 IPin_AddRef(pReceivePin);
320 hr = IMemAllocator_Commit(This->pAlloc);
321 }
322
323 if (SUCCEEDED(hr))
325
326 if (FAILED(hr))
327 {
328 if (This->pReader)
329 IAsyncReader_Release(This->pReader);
330 This->pReader = NULL;
331 if (This->prefAlloc)
332 IMemAllocator_Release(This->prefAlloc);
333 This->prefAlloc = NULL;
334 if (This->pAlloc)
335 IMemAllocator_Release(This->pAlloc);
336 This->pAlloc = NULL;
337 }
338 }
339 else
341 LeaveCriticalSection(This->pin.pCritSec);
342 return hr;
343}
enum _PinDirection PIN_DIRECTION
@ PINDIR_OUTPUT
Definition: axcore.idl:42
const GUID IID_IAsyncReader
HRESULT StdMemAllocator_create(LPUNKNOWN lpUnkOuter, LPVOID *ppv)
Definition: memallocator.c:898
static HRESULT PullPin_InitProcessing(PullPin *This)
Definition: pin.c:578
static HRESULT CopyMediaType(AM_MEDIA_TYPE *pDest, const AM_MEDIA_TYPE *pSrc)
Definition: filtergraph.c:706
void dump_AM_MEDIA_TYPE(const AM_MEDIA_TYPE *pmt)
Definition: enummedia.c:38
#define VFW_E_ALREADY_CONNECTED
Definition: vfwmsgs.h:43
#define VFW_E_TYPE_NOT_ACCEPTED
Definition: vfwmsgs.h:81
#define VFW_E_INVALID_DIRECTION
Definition: vfwmsgs.h:47
static const WCHAR props[]
Definition: wbemdisp.c:288

Referenced by Parser_PullPin_ReceiveConnection().

◆ PullPin_Release()

ULONG WINAPI PullPin_Release ( IPin iface)

Definition at line 374 of file pin.c.

375{
377 ULONG refCount = InterlockedDecrement(&This->pin.refCount);
378
379 TRACE("(%p)->() Release from %d\n", This, refCount + 1);
380
381 if (!refCount)
382 {
383 WaitForSingleObject(This->hEventStateChanged, INFINITE);
384 assert(!This->hThread);
385
386 if(This->prefAlloc)
387 IMemAllocator_Release(This->prefAlloc);
388 if(This->pAlloc)
389 IMemAllocator_Release(This->pAlloc);
390 if(This->pReader)
391 IAsyncReader_Release(This->pReader);
392 CloseHandle(This->thread_sleepy);
393 CloseHandle(This->hEventStateChanged);
394 This->thread_lock.DebugInfo->Spare[0] = 0;
395 DeleteCriticalSection(&This->thread_lock);
397 return 0;
398 }
399 return refCount;
400}
#define InterlockedDecrement
Definition: armddk.h:52
uint32_t ULONG
Definition: typedefs.h:59
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

◆ PullPin_StartProcessing()

HRESULT PullPin_StartProcessing ( PullPin This)

Definition at line 623 of file pin.c.

624{
625 /* if we are connected */
626 TRACE("(%p)->()\n", This);
627 if(This->pAlloc)
628 {
629 assert(This->hThread);
630
632
633 assert(This->state == Req_Sleepy);
634
635 /* Wake up! */
636 assert(WaitForSingleObject(This->thread_sleepy, 0) == WAIT_TIMEOUT);
637 This->state = Req_Run;
638 This->stop_playback = FALSE;
639 ResetEvent(This->hEventStateChanged);
640 SetEvent(This->thread_sleepy);
641 }
642
643 return S_OK;
644}
#define FALSE
Definition: types.h:117

Referenced by Parser_Run(), and PullPin_EndFlush().

◆ PullPin_WaitForStateChange()

HRESULT PullPin_WaitForStateChange ( PullPin This,
DWORD  dwMilliseconds 
)

Definition at line 708 of file pin.c.

709{
710 if (WaitForSingleObject(This->hEventStateChanged, dwMilliseconds) == WAIT_TIMEOUT)
711 return S_FALSE;
712 return S_OK;
713}

Referenced by Parser_Destroy(), Parser_GetState(), Parser_Stop(), PullPin_BeginFlush(), PullPin_EndFlush(), PullPin_PauseProcessing(), PullPin_StartProcessing(), and PullPin_StopProcessing().