|Microsoft DirectX 9.0|
One function of the Filter Graph Manager is to synchronize all of the filters in the graph to the same clock, called the reference clock.
Any object that exposes the IReferenceClock interface can act as the reference clock. The reference clock might be provided by a DirectShow filter typically the audio renderer, which has access to a hardware timer. As a fallback, the Filter Graph Manager can use the system time.
Nominally, a reference clock measures time in 100-nanosecond intervals, although the actual accuracy of the clock might be less. To retrieve the clock's current time, call the IReferenceClock::GetTime method. The clock's baselinethe time from which it starts countingdepends on the implementation, so the value returned by GetTime is not inherently meaningful. What matters is the delta from when the graph started running.
Although the accuracy of a reference clock can vary, the times returned by the GetTime method are guaranteed to increase monotonically. In other words, clock times will never go backward. If a reference clock is generating clock times from a hardware source and the hardware clock jumps backward (for example, if there is an adjustment to the clock), the GetTime method should continue to return the last reported time until the hardware clock catches up. For more information, see CBaseReferenceClock Class.
Default Reference Clock
The Filter Graph Manager automatically selects a reference clock when the graph runs. It uses the following algorithm to select the clock:
Setting the Reference Clock
An application can select a clock by calling the IMediaFilter::SetSyncSource method on the Filter Graph Manager. You should do this only if you have a particular reason to prefer another clock.
You can instruct the Filter Graph Manager not to use a reference clock by calling SetSyncSource with the value NULL. For example, you might do this to process samples as quickly as possible. To restore the default reference clock, call the IFilterGraph::SetDefaultSyncSource method on the Filter Graph Manager.
Whenever the reference clock changes, the Filter Graph Manager notifies each filter by calling its IMediaFilter::SetSyncSource method. Applications should never call this method on filters.