From 3840443958aaae161a22c071f79eb54b969b0af0 Mon Sep 17 00:00:00 2001 From: Akihiro Sagawa Date: Tue, 29 May 2018 08:19:08 -0500 Subject: [PATCH] winmm: Reset the tick counter after handling messages. Otherwise, events might be triggered immediately after a resuming. Signed-off-by: Akihiro Sagawa Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- dlls/winmm/tests/midi.c | 4 ++-- dlls/winmm/winmm.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/winmm/tests/midi.c b/dlls/winmm/tests/midi.c index 091a500db79..fe3cc5c8767 100644 --- a/dlls/winmm/tests/midi.c +++ b/dlls/winmm/tests/midi.c @@ -893,7 +893,7 @@ static void test_midiStream(UINT udev, HWND hwnd) expected = 250; /* = 12 ticks in 120 BPM */ ret = get_position(hm, TIME_MS); - todo_wine ok(ret >= expected - MARGIN && ret <= expected + MARGIN, + ok(ret >= expected - MARGIN && ret <= expected + MARGIN, "expected greater than %ums, got %ums\n", expected, ret); trace("after playing, got %ums\n", ret); @@ -914,7 +914,7 @@ static void test_midiStream(UINT udev, HWND hwnd) So, the second event happens at dwDeltaTime(250ms) + 100ms after the first event. */ expected = 250 + 100; diff = records.time_stamp[1] - records.time_stamp[0]; - todo_wine ok(diff >= expected - MARGIN && diff <= expected + MARGIN, + ok(diff >= expected - MARGIN && diff <= expected + MARGIN, "expected %u ~ %ums, got %ums (dev=%d)\n", expected - MARGIN, expected + MARGIN, diff, udev); rc = midiOutUnprepareHeader((HMIDIOUT)hm, &mhdr, sizeof(mhdr)); diff --git a/dlls/winmm/winmm.c b/dlls/winmm/winmm.c index 2031c79d1c7..ef7dcdfc9a6 100644 --- a/dlls/winmm/winmm.c +++ b/dlls/winmm/winmm.c @@ -1197,6 +1197,8 @@ start_header: goto start_header; } } + /* reset dwToGo because dwStartTicks might be updated */ + dwToGo = lpMidiStrm->dwStartTicks + lpMidiStrm->dwPositionMS; } else { /* timeout, so me->dwDeltaTime is elapsed, can break the while loop */ break;