Here's a 1/2 early scheduling dshowhelper.dll with delay = 0 for late frames in the scheduler and a sleep(3) removed. In case you want to try this more "aggressive" version that tries to render frames even earlier. It's my current development version trying out to find some ways to enhance playback (so far out of luck on my machine).
You can easily play with the values and the delay here as all the relevant lines are listed in the patch.
What might also help is bumping the thread priority up. But this was commented out in the EVR presenter before I started to work on it, therefore I never put it in again as somebody must have done this for a reason. I run MP and Halli (increased buffer as well) at higher priority.
If this really helps on your machines we need to do more tests. As said I have rarely dropped frames on my box and when they are some (beside of the beginning of playback) they are huge because of external events on my machine (it does other stuff in the background).
Edit: DLL removed as it didn't work better
You can easily play with the values and the delay here as all the relevant lines are listed in the patch.
What might also help is bumping the thread priority up. But this was commented out in the EVR presenter before I started to work on it, therefore I never put it in again as somebody must have done this for a reason. I run MP and Halli (increased buffer as well) at higher priority.
Code:
Index: source/EVRCustomPresenter.cpp
===================================================================
--- source/EVRCustomPresenter.cpp (revision 24764)
+++ source/EVRCustomPresenter.cpp (working copy)
@@ -1078,8 +1078,8 @@
}
LOG_TRACE("Time to schedule: %I64d", *pNextSampleTime);
- // If we are ahead up to one quarter of a frame present sample as the vsync will be waited for anyway
- if (*pNextSampleTime > m_rtTimePerFrame/4)
+ // If we are ahead up to one half + 1ms of a frame present sample as the vsync will be waited for anyway
+ if (*pNextSampleTime > (m_rtTimePerFrame/2)+10000)
{
break;
}
@@ -1101,8 +1101,6 @@
else
{
CHECK_HR(PresentSample(pSample), "PresentSample failed");
- // EXPERIMENTAL: give other threads some time to breath
- Sleep(3);
}
*pNextSampleTime = 0;
ReturnSample(pSample, TRUE);
Index: source/Scheduler.cpp
===================================================================
--- source/Scheduler.cpp (revision 24764)
+++ source/Scheduler.cpp (working copy)
@@ -110,13 +110,13 @@
timePerFrame = p->pPresenter->GetFrameDuration();
if (hnsSampleTime > 0)
{
- // wait for 3/4 sample time or 3/4 of frame duration depending on what is smaller
- delay = min((hnsSampleTime/100*75), (timePerFrame/100*75));
+ // wait for 1/2 sample time or 1/2 of frame duration depending on what is smaller
+ delay = min((hnsSampleTime/2), (timePerFrame/2));
}
else
{
- // workaround for unknown bugs
- delay = timePerFrame/100*25;
+ // do not schedule late frames
+ delay = 0;
}
if (delay >= 10000)
{
If this really helps on your machines we need to do more tests. As said I have rarely dropped frames on my box and when they are some (beside of the beginning of playback) they are huge because of external events on my machine (it does other stuff in the background).
Edit: DLL removed as it didn't work better