Sync to Wine-20041019:

Vincent Beron <vberon@mecano.gme.usherb.ca>
- Fix various function prototypes.
Jeremy White <jwhite@codeweavers.com>
- Revise winmm/time.c to fix timer resolution at 1 ms. This then allows
a much more efficient implementation of timer events and timeGetTime,
and callers that used sub 10 ms resolution will now get correct
results.
Hans Leidekker <hans@it.vu.nl>
- Fix signed/unsigned comparison warnings.
Eric Pouech <pouech-eric@wanadoo.fr>
- bring the multimedia doc up-to-date
- moved the TODO from the doc into the code

svn path=/trunk/; revision=11349
This commit is contained in:
Gé van Geldorp 2004-10-20 17:42:11 +00:00
parent c333fa4ed1
commit 1b613704b0
6 changed files with 242 additions and 172 deletions

View file

@ -468,7 +468,7 @@ HMODULE WINAPI GetDriverModuleHandle(HDRVR hDrvr)
* DefDriverProc [WINMM.@] * DefDriverProc [WINMM.@]
* DrvDefDriverProc [WINMM.@] * DrvDefDriverProc [WINMM.@]
*/ */
LRESULT WINAPI DefDriverProc(DWORD dwDriverIdentifier, HDRVR hDrv, LRESULT WINAPI DefDriverProc(DWORD_PTR dwDriverIdentifier, HDRVR hDrv,
UINT Msg, LPARAM lParam1, LPARAM lParam2) UINT Msg, LPARAM lParam1, LPARAM lParam2)
{ {
switch (Msg) { switch (Msg) {

View file

@ -308,7 +308,7 @@ UINT16 WINAPI mixerGetLineControls16(HMIXEROBJ16 hmix,
{ {
MIXERLINECONTROLSA mlcA; MIXERLINECONTROLSA mlcA;
DWORD ret; DWORD ret;
int i; unsigned int i;
LPMIXERCONTROL16 lpmc16; LPMIXERCONTROL16 lpmc16;
TRACE("(%04x, %p, %08lx)\n", hmix, lpmlc16, fdwControls); TRACE("(%04x, %p, %08lx)\n", hmix, lpmlc16, fdwControls);
@ -2524,12 +2524,9 @@ void MMSYSTEM_MMTIME16to32(LPMMTIME mmt32, const MMTIME16* mmt16)
*/ */
MMRESULT16 WINAPI timeGetSystemTime16(LPMMTIME16 lpTime, UINT16 wSize) MMRESULT16 WINAPI timeGetSystemTime16(LPMMTIME16 lpTime, UINT16 wSize)
{ {
TRACE("(%p, %u);\n", lpTime, wSize);
if (wSize >= sizeof(*lpTime)) { if (wSize >= sizeof(*lpTime)) {
lpTime->wType = TIME_MS; lpTime->wType = TIME_MS;
TIME_MMTimeStart(); lpTime->u.ms = GetTickCount();
lpTime->u.ms = WINMM_SysTimeMS;
TRACE("=> %lu\n", lpTime->u.ms); TRACE("=> %lu\n", lpTime->u.ms);
} }

View file

@ -45,23 +45,44 @@ WINE_DEFAULT_DEBUG_CHANNEL(mmtime);
static HANDLE TIME_hMMTimer; static HANDLE TIME_hMMTimer;
static LPWINE_TIMERENTRY TIME_TimersList; static LPWINE_TIMERENTRY TIME_TimersList;
static HANDLE TIME_hKillEvent; static HANDLE TIME_hKillEvent;
DWORD WINMM_SysTimeMS; static HANDLE TIME_hWakeEvent;
static BOOL TIME_TimeToDie = TRUE;
/* /*
* FIXME * Some observations on the behavior of winmm on Windows.
* We're using "1" as the mininum resolution to the timer, * First, the call to timeBeginPeriod(xx) can never be used
* as Windows 95 does, according to the docs. Maybe it should * to raise the timer resolution, only lower it.
* depend on the computers resources! *
* Second, a brief survey of a variety of Win 2k and Win X
* machines showed that a 'standard' (aka default) timer
* resolution was 1 ms (Win9x is documented as being 1). However, one
* machine had a standard timer resolution of 10 ms.
*
* Further, if we set our default resolution to 1,
* the implementation of timeGetTime becomes GetTickCount(),
* and we can optimize the code to reduce overhead.
*
* Additionally, a survey of Event behaviors shows that
* if we request a Periodic event every 50 ms, then Windows
* makes sure to trigger that event 20 times in the next
* second. If delays prevent that from happening on exact
* schedule, Windows will trigger the events as close
* to the original schedule as is possible, and will eventually
* bring the event triggers back onto a schedule that is
* consistent with what would have happened if there were
* no delays.
*
* Jeremy White, October 2004
*/ */
#define MMSYSTIME_MININTERVAL (1) #define MMSYSTIME_MININTERVAL (1)
#define MMSYSTIME_MAXINTERVAL (65535) #define MMSYSTIME_MAXINTERVAL (65535)
#define MMSYSTIME_STDINTERVAL (10) /* reasonable value? */
static void TIME_TriggerCallBack(LPWINE_TIMERENTRY lpTimer) static void TIME_TriggerCallBack(LPWINE_TIMERENTRY lpTimer)
{ {
TRACE("before CallBack => lpFunc=%p wTimerID=%04X dwUser=%08lX !\n", TRACE("%04lx:CallBack => lpFunc=%p wTimerID=%04X dwUser=%08lX dwTriggerTime %ld(delta %ld)\n",
lpTimer->lpFunc, lpTimer->wTimerID, lpTimer->dwUser); GetCurrentThreadId(), lpTimer->lpFunc, lpTimer->wTimerID, lpTimer->dwUser,
lpTimer->dwTriggerTime, GetTickCount() - lpTimer->dwTriggerTime);
/* - 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
@ -87,83 +108,116 @@ static void TIME_TriggerCallBack(LPWINE_TIMERENTRY lpTimer)
lpTimer->wFlags, lpTimer->lpFunc); lpTimer->wFlags, lpTimer->lpFunc);
break; break;
} }
TRACE("after CallBack !\n");
} }
/************************************************************************** /**************************************************************************
* TIME_MMSysTimeCallback * TIME_MMSysTimeCallback
*/ */
static void CALLBACK TIME_MMSysTimeCallback(LPWINE_MM_IDATA iData) static DWORD CALLBACK TIME_MMSysTimeCallback(LPWINE_MM_IDATA iData)
{ {
static int nSizeLpTimers; static int nSizeLpTimers;
static LPWINE_TIMERENTRY lpTimers; static LPWINE_TIMERENTRY lpTimers;
LPWINE_TIMERENTRY timer, *ptimer, *next_ptimer; LPWINE_TIMERENTRY timer, *ptimer, *next_ptimer;
DWORD delta = GetTickCount() - WINMM_SysTimeMS;
int idx; int idx;
DWORD cur_time;
DWORD delta_time;
DWORD ret_time = INFINITE;
DWORD adjust_time;
TRACE("Time delta: %ld\n", delta);
while (delta >= MMSYSTIME_MININTERVAL) { /* optimize for the most frequent case - no events */
delta -= MMSYSTIME_MININTERVAL; if (! TIME_TimersList)
WINMM_SysTimeMS += MMSYSTIME_MININTERVAL; return(ret_time);
/* since timeSetEvent() and timeKillEvent() can be called /* since timeSetEvent() and timeKillEvent() can be called
* from 16 bit code, there are cases where win16 lock is * from 16 bit code, there are cases where win16 lock is
* locked upon entering timeSetEvent(), and then the mm timer * locked upon entering timeSetEvent(), and then the mm timer
* critical section is locked. This function cannot call the * critical section is locked. This function cannot call the
* timer callback with the crit sect locked (because callback * timer callback with the crit sect locked (because callback
* may need to acquire Win16 lock, thus providing a deadlock * may need to acquire Win16 lock, thus providing a deadlock
* situation). * situation).
* To cope with that, we just copy the WINE_TIMERENTRY struct * To cope with that, we just copy the WINE_TIMERENTRY struct
* that need to trigger the callback, and call it without the * that need to trigger the callback, and call it without the
* mm timer crit sect locked. * mm timer crit sect locked.
* the hKillTimeEvent is used to mark the section where we * the hKillTimeEvent is used to mark the section where we
* handle the callbacks so we can do synchronous kills. * handle the callbacks so we can do synchronous kills.
* EPP 99/07/13, updated 04/01/10 * EPP 99/07/13, updated 04/01/10
*/ */
idx = 0; idx = 0;
cur_time = GetTickCount();
EnterCriticalSection(&iData->cs); EnterCriticalSection(&iData->cs);
for (ptimer = &TIME_TimersList; *ptimer != NULL; ) { for (ptimer = &TIME_TimersList; *ptimer != NULL; ) {
timer = *ptimer; timer = *ptimer;
next_ptimer = &timer->lpNext; next_ptimer = &timer->lpNext;
if (timer->uCurTime < MMSYSTIME_MININTERVAL) { if (cur_time >= timer->dwTriggerTime)
/* since lpTimer->wDelay is >= MININTERVAL, wCurTime value {
* shall be correct (>= 0) if (timer->lpFunc) {
*/ if (idx == nSizeLpTimers) {
timer->uCurTime += timer->wDelay - MMSYSTIME_MININTERVAL; if (lpTimers)
if (timer->lpFunc) { lpTimers = (LPWINE_TIMERENTRY)
if (idx == nSizeLpTimers) { HeapReAlloc(GetProcessHeap(), 0, lpTimers,
if (lpTimers) ++nSizeLpTimers * sizeof(WINE_TIMERENTRY));
lpTimers = (LPWINE_TIMERENTRY) else
HeapReAlloc(GetProcessHeap(), 0, lpTimers, lpTimers = (LPWINE_TIMERENTRY)
++nSizeLpTimers * sizeof(WINE_TIMERENTRY)); HeapAlloc(GetProcessHeap(), 0,
else ++nSizeLpTimers * sizeof(WINE_TIMERENTRY));
lpTimers = (LPWINE_TIMERENTRY)
HeapAlloc(GetProcessHeap(), 0,
++nSizeLpTimers * sizeof(WINE_TIMERENTRY));
}
lpTimers[idx++] = *timer;
}
/* TIME_ONESHOT is defined as 0 */
if (!(timer->wFlags & TIME_PERIODIC))
{
/* unlink timer from timers list */
*ptimer = *next_ptimer;
HeapFree(GetProcessHeap(), 0, timer);
} }
} else { lpTimers[idx++] = *timer;
timer->uCurTime -= MMSYSTIME_MININTERVAL;
}
ptimer = next_ptimer;
}
if (TIME_hKillEvent) ResetEvent(TIME_hKillEvent);
LeaveCriticalSection(&iData->cs);
while (idx > 0) TIME_TriggerCallBack(&lpTimers[--idx]); }
if (TIME_hKillEvent) SetEvent(TIME_hKillEvent);
/* Update the time after we make the copy to preserve
the original trigger time */
timer->dwTriggerTime += timer->wDelay;
/* TIME_ONESHOT is defined as 0 */
if (!(timer->wFlags & TIME_PERIODIC))
{
/* unlink timer from timers list */
*ptimer = *next_ptimer;
HeapFree(GetProcessHeap(), 0, timer);
/* We don't need to trigger oneshots again */
delta_time = INFINITE;
}
else
{
/* Compute when this event needs this function
to be called again */
if (timer->dwTriggerTime <= cur_time)
delta_time = 0;
else
delta_time = timer->dwTriggerTime - cur_time;
}
}
else
delta_time = timer->dwTriggerTime - cur_time;
/* Determine when we need to return to this function */
ret_time = min(ret_time, delta_time);
ptimer = next_ptimer;
} }
if (TIME_hKillEvent) ResetEvent(TIME_hKillEvent);
LeaveCriticalSection(&iData->cs);
while (idx > 0) TIME_TriggerCallBack(&lpTimers[--idx]);
if (TIME_hKillEvent) SetEvent(TIME_hKillEvent);
/* Finally, adjust the recommended wait time downward
by the amount of time the processing routines
actually took */
adjust_time = GetTickCount() - cur_time;
if (adjust_time > ret_time)
ret_time = 0;
else
ret_time -= adjust_time;
/* We return the amount of time our caller should sleep
before needing to check in on us again */
return(ret_time);
} }
/************************************************************************** /**************************************************************************
@ -172,23 +226,43 @@ static LPWINE_TIMERENTRY lpTimers;
static DWORD CALLBACK TIME_MMSysTimeThread(LPVOID arg) static DWORD CALLBACK TIME_MMSysTimeThread(LPVOID arg)
{ {
LPWINE_MM_IDATA iData = (LPWINE_MM_IDATA)arg; LPWINE_MM_IDATA iData = (LPWINE_MM_IDATA)arg;
volatile HANDLE *pActive = (volatile HANDLE *)&TIME_hMMTimer; DWORD sleep_time;
DWORD last_time, cur_time; DWORD rc;
#ifndef __REACTOS__ TRACE("Starting main winmm thread\n");
usleep(MMSYSTIME_STDINTERVAL * 1000);
#endif /* __REACTOS__ */
last_time = GetTickCount(); /* FIXME: As an optimization, we could have
while (*pActive) { this thread die when there are no more requests
TIME_MMSysTimeCallback(iData); pending, and then get recreated on the first
cur_time = GetTickCount(); new event; it's not clear if that would be worth
while (last_time < cur_time) it or not. */
last_time += MMSYSTIME_STDINTERVAL;
#ifndef __REACTOS__ while (! TIME_TimeToDie)
usleep((last_time - cur_time) * 1000); {
#endif /* __REACTOS__ */ sleep_time = TIME_MMSysTimeCallback(iData);
if (sleep_time == 0)
{
/* This Sleep is controversial; it was added to make
Wine able to replicate a high speed (e.g. 1 ms)
timer event where the called event routine chews
a lot of CPU. This is required because of the
bias some Linux kernel versions have against threads that
chew a lot of the CPU; this Sleep(0) yields enough
in that spin case doesn't trigger the bias.
Further, it should do no harm, but an fyi. */
Sleep(0);
continue;
}
rc = WaitForSingleObject(TIME_hWakeEvent, sleep_time);
if (rc != WAIT_TIMEOUT && rc != WAIT_OBJECT_0)
{
FIXME("Unexpected error %ld(%ld) in timer thread\n", rc, GetLastError());
break;
}
} }
TRACE("Exiting main winmm thread\n");
return 0; return 0;
} }
@ -197,13 +271,10 @@ static DWORD CALLBACK TIME_MMSysTimeThread(LPVOID arg)
*/ */
void TIME_MMTimeStart(void) void TIME_MMTimeStart(void)
{ {
/* one could think it's possible to stop the service thread activity when no more
* mm timers are active, but this would require to keep mmSysTimeMS up-to-date
* without being incremented within the service thread callback.
*/
if (!TIME_hMMTimer) { if (!TIME_hMMTimer) {
WINMM_SysTimeMS = GetTickCount();
TIME_TimersList = NULL; TIME_TimersList = NULL;
TIME_hWakeEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
TIME_TimeToDie = FALSE;
TIME_hMMTimer = CreateThread(NULL, 0, TIME_MMSysTimeThread, WINMM_IData, 0, NULL); TIME_hMMTimer = CreateThread(NULL, 0, TIME_MMSysTimeThread, WINMM_IData, 0, NULL);
} }
} }
@ -213,12 +284,18 @@ void TIME_MMTimeStart(void)
*/ */
void TIME_MMTimeStop(void) void TIME_MMTimeStop(void)
{ {
/* FIXME: in the worst case, we're going to wait 65 seconds here :-( */
if (TIME_hMMTimer) { if (TIME_hMMTimer) {
HANDLE hMMTimer = TIME_hMMTimer;
TIME_TimeToDie = TRUE;
SetEvent(TIME_hWakeEvent);
/* FIXME: in the worst case, we're going to wait 65 seconds here :-( */
WaitForSingleObject(TIME_hMMTimer, INFINITE);
CloseHandle(TIME_hMMTimer);
CloseHandle(TIME_hWakeEvent);
TIME_hMMTimer = 0; TIME_hMMTimer = 0;
WaitForSingleObject(hMMTimer, INFINITE); TIME_TimersList = NULL;
CloseHandle(hMMTimer);
} }
} }
@ -227,14 +304,11 @@ void TIME_MMTimeStop(void)
*/ */
MMRESULT WINAPI timeGetSystemTime(LPMMTIME lpTime, UINT wSize) MMRESULT WINAPI timeGetSystemTime(LPMMTIME lpTime, UINT wSize)
{ {
TRACE("(%p, %u);\n", lpTime, wSize);
if (wSize >= sizeof(*lpTime)) { if (wSize >= sizeof(*lpTime)) {
TIME_MMTimeStart();
lpTime->wType = TIME_MS; lpTime->wType = TIME_MS;
lpTime->u.ms = WINMM_SysTimeMS; lpTime->u.ms = GetTickCount();
TRACE("=> %lu\n", lpTime->u.ms);
} }
return 0; return 0;
@ -261,8 +335,11 @@ WORD TIME_SetEventInternal(UINT wDelay, UINT wResol,
TIME_MMTimeStart(); TIME_MMTimeStart();
lpNewTimer->uCurTime = wDelay;
lpNewTimer->wDelay = wDelay; lpNewTimer->wDelay = wDelay;
lpNewTimer->dwTriggerTime = GetTickCount() + wDelay;
/* FIXME - wResol is not respected, although it is not clear
that we could change our precision meaningfully */
lpNewTimer->wResol = wResol; lpNewTimer->wResol = wResol;
lpNewTimer->lpFunc = lpFunc; lpNewTimer->lpFunc = lpFunc;
lpNewTimer->dwUser = dwUser; lpNewTimer->dwUser = dwUser;
@ -283,6 +360,9 @@ WORD TIME_SetEventInternal(UINT wDelay, UINT wResol,
LeaveCriticalSection(&WINMM_IData->cs); LeaveCriticalSection(&WINMM_IData->cs);
/* Wake the service thread in case there is work to be done */
SetEvent(TIME_hWakeEvent);
TRACE("=> %u\n", wNewID + 1); TRACE("=> %u\n", wNewID + 1);
return wNewID + 1; return wNewID + 1;
@ -337,7 +417,7 @@ MMRESULT WINAPI timeKillEvent(UINT wID)
*/ */
MMRESULT WINAPI timeGetDevCaps(LPTIMECAPS lpCaps, UINT wSize) MMRESULT WINAPI timeGetDevCaps(LPTIMECAPS lpCaps, UINT wSize)
{ {
TRACE("(%p, %u) !\n", lpCaps, wSize); TRACE("(%p, %u)\n", lpCaps, wSize);
lpCaps->wPeriodMin = MMSYSTIME_MININTERVAL; lpCaps->wPeriodMin = MMSYSTIME_MININTERVAL;
lpCaps->wPeriodMax = MMSYSTIME_MAXINTERVAL; lpCaps->wPeriodMax = MMSYSTIME_MAXINTERVAL;
@ -349,10 +429,14 @@ MMRESULT WINAPI timeGetDevCaps(LPTIMECAPS lpCaps, UINT wSize)
*/ */
MMRESULT WINAPI timeBeginPeriod(UINT wPeriod) MMRESULT WINAPI timeBeginPeriod(UINT wPeriod)
{ {
TRACE("(%u) !\n", wPeriod);
if (wPeriod < MMSYSTIME_MININTERVAL || wPeriod > MMSYSTIME_MAXINTERVAL) if (wPeriod < MMSYSTIME_MININTERVAL || wPeriod > MMSYSTIME_MAXINTERVAL)
return TIMERR_NOCANDO; return TIMERR_NOCANDO;
if (wPeriod > MMSYSTIME_MININTERVAL)
{
FIXME("Stub; we set our timer resolution at minimum\n");
}
return 0; return 0;
} }
@ -361,10 +445,13 @@ MMRESULT WINAPI timeBeginPeriod(UINT wPeriod)
*/ */
MMRESULT WINAPI timeEndPeriod(UINT wPeriod) MMRESULT WINAPI timeEndPeriod(UINT wPeriod)
{ {
TRACE("(%u) !\n", wPeriod);
if (wPeriod < MMSYSTIME_MININTERVAL || wPeriod > MMSYSTIME_MAXINTERVAL) if (wPeriod < MMSYSTIME_MININTERVAL || wPeriod > MMSYSTIME_MAXINTERVAL)
return TIMERR_NOCANDO; return TIMERR_NOCANDO;
if (wPeriod > MMSYSTIME_MININTERVAL)
{
FIXME("Stub; we set our timer resolution at minimum\n");
}
return 0; return 0;
} }
@ -374,12 +461,15 @@ MMRESULT WINAPI timeEndPeriod(UINT wPeriod)
*/ */
DWORD WINAPI timeGetTime(void) DWORD WINAPI timeGetTime(void)
{ {
#if defined(COMMENTOUTPRIORTODELETING)
DWORD count; DWORD count;
/* FIXME: releasing the win16 lock here is a temporary hack (I hope) /* FIXME: releasing the win16 lock here is a temporary hack (I hope)
* that lets mciavi.drv run correctly * that lets mciavi.drv run correctly
*/ */
if (pFnReleaseThunkLock) pFnReleaseThunkLock(&count); if (pFnReleaseThunkLock) pFnReleaseThunkLock(&count);
TIME_MMTimeStart();
if (pFnRestoreThunkLock) pFnRestoreThunkLock(count); if (pFnRestoreThunkLock) pFnRestoreThunkLock(count);
return WINMM_SysTimeMS; #endif
return GetTickCount();
} }

View file

@ -1,10 +1,10 @@
Index: lolvldrv.c Index: lolvldrv.c
=================================================================== ===================================================================
RCS file: /home/wine/wine/dlls/winmm/lolvldrv.c,v RCS file: /home/wine/wine/dlls/winmm/lolvldrv.c,v
retrieving revision 1.59 retrieving revision 1.61
diff -u -r1.59 lolvldrv.c diff -u -r1.61 lolvldrv.c
--- lolvldrv.c 20 Aug 2004 20:01:31 -0000 1.59 --- lolvldrv.c 22 Sep 2004 04:00:14 -0000 1.61
+++ lolvldrv.c 19 Sep 2004 11:38:37 -0000 +++ lolvldrv.c 20 Oct 2004 17:54:30 -0000
@@ -758,11 +758,18 @@ @@ -758,11 +758,18 @@
{ {
TRACE("()\n"); TRACE("()\n");
@ -26,41 +26,14 @@ diff -u -r1.59 lolvldrv.c
return TRUE; return TRUE;
} }
Index: time.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/time.c,v
retrieving revision 1.26
diff -u -r1.26 time.c
--- time.c 12 Jan 2004 21:03:10 -0000 1.26
+++ time.c 19 Sep 2004 11:38:41 -0000
@@ -175,14 +175,19 @@
volatile HANDLE *pActive = (volatile HANDLE *)&TIME_hMMTimer;
DWORD last_time, cur_time;
+#ifndef __REACTOS__
usleep(MMSYSTIME_STDINTERVAL * 1000);
+#endif /* __REACTOS__ */
+
last_time = GetTickCount();
while (*pActive) {
TIME_MMSysTimeCallback(iData);
cur_time = GetTickCount();
while (last_time < cur_time)
last_time += MMSYSTIME_STDINTERVAL;
+#ifndef __REACTOS__
usleep((last_time - cur_time) * 1000);
+#endif /* __REACTOS__ */
}
return 0;
}
Index: winmm.c Index: winmm.c
=================================================================== ===================================================================
RCS file: /home/wine/wine/dlls/winmm/winmm.c,v RCS file: /home/wine/wine/dlls/winmm/winmm.c,v
retrieving revision 1.42 retrieving revision 1.45
diff -u -r1.42 winmm.c diff -u -r1.45 winmm.c
--- winmm.c 16 Aug 2004 23:19:17 -0000 1.42 --- winmm.c 19 Oct 2004 23:55:15 -0000 1.45
+++ winmm.c 19 Sep 2004 11:38:42 -0000 +++ winmm.c 20 Oct 2004 17:54:32 -0000
@@ -83,7 +83,9 @@ @@ -94,7 +94,9 @@
return FALSE; return FALSE;
WINMM_IData->hWinMM32Instance = hInstDLL; WINMM_IData->hWinMM32Instance = hInstDLL;
InitializeCriticalSection(&WINMM_IData->cs); InitializeCriticalSection(&WINMM_IData->cs);
@ -70,7 +43,7 @@ diff -u -r1.42 winmm.c
WINMM_IData->psStopEvent = CreateEventA(NULL, TRUE, FALSE, NULL); WINMM_IData->psStopEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
WINMM_IData->psLastEvent = CreateEventA(NULL, TRUE, FALSE, NULL); WINMM_IData->psLastEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
TRACE("Created IData (%p)\n", WINMM_IData); TRACE("Created IData (%p)\n", WINMM_IData);
@@ -126,10 +128,12 @@ @@ -137,10 +139,12 @@
loaded = -1; loaded = -1;
if (h) if (h)
{ {
@ -89,7 +62,7 @@ RCS file: /home/wine/wine/dlls/winmm/winmm_res.rc,v
retrieving revision 1.17 retrieving revision 1.17
diff -u -r1.17 winmm_res.rc diff -u -r1.17 winmm_res.rc
--- winmm_res.rc 16 Aug 2004 20:02:09 -0000 1.17 --- winmm_res.rc 16 Aug 2004 20:02:09 -0000 1.17
+++ winmm_res.rc 19 Sep 2004 11:38:45 -0000 +++ winmm_res.rc 20 Oct 2004 17:54:32 -0000
@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
#include "winmm_Es.rc" #include "winmm_Es.rc"
#include "winmm_Fr.rc" #include "winmm_Fr.rc"

View file

@ -162,7 +162,7 @@ typedef struct tagWINE_TIMERENTRY {
DWORD dwUser; DWORD dwUser;
UINT16 wFlags; UINT16 wFlags;
UINT16 wTimerID; UINT16 wTimerID;
UINT uCurTime; DWORD dwTriggerTime;
struct tagWINE_TIMERENTRY* lpNext; struct tagWINE_TIMERENTRY* lpNext;
} WINE_TIMERENTRY, *LPWINE_TIMERENTRY; } WINE_TIMERENTRY, *LPWINE_TIMERENTRY;
@ -250,25 +250,25 @@ const char* MCI_MessageToString(UINT16 wMsg);
UINT WINAPI MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data); UINT WINAPI MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data);
LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2); LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2);
DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2, BOOL bFrom32); DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2, BOOL bFrom32);
DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2); DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2);
DWORD MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwParam2); DWORD MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2);
UINT MCI_SetCommandTable(void *table, UINT uDevType); UINT MCI_SetCommandTable(void *table, UINT uDevType);
BOOL WINMM_CheckForMMSystem(void); BOOL WINMM_CheckForMMSystem(void);
const char* WINMM_ErrorToString(MMRESULT error); const char* WINMM_ErrorToString(MMRESULT error);
UINT MIXER_Open(LPHMIXER lphMix, UINT uDeviceID, DWORD dwCallback, UINT MIXER_Open(LPHMIXER lphMix, UINT uDeviceID, DWORD_PTR dwCallback,
DWORD dwInstance, DWORD fdwOpen, BOOL bFrom32); DWORD_PTR dwInstance, DWORD fdwOpen, BOOL bFrom32);
UINT MIDI_OutOpen(HMIDIOUT* lphMidiOut, UINT uDeviceID, DWORD dwCallback, UINT MIDI_OutOpen(HMIDIOUT* lphMidiOut, UINT uDeviceID, DWORD_PTR dwCallback,
DWORD dwInstance, DWORD dwFlags, BOOL bFrom32); DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32);
UINT MIDI_InOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD dwCallback, UINT MIDI_InOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD_PTR dwCallback,
DWORD dwInstance, DWORD dwFlags, BOOL bFrom32); DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32);
MMRESULT MIDI_StreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID, MMRESULT MIDI_StreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID,
DWORD cMidi, DWORD dwCallback, DWORD cMidi, DWORD_PTR dwCallback,
DWORD dwInstance, DWORD fdwOpen, BOOL bFrom32); DWORD_PTR dwInstance, DWORD fdwOpen, BOOL bFrom32);
UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType, UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType,
const LPWAVEFORMATEX lpFormat, DWORD dwCallback, const LPWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
DWORD dwInstance, DWORD dwFlags, BOOL bFrom32); DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32);
HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo,
DWORD dwOpenFlags, enum mmioProcType type); DWORD dwOpenFlags, enum mmioProcType type);
@ -285,7 +285,6 @@ void TIME_MMTimeStop(void);
/* Global variables */ /* Global variables */
extern LPWINE_MM_IDATA WINMM_IData; extern LPWINE_MM_IDATA WINMM_IData;
extern DWORD WINMM_SysTimeMS;
/* pointers to 16 bit functions (if sibling MMSYSTEM.DLL is loaded /* pointers to 16 bit functions (if sibling MMSYSTEM.DLL is loaded
* NULL otherwise * NULL otherwise

View file

@ -28,6 +28,17 @@
* 99/9 added support for loadable low level drivers * 99/9 added support for loadable low level drivers
*/ */
/* TODO
* + it seems that some programs check what's installed in
* registry against the value returned by drivers. Wine is
* currently broken regarding this point.
* + check thread-safeness for MMSYSTEM and WINMM entry points
* + unicode entry points are badly supported (would require
* moving 32 bit drivers as Unicode as they are supposed to be)
* + allow joystick and timer external calls as we do for wave,
* midi, mixer and aux
*/
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
@ -430,7 +441,7 @@ UINT WINAPI mixerGetControlDetailsW(HMIXEROBJ hmix, LPMIXERCONTROLDETAILS lpmcd,
MIXERCONTROLDETAILS_LISTTEXTW *pDetailsW = (MIXERCONTROLDETAILS_LISTTEXTW *)lpmcd->paDetails; MIXERCONTROLDETAILS_LISTTEXTW *pDetailsW = (MIXERCONTROLDETAILS_LISTTEXTW *)lpmcd->paDetails;
MIXERCONTROLDETAILS_LISTTEXTA *pDetailsA; MIXERCONTROLDETAILS_LISTTEXTA *pDetailsA;
int size = max(1, lpmcd->cChannels) * sizeof(MIXERCONTROLDETAILS_LISTTEXTA); int size = max(1, lpmcd->cChannels) * sizeof(MIXERCONTROLDETAILS_LISTTEXTA);
int i; unsigned int i;
if (lpmcd->u.cMultipleItems != 0) { if (lpmcd->u.cMultipleItems != 0) {
size *= lpmcd->u.cMultipleItems; size *= lpmcd->u.cMultipleItems;
@ -495,7 +506,7 @@ UINT WINAPI mixerGetLineControlsW(HMIXEROBJ hmix, LPMIXERLINECONTROLSW lpmlcW,
{ {
MIXERLINECONTROLSA mlcA; MIXERLINECONTROLSA mlcA;
DWORD ret; DWORD ret;
int i; unsigned int i;
TRACE("(%p, %p, %08lx)\n", hmix, lpmlcW, fdwControls); TRACE("(%p, %p, %08lx)\n", hmix, lpmlcW, fdwControls);
@ -1671,8 +1682,8 @@ UINT WINAPI midiInGetErrorTextA(UINT uError, LPSTR lpText, UINT uSize)
return MIDI_GetErrorText(uError, lpText, uSize); return MIDI_GetErrorText(uError, lpText, uSize);
} }
UINT MIDI_InOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD dwCallback, UINT MIDI_InOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD_PTR dwCallback,
DWORD dwInstance, DWORD dwFlags, BOOL bFrom32) DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32)
{ {
HANDLE hMidiIn; HANDLE hMidiIn;
LPWINE_MIDI lpwm; LPWINE_MIDI lpwm;
@ -1710,7 +1721,7 @@ UINT MIDI_InOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, DWORD dwCallback,
* midiInOpen [WINMM.@] * midiInOpen [WINMM.@]
*/ */
UINT WINAPI midiInOpen(HMIDIIN* lphMidiIn, UINT uDeviceID, UINT WINAPI midiInOpen(HMIDIIN* lphMidiIn, UINT uDeviceID,
DWORD dwCallback, DWORD dwInstance, DWORD dwFlags) DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD dwFlags)
{ {
return MIDI_InOpen(lphMidiIn, uDeviceID, dwCallback, dwInstance, dwFlags, TRUE); return MIDI_InOpen(lphMidiIn, uDeviceID, dwCallback, dwInstance, dwFlags, TRUE);
} }
@ -2219,7 +2230,7 @@ MMRESULT WINAPI midiStreamClose(HMIDISTRM hMidiStrm)
* MMSYSTEM_MidiStream_Open [internal] * MMSYSTEM_MidiStream_Open [internal]
*/ */
MMRESULT MIDI_StreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID, DWORD cMidi, MMRESULT MIDI_StreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID, DWORD cMidi,
DWORD dwCallback, DWORD dwInstance, DWORD fdwOpen, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen,
BOOL bFrom32) BOOL bFrom32)
{ {
WINE_MIDIStream* lpMidiStrm; WINE_MIDIStream* lpMidiStrm;
@ -2286,8 +2297,8 @@ MMRESULT MIDI_StreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID, DWORD cMidi
* midiStreamOpen [WINMM.@] * midiStreamOpen [WINMM.@]
*/ */
MMRESULT WINAPI midiStreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID, MMRESULT WINAPI midiStreamOpen(HMIDISTRM* lphMidiStrm, LPUINT lpuDeviceID,
DWORD cMidi, DWORD dwCallback, DWORD cMidi, DWORD_PTR dwCallback,
DWORD dwInstance, DWORD fdwOpen) DWORD_PTR dwInstance, DWORD fdwOpen)
{ {
return MIDI_StreamOpen(lphMidiStrm, lpuDeviceID, cMidi, dwCallback, return MIDI_StreamOpen(lphMidiStrm, lpuDeviceID, cMidi, dwCallback,
dwInstance, fdwOpen, TRUE); dwInstance, fdwOpen, TRUE);
@ -2471,8 +2482,8 @@ MMRESULT WINAPI midiStreamStop(HMIDISTRM hMidiStrm)
} }
UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType, UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType,
const LPWAVEFORMATEX lpFormat, DWORD dwCallback, const LPWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
DWORD dwInstance, DWORD dwFlags, BOOL bFrom32) DWORD_PTR dwInstance, DWORD dwFlags, BOOL bFrom32)
{ {
HANDLE handle; HANDLE handle;
LPWINE_MLD wmld; LPWINE_MLD wmld;
@ -3039,8 +3050,8 @@ UINT WINAPI waveInGetErrorTextW(UINT uError, LPWSTR lpText, UINT uSize)
* waveInOpen [WINMM.@] * waveInOpen [WINMM.@]
*/ */
UINT WINAPI waveInOpen(HWAVEIN* lphWaveIn, UINT uDeviceID, UINT WINAPI waveInOpen(HWAVEIN* lphWaveIn, UINT uDeviceID,
const LPWAVEFORMATEX lpFormat, DWORD dwCallback, const LPWAVEFORMATEX lpFormat, DWORD_PTR dwCallback,
DWORD dwInstance, DWORD dwFlags) DWORD_PTR dwInstance, DWORD dwFlags)
{ {
return WAVE_Open((HANDLE*)lphWaveIn, uDeviceID, MMDRV_WAVEIN, lpFormat, return WAVE_Open((HANDLE*)lphWaveIn, uDeviceID, MMDRV_WAVEIN, lpFormat,
dwCallback, dwInstance, dwFlags, TRUE); dwCallback, dwInstance, dwFlags, TRUE);