winedos: Fixed a problem with timer values that are below 50ms.

This commit is contained in:
Peter Dons Tychsen 2008-11-26 22:22:41 +01:00 committed by Alexandre Julliard
parent cb7a0da5db
commit 7160d8c709
1 changed files with 20 additions and 4 deletions

View File

@ -58,6 +58,8 @@ static UINT TIMER_ticks = 0;
/* Number of pending timer IRQs. */
static LONG TIMER_pending = 0;
/* Number of milliseconds between IRQs. */
static DWORD TIMER_millis = 0;
/***********************************************************************
* TIMER_Relay
@ -81,11 +83,11 @@ static void CALLBACK TIMER_TimerProc( HWND hwnd,
DWORD dwTime )
{
LONG pending = InterlockedIncrement( &TIMER_pending );
DWORD delta = (dwTime >= TIMER_stamp) ?
(dwTime - TIMER_stamp) : (0xffffffff - (TIMER_stamp - dwTime));
if (pending >= TIMER_MAX_PENDING)
{
DWORD delta = (dwTime >= TIMER_stamp) ?
(dwTime - TIMER_stamp) : (0xffffffff - (TIMER_stamp - dwTime));
if (delta >= 60000)
{
@ -97,8 +99,19 @@ static void CALLBACK TIMER_TimerProc( HWND hwnd,
}
else
{
TIMER_stamp = dwTime;
DOSVM_QueueEvent( 0, DOS_PRIORITY_REALTIME, TIMER_Relay, NULL );
int i;
/* Calculate the number of valid timer interrupts we can generate */
DWORD count = delta / TIMER_millis;
/* Forward the timestamp with the time used */
TIMER_stamp += (count * TIMER_millis);
/* Generate interrupts */
for(i=0;i<count;i++)
{
DOSVM_QueueEvent( 0, DOS_PRIORITY_REALTIME, TIMER_Relay, NULL );
}
}
}
@ -122,6 +135,9 @@ static void WINAPI TIMER_DoSetTimer( ULONG_PTR arg )
TIMER_id = SetTimer( NULL, 0, millis, TIMER_TimerProc );
TIMER_stamp = GetTickCount();
TIMER_ticks = arg;
/* Remember number of milliseconds to wait */
TIMER_millis = millis;
}