Francois,
thank you for helping remove timing-caused flakiness from the tests.
I believe you forgot to test your patch in Wine(!). The test + ok(400 <= p2 && p2 <= 600, "%ums is not in the expected 400-600ms range\n", p2); should fail in every version of Wine.
Ironically, the reason is mentioned in your patch: /* Give Wine's asynchronous thread time to start up. Furthermore, * it uses 3 buffers per second, so that the positions reported * will be 333ms, 667ms etc. at best. */
IIRC, the first non-null position reported by Wine is 667ms, because it successfully queues two 333ms buffers to waveOut.
I suggest adding a todo_wine plus an additional ok(0<p2 && strcmp(buf,"2000")) that Wine won't fail. And I'd decrease the sleep to e.g. 200 and 100 <= p2 && p2 <= 300 All those times sum up, the winmm test run long enough already.
MCIWave should use winmm:waveOutGetPosition while playing, however the MCI devices hardly have any decent thread-safety and the construct if(status == MODE_PLAYING) waveOutGetPosition(hWave, &pos) else pos = stopped_pos; is unsafe, as the player may have exited meanwhile and closed hWave.
It's a compatibility bug since day one of mciwave in git history that the position increments 3 times per second only. Yet so far, no app seems to have been bothered.
Regards, Jörg Höhle