From 781d530e9c0d39aa117930317e7c1911d4829fbf Mon Sep 17 00:00:00 2001 From: Arkadiusz Hiler Date: Tue, 25 Aug 2020 10:54:00 +0300 Subject: [PATCH] winmm: Add timeGetTime() implementation. Signed-off-by: Arkadiusz Hiler Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- dlls/winmm/tests/joystick.c | 4 ++-- dlls/winmm/tests/midi.c | 2 +- dlls/winmm/time.c | 18 ++++++++++++------ dlls/winmm/winmm.c | 12 ++++++------ dlls/winmm/winmm.spec | 2 +- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/dlls/winmm/tests/joystick.c b/dlls/winmm/tests/joystick.c index 7531bd6481f..313e9684e96 100644 --- a/dlls/winmm/tests/joystick.c +++ b/dlls/winmm/tests/joystick.c @@ -202,12 +202,12 @@ static void test_api(void) if (winetest_interactive) { #define MAX_TIME 15000 - DWORD tick = GetTickCount(), spent; + DWORD tick = timeGetTime(), spent; infoex.ex.dwSize = sizeof(infoex.ex); infoex.ex.dwFlags = JOY_RETURNALL; do { - spent = GetTickCount() - tick; + spent = timeGetTime() - tick; ret = joyGetPosEx(joyid, &infoex.ex); if (ret == JOYERR_NOERROR) { diff --git a/dlls/winmm/tests/midi.c b/dlls/winmm/tests/midi.c index 2b1e91fe98a..a78f9b5ac71 100644 --- a/dlls/winmm/tests/midi.c +++ b/dlls/winmm/tests/midi.c @@ -555,7 +555,7 @@ static void CALLBACK time_stamp_callback(HMIDIOUT hmo, UINT msg, DWORD_PTR insta switch (msg) { case MM_MOM_POSITIONCB: if (records->count < ARRAY_SIZE(records->time_stamp)) - records->time_stamp[records->count] = GetTickCount(); + records->time_stamp[records->count] = timeGetTime(); records->count++; break; case MM_MOM_DONE: diff --git a/dlls/winmm/time.c b/dlls/winmm/time.c index 22c89852a2f..de2a3fbc61e 100644 --- a/dlls/winmm/time.c +++ b/dlls/winmm/time.c @@ -131,7 +131,7 @@ static int TIME_MMSysTimeCallback(void) } timer = LIST_ENTRY( ptr, WINE_TIMERENTRY, entry ); - delta_time = timer->dwTriggerTime - GetTickCount(); + delta_time = timer->dwTriggerTime - timeGetTime(); if (delta_time > 0) break; list_remove( &timer->entry ); @@ -242,16 +242,22 @@ void TIME_MMTimeStop(void) */ MMRESULT WINAPI timeGetSystemTime(LPMMTIME lpTime, UINT wSize) { - if (wSize >= sizeof(*lpTime)) { - lpTime->wType = TIME_MS; - lpTime->u.ms = GetTickCount(); - + lpTime->wType = TIME_MS; + lpTime->u.ms = timeGetTime(); } return 0; } +/************************************************************************** + * timeGetTime [WINMM.@] + */ +DWORD WINAPI timeGetTime(void) +{ + return GetTickCount(); +} + /************************************************************************** * timeSetEvent [WINMM.@] */ @@ -272,7 +278,7 @@ MMRESULT WINAPI timeSetEvent(UINT wDelay, UINT wResol, LPTIMECALLBACK lpFunc, return 0; lpNewTimer->wDelay = wDelay; - lpNewTimer->dwTriggerTime = GetTickCount() + wDelay; + lpNewTimer->dwTriggerTime = timeGetTime() + wDelay; /* FIXME - wResol is not respected, although it is not clear that we could change our precision meaningfully */ diff --git a/dlls/winmm/winmm.c b/dlls/winmm/winmm.c index 9075a78f343..eea29ea61e5 100644 --- a/dlls/winmm/winmm.c +++ b/dlls/winmm/winmm.c @@ -1030,7 +1030,7 @@ static DWORD midistream_get_playing_position(WINE_MIDIStream* lpMidiStrm) case MSM_STATUS_PAUSED: return lpMidiStrm->dwElapsedMS; case MSM_STATUS_PLAYING: - return GetTickCount() - lpMidiStrm->dwStartTicks; + return timeGetTime() - lpMidiStrm->dwStartTicks; default: FIXME("Unknown playing status %hu\n", lpMidiStrm->status); return 0; @@ -1080,7 +1080,7 @@ static BOOL MMSYSTEM_MidiStream_MessageHandler(WINE_MIDIStream* lpMidiStrm, LPWI /* FIXME: send out cc64 0 (turn off sustain pedal) on every channel */ if (lpMidiStrm->status != MSM_STATUS_PLAYING) { EnterCriticalSection(&lpMidiStrm->lock); - lpMidiStrm->dwStartTicks = GetTickCount() - lpMidiStrm->dwElapsedMS; + lpMidiStrm->dwStartTicks = timeGetTime() - lpMidiStrm->dwElapsedMS; lpMidiStrm->status = MSM_STATUS_PLAYING; LeaveCriticalSection(&lpMidiStrm->lock); } @@ -1090,7 +1090,7 @@ static BOOL MMSYSTEM_MidiStream_MessageHandler(WINE_MIDIStream* lpMidiStrm, LPWI /* FIXME: send out cc64 0 (turn off sustain pedal) on every channel */ if (lpMidiStrm->status != MSM_STATUS_PAUSED) { EnterCriticalSection(&lpMidiStrm->lock); - lpMidiStrm->dwElapsedMS = GetTickCount() - lpMidiStrm->dwStartTicks; + lpMidiStrm->dwElapsedMS = timeGetTime() - lpMidiStrm->dwStartTicks; lpMidiStrm->status = MSM_STATUS_PAUSED; LeaveCriticalSection(&lpMidiStrm->lock); } @@ -1126,7 +1126,7 @@ static BOOL MMSYSTEM_MidiStream_MessageHandler(WINE_MIDIStream* lpMidiStrm, LPWI case WINE_MSM_HEADER: /* sets initial tick count for first MIDIHDR */ if (!lpMidiStrm->dwStartTicks) - lpMidiStrm->dwStartTicks = GetTickCount(); + lpMidiStrm->dwStartTicks = timeGetTime(); lpMidiHdr = (LPMIDIHDR)msg->lParam; lpData = (LPBYTE)lpMidiHdr->lpData; TRACE("Adding %s lpMidiHdr=%p [lpData=0x%p dwBytesRecorded=%u/%u dwFlags=0x%08x size=%lu]\n", @@ -1235,8 +1235,8 @@ start_header: dwToGo = lpMidiStrm->dwStartTicks + lpMidiStrm->position_usec / 1000; - TRACE("%u/%u/%u\n", dwToGo, GetTickCount(), me->dwDeltaTime); - while (dwToGo - (dwCurrTC = GetTickCount()) <= MAXLONG) { + TRACE("%u/%u/%u\n", dwToGo, timeGetTime(), me->dwDeltaTime); + while (dwToGo - (dwCurrTC = timeGetTime()) <= MAXLONG) { if (MsgWaitForMultipleObjects(0, NULL, FALSE, dwToGo - dwCurrTC, QS_ALLINPUT) == WAIT_OBJECT_0) { /* got a message, handle it */ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) { diff --git a/dlls/winmm/winmm.spec b/dlls/winmm/winmm.spec index 9c6ed2dfa83..d7c7379d77c 100644 --- a/dlls/winmm/winmm.spec +++ b/dlls/winmm/winmm.spec @@ -147,7 +147,7 @@ @ stdcall timeEndPeriod(long) @ stdcall timeGetDevCaps(ptr long) @ stdcall timeGetSystemTime(ptr long) -@ stdcall timeGetTime() kernel32.GetTickCount +@ stdcall timeGetTime() @ stdcall timeKillEvent(long) @ stdcall timeSetEvent(long long ptr long long) @ stdcall waveInAddBuffer(long ptr long)