Comment 124 for bug 278318

Revision history for this message
In , Will Uther (willu-mailinglists) wrote :

Started doing some debugging.

The mythtv vsync code is here: <http://svn.mythtv.org/trac/browser/trunk/mythtv/libs/libmythtv/vsync.cpp>.

If you edit the function drmWaitVBlank() on line 264 to include some calls to gettimeofday() and print out when the wait is less than 10ms, you'll see plenty of output.

If you look in the function DRMVideoSync::WaitForFrame() at line 325 you'll see some commented out debug statements. If you uncomment them you get:

WaitForFrame at : 15548 Delay at first sync: 7750
Wait 1 intervals. Count 60491126 Delay -8970
WaitForFrame at : 24978 Delay at first sync: 14499
Wait 1 intervals. Count 60491128 Delay -2240
WaitForFrame at : 46073 Delay at first sync: 37744
Wait 3 intervals. Count 60491132 Delay -12440
WaitForFrame at : 20562 Delay at first sync: 11037
Wait 1 intervals. Count 60491134 Delay -5689
WaitForFrame at : 28353 Delay at first sync: 17584
Wait 2 intervals. Count 60491137 Delay -15875
WaitForFrame at : 16296 Delay at first sync: 7597

The waitForFrame number is how long myth thinks you should wait from the time that function is called until the next frame should be displayed - i.e. how long it thinks it should sleep for. It then tries to sleep until the next vblank. It then calculates how long it has to sleep until it is near the next frame and shows that as the Delay number on the first line. i.e. the difference between those two numbers is how long the ioctl actually waited. Also note that the second number should be around 0 if myth was perfectly synced. This wont happen as there is 20ms between video frames and 16ms between vsyncs.