Commit 1a229642 authored by Ove Kaaven's avatar Ove Kaaven Committed by Alexandre Julliard

Use service thread for "true" multimedia timers.

Removed implementation of fake multimedia timers. Set minimum resolution to 10 ms (the timing resolution of the Linux kernel). Fixed a couple of flaws.
parent 155168eb
...@@ -14,14 +14,13 @@ ...@@ -14,14 +14,13 @@
#include "callback.h" #include "callback.h"
#include "mmsystem.h" #include "mmsystem.h"
#include "xmalloc.h" #include "xmalloc.h"
#include "services.h"
#include "options.h" #include "options.h"
#include "debugtools.h" #include "debugtools.h"
DECLARE_DEBUG_CHANNEL(mmsys) DECLARE_DEBUG_CHANNEL(mmsys)
DECLARE_DEBUG_CHANNEL(mmtime) DECLARE_DEBUG_CHANNEL(mmtime)
#define USE_FAKE_MM_TIMERS
static MMTIME16 mmSysTimeMS; static MMTIME16 mmSysTimeMS;
static MMTIME16 mmSysTimeSMPTE; static MMTIME16 mmSysTimeSMPTE;
...@@ -39,12 +38,7 @@ typedef struct tagTIMERENTRY { ...@@ -39,12 +38,7 @@ typedef struct tagTIMERENTRY {
} TIMERENTRY, *LPTIMERENTRY; } TIMERENTRY, *LPTIMERENTRY;
static LPTIMERENTRY lpTimerList = NULL; static LPTIMERENTRY lpTimerList = NULL;
static HANDLE hMMTimer;
#ifdef USE_FAKE_MM_TIMERS
static DWORD dwLastCBTick = 0;
static BOOL bUseFakeTimers = FALSE;
static WORD wInCallBackLoop = 0;
#endif
/* /*
* FIXME * FIXME
...@@ -52,7 +46,7 @@ static WORD wInCallBackLoop = 0; ...@@ -52,7 +46,7 @@ static WORD wInCallBackLoop = 0;
* as Windows 95 does, according to the docs. Maybe it should * as Windows 95 does, according to the docs. Maybe it should
* depend on the computers resources! * depend on the computers resources!
*/ */
#define MMSYSTIME_MININTERVAL (1) #define MMSYSTIME_MININTERVAL /* (1) */ (10)
#define MMSYSTIME_MAXINTERVAL (65535) #define MMSYSTIME_MAXINTERVAL (65535)
static void TIME_TriggerCallBack(LPTIMERENTRY lpTimer, DWORD dwCurrent) static void TIME_TriggerCallBack(LPTIMERENTRY lpTimer, DWORD dwCurrent)
...@@ -99,30 +93,20 @@ static void TIME_TriggerCallBack(LPTIMERENTRY lpTimer, DWORD dwCurrent) ...@@ -99,30 +93,20 @@ static void TIME_TriggerCallBack(LPTIMERENTRY lpTimer, DWORD dwCurrent)
/************************************************************************** /**************************************************************************
* TIME_MMSysTimeCallback * TIME_MMSysTimeCallback
*/ */
static VOID WINAPI TIME_MMSysTimeCallback( HWND hwnd, UINT msg, static VOID CALLBACK TIME_MMSysTimeCallback( ULONG_PTR dummy )
UINT id, DWORD dwTime )
{ {
LPTIMERENTRY lpTimer; LPTIMERENTRY lpTimer;
mmSysTimeMS.u.ms += MMSYSTIME_MININTERVAL; mmSysTimeMS.u.ms += MMSYSTIME_MININTERVAL;
mmSysTimeSMPTE.u.smpte.frame++; mmSysTimeSMPTE.u.smpte.frame++;
#ifdef USE_FAKE_MM_TIMERS for (lpTimer = lpTimerList; lpTimer != NULL; lpTimer = lpTimer->Next) {
if (bUseFakeTimers) if (lpTimer->wCurTime < MMSYSTIME_MININTERVAL) {
dwLastCBTick = GetTickCount(); TIME_TriggerCallBack(lpTimer, mmSysTimeMS.u.ms);
} else {
if (!wInCallBackLoop++) lpTimer->wCurTime -= MMSYSTIME_MININTERVAL;
#endif
for (lpTimer = lpTimerList; lpTimer != NULL; lpTimer = lpTimer->Next) {
if (lpTimer->wCurTime < MMSYSTIME_MININTERVAL) {
TIME_TriggerCallBack(lpTimer, dwTime);
} else {
lpTimer->wCurTime -= MMSYSTIME_MININTERVAL;
}
} }
#ifdef USE_FAKE_MM_TIMERS }
wInCallBackLoop--;
#endif
} }
/************************************************************************** /**************************************************************************
...@@ -135,7 +119,7 @@ static void StartMMTime() ...@@ -135,7 +119,7 @@ static void StartMMTime()
if (!mmTimeStarted) { if (!mmTimeStarted) {
mmTimeStarted = TRUE; mmTimeStarted = TRUE;
mmSysTimeMS.wType = TIME_MS; mmSysTimeMS.wType = TIME_MS;
mmSysTimeMS.u.ms = 0; mmSysTimeMS.u.ms = GetTickCount();
mmSysTimeSMPTE.wType = TIME_SMPTE; mmSysTimeSMPTE.wType = TIME_SMPTE;
mmSysTimeSMPTE.u.smpte.hour = 0; mmSysTimeSMPTE.u.smpte.hour = 0;
mmSysTimeSMPTE.u.smpte.min = 0; mmSysTimeSMPTE.u.smpte.min = 0;
...@@ -143,13 +127,7 @@ static void StartMMTime() ...@@ -143,13 +127,7 @@ static void StartMMTime()
mmSysTimeSMPTE.u.smpte.frame = 0; mmSysTimeSMPTE.u.smpte.frame = 0;
mmSysTimeSMPTE.u.smpte.fps = 0; mmSysTimeSMPTE.u.smpte.fps = 0;
mmSysTimeSMPTE.u.smpte.dummy = 0; mmSysTimeSMPTE.u.smpte.dummy = 0;
SetTimer( 0, 0, MMSYSTIME_MININTERVAL, TIME_MMSysTimeCallback ); hMMTimer = SERVICE_AddTimer( MMSYSTIME_MININTERVAL*1000L, TIME_MMSysTimeCallback, 0 );
#ifdef USE_FAKE_MM_TIMERS
bUseFakeTimers = PROFILE_GetWineIniBool("options", "MMFakeTimers", TRUE);
TRACE_(mmtime)("FakeTimer=%c\n", bUseFakeTimers ? 'Y' : 'N');
if (bUseFakeTimers)
dwLastCBTick = GetTickCount();
#endif
} }
} }
...@@ -336,36 +314,6 @@ MMRESULT16 WINAPI timeEndPeriod16(UINT16 wPeriod) ...@@ -336,36 +314,6 @@ MMRESULT16 WINAPI timeEndPeriod16(UINT16 wPeriod)
*/ */
DWORD WINAPI timeGetTime() DWORD WINAPI timeGetTime()
{ {
DWORD dwNewTick = GetTickCount();
StartMMTime(); StartMMTime();
#ifdef USE_FAKE_MM_TIMERS return mmSysTimeMS.u.ms;
if (bUseFakeTimers) {
if (!wInCallBackLoop++) {
DWORD dwDelta;
if (dwNewTick < dwLastCBTick) {
ERR_(mmtime)("dwNewTick(%lu) < dwLastCBTick(%lu)\n", dwNewTick, dwLastCBTick);
}
dwDelta = dwNewTick - dwLastCBTick;
if (dwDelta > MMSYSTIME_MININTERVAL) {
LPTIMERENTRY lpTimer;
mmSysTimeMS.u.ms += dwDelta; /* FIXME: faked timer */
dwLastCBTick = dwNewTick;
for (lpTimer = lpTimerList; lpTimer != NULL; lpTimer = lpTimer->Next) {
if (lpTimer->wCurTime < dwDelta) {
TIME_TriggerCallBack(lpTimer, dwNewTick);
} else {
lpTimer->wCurTime -= dwDelta;
}
}
}
}
dwNewTick = mmSysTimeMS.u.ms;
wInCallBackLoop--;
}
#endif
return dwNewTick;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment