Odd, as when the bug would be in the EVR presenter it should be as buggy on all files. So, there should be some external dependancy as well that causes the issue to appear.
[..]
V-sync is driven by the display drivers, EVR presenter cannot change that. There could be a bug in the code that fails to schedule the samples to be displayed, but I still haven't figured out how such could affect the audio / video sync.
If I decode the sound instead of passthrough (so I can listed over headphones and the analog outputs of the HTPC) the effect is a little bit different. When the video starts to go out of sync, the internal player pauses for a fraction of a second and then continues, like it wants to catch up with audio. But sometimes it failed to do so (probably the drift is already too big) and pauses for nearly a second before continuing with the next frame resulting in being completly out of sync. This repeats over and over again. The effect here is similar to skip forward/skip backwards where audio and video are completly out of sync when using EVR. With VMR the problem does not come up.Have you tested the analog audio output?
Interesting idea. It could be that the drift only occurs when hardware acceleration is in place. Need to check some BIOS settings and turn of anything that "boots" or "optimizes" and could have an effect of the video clock speed. Cannot hurt to check. Thanks for the idea.I idea : be carreful to the bios and the bus optimisation. Mine can change automaticaly video clock +5% : disabled. FYI I have also a sync problem if I use post postprocessing.
Is there any debug/trace code in the dshowhelper.dll (I assume it contains the renderer interface)? I have Visual Studio 2008 installed on my machine and can compile MediaPortal SVN and also try out some stuff in the code if you point me roughly in the right direction where to look.
I started playback of movie with AVC video and AC3 audio this time. I resumed where I last left off. Horrible out of sync and slowly started to drift even more. I paused the movie and resumed, no difference. I then skipped back a little to get it in sync again. It was still a bit off and slowly drifted out of sync again for about the next 60-90 seconds.
I started playback of movie with AVC video and AC3 audio this time. I resumed where I last left off. Horrible out of sync and slowly started to drift even more. I paused the movie and resumed, no difference. I then skipped back a little to get it in sync again. It was still a bit off and slowly drifted out of sync again for about the next 60-90 seconds.
I can confirm that. I have exactly that behavior in my htpc. When I skip -15 sec the sync is ok.
Yes, audio is playing ahead of video and the gap keeps on increasing the longer the video plays. When it really gets bad some attempt to correct this is being bade. I assume this is the one second thingy in GetTimeToSchedule.Something odd as the video samples seems to get late, and that gap increases. Is the audio playing ahead of the video? To me it looks like EVR presenter is scheduling the samples wrongly, unfortunately I cannot see from the code whay would be wrong. It would be helpful if I could debug the issue.
Changing these values doesn't have any constant effect unless I change them dramatically which screws up things even more but don't have any affect on the drift.You could try changing few parameters. just for fun (try both, smaller and bigger values)
//too late, but present anyway
Log("frame is too late for %I64d ms, last sleep time %d ms.", -*pNextSampleTime/10000, msLastSleepTime );
CHECK_HR(PresentSample(pSample), "PresentSample failed");
//too late, but present anyway
Log("frame is too late for %I64d ms, last sleep time %d ms.", -*pNextSampleTime/10000, msLastSleepTime );
m_didSkip = true;
Log( "skipping frame, behind %I64d ms, last sleep time %d ms.", -*pNextSampleTime/10000, msLastSleepTime );
// CHECK_HR(PresentSample(pSample), "PresentSample failed");
10-09-2009 02:20:09.286 [dd4]OnClockRestart
10-09-2009 02:20:09.321 [bc8]dangerous and unlikely time to schedule [0D909258]: 1597710534. scheduled time: 1597970384, now: 259850
10-09-2009 02:20:09.321 [bc8]Flushing: size=3
10-09-2009 02:20:09.444 [d08]Scheduling sample from the past (133 ms, last call to NotifyWorker: 155 ms)
10-09-2009 02:20:09.444 [bc8]frame is too late for 133 ms, last sleep time 20 ms.
10-09-2009 02:20:09.444 [bc8]skipping frame, behind 133 ms, last sleep time 20 ms.
10-09-2009 02:20:09.449 [d08]Scheduling sample from the past (96 ms, last call to NotifyWorker: 5 ms)
10-09-2009 02:20:09.450 [bc8]frame is too late for 96 ms, last sleep time 20 ms.
10-09-2009 02:20:09.450 [bc8]skipping frame, behind 96 ms, last sleep time 20 ms.
10-09-2009 02:20:09.454 [d08]Scheduling sample from the past (60 ms, last call to NotifyWorker: 4 ms)
10-09-2009 02:20:09.454 [bc8]frame is too late for 60 ms, last sleep time 20 ms.
10-09-2009 02:20:09.454 [bc8]skipping frame, behind 60 ms, last sleep time 20 ms.
10-09-2009 02:20:09.459 [d08]Scheduling sample from the past (23 ms, last call to NotifyWorker: 5 ms)
10-09-2009 02:20:23.633 [dd4]OnClockPause
Index: EVRCustomPresenter.cpp
===================================================================
--- EVRCustomPresenter.cpp (revision 23545)
+++ EVRCustomPresenter.cpp (working copy)
@@ -1347,8 +1347,13 @@
else
{
//too late, but present anyway
- Log("frame is too late for %I64d ms, last sleep time %d ms.", -*pNextSampleTime/10000, msLastSleepTime );
- CHECK_HR(PresentSample(pSample), "PresentSample failed");
+ //Log("frame is too late for %I64d ms, last sleep time %d ms.", -*pNextSampleTime/10000, msLastSleepTime );
+ //CHECK_HR(PresentSample(pSample), "PresentSample failed");
+
+ //too late, don't present
+ m_iFramesDropped++;
+ m_didSkip = true;
+ Log( "skipping frame, behind %I64d ms, last sleep time %d ms.", -*pNextSampleTime/10000, msLastSleepTime );
}
}
else
One question: why are late frames displayed anyway? I don't really understand the reason for this. At least when frames are continously late skipping needs to occur. Unless a higher refresh rate can compensate for it. Then it would make sense just to display the frames for an accelerated playback (see assumption futher up). But this would break as soon as the problems occur on the material's native rate with a lag higher than the time a single frame is displayed.
This is where a workaround could be implemented even though the root cause is not known. Either skipping frames on playback start or ignoring vsync and display samples immediately until playback is in sync. The lag increases because nothing is early enough for compensation (vsync might play a role here), but I won't investigate this one because it's only a side effect. Focus should be on being in sync in the first place or getting there after playbacks starts as quick and smooth as possible.