From a7df4866db55ec6623b8cb817164b12867f616a4 Mon Sep 17 00:00:00 2001
From: Francois Gouget <fgouget@codeweavers.com>
Date: Fri, 13 Nov 2020 12:30:17 +0100
Subject: [PATCH 2/3] mmdevapi:render: Make sure to get an upper bound on the
 stream time.
To: Wine Devel <wine-devel@winehq.org>

IAudioClient::Start() can take up to 3 ms so start counting before the
call. Also stop the clock after IAudioClient::GetPosition() has returned
a value to be sure.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
---
 dlls/mmdevapi/tests/render.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/mmdevapi/tests/render.c b/dlls/mmdevapi/tests/render.c
index 839cca4ab80..eaca42d6896 100644
--- a/dlls/mmdevapi/tests/render.c
+++ b/dlls/mmdevapi/tests/render.c
@@ -1090,18 +1090,18 @@ static void test_clock(int share)
     ok(hr == S_OK, "GetPosition failed: %08x\n", hr);
     ok(pos == 0, "GetPosition returned non-zero pos before being started\n");
 
+    get_ms_since(&last_time);
     hr = IAudioClient_Start(ac); /* #1 */
     ok(hr == S_OK, "Start failed: %08x\n", hr);
 
-    get_ms_since(&last_time);
     Sleep(100);
-    slept += get_ms_since(&last_time);
 
     hr = IAudioClient_GetStreamLatency(ac, &t1);
     ok(hr == S_OK, "GetStreamLatency failed: %08x\n", hr);
     ok(t1 == t2, "Latency not constant, delta %ld\n", (long)(t1-t2));
 
     hr = IAudioClock_GetPosition(acl, &pos, NULL);
+    slept += get_ms_since(&last_time);
     ok(hr == S_OK, "GetPosition failed: %08x\n", hr);
     ok(pos > 0, "Position %u vs. last %u\n", (UINT)pos,0);
     /* in rare cases is slept*1.1 not enough with dmix */
-- 
2.20.1

