mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 20:59:54 +00:00
Put back visible minimum timer resolution to 1 ms.
Decorrelate the service thread resolution from the user required timer & visible minimum resolutions. Removed the Callback.TimeFuncProc entry.
This commit is contained in:
parent
939e252bdc
commit
a5bad1034e
@ -1,6 +1,7 @@
|
|||||||
Makefile
|
Makefile
|
||||||
lolvldrv.glue.c
|
lolvldrv.glue.c
|
||||||
mmsystem.glue.c
|
mmsystem.glue.c
|
||||||
|
time.glue.c
|
||||||
mmsystem.spec.c
|
mmsystem.spec.c
|
||||||
winmm.spec.c
|
winmm.spec.c
|
||||||
winmm_res.s
|
winmm_res.s
|
||||||
|
@ -19,13 +19,27 @@ C_SRCS = \
|
|||||||
time.c
|
time.c
|
||||||
|
|
||||||
GLUE = lolvldrv.c \
|
GLUE = lolvldrv.c \
|
||||||
mmsystem.c
|
mmsystem.c \
|
||||||
|
time.c
|
||||||
|
|
||||||
RC_SRCS= \
|
RC_SRCS= \
|
||||||
winmm_res.rc
|
winmm_res.rc
|
||||||
|
|
||||||
all: check_wrc $ $(MODULE).o
|
all: check_wrc $ $(MODULE).o
|
||||||
|
|
||||||
|
SUBDIRS = \
|
||||||
|
mcianim \
|
||||||
|
mciavi \
|
||||||
|
mcicda \
|
||||||
|
mciseq \
|
||||||
|
mciwave \
|
||||||
|
midimap \
|
||||||
|
wavemap \
|
||||||
|
wineoss
|
||||||
|
|
||||||
|
$(SUBDIRS): dummy
|
||||||
|
@cd $@; $(MAKE)
|
||||||
|
|
||||||
@MAKE_RULES@
|
@MAKE_RULES@
|
||||||
|
|
||||||
$(RC_SRCS:.rc=.s): $(WRC)
|
$(RC_SRCS:.rc=.s): $(WRC)
|
||||||
|
@ -8,8 +8,7 @@
|
|||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "winbase.h"
|
#include "winuser.h"
|
||||||
#include "callback.h"
|
|
||||||
#include "winemm.h"
|
#include "winemm.h"
|
||||||
#include "services.h"
|
#include "services.h"
|
||||||
#include "syslevel.h"
|
#include "syslevel.h"
|
||||||
@ -23,13 +22,17 @@ DEFAULT_DEBUG_CHANNEL(mmtime)
|
|||||||
* 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) */ (10)
|
#define MMSYSTIME_MININTERVAL (1)
|
||||||
#define MMSYSTIME_MAXINTERVAL (65535)
|
#define MMSYSTIME_MAXINTERVAL (65535)
|
||||||
|
|
||||||
static void TIME_TriggerCallBack(LPWINE_TIMERENTRY lpTimer, DWORD dwCurrent)
|
/* ### start build ### */
|
||||||
|
extern WORD CALLBACK TIME_CallTo16_word_wwlll(FARPROC16,WORD,WORD,LONG,LONG,LONG);
|
||||||
|
/* ### stop build ### */
|
||||||
|
|
||||||
|
static void TIME_TriggerCallBack(LPWINE_TIMERENTRY lpTimer)
|
||||||
{
|
{
|
||||||
TRACE("before CallBack (%lu) => lpFunc=%p wTimerID=%04X dwUser=%08lX !\n",
|
TRACE("before CallBack => lpFunc=%p wTimerID=%04X dwUser=%08lX !\n",
|
||||||
dwCurrent, lpTimer->lpFunc, lpTimer->wTimerID, lpTimer->dwUser);
|
lpTimer->lpFunc, lpTimer->wTimerID, lpTimer->dwUser);
|
||||||
|
|
||||||
/* - TimeProc callback that is called here is something strange, under Windows 3.1x it is called
|
/* - TimeProc callback that is called here is something strange, under Windows 3.1x it is called
|
||||||
* during interrupt time, is allowed to execute very limited number of API calls (like
|
* during interrupt time, is allowed to execute very limited number of API calls (like
|
||||||
@ -41,9 +44,8 @@ static void TIME_TriggerCallBack(LPWINE_TIMERENTRY lpTimer, DWORD dwCurrent)
|
|||||||
if (lpTimer->wFlags & WINE_TIMER_IS32)
|
if (lpTimer->wFlags & WINE_TIMER_IS32)
|
||||||
((LPTIMECALLBACK)lpTimer->lpFunc)(lpTimer->wTimerID, 0, lpTimer->dwUser, 0, 0);
|
((LPTIMECALLBACK)lpTimer->lpFunc)(lpTimer->wTimerID, 0, lpTimer->dwUser, 0, 0);
|
||||||
else
|
else
|
||||||
Callbacks->CallTimeFuncProc(lpTimer->lpFunc,
|
TIME_CallTo16_word_wwlll(lpTimer->lpFunc, lpTimer->wTimerID, 0,
|
||||||
lpTimer->wTimerID, 0,
|
lpTimer->dwUser, 0, 0);
|
||||||
lpTimer->dwUser, 0, 0);
|
|
||||||
break;
|
break;
|
||||||
case TIME_CALLBACK_EVENT_SET:
|
case TIME_CALLBACK_EVENT_SET:
|
||||||
SetEvent((HANDLE)lpTimer->lpFunc);
|
SetEvent((HANDLE)lpTimer->lpFunc);
|
||||||
@ -52,7 +54,8 @@ static void TIME_TriggerCallBack(LPWINE_TIMERENTRY lpTimer, DWORD dwCurrent)
|
|||||||
PulseEvent((HANDLE)lpTimer->lpFunc);
|
PulseEvent((HANDLE)lpTimer->lpFunc);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FIXME("Unknown callback type 0x%04x for mmtime callback (%p), ignored.\n", lpTimer->wFlags, lpTimer->lpFunc);
|
FIXME("Unknown callback type 0x%04x for mmtime callback (%p), ignored.\n",
|
||||||
|
lpTimer->wFlags, lpTimer->lpFunc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
TRACE("after CallBack !\n");
|
TRACE("after CallBack !\n");
|
||||||
@ -65,55 +68,61 @@ static void CALLBACK TIME_MMSysTimeCallback(ULONG_PTR ptr_)
|
|||||||
{
|
{
|
||||||
LPWINE_TIMERENTRY lpTimer, lpNextTimer;
|
LPWINE_TIMERENTRY lpTimer, lpNextTimer;
|
||||||
LPWINE_MM_IDATA iData = (LPWINE_MM_IDATA)ptr_;
|
LPWINE_MM_IDATA iData = (LPWINE_MM_IDATA)ptr_;
|
||||||
|
DWORD delta = GetTickCount() - iData->mmSysTimeMS;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
iData->mmSysTimeMS += MMSYSTIME_MININTERVAL;
|
TRACE("Time delta: %ld\n", delta);
|
||||||
|
|
||||||
/* since timeSetEvent() and timeKillEvent() can be called
|
while (delta >= MMSYSTIME_MININTERVAL) {
|
||||||
* from 16 bit code, there are cases where win16 lock is
|
delta -= MMSYSTIME_MININTERVAL;
|
||||||
* locked upon entering timeSetEvent(), and then the mm timer
|
iData->mmSysTimeMS += MMSYSTIME_MININTERVAL;
|
||||||
* critical section is locked. This function cannot call the
|
|
||||||
* timer callback with the crit sect locked (because callback
|
/* since timeSetEvent() and timeKillEvent() can be called
|
||||||
* may need to acquire Win16 lock, thus providing a deadlock
|
* from 16 bit code, there are cases where win16 lock is
|
||||||
* situation).
|
* locked upon entering timeSetEvent(), and then the mm timer
|
||||||
* To cope with that, we just copy the WINE_TIMERENTRY struct
|
* critical section is locked. This function cannot call the
|
||||||
* that need to trigger the callback, and call it without the
|
* timer callback with the crit sect locked (because callback
|
||||||
* mm timer crit sect locked. The bad side of this
|
* may need to acquire Win16 lock, thus providing a deadlock
|
||||||
* implementation is that, in some cases, the callback may be
|
* situation).
|
||||||
* invoked *after* a timer has been destroyed...
|
* To cope with that, we just copy the WINE_TIMERENTRY struct
|
||||||
* EPP 99/07/13
|
* that need to trigger the callback, and call it without the
|
||||||
*/
|
* mm timer crit sect locked. The bad side of this
|
||||||
idx = 0;
|
* implementation is that, in some cases, the callback may be
|
||||||
|
* invoked *after* a timer has been destroyed...
|
||||||
EnterCriticalSection(&iData->cs);
|
* EPP 99/07/13
|
||||||
for (lpTimer = iData->lpTimerList; lpTimer != NULL; ) {
|
*/
|
||||||
lpNextTimer = lpTimer->lpNext;
|
idx = 0;
|
||||||
if (lpTimer->uCurTime < MMSYSTIME_MININTERVAL) {
|
|
||||||
/* since lpTimer->wDelay is >= MININTERVAL, wCurTime value
|
EnterCriticalSection(&iData->cs);
|
||||||
* shall be correct (>= 0)
|
for (lpTimer = iData->lpTimerList; lpTimer != NULL; ) {
|
||||||
*/
|
lpNextTimer = lpTimer->lpNext;
|
||||||
lpTimer->uCurTime += lpTimer->wDelay - MMSYSTIME_MININTERVAL;
|
if (lpTimer->uCurTime < MMSYSTIME_MININTERVAL) {
|
||||||
if (lpTimer->lpFunc) {
|
/* since lpTimer->wDelay is >= MININTERVAL, wCurTime value
|
||||||
if (idx == iData->nSizeLpTimers) {
|
* shall be correct (>= 0)
|
||||||
iData->lpTimers = (LPWINE_TIMERENTRY)
|
*/
|
||||||
HeapReAlloc(GetProcessHeap(), 0,
|
lpTimer->uCurTime += lpTimer->wDelay - MMSYSTIME_MININTERVAL;
|
||||||
iData->lpTimers,
|
if (lpTimer->lpFunc) {
|
||||||
++iData->nSizeLpTimers * sizeof(WINE_TIMERENTRY));
|
if (idx == iData->nSizeLpTimers) {
|
||||||
|
iData->lpTimers = (LPWINE_TIMERENTRY)
|
||||||
|
HeapReAlloc(GetProcessHeap(), 0,
|
||||||
|
iData->lpTimers,
|
||||||
|
++iData->nSizeLpTimers * sizeof(WINE_TIMERENTRY));
|
||||||
|
}
|
||||||
|
iData->lpTimers[idx++] = *lpTimer;
|
||||||
}
|
}
|
||||||
iData->lpTimers[idx++] = *lpTimer;
|
/* TIME_ONESHOT is defined as 0 */
|
||||||
|
if (!(lpTimer->wFlags & TIME_PERIODIC))
|
||||||
|
timeKillEvent(lpTimer->wTimerID);
|
||||||
|
} else {
|
||||||
|
lpTimer->uCurTime -= MMSYSTIME_MININTERVAL;
|
||||||
}
|
}
|
||||||
/* TIME_ONESHOT is defined as 0 */
|
lpTimer = lpNextTimer;
|
||||||
if (!(lpTimer->wFlags & TIME_PERIODIC))
|
}
|
||||||
timeKillEvent(lpTimer->wTimerID);
|
LeaveCriticalSection(&iData->cs);
|
||||||
} else {
|
|
||||||
lpTimer->uCurTime -= MMSYSTIME_MININTERVAL;
|
while (idx > 0) {
|
||||||
|
TIME_TriggerCallBack(&iData->lpTimers[--idx]);
|
||||||
}
|
}
|
||||||
lpTimer = lpNextTimer;
|
|
||||||
}
|
|
||||||
LeaveCriticalSection(&iData->cs);
|
|
||||||
|
|
||||||
while (idx > 0) {
|
|
||||||
TIME_TriggerCallBack(&iData->lpTimers[--idx], iData->mmSysTimeMS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +147,8 @@ static LPWINE_MM_IDATA MULTIMEDIA_MMTimeStart(void)
|
|||||||
if (!iData->hMMTimer) {
|
if (!iData->hMMTimer) {
|
||||||
iData->mmSysTimeMS = GetTickCount();
|
iData->mmSysTimeMS = GetTickCount();
|
||||||
iData->lpTimerList = NULL;
|
iData->lpTimerList = NULL;
|
||||||
iData->hMMTimer = SERVICE_AddTimer(MMSYSTIME_MININTERVAL*1000L, TIME_MMSysTimeCallback, (DWORD)iData);
|
/* 10ms seems a reasonable value ?? */
|
||||||
|
iData->hMMTimer = SERVICE_AddTimer(10*1000L, TIME_MMSysTimeCallback, (DWORD)iData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return iData;
|
return iData;
|
||||||
|
Loading…
Reference in New Issue
Block a user