On Friday 14 March 2008 04:25:02 pm Maarten Lankhorst wrote:
Use the fallback system IReferenceClock, unless the app comes up with its own clock.
This doesn't look right. According to MSDN, the clock used when Run is called is chosen by the following algorithm:
1- The app called IMediaFilter::SetSyncSource
2- A live filter source is connected to the graph and supports the IReferenceClock interface
3- Any filters support IReferenceClock, starting with renderers and going "upstream" (following pin connections to the source), and falling back to disconnected filters if still nothing. Normally, an audio renderer would be selected here.
4- If still nothing, use the system reference clock.
I don't think SetDefaultSyncSource should should just jump right to the system clock. As far as I can tell, you need to hold a reference to a clock, and a bool saying if it's custom set (as even NULL can be a valid custom override). When Run is called, if no custom override is set, it would release the current set clock (if any) and check as steps 2, 3, and 4 describe.
So really what the function needs to do is release the current set reference clock (if non-NULL), clear a custom-override flag (while SetSyncSource sets the custom-override flag and holds a reference for non-NULL filters), and check steps 2, 3, and 4. So something like:
SetSyncSource(clock) { if(this->ref_clock) this->ref_clock->Release(); this->ref_clock = clock; if(clock) clock->AddRef(); this->custom_clock = TRUE; } SetDefaultSyncSource() { SetSyncSource(NULL); this->custom_clock = FALSE; ...do steps 2, 3, and 4... this->ref_clock = selected_clock; } Run() { if(!this->custom_clock) SetDefaultSyncSource(); ...run... }
Hi Chris,
2008/3/14, Chris Robinson chris.kcat@gmail.com:
On Friday 14 March 2008 04:25:02 pm Maarten Lankhorst wrote:
Use the fallback system IReferenceClock, unless the app comes up with its own clock.
This doesn't look right. According to MSDN, the clock used when Run is called is chosen by the following algorithm:
1- The app called IMediaFilter::SetSyncSource
2- A live filter source is connected to the graph and supports the IReferenceClock interface
3- Any filters support IReferenceClock, starting with renderers and going "upstream" (following pin connections to the source), and falling back to disconnected filters if still nothing. Normally, an audio renderer would be selected here.
4- If still nothing, use the system reference clock.
Almost right.
You're specifying behavior when doing 'run'.
Quoting msdn on IFilterGraph::SetSyncSource: "This method instructs the Filter Graph Manager to choose a reference clock using its default algorithm. For more information about the algorithm that it uses, see Reference Clocks."
There are also strict criteria for live filter sources (basically webcams or microphones), and when a ireferenceclock will be used from audio. It needs to expose some interfaces before it is chosen as reference clock. This patch sets the reference clock to the system clock, unless overridden by the application. When SetDefaultSyncSource is called the clock is reset to the system clock.
This isn't entirely conforming, but it's the best solution at the moment.
Cheers, Maarten.