1
0

sysclock.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //------------------------------------------------------------------------------
  2. // File: SysClock.cpp
  3. //
  4. // Desc: DirectShow base classes - implements a system clock based on
  5. // IReferenceClock.
  6. //
  7. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
  8. //------------------------------------------------------------------------------
  9. #include <streams.h>
  10. #include <limits.h>
  11. #ifdef FILTER_DLL
  12. /* List of class IDs and creator functions for the class factory. This
  13. provides the link between the OLE entry point in the DLL and an object
  14. being created. The class factory will call the static CreateInstance
  15. function when it is asked to create a CLSID_SystemClock object */
  16. CFactoryTemplate g_Templates[1] = {
  17. {&CLSID_SystemClock, CSystemClock::CreateInstance}
  18. };
  19. int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
  20. #endif
  21. /* This goes in the factory template table to create new instances */
  22. CUnknown * WINAPI CSystemClock::CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr)
  23. {
  24. return new CSystemClock(NAME("System reference clock"),pUnk, phr);
  25. }
  26. CSystemClock::CSystemClock(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr) :
  27. CBaseReferenceClock(pName, pUnk, phr)
  28. {
  29. }
  30. STDMETHODIMP CSystemClock::NonDelegatingQueryInterface(
  31. REFIID riid,
  32. __deref_out void ** ppv)
  33. {
  34. if (riid == IID_IPersist)
  35. {
  36. return GetInterface(static_cast<IPersist *>(this), ppv);
  37. }
  38. else if (riid == IID_IAMClockAdjust)
  39. {
  40. return GetInterface(static_cast<IAMClockAdjust *>(this), ppv);
  41. }
  42. else
  43. {
  44. return CBaseReferenceClock::NonDelegatingQueryInterface(riid, ppv);
  45. }
  46. }
  47. /* Return the clock's clsid */
  48. STDMETHODIMP
  49. CSystemClock::GetClassID(__out CLSID *pClsID)
  50. {
  51. CheckPointer(pClsID,E_POINTER);
  52. ValidateReadWritePtr(pClsID,sizeof(CLSID));
  53. *pClsID = CLSID_SystemClock;
  54. return NOERROR;
  55. }
  56. STDMETHODIMP
  57. CSystemClock::SetClockDelta(REFERENCE_TIME rtDelta)
  58. {
  59. return SetTimeDelta(rtDelta);
  60. }