ReactOS 0.4.15-dev-5669-g09dde2c
CKsClockForwarder Class Reference
Inheritance diagram for CKsClockForwarder:
Collaboration diagram for CKsClockForwarder:

Public Member Functions

STDMETHODIMP QueryInterface (REFIID InterfaceId, PVOID *Interface)
 
 STDMETHODIMP_ (ULONG) AddRef()
 
 STDMETHODIMP_ (ULONG) Release()
 
HRESULT STDMETHODCALLTYPE Stop ()
 
HRESULT STDMETHODCALLTYPE Pause ()
 
HRESULT STDMETHODCALLTYPE Run (REFERENCE_TIME tStart)
 
HRESULT STDMETHODCALLTYPE SetSyncSource (IReferenceClock *pClock)
 
HRESULT STDMETHODCALLTYPE NotifyGraphChange ()
 
HANDLE STDMETHODCALLTYPE KsGetObjectHandle ()
 
 CKsClockForwarder (HANDLE handle)
 
virtual ~CKsClockForwarder ()
 
HRESULT STDMETHODCALLTYPE SetClockState (KSSTATE State)
 
HRESULT Stop (void)
 
HRESULT Pause (void)
 
HRESULT Run (REFERENCE_TIME tStart)
 
HRESULT SetSyncSource ([in] IReferenceClock *pClock)
 
HRESULT NotifyGraphChange (void)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Protected Attributes

LONG m_Ref
 
HANDLE m_Handle
 
IReferenceClockm_Clock
 
HANDLE m_hEvent
 
HANDLE m_hThread
 
BOOL m_ThreadStarted
 
BOOL m_PendingStop
 
BOOL m_ForceStart
 
KSSTATE m_State
 
REFERENCE_TIME m_Time
 

Friends

DWORD WINAPI CKsClockForwarder_ThreadStartup (LPVOID lpParameter)
 

Additional Inherited Members

- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 

Detailed Description

Definition at line 15 of file clockforward.cpp.

Constructor & Destructor Documentation

◆ CKsClockForwarder()

CKsClockForwarder::CKsClockForwarder ( HANDLE  handle)

Definition at line 66 of file clockforward.cpp.

67 : m_Ref(0),
69 m_Clock(0),
76 m_Time(0)
77{
78}
IReferenceClock * m_Clock
REFERENCE_TIME m_Time
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
@ KSSTATE_STOP
Definition: ks.h:1215

◆ ~CKsClockForwarder()

virtual CKsClockForwarder::~CKsClockForwarder ( )
inlinevirtual

Definition at line 49 of file clockforward.cpp.

49{};

Member Function Documentation

◆ KsGetObjectHandle()

HANDLE STDMETHODCALLTYPE CKsClockForwarder::KsGetObjectHandle ( )

Definition at line 267 of file clockforward.cpp.

268{
269 return m_Handle;
270}

◆ NotifyGraphChange()

HRESULT STDMETHODCALLTYPE CKsClockForwarder::NotifyGraphChange ( void  )

Implements IDistributorNotify.

Definition at line 252 of file clockforward.cpp.

253{
254#ifdef KSPROXY_TRACE
255 OutputDebugString("CKsClockForwarder::NotifyGraphChange\n");
256#endif
257
258 return NOERROR;
259}
#define OutputDebugString
Definition: winbase.h:3761
#define NOERROR
Definition: winerror.h:2354

◆ Pause()

HRESULT STDMETHODCALLTYPE CKsClockForwarder::Pause ( void  )

Implements IDistributorNotify.

Definition at line 162 of file clockforward.cpp.

163{
164#ifdef KSPROXY_TRACE
165 OutputDebugString("CKsClockForwarder::Pause\n");
166#endif
167
168 if (!m_hEvent)
169 {
171 if (!m_hEvent)
173 }
174
175 if (m_State <= KSSTATE_PAUSE)
176 {
177 if (m_State == KSSTATE_STOP)
179
182 }
183 else
184 {
185 if (!m_ForceStart)
186 {
188 }
189 }
190
191 if (!m_hThread)
192 {
194 if (!m_hThread)
196 }
197
198 return NOERROR;
199}
HRESULT STDMETHODCALLTYPE SetClockState(KSSTATE State)
friend DWORD WINAPI CKsClockForwarder_ThreadStartup(LPVOID lpParameter)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
@ KSSTATE_ACQUIRE
Definition: ks.h:1216
@ KSSTATE_PAUSE
Definition: ks.h:1217
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
#define SEVERITY_ERROR
Definition: winerror.h:65
#define FACILITY_WIN32
Definition: winerror.h:27

Referenced by Run().

◆ QueryInterface()

HRESULT STDMETHODCALLTYPE CKsClockForwarder::QueryInterface ( REFIID  InterfaceId,
PVOID Interface 
)

Definition at line 82 of file clockforward.cpp.

85{
86 if (IsEqualGUID(refiid, IID_IUnknown))
87 {
88 *Output = PVOID(this);
89 reinterpret_cast<IUnknown*>(*Output)->AddRef();
90 return NOERROR;
91 }
92 if (IsEqualGUID(refiid, IID_IKsObject) ||
94 {
95 *Output = (IKsObject*)(this);
96 reinterpret_cast<IKsObject*>(*Output)->AddRef();
97 return NOERROR;
98 }
99
101 {
102 *Output = (IDistributorNotify*)(this);
103 reinterpret_cast<IDistributorNotify*>(*Output)->AddRef();
104 return NOERROR;
105 }
106
107 return E_NOINTERFACE;
108}
const GUID IID_IUnknown
const GUID IID_IKsClockForwarder
const GUID IID_IKsObject
const GUID IID_IDistributorNotify
ULONG AddRef()
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
@ Output
Definition: arc.h:85
void * PVOID
Definition: typedefs.h:50
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ Run()

HRESULT STDMETHODCALLTYPE CKsClockForwarder::Run ( REFERENCE_TIME  tStart)

Implements IDistributorNotify.

Definition at line 203 of file clockforward.cpp.

205{
206#ifdef KSPROXY_TRACE
207 OutputDebugString("CKsClockForwarder::Run\n");
208#endif
209
210 m_Time = tStart;
211
212 if (!m_hEvent || !m_hThread)
213 {
215 HRESULT hr = Pause();
217
218 if (FAILED(hr))
219 return hr;
220 }
221
223
226
227 return NOERROR;
228}
HRESULT STDMETHODCALLTYPE Pause()
#define TRUE
Definition: types.h:120
#define assert(x)
Definition: debug.h:53
#define FAILED(hr)
Definition: intsafe.h:51
@ KSSTATE_RUN
Definition: ks.h:1218
HRESULT hr
Definition: shlfolder.c:183
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733

◆ SetClockState()

HRESULT STDMETHODCALLTYPE CKsClockForwarder::SetClockState ( KSSTATE  State)

Definition at line 275 of file clockforward.cpp.

276{
279
283
285 if (SUCCEEDED(hr))
286 m_State = State;
287
288#ifdef KSPROXY_TRACE
289 WCHAR Buffer[100];
290 swprintf(Buffer, L"CKsClockForwarder::SetClockState m_State %u State %u hr %lx\n", m_State, State, hr);
292#endif
293
294 return hr;
295}
Definition: bufpool.h:45
#define swprintf
Definition: precomp.h:40
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
KSSTATE
Definition: ks.h:1214
@ KSPROPERTY_CLOCK_STATE
Definition: ks.h:323
#define KSPROPSETID_Clock
Definition: ks.h:315
KSDDKAPI HRESULT WINAPI KsSynchronousDeviceControl(HANDLE Handle, ULONG IoControl, PVOID InBuffer, ULONG InLength, PVOID OutBuffer, ULONG OutLength, PULONG BytesReturned)
Definition: ksproxy.cpp:34
#define L(x)
Definition: ntvdm.h:50
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesReturned
Definition: wdfiotarget.h:1052
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by Pause(), Run(), and Stop().

◆ SetSyncSource()

HRESULT STDMETHODCALLTYPE CKsClockForwarder::SetSyncSource ( IReferenceClock pClock)

Implements IDistributorNotify.

Definition at line 232 of file clockforward.cpp.

234{
235#ifdef KSPROXY_TRACE
236 OutputDebugString("CKsClockForwarder::SetSyncSource\n");
237#endif
238
239 if (pClock)
240 pClock->AddRef();
241
242 if (m_Clock)
243 m_Clock->Release();
244
245
246 m_Clock = pClock;
247 return NOERROR;
248}
ULONG Release()

◆ STDMETHODIMP_() [1/2]

CKsClockForwarder::STDMETHODIMP_ ( ULONG  )
inline

Definition at line 21 of file clockforward.cpp.

22 {
24 return m_Ref;
25 }
#define InterlockedIncrement
Definition: armddk.h:53

◆ STDMETHODIMP_() [2/2]

CKsClockForwarder::STDMETHODIMP_ ( ULONG  )
inline

Definition at line 26 of file clockforward.cpp.

27 {
29
30 if (!m_Ref)
31 {
32 delete this;
33 return 0;
34 }
35 return m_Ref;
36 }
#define InterlockedDecrement
Definition: armddk.h:52

◆ Stop()

HRESULT STDMETHODCALLTYPE CKsClockForwarder::Stop ( void  )

Implements IDistributorNotify.

Definition at line 117 of file clockforward.cpp.

118{
119#ifdef KSPROXY_TRACE
120 WCHAR Buffer[200];
121 swprintf(Buffer, L"CKsClockForwarder::Stop m_ThreadStarted %u m_PendingStop %u m_hThread %p m_hEvent %p m_Handle %p\n", m_ThreadStarted, m_PendingStop, m_hThread, m_hEvent, m_Handle);
123#endif
124
125 m_Time = 0;
126 if (m_ThreadStarted)
127 {
128 // signal pending stop
129 m_PendingStop = true;
130
133
134 // set stop event
136
137 // wait untill the thread has finished
139
140 // close thread handle
142
143 // zero handle
144 m_hThread = NULL;
145 }
146
147 if (m_hEvent)
148 {
149 // close stop event
151 m_hEvent = NULL;
152 }
153
154 m_PendingStop = false;
155
157 return NOERROR;
158}
#define CloseHandle
Definition: compat.h:739
#define INFINITE
Definition: serial.h:102
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82

Friends And Related Function Documentation

◆ CKsClockForwarder_ThreadStartup

DWORD WINAPI CKsClockForwarder_ThreadStartup ( LPVOID  lpParameter)
friend

Definition at line 299 of file clockforward.cpp.

300{
303
304 CKsClockForwarder * Fwd = (CKsClockForwarder*)lpParameter;
305
306 Fwd->m_ThreadStarted = TRUE;
307
308 do
309 {
310 if (Fwd->m_PendingStop)
311 break;
312
313 if (Fwd->m_State != KSSTATE_RUN)
315
320
321 Fwd->m_Clock->GetTime(&Time);
322 Time -= Fwd->m_Time;
323
325 }
326 while(TRUE);
327
328 Fwd->m_ThreadStarted = FALSE;
329 return NOERROR;
330}
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
HRESULT GetTime([out] REFERENCE_TIME *pTime)
@ KSPROPERTY_CLOCK_TIME
Definition: ks.h:318
static PLARGE_INTEGER Time
Definition: time.c:105

Referenced by Pause().

Member Data Documentation

◆ m_Clock

IReferenceClock* CKsClockForwarder::m_Clock
protected

Definition at line 54 of file clockforward.cpp.

Referenced by SetSyncSource().

◆ m_ForceStart

BOOL CKsClockForwarder::m_ForceStart
protected

Definition at line 59 of file clockforward.cpp.

Referenced by Pause(), and Run().

◆ m_Handle

HANDLE CKsClockForwarder::m_Handle
protected

Definition at line 53 of file clockforward.cpp.

Referenced by KsGetObjectHandle(), SetClockState(), and Stop().

◆ m_hEvent

HANDLE CKsClockForwarder::m_hEvent
protected

Definition at line 55 of file clockforward.cpp.

Referenced by Pause(), Run(), and Stop().

◆ m_hThread

HANDLE CKsClockForwarder::m_hThread
protected

Definition at line 56 of file clockforward.cpp.

Referenced by Pause(), Run(), and Stop().

◆ m_PendingStop

BOOL CKsClockForwarder::m_PendingStop
protected

Definition at line 58 of file clockforward.cpp.

Referenced by Stop().

◆ m_Ref

LONG CKsClockForwarder::m_Ref
protected

Definition at line 52 of file clockforward.cpp.

Referenced by STDMETHODIMP_().

◆ m_State

KSSTATE CKsClockForwarder::m_State
protected

Definition at line 60 of file clockforward.cpp.

Referenced by Pause(), and SetClockState().

◆ m_ThreadStarted

BOOL CKsClockForwarder::m_ThreadStarted
protected

Definition at line 57 of file clockforward.cpp.

Referenced by Stop().

◆ m_Time

REFERENCE_TIME CKsClockForwarder::m_Time
protected

Definition at line 61 of file clockforward.cpp.

Referenced by Run(), and Stop().


The documentation for this class was generated from the following file: