Synchronizing the VMR to the Monitor's Refresh Rate
Microsoft DirectShow 9.0 |
Synchronizing the VMR to the Monitor's Refresh Rate
In rare scenarios, you may wish to precisely synchronize video rendering with the monitor's refresh rate, so that exactly one new frame is presented each time the monitor refreshes. The most reliable way to do this is to create a custom allocator-presenter that uses a flip operation instead of a blit operation to write the video bits into the primary surface. "Flip" is called each time the monitor refreshes, so if your video stream contains no time stamps, the VMR will render as fast as possible to the primary surface, but the surface will block the stream until the Flip operation completes. This means that, as long as the CPU is not overburdened, the next frame will always be waiting in the primary surface each time the monitor refreshes. However, if some other CPU-intensive process is running, it could possibly starve your DirectShow streaming thread so that it cannot deliver video frames fast enough to the primary surface.