ReactOS  0.4.15-dev-1171-gab82533
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)
 
- 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),
70  m_hEvent(NULL),
71  m_hThread(NULL),
76  m_Time(0)
77 {
78 }
REFERENCE_TIME m_Time
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
IReferenceClock * m_Clock

◆ ~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 NOERROR
Definition: winerror.h:2354
#define OutputDebugString
Definition: winbase.h:3730

◆ 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 
180  if (m_State == KSSTATE_ACQUIRE)
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 }
#define NOERROR
Definition: winerror.h:2354
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define OutputDebugString
Definition: winbase.h:3730
friend DWORD WINAPI CKsClockForwarder_ThreadStartup(LPVOID lpParameter)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define FALSE
Definition: types.h:117
HRESULT STDMETHODCALLTYPE SetClockState(KSSTATE State)
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:136
smooth NULL
Definition: ftsmooth.c:416
#define MAKE_HRESULT(sev, fac, code)
Definition: dmerror.h:30
#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 
100  if (IsEqualGUID(refiid, IID_IDistributorNotify))
101  {
102  *Output = (IDistributorNotify*)(this);
103  reinterpret_cast<IDistributorNotify*>(*Output)->AddRef();
104  return NOERROR;
105  }
106 
107  return E_NOINTERFACE;
108 }
#define E_NOINTERFACE
Definition: winerror.h:2364
#define NOERROR
Definition: winerror.h:2354
const GUID IID_IKsObject
void * PVOID
Definition: retypes.h:9
const GUID IID_IUnknown
const GUID IID_IKsClockForwarder
Definition: arc.h:85
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
const GUID IID_IDistributorNotify

◆ 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  {
214  m_ForceStart = TRUE;
215  HRESULT hr = Pause();
217 
218  if (FAILED(hr))
219  return hr;
220  }
221 
222  assert(m_hThread);
223 
226 
227  return NOERROR;
228 }
HRESULT hr
Definition: shlfolder.c:183
#define NOERROR
Definition: winerror.h:2354
#define TRUE
Definition: types.h:120
#define assert(x)
Definition: debug.h:53
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
REFERENCE_TIME m_Time
#define OutputDebugString
Definition: winbase.h:3730
#define FALSE
Definition: types.h:117
HRESULT STDMETHODCALLTYPE SetClockState(KSSTATE State)
LONG HRESULT
Definition: typedefs.h:79
HRESULT STDMETHODCALLTYPE Pause()

◆ 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 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
HRESULT hr
Definition: shlfolder.c:183
_In_ ULONG _In_ ULONG State
Definition: potypes.h:516
KSDDKAPI HRESULT WINAPI KsSynchronousDeviceControl(HANDLE Handle, ULONG IoControl, PVOID InBuffer, ULONG InLength, PVOID OutBuffer, ULONG OutLength, PULONG BytesReturned)
Definition: ksproxy.cpp:34
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
const GUID KSPROPSETID_Clock
Definition: pin.c:115
Definition: bufpool.h:45
_In_ LPCGUID _In_ SIZE_T _In_ SIZE_T _Out_opt_ PSIZE_T BytesReturned
Definition: potypes.h:549
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define swprintf(buf, format,...)
Definition: sprintf.c:56
static const WCHAR L[]
Definition: oid.c:1250
_In_ DWORD Property
Definition: setupapi.h:1545
KSSTATE
Definition: ks.h:1214
unsigned int ULONG
Definition: retypes.h:1
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
#define SUCCEEDED(hr)
Definition: intsafe.h:49

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 }
#define NOERROR
Definition: winerror.h:2354
#define OutputDebugString
Definition: winbase.h:3730
ULONG Release()
ULONG AddRef()
IReferenceClock * m_Clock

◆ 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 
131  assert(m_hThread);
132  assert(m_hEvent);
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:487
#define NOERROR
Definition: winerror.h:2354
#define assert(x)
Definition: debug.h:53
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
REFERENCE_TIME m_Time
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HRESULT STDMETHODCALLTYPE SetClockState(KSSTATE State)
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define swprintf(buf, format,...)
Definition: sprintf.c:56
static const WCHAR L[]
Definition: oid.c:1250
#define INFINITE
Definition: serial.h:102

Friends And Related Function Documentation

◆ CKsClockForwarder_ThreadStartup

DWORD WINAPI CKsClockForwarder_ThreadStartup ( LPVOID  lpParameter)
friend

Definition at line 299 of file clockforward.cpp.

300 {
303 
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 }
#define IOCTL_KS_PROPERTY
Definition: ks.h:127
#define NOERROR
Definition: winerror.h:2354
#define TRUE
Definition: types.h:120
KSDDKAPI HRESULT WINAPI KsSynchronousDeviceControl(HANDLE Handle, ULONG IoControl, PVOID InBuffer, ULONG InLength, PVOID OutBuffer, ULONG OutLength, PULONG BytesReturned)
Definition: ksproxy.cpp:34
REFERENCE_TIME m_Time
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
const GUID KSPROPSETID_Clock
Definition: pin.c:115
_In_ LPCGUID _In_ SIZE_T _In_ SIZE_T _Out_opt_ PSIZE_T BytesReturned
Definition: potypes.h:549
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
LPVOID lpParameter
Definition: kernel32.h:241
_In_ DWORD Property
Definition: setupapi.h:1545
unsigned int ULONG
Definition: retypes.h:1
#define INFINITE
Definition: serial.h:102
IReferenceClock * m_Clock
#define KSPROPERTY_TYPE_SET
Definition: dmksctrl.h:43
HRESULT GetTime([out] REFERENCE_TIME *pTime)
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 CKsClockForwarder_ThreadStartup(), and 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

◆ m_hEvent

HANDLE CKsClockForwarder::m_hEvent
protected

Definition at line 55 of file clockforward.cpp.

Referenced by CKsClockForwarder_ThreadStartup(), 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 CKsClockForwarder_ThreadStartup(), and 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 CKsClockForwarder_ThreadStartup(), Pause(), and SetClockState().

◆ m_ThreadStarted

BOOL CKsClockForwarder::m_ThreadStarted
protected

Definition at line 57 of file clockforward.cpp.

Referenced by CKsClockForwarder_ThreadStartup(), and Stop().

◆ m_Time

REFERENCE_TIME CKsClockForwarder::m_Time
protected

Definition at line 61 of file clockforward.cpp.

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


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