winmm: Fix conversion to MMTIME, avoid floating point arithmetic.

Joerg-Cyril.Hoehle at Joerg-Cyril.Hoehle at
Thu Jan 5 03:24:51 CST 2012


both the old alsa.c and waveform.c convert incorrectly, mainly because smpte.sec is a small BYTE entity.

I've preserved without further testing alsa.c's original rounding mode.
Note that winmm/tests/wave and winmm/waveform round differently, but it's enough for the performed tests.

Regarding the a * b / c pattern, every time I encountered it (in mciwave and mmdevapi),
MulDiv was the rounding function that produced results like native. Possibly MulDiv is used in many more such
places. Perhaps MS used MulDiv extensively because that was THE function that dealt well with
large UINT32 back when UINT64 was unavailable, i.e. (UINT64)a * b / c not useable.

All places that use (double) for higher resolution than UINT32 ought to be rewritten.

 Jörg Höhle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-winmm-Fix-conversion-to-MMTIME-avoid-floating-poin.patch
Type: application/octet-stream
Size: 3218 bytes
Desc: 0001-winmm-Fix-conversion-to-MMTIME-avoid-floating-poin.patch
URL: <>

More information about the wine-patches mailing list