Jörg Höhle : mciwave: Seek stops and rounds position down modulo nBlockAlign.
Alexandre Julliard
julliard at winehq.org
Wed Nov 11 08:33:25 CST 2009
Module: wine
Branch: master
Commit: 7c62fe4639d7c6b8dbeb2e95561339f360660f40
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7c62fe4639d7c6b8dbeb2e95561339f360660f40
Author: Jörg Höhle <hoehle at users.sourceforge.net>
Date: Wed Oct 21 16:54:33 2009 +0200
mciwave: Seek stops and rounds position down modulo nBlockAlign.
---
dlls/mciwave/mciwave.c | 33 ++++++++++++++++++++++-----------
dlls/winmm/tests/mci.c | 12 ++++++++++++
2 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/dlls/mciwave/mciwave.c b/dlls/mciwave/mciwave.c
index b7a054b..d60d415 100644
--- a/dlls/mciwave/mciwave.c
+++ b/dlls/mciwave/mciwave.c
@@ -1240,26 +1240,37 @@ static DWORD WAVE_mciResume(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_GENERIC_PAR
static DWORD WAVE_mciSeek(MCIDEVICEID wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
{
WINE_MCIWAVE* wmw = WAVE_mciGetOpenDev(wDevID);
+ DWORD position, dwRet;
TRACE("(%04X, %08X, %p);\n", wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
if (wmw == NULL) return MCIERR_INVALID_DEVICE_ID;
- WAVE_mciStop(wDevID, MCI_WAIT, 0);
+ position = dwFlags & (MCI_SEEK_TO_START|MCI_SEEK_TO_END|MCI_TO);
+ if (!position) return MCIERR_MISSING_PARAMETER;
+ if (position&(position-1)) return MCIERR_FLAGS_NOT_COMPATIBLE;
- if (dwFlags & MCI_SEEK_TO_START) {
- wmw->dwPosition = 0;
- } else if (dwFlags & MCI_SEEK_TO_END) {
- wmw->dwPosition = wmw->ckWaveData.cksize;
- } else if (dwFlags & MCI_TO) {
- wmw->dwPosition = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo);
+ /* Stop sends MCI_NOTIFY_ABORTED when needed */
+ dwRet = WAVE_mciStop(wDevID, MCI_WAIT, 0);
+ if (dwRet != MMSYSERR_NOERROR) return dwRet;
+
+ if (dwFlags & MCI_TO) {
+ position = WAVE_ConvertTimeFormatToByte(wmw, lpParms->dwTo);
+ if (position > wmw->ckWaveData.cksize)
+ return MCIERR_OUTOFRANGE;
+ } else if (dwFlags & MCI_SEEK_TO_START) {
+ position = 0;
} else {
- WARN("dwFlag doesn't tell where to seek to...\n");
- return MCIERR_MISSING_PARAMETER;
+ position = wmw->ckWaveData.cksize;
}
-
- TRACE("Seeking to position=%u bytes\n", wmw->dwPosition);
+ /* Seek rounds down, unless at end */
+ if (position != wmw->ckWaveData.cksize) {
+ position /= wmw->lpWaveFormat->nBlockAlign;
+ position *= wmw->lpWaveFormat->nBlockAlign;
+ }
+ wmw->dwPosition = position;
+ TRACE("Seeking to position=%u bytes\n", position);
if (dwFlags & MCI_NOTIFY)
WAVE_mciNotify(lpParms->dwCallback, wmw, MCI_NOTIFY_SUCCESSFUL);
diff --git a/dlls/winmm/tests/mci.c b/dlls/winmm/tests/mci.c
index 248958b..e450a22 100644
--- a/dlls/winmm/tests/mci.c
+++ b/dlls/winmm/tests/mci.c
@@ -486,6 +486,18 @@ static void test_asyncWAVE(HWND hwnd)
err = mciSendString("seek mysound to 0 wait", NULL, 0, NULL);
ok(!err,"mci seek to start returned error: %d\n", err);
+ /* Seek stops. */
+ err = mciSendString("status mysound mode", buf, sizeof(buf), NULL);
+ ok(!err,"mci status mode returned error: %d\n", err);
+ if(!err) ok(!strcmp(buf,"stopped"), "mci status mode: %s\n", buf);
+
+ err = mciSendString("seek mysound wait", NULL, 0, NULL);
+ ok(err==MCIERR_MISSING_PARAMETER,"mci seek to nowhere returned error: %d\n", err);
+
+ /* cdaudio does not detect to start to end as error */
+ err = mciSendString("seek mysound to start to 0", NULL, 0, NULL);
+ ok(err==MCIERR_FLAGS_NOT_COMPATIBLE,"mci seek to start to 0 returned error: %d\n", err);
+
err = mciSendString("play mysound to 1000 notify", NULL, 0, hwnd);
ok(!err,"mci play returned error: %d\n", err);
More information about the wine-cvs
mailing list