Fix winmm/wavemap SMPTE rounding

Jeremy White jwhite at codeweavers.com
Tue Feb 22 16:57:38 CST 2005


In calculating the SMPTE time, we would round incorrectly
(0:0:4.30 instead of 0:0:5.0 [the last column only goes to 29]).
This patch should fix that, and reduces the failed tests by a bit.
-------------- next part --------------
Index: dlls/winmm/wineoss/audio.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/wineoss/audio.c,v
retrieving revision 1.152
diff -u -r1.152 audio.c
--- dlls/winmm/wineoss/audio.c	28 Jan 2005 17:21:07 -0000	1.152
+++ dlls/winmm/wineoss/audio.c	22 Feb 2005 22:15:21 -0000
@@ -216,7 +216,9 @@
         TRACE("TIME_MS=%lu\n", lpTime->u.ms);
         break;
     case TIME_SMPTE:
+        lpTime->u.smpte.fps = 30;
         position = position / (format->Format.wBitsPerSample / 8 * format->Format.nChannels);
+        position += (format->Format.nSamplesPerSec / lpTime->u.smpte.fps) - 1; /* round up */
         lpTime->u.smpte.sec = position / format->Format.nSamplesPerSec;
         position -= lpTime->u.smpte.sec * format->Format.nSamplesPerSec;
         lpTime->u.smpte.min = lpTime->u.smpte.sec / 60;
@@ -225,12 +227,6 @@
         lpTime->u.smpte.min -= 60 * lpTime->u.smpte.hour;
         lpTime->u.smpte.fps = 30;
         lpTime->u.smpte.frame = position * lpTime->u.smpte.fps / format->Format.nSamplesPerSec;
-        position -= lpTime->u.smpte.frame * format->Format.nSamplesPerSec / lpTime->u.smpte.fps;
-        if (position != 0)
-        {
-            /* Round up */
-            lpTime->u.smpte.frame++;
-        }
         TRACE("TIME_SMPTE=%02u:%02u:%02u:%02u\n",
               lpTime->u.smpte.hour, lpTime->u.smpte.min,
               lpTime->u.smpte.sec, lpTime->u.smpte.frame);


More information about the wine-patches mailing list