CBaseReferenceClock class implements a reference clock.
|Protected Member Variables||Description|
|m_pSchedule||CAMSchedule object that handles scheduling tasks for the clock.|
|GetPrivateTime||Retrieves the real time from the clock.|
|SetTimeDelta||Adjusts the internal clock time.|
|GetSchedule||Retrieves a pointer to the clock's scheduling object.|
|TriggerThread||Wakes up the worker thread that handles scheduling.|
|GetTime||Retrieves the current reference time.|
|AdviseTime||Creates a one-shot advise request.|
|AdvisePeriodic||Creates a periodic advise request.|
|Unadvise||Removes a pending advise request.|
|GetDefaultTimerResolution||Returns the current resolution of the reference clock's timer.|
|SetDefaultTimerResolution||Sets the resolution of the reference clock's timer.|
|ConvertToMilliseconds||Converts a reference time to milliseconds.|
This class implements a reference clock that supports the IReferenceClock and IReferenceClockTimerControl interfaces. If a filter can provide a reference clock for the filter graph—for example, by accessing a hardware device—it can use this class to implement the clock.
CBaseReferenceClock object maintains two distinct time values:
- Internally, the CBaseReferenceClock::GetPrivateTime method returns the actual time kept by the clock.
- Externally, the CBaseReferenceClock::GetTime method returns the reference time for the filter graph.
It is valid for the internal clock to run backward over brief periods. For example, if the clock drifts forward, the filter can adjust it backward. (See CBaseReferenceClock::SetTimeDelta.) The GetTime method uses the time values reported by GetPrivateTime. However, the reference time is monotonically increasing; in other words, it never runs backward. Therefore, if the internal clock runs backward, GetTime continues to report the old time until the internal clock catches up.
For example, the two methods might return the following sequences:
GetPrivateTime: 105, 106, 103, 104, 105, 106, 107, 108 GetTime: 105, 106, 106, 106, 106, 106, 107, 108
On the third clock tick, the internal clock jumps backward to 103. The GetTime method continues to report 106 until the internal clock catches up.
By default, GetPrivateTime returns the system time, through a call to the timeGetTime function. A filter that is providing a reference clock from an external device can do one of the following:
- Override GetPrivateTime to return the time from the device.
- Monitor the discrepancy between the device time and the system time, and call SetTimeDelta to make corrections.
This class uses a CAMSchedule object to handle scheduling of advise requests. For details, see the documentation for the CAMSchedule class.