rate. Right now, at 25ms between frames about 1 in 10 is delayed by a=
few ms. I've used other programs that manage to get this kind of
success at 10ms between frames.
I'm using a multimedia timer (see below) to get my current level of
accuracy. What can I do to improve things?
Thanks,
PaulH
int delay = 25; //25 ms between frames
HANDLE hSendNextFrame = CreateEvent( NULL, FALSE, FALSE, NULL );
Do you call timeBeginPeriod() before creating the periodic timer?
Something like:
TIMECAPS tc;
if (::timeGetDevCaps(&tc, sizeof(TIMECAPS)) == TIMERR_NOERROR)
{
// Try for 1ms resolution - accept best
UINT TimerRes = min(max(tc.wPeriodMin, 1), tc.wPeriodMax);
::timeBeginPeriod(TimerRes);
Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
MMRESULT mmNextFrameTimer = timeSetEvent( delay,
1,
reinterpret_cast<
LPTIMECALLBACK >( hSendNextFrame ),
NULL,
TIME_PERIODIC |
TIME_CALLBACK_EVENT_SET );
while( TRUE ) {
if( sendto( address, data ) < 0 ) {
//error condition
}
::WaitForSingleObject( hSendNextFrame, delay + 100 );
}
timeKillEvent( mmNextFrameTime );
CloseHandle( hSendNextFrame );
Good thought. But, timeSetEvent() already calls timeBeginPeriod() to
set the accuracy.
I tried it anyway to see if it helped. It did not.