Add AppDefaults app selection to control panel
[wine/gsoc-2012-control.git] / dlls / quartz / pin.h
blob428fa6fe8e4eae29356f9490340a9fefba59e5ed
1 /*
2 * IPin function declarations to allow inheritance
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 /* This function will process incoming samples to the pin.
22 * Any return value valid in IMemInputPin::Receive is allowed here
24 * Cookie is the cookie that was set when requesting the buffer, if you don't
25 * implement custom requesting, you can safely ignore this
27 typedef HRESULT (* SAMPLEPROC_PULL)(LPVOID userdata, IMediaSample * pSample, DWORD_PTR cookie);
29 /* This function will determine whether a type is supported or not.
30 * It is allowed to return any error value (within reason), as opposed
31 * to IPin::QueryAccept which is only allowed to return S_OK or S_FALSE.
33 typedef HRESULT (* QUERYACCEPTPROC)(LPVOID userdata, const AM_MEDIA_TYPE * pmt);
35 /* This function is called prior to finalizing a connection with
36 * another pin and can be used to get things from the other pin
37 * like IMemInput interfaces.
39 * props contains some defaults, but you can safely override them to your liking
41 typedef HRESULT (* PRECONNECTPROC)(IPin * iface, IPin * pConnectPin, ALLOCATOR_PROPERTIES *props);
43 /* This function is called whenever a cleanup operation has to occur,
44 * this is usually after a flush, seek, or end of stream notification.
45 * This code may even be repeated multiple times, so build your code to
46 * tolerate this behavior. Return value is ignored and should be S_OK.
48 typedef HRESULT (* CLEANUPPROC) (LPVOID userdata);
50 /* This function is called whenever a request for a new sample is made,
51 * If you implement it (it can be NULL for default behavior), you have to
52 * call IMemAllocator_GetBuffer and IMemAllocator_RequestBuffer
53 * This is useful if you want to request more than 1 buffer at simultaneously
55 * This will also cause the Sample Proc to be called with empty buffers to indicate
56 * failure in retrieving the sample.
58 typedef HRESULT (* REQUESTPROC) (LPVOID userdata);
60 /* This function is called after processing is done (for whatever reason that is caused)
61 * This is useful if you create processing threads that need to die
63 typedef HRESULT (* STOPPROCESSPROC) (LPVOID userdata);
65 #define ALIGNDOWN(value,boundary) ((value)/(boundary)*(boundary))
66 #define ALIGNUP(value,boundary) (ALIGNDOWN((value)+(boundary)-1, (boundary)))
68 typedef struct PullPin
70 /* inheritance C style! */
71 BasePin pin;
72 LPVOID pUserData;
74 REFERENCE_TIME rtStart, rtCurrent, rtNext, rtStop;
75 IAsyncReader * pReader;
76 IMemAllocator * prefAlloc;
77 IMemAllocator * pAlloc;
78 QUERYACCEPTPROC fnQueryAccept;
79 SAMPLEPROC_PULL fnSampleProc;
80 PRECONNECTPROC fnPreConnect;
81 REQUESTPROC fnCustomRequest;
82 CLEANUPPROC fnCleanProc;
83 STOPPROCESSPROC fnDone;
84 double dRate;
85 BOOL stop_playback;
86 DWORD cbAlign;
88 /* Any code that touches the thread must hold the thread lock,
89 * lock order: thread_lock and then the filter critical section
90 * also signal thread_sleepy so the thread knows to wake up
92 CRITICAL_SECTION thread_lock;
93 HANDLE hThread;
94 DWORD requested_state;
95 HANDLE hEventStateChanged, thread_sleepy;
96 DWORD state;
97 } PullPin;
99 #define Req_Sleepy 0
100 #define Req_Die 1
101 #define Req_Run 2
102 #define Req_Pause 3
104 /*** Constructors ***/
105 HRESULT PullPin_Construct(const IPinVtbl *PullPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PULL pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, STOPPROCESSPROC, REQUESTPROC pCustomRequest, LPCRITICAL_SECTION pCritSec, IPin ** ppPin);
107 /**************************/
108 /*** Pin Implementation ***/
110 /* Pull Pin */
111 HRESULT WINAPI PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
112 HRESULT WINAPI PullPin_Disconnect(IPin * iface);
113 HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv);
114 ULONG WINAPI PullPin_Release(IPin * iface);
115 HRESULT WINAPI PullPin_EndOfStream(IPin * iface);
116 HRESULT WINAPI PullPin_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt);
117 HRESULT WINAPI PullPin_BeginFlush(IPin * iface);
118 HRESULT WINAPI PullPin_EndFlush(IPin * iface);
119 HRESULT WINAPI PullPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
121 /* Thread interaction functions: Hold the thread_lock before calling them */
122 HRESULT PullPin_StartProcessing(PullPin * This);
123 HRESULT PullPin_PauseProcessing(PullPin * This);
124 HRESULT PullPin_WaitForStateChange(PullPin * This, DWORD dwMilliseconds);
126 /* COM helpers */
127 static inline PullPin *impl_PullPin_from_IPin( IPin *iface )
129 return CONTAINING_RECORD(iface, PullPin, pin.IPin_iface);