msacm32/tests: Add some acmStreamPrepareHeader and acmStreamConvert tests.

Signed-off-by: Bruno Jesus <00cpxxx@gmail.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Bruno Jesus 2015-11-24 17:08:00 +08:00 committed by Alexandre Julliard
parent c9a040b510
commit cb5ba51f94
1 changed files with 91 additions and 1 deletions

View File

@ -527,7 +527,7 @@ static void test_prepareheader(void)
WAVEFORMATEX dst; WAVEFORMATEX dst;
MMRESULT mr; MMRESULT mr;
ACMSTREAMHEADER hdr; ACMSTREAMHEADER hdr;
BYTE buf[sizeof(WAVEFORMATEX) + 32], pcm[512], input[512]; BYTE buf[sizeof(WAVEFORMATEX) + 32], pcm[2048], input[512];
ADPCMCOEFSET *coef; ADPCMCOEFSET *coef;
src = (ADPCMWAVEFORMAT*)buf; src = (ADPCMWAVEFORMAT*)buf;
@ -567,6 +567,7 @@ static void test_prepareheader(void)
mr = acmStreamOpen(&has, NULL, (WAVEFORMATEX*)src, &dst, NULL, 0, 0, 0); mr = acmStreamOpen(&has, NULL, (WAVEFORMATEX*)src, &dst, NULL, 0, 0, 0);
ok(mr == MMSYSERR_NOERROR, "open failed: 0x%x\n", mr); ok(mr == MMSYSERR_NOERROR, "open failed: 0x%x\n", mr);
memset(input, 0, sizeof(input));
memset(&hdr, 0, sizeof(hdr)); memset(&hdr, 0, sizeof(hdr));
hdr.cbStruct = sizeof(hdr); hdr.cbStruct = sizeof(hdr);
hdr.pbSrc = input; hdr.pbSrc = input;
@ -594,6 +595,95 @@ static void test_prepareheader(void)
ok(mr == MMSYSERR_NOERROR, "prepare failed: 0x%x\n", mr); ok(mr == MMSYSERR_NOERROR, "prepare failed: 0x%x\n", mr);
ok(hdr.fdwStatus == (ACMSTREAMHEADER_STATUSF_PREPARED | ACMSTREAMHEADER_STATUSF_DONE), "header wasn't prepared: 0x%x\n", hdr.fdwStatus); ok(hdr.fdwStatus == (ACMSTREAMHEADER_STATUSF_PREPARED | ACMSTREAMHEADER_STATUSF_DONE), "header wasn't prepared: 0x%x\n", hdr.fdwStatus);
hdr.cbSrcLengthUsed = 12345;
hdr.cbDstLengthUsed = 12345;
hdr.fdwStatus &= ~ACMSTREAMHEADER_STATUSF_DONE;
mr = acmStreamConvert(has, &hdr, ACM_STREAMCONVERTF_BLOCKALIGN);
ok(mr == MMSYSERR_NOERROR, "convert failed: 0x%x\n", mr);
ok(hdr.fdwStatus & ACMSTREAMHEADER_STATUSF_DONE, "conversion was not done: 0x%x\n", hdr.fdwStatus);
ok(hdr.cbSrcLengthUsed == hdr.cbSrcLength, "expected %d, got %d\n", hdr.cbSrcLength, hdr.cbSrcLengthUsed);
todo_wine
ok(hdr.cbDstLengthUsed == 1010, "expected 1010, got %d\n", hdr.cbDstLengthUsed);
mr = acmStreamUnprepareHeader(has, &hdr, 0);
ok(mr == MMSYSERR_NOERROR, "unprepare failed: 0x%x\n", mr);
ok(hdr.fdwStatus == ACMSTREAMHEADER_STATUSF_DONE, "header wasn't unprepared: 0x%x\n", hdr.fdwStatus);
/* The 2 next tests are related to Lost Horizon (bug 24723) */
memset(&hdr, 0, sizeof(hdr));
hdr.cbStruct = sizeof(hdr);
hdr.pbSrc = input;
hdr.cbSrcLength = sizeof(input);
hdr.pbDst = pcm;
hdr.cbDstLength = -4;
mr = acmStreamPrepareHeader(has, &hdr, 0);
if (sizeof(void *) == 4) /* 64 bit fails on this test */
{
ok(mr == MMSYSERR_NOERROR, "prepare failed: 0x%x\n", mr);
ok(hdr.fdwStatus == ACMSTREAMHEADER_STATUSF_PREPARED, "header wasn't prepared: 0x%x\n", hdr.fdwStatus);
hdr.cbSrcLengthUsed = 12345;
hdr.cbDstLengthUsed = 12345;
hdr.fdwStatus &= ~ACMSTREAMHEADER_STATUSF_DONE;
mr = acmStreamConvert(has, &hdr, ACM_STREAMCONVERTF_BLOCKALIGN);
ok(mr == MMSYSERR_NOERROR, "convert failed: 0x%x\n", mr);
ok(hdr.fdwStatus & ACMSTREAMHEADER_STATUSF_DONE, "conversion was not done: 0x%x\n", hdr.fdwStatus);
ok(hdr.cbSrcLengthUsed == hdr.cbSrcLength, "expected %d, got %d\n", hdr.cbSrcLength, hdr.cbSrcLengthUsed);
todo_wine
ok(hdr.cbDstLengthUsed == 1010, "expected 1010, got %d\n", hdr.cbDstLengthUsed);
mr = acmStreamUnprepareHeader(has, &hdr, 0);
ok(mr == MMSYSERR_NOERROR, "unprepare failed: 0x%x\n", mr);
ok(hdr.fdwStatus == ACMSTREAMHEADER_STATUSF_DONE, "header wasn't unprepared: 0x%x\n", hdr.fdwStatus);
}
else
ok(mr == MMSYSERR_INVALPARAM, "expected 11, got %d\n", mr);
memset(&hdr, 0, sizeof(hdr));
hdr.cbStruct = sizeof(hdr);
hdr.pbSrc = input;
hdr.cbSrcLength = 24;
hdr.pbDst = pcm;
hdr.cbDstLength = -4;
mr = acmStreamPrepareHeader(has, &hdr, 0);
todo_wine {
ok(mr == ACMERR_NOTPOSSIBLE, "expected 0x200, got 0x%x\n", mr);
ok(hdr.fdwStatus == 0, "expected 0, got 0x%x\n", hdr.fdwStatus);
hdr.cbSrcLengthUsed = 12345;
hdr.cbDstLengthUsed = 12345;
mr = acmStreamConvert(has, &hdr, ACM_STREAMCONVERTF_BLOCKALIGN);
ok(mr == ACMERR_UNPREPARED, "expected 0x202, got 0x%x\n", mr);
ok(hdr.cbSrcLengthUsed == 12345, "expected 12345, got %d\n", hdr.cbSrcLengthUsed);
ok(hdr.cbDstLengthUsed == 12345, "expected 12345, got %d\n", hdr.cbDstLengthUsed);
mr = acmStreamUnprepareHeader(has, &hdr, 0);
ok(mr == ACMERR_UNPREPARED, "expected 0x202, got 0x%x\n", mr);
}
/* Less output space than required */
memset(&hdr, 0, sizeof(hdr));
hdr.cbStruct = sizeof(hdr);
hdr.pbSrc = input;
hdr.cbSrcLength = sizeof(input);
hdr.pbDst = pcm;
hdr.cbDstLength = 32;
mr = acmStreamPrepareHeader(has, &hdr, 0);
ok(mr == MMSYSERR_NOERROR, "prepare failed: 0x%x\n", mr);
ok(hdr.fdwStatus == ACMSTREAMHEADER_STATUSF_PREPARED, "header wasn't prepared: 0x%x\n", hdr.fdwStatus);
hdr.cbSrcLengthUsed = 12345;
hdr.cbDstLengthUsed = 12345;
hdr.fdwStatus &= ~ACMSTREAMHEADER_STATUSF_DONE;
mr = acmStreamConvert(has, &hdr, ACM_STREAMCONVERTF_BLOCKALIGN);
ok(mr == MMSYSERR_NOERROR, "convert failed: 0x%x\n", mr);
ok(hdr.fdwStatus & ACMSTREAMHEADER_STATUSF_DONE, "conversion was not done: 0x%x\n", hdr.fdwStatus);
todo_wine
ok(hdr.cbSrcLengthUsed == hdr.cbSrcLength, "expected %d, got %d\n", hdr.cbSrcLength, hdr.cbSrcLengthUsed);
todo_wine
ok(hdr.cbDstLengthUsed == hdr.cbDstLength, "expected %d, got %d\n", hdr.cbDstLength, hdr.cbDstLengthUsed);
mr = acmStreamUnprepareHeader(has, &hdr, 0); mr = acmStreamUnprepareHeader(has, &hdr, 0);
ok(mr == MMSYSERR_NOERROR, "unprepare failed: 0x%x\n", mr); ok(mr == MMSYSERR_NOERROR, "unprepare failed: 0x%x\n", mr);
ok(hdr.fdwStatus == ACMSTREAMHEADER_STATUSF_DONE, "header wasn't unprepared: 0x%x\n", hdr.fdwStatus); ok(hdr.fdwStatus == ACMSTREAMHEADER_STATUSF_DONE, "header wasn't unprepared: 0x%x\n", hdr.fdwStatus);