mciwave: Seek stops and rounds position down modulo nBlockAlign.

This commit is contained in:
Jörg Höhle 2009-10-21 16:54:33 +02:00 committed by Alexandre Julliard
parent afe944c085
commit 7c62fe4639
2 changed files with 34 additions and 11 deletions

View File

@ -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);

View File

@ -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);