2004-05-03 22:17:43 +02:00
|
|
|
/*
|
|
|
|
* Unit tests for msacm functions
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004 Robert Reif
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-05-03 22:17:43 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "mmsystem.h"
|
2004-08-11 21:35:34 +02:00
|
|
|
#define NOBITMAP
|
2004-05-03 22:17:43 +02:00
|
|
|
#include "mmreg.h"
|
|
|
|
#include "msacm.h"
|
|
|
|
|
2004-05-10 21:56:53 +02:00
|
|
|
static BOOL CALLBACK FormatTagEnumProc(HACMDRIVERID hadid,
|
2013-10-23 22:38:41 +02:00
|
|
|
PACMFORMATTAGDETAILSA paftd,
|
2009-02-05 09:52:31 +01:00
|
|
|
DWORD_PTR dwInstance,
|
2004-05-10 21:56:53 +02:00
|
|
|
DWORD fdwSupport)
|
|
|
|
{
|
2004-08-11 20:49:52 +02:00
|
|
|
if (winetest_interactive)
|
2006-10-05 22:05:58 +02:00
|
|
|
trace(" Format 0x%04x: %s\n", paftd->dwFormatTag, paftd->szFormatTag);
|
2004-05-10 21:56:53 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-05-03 22:17:43 +02:00
|
|
|
static BOOL CALLBACK FormatEnumProc(HACMDRIVERID hadid,
|
2013-10-23 22:38:41 +02:00
|
|
|
LPACMFORMATDETAILSA pafd,
|
2009-02-05 09:52:31 +01:00
|
|
|
DWORD_PTR dwInstance,
|
2004-05-03 22:17:43 +02:00
|
|
|
DWORD fd)
|
|
|
|
{
|
2004-08-11 20:49:52 +02:00
|
|
|
if (winetest_interactive)
|
2006-10-05 22:05:58 +02:00
|
|
|
trace(" 0x%04x, %s\n", pafd->dwFormatTag, pafd->szFormat);
|
2004-05-03 22:17:43 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL CALLBACK DriverEnumProc(HACMDRIVERID hadid,
|
2009-02-05 09:52:31 +01:00
|
|
|
DWORD_PTR dwInstance,
|
2004-05-03 22:17:43 +02:00
|
|
|
DWORD fdwSupport)
|
|
|
|
{
|
|
|
|
MMRESULT rc;
|
2013-10-23 22:38:41 +02:00
|
|
|
ACMDRIVERDETAILSA dd;
|
2004-05-03 22:17:43 +02:00
|
|
|
HACMDRIVER had;
|
2006-01-17 16:00:16 +01:00
|
|
|
|
|
|
|
DWORD dwDriverPriority;
|
|
|
|
DWORD dwDriverSupport;
|
2004-05-03 22:17:43 +02:00
|
|
|
|
2004-08-11 20:49:52 +02:00
|
|
|
if (winetest_interactive) {
|
|
|
|
trace("id: %p\n", hadid);
|
|
|
|
trace(" Supports:\n");
|
|
|
|
if (fdwSupport & ACMDRIVERDETAILS_SUPPORTF_ASYNC)
|
|
|
|
trace(" async conversions\n");
|
|
|
|
if (fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CODEC)
|
|
|
|
trace(" different format conversions\n");
|
|
|
|
if (fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CONVERTER)
|
|
|
|
trace(" same format conversions\n");
|
|
|
|
if (fdwSupport & ACMDRIVERDETAILS_SUPPORTF_FILTER)
|
|
|
|
trace(" filtering\n");
|
|
|
|
}
|
2004-05-03 22:17:43 +02:00
|
|
|
|
|
|
|
/* try an invalid pointer */
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmDriverDetailsA(hadid, 0, 0);
|
2004-05-03 22:17:43 +02:00
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmDriverDetailsA(): rc = %08x, should be %08x\n",
|
2004-05-03 22:17:43 +02:00
|
|
|
rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
/* try an invalid structure size */
|
|
|
|
ZeroMemory(&dd, sizeof(dd));
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmDriverDetailsA(hadid, &dd, 0);
|
2004-05-03 22:17:43 +02:00
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmDriverDetailsA(): rc = %08x, should be %08x\n",
|
2004-05-03 22:17:43 +02:00
|
|
|
rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
/* MSDN says this should fail but it doesn't in practice */
|
|
|
|
dd.cbStruct = 4;
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmDriverDetailsA(hadid, &dd, 0);
|
2009-08-21 16:22:56 +02:00
|
|
|
ok(rc == MMSYSERR_NOERROR || rc == MMSYSERR_NOTSUPPORTED,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmDriverDetailsA(): rc = %08x, should be %08x\n",
|
2004-05-03 22:17:43 +02:00
|
|
|
rc, MMSYSERR_NOERROR);
|
|
|
|
|
|
|
|
/* try an invalid handle */
|
|
|
|
dd.cbStruct = sizeof(dd);
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmDriverDetailsA((HACMDRIVERID)1, &dd, 0);
|
2004-05-03 22:17:43 +02:00
|
|
|
ok(rc == MMSYSERR_INVALHANDLE,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmDriverDetailsA(): rc = %08x, should be %08x\n",
|
2004-05-03 22:17:43 +02:00
|
|
|
rc, MMSYSERR_INVALHANDLE);
|
|
|
|
|
|
|
|
/* try an invalid handle and pointer */
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmDriverDetailsA((HACMDRIVERID)1, 0, 0);
|
2004-05-03 22:17:43 +02:00
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmDriverDetailsA(): rc = %08x, should be %08x\n",
|
2004-05-03 22:17:43 +02:00
|
|
|
rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
/* try invalid details */
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmDriverDetailsA(hadid, &dd, -1);
|
2004-05-03 22:17:43 +02:00
|
|
|
ok(rc == MMSYSERR_INVALFLAG,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmDriverDetailsA(): rc = %08x, should be %08x\n",
|
2004-05-03 22:17:43 +02:00
|
|
|
rc, MMSYSERR_INVALFLAG);
|
|
|
|
|
|
|
|
/* try valid parameters */
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmDriverDetailsA(hadid, &dd, 0);
|
2009-08-21 16:22:56 +02:00
|
|
|
ok(rc == MMSYSERR_NOERROR || rc == MMSYSERR_NOTSUPPORTED,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmDriverDetailsA(): rc = %08x, should be %08x\n",
|
2004-05-03 22:17:43 +02:00
|
|
|
rc, MMSYSERR_NOERROR);
|
|
|
|
|
2005-12-20 11:48:01 +01:00
|
|
|
/* cbStruct should contain size of returned data (at most sizeof(dd))
|
|
|
|
TODO: should it be *exactly* sizeof(dd), as tested here?
|
|
|
|
*/
|
2009-10-06 10:35:29 +02:00
|
|
|
if (rc == MMSYSERR_NOERROR) {
|
2015-09-21 20:13:24 +02:00
|
|
|
static const struct {
|
2015-05-26 22:09:31 +02:00
|
|
|
const char *shortname;
|
2015-09-21 20:13:24 +02:00
|
|
|
WORD mid;
|
|
|
|
WORD pid;
|
|
|
|
WORD pid_alt;
|
2015-05-26 22:09:31 +02:00
|
|
|
} *iter, expected_ids[] = {
|
|
|
|
{ "Microsoft IMA ADPCM", MM_MICROSOFT, MM_MSFT_ACM_IMAADPCM },
|
|
|
|
{ "MS-ADPCM", MM_MICROSOFT, MM_MSFT_ACM_MSADPCM },
|
|
|
|
{ "Microsoft CCITT G.711", MM_MICROSOFT, MM_MSFT_ACM_G711},
|
2015-09-21 20:13:24 +02:00
|
|
|
{ "MPEG Layer-3 Codec", MM_FRAUNHOFER_IIS, MM_FHGIIS_MPEGLAYER3_DECODE, MM_FHGIIS_MPEGLAYER3_PROFESSIONAL },
|
2015-05-26 22:09:31 +02:00
|
|
|
{ "MS-PCM", MM_MICROSOFT, MM_MSFT_ACM_PCM },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
2005-12-20 11:48:01 +01:00
|
|
|
ok(dd.cbStruct == sizeof(dd),
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmDriverDetailsA(): cbStruct = %08x\n", dd.cbStruct);
|
2015-05-26 22:09:31 +02:00
|
|
|
|
|
|
|
for (iter = expected_ids; iter->shortname; ++iter) {
|
2015-10-13 23:58:37 +02:00
|
|
|
if (!strcmp(iter->shortname, dd.szShortName)) {
|
2015-09-21 20:13:24 +02:00
|
|
|
/* try alternative product id on mismatch */
|
|
|
|
if (iter->pid_alt && iter->pid != dd.wPid)
|
|
|
|
ok(iter->mid == dd.wMid && iter->pid_alt == dd.wPid,
|
|
|
|
"Got wrong manufacturer (0x%x vs 0x%x) or product (0x%x vs 0x%x)\n",
|
|
|
|
dd.wMid, iter->mid,
|
|
|
|
dd.wPid, iter->pid_alt);
|
|
|
|
else
|
|
|
|
ok(iter->mid == dd.wMid && iter->pid == dd.wPid,
|
2015-05-26 22:09:31 +02:00
|
|
|
"Got wrong manufacturer (0x%x vs 0x%x) or product (0x%x vs 0x%x)\n",
|
|
|
|
dd.wMid, iter->mid,
|
|
|
|
dd.wPid, iter->pid);
|
|
|
|
}
|
|
|
|
}
|
2005-12-20 11:48:01 +01:00
|
|
|
}
|
|
|
|
|
2004-08-11 20:49:52 +02:00
|
|
|
if (rc == MMSYSERR_NOERROR && winetest_interactive) {
|
2004-05-03 22:17:43 +02:00
|
|
|
trace(" Short name: %s\n", dd.szShortName);
|
|
|
|
trace(" Long name: %s\n", dd.szLongName);
|
|
|
|
trace(" Copyright: %s\n", dd.szCopyright);
|
|
|
|
trace(" Licensing: %s\n", dd.szLicensing);
|
|
|
|
trace(" Features: %s\n", dd.szFeatures);
|
2006-10-05 22:05:58 +02:00
|
|
|
trace(" Supports %u formats\n", dd.cFormatTags);
|
|
|
|
trace(" Supports %u filter formats\n", dd.cFilterTags);
|
2015-05-26 22:09:31 +02:00
|
|
|
trace(" Mid: 0x%x\n", dd.wMid);
|
|
|
|
trace(" Pid: 0x%x\n", dd.wPid);
|
2004-05-03 22:17:43 +02:00
|
|
|
}
|
|
|
|
|
2006-01-17 16:00:16 +01:00
|
|
|
/* try bad pointer */
|
|
|
|
rc = acmMetrics((HACMOBJ)hadid, ACM_METRIC_DRIVER_PRIORITY, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
|
|
|
"acmMetrics(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
/* try bad handle */
|
|
|
|
rc = acmMetrics((HACMOBJ)1, ACM_METRIC_DRIVER_PRIORITY, &dwDriverPriority);
|
|
|
|
ok(rc == MMSYSERR_INVALHANDLE,
|
|
|
|
"acmMetrics(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALHANDLE);
|
|
|
|
|
|
|
|
/* try bad pointer and handle */
|
|
|
|
rc = acmMetrics((HACMOBJ)1, ACM_METRIC_DRIVER_PRIORITY, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALHANDLE,
|
|
|
|
"acmMetrics(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALHANDLE);
|
|
|
|
|
|
|
|
/* try valid parameters */
|
|
|
|
rc = acmMetrics((HACMOBJ)hadid, ACM_METRIC_DRIVER_PRIORITY, &dwDriverSupport);
|
|
|
|
ok(rc == MMSYSERR_NOERROR,
|
|
|
|
"acmMetrics(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_NOERROR);
|
|
|
|
|
|
|
|
/* try bad pointer */
|
|
|
|
rc = acmMetrics((HACMOBJ)hadid, ACM_METRIC_DRIVER_SUPPORT, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
|
|
|
"acmMetrics(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
/* try bad handle */
|
|
|
|
rc = acmMetrics((HACMOBJ)1, ACM_METRIC_DRIVER_SUPPORT, &dwDriverSupport);
|
|
|
|
ok(rc == MMSYSERR_INVALHANDLE,
|
|
|
|
"acmMetrics(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALHANDLE);
|
|
|
|
|
|
|
|
/* try bad pointer and handle */
|
|
|
|
rc = acmMetrics((HACMOBJ)1, ACM_METRIC_DRIVER_SUPPORT, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALHANDLE,
|
|
|
|
"acmMetrics(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALHANDLE);
|
|
|
|
|
|
|
|
/* try valid parameters */
|
|
|
|
rc = acmMetrics((HACMOBJ)hadid, ACM_METRIC_DRIVER_SUPPORT, &dwDriverSupport);
|
|
|
|
ok(rc == MMSYSERR_NOERROR,
|
|
|
|
"acmMetrics(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_NOERROR);
|
|
|
|
|
2004-05-03 22:17:43 +02:00
|
|
|
/* try invalid pointer */
|
|
|
|
rc = acmDriverOpen(0, hadid, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
|
|
|
"acmDriverOpen(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
/* try invalid handle */
|
|
|
|
rc = acmDriverOpen(&had, (HACMDRIVERID)1, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALHANDLE,
|
|
|
|
"acmDriverOpen(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALHANDLE);
|
|
|
|
|
|
|
|
/* try invalid open */
|
|
|
|
rc = acmDriverOpen(&had, hadid, -1);
|
|
|
|
ok(rc == MMSYSERR_INVALFLAG,
|
|
|
|
"acmDriverOpen(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALFLAG);
|
|
|
|
|
|
|
|
/* try valid parameters */
|
|
|
|
rc = acmDriverOpen(&had, hadid, 0);
|
2009-08-21 16:22:56 +02:00
|
|
|
ok(rc == MMSYSERR_NOERROR || rc == MMSYSERR_NODRIVER,
|
2004-05-03 22:17:43 +02:00
|
|
|
"acmDriverOpen(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_NOERROR);
|
|
|
|
|
|
|
|
if (rc == MMSYSERR_NOERROR) {
|
|
|
|
DWORD dwSize;
|
|
|
|
HACMDRIVERID hid;
|
|
|
|
|
|
|
|
/* try bad pointer */
|
|
|
|
rc = acmDriverID((HACMOBJ)had, 0, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
|
|
|
"acmDriverID(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
/* try bad handle */
|
|
|
|
rc = acmDriverID((HACMOBJ)1, &hid, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALHANDLE,
|
2006-01-17 16:00:16 +01:00
|
|
|
"acmDriverID(): rc = %08x, should be %08x\n",
|
2004-05-03 22:17:43 +02:00
|
|
|
rc, MMSYSERR_INVALHANDLE);
|
|
|
|
|
|
|
|
/* try bad handle and pointer */
|
|
|
|
rc = acmDriverID((HACMOBJ)1, 0, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALHANDLE,
|
2006-01-17 16:00:16 +01:00
|
|
|
"acmDriverID(): rc = %08x, should be %08x\n",
|
2004-05-03 22:17:43 +02:00
|
|
|
rc, MMSYSERR_INVALHANDLE);
|
|
|
|
|
|
|
|
/* try bad flag */
|
|
|
|
rc = acmDriverID((HACMOBJ)had, &hid, 1);
|
|
|
|
ok(rc == MMSYSERR_INVALFLAG,
|
|
|
|
"acmDriverID(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALFLAG);
|
|
|
|
|
|
|
|
/* try valid parameters */
|
|
|
|
rc = acmDriverID((HACMOBJ)had, &hid, 0);
|
|
|
|
ok(rc == MMSYSERR_NOERROR,
|
|
|
|
"acmDriverID(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_NOERROR);
|
|
|
|
ok(hid == hadid,
|
2005-09-12 16:12:46 +02:00
|
|
|
"acmDriverID() returned ID %p doesn't equal %p\n",
|
|
|
|
hid, hadid);
|
2004-05-03 22:17:43 +02:00
|
|
|
|
|
|
|
/* try bad pointer */
|
|
|
|
rc = acmMetrics((HACMOBJ)had, ACM_METRIC_MAX_SIZE_FORMAT, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
|
|
|
"acmMetrics(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
/* try bad handle */
|
|
|
|
rc = acmMetrics((HACMOBJ)1, ACM_METRIC_MAX_SIZE_FORMAT, &dwSize);
|
|
|
|
ok(rc == MMSYSERR_INVALHANDLE,
|
|
|
|
"acmMetrics(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALHANDLE);
|
|
|
|
|
|
|
|
/* try bad pointer and handle */
|
|
|
|
rc = acmMetrics((HACMOBJ)1, ACM_METRIC_MAX_SIZE_FORMAT, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALHANDLE,
|
|
|
|
"acmMetrics(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALHANDLE);
|
|
|
|
|
|
|
|
/* try valid parameters */
|
|
|
|
rc = acmMetrics((HACMOBJ)had, ACM_METRIC_MAX_SIZE_FORMAT, &dwSize);
|
|
|
|
ok(rc == MMSYSERR_NOERROR,
|
|
|
|
"acmMetrics(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_NOERROR);
|
|
|
|
if (rc == MMSYSERR_NOERROR) {
|
2013-10-23 22:38:41 +02:00
|
|
|
ACMFORMATDETAILSA fd;
|
2004-05-10 21:56:53 +02:00
|
|
|
WAVEFORMATEX * pwfx;
|
2013-10-23 22:38:41 +02:00
|
|
|
ACMFORMATTAGDETAILSA aftd;
|
2004-05-10 21:56:53 +02:00
|
|
|
|
2004-05-03 22:17:43 +02:00
|
|
|
/* try bad pointer */
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmFormatEnumA(had, 0, FormatEnumProc, 0, 0);
|
2004-05-03 22:17:43 +02:00
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmFormatEnumA(): rc = %08x, should be %08x\n",
|
2004-05-03 22:17:43 +02:00
|
|
|
rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
/* try bad structure size */
|
|
|
|
ZeroMemory(&fd, sizeof(fd));
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmFormatEnumA(had, &fd, FormatEnumProc, 0, 0);
|
2004-05-03 22:17:43 +02:00
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmFormatEnumA(): rc = %08x, should be %08x\n",
|
2004-05-03 22:17:43 +02:00
|
|
|
rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
fd.cbStruct = sizeof(fd) - 1;
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmFormatEnumA(had, &fd, FormatEnumProc, 0, 0);
|
2004-05-03 22:17:43 +02:00
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmFormatEnumA(): rc = %08x, should be %08x\n",
|
2004-05-03 22:17:43 +02:00
|
|
|
rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
if (dwSize < sizeof(WAVEFORMATEX))
|
|
|
|
dwSize = sizeof(WAVEFORMATEX);
|
|
|
|
|
2007-06-26 01:05:19 +02:00
|
|
|
pwfx = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize);
|
2004-05-03 22:17:43 +02:00
|
|
|
|
|
|
|
pwfx->cbSize = LOWORD(dwSize) - sizeof(WAVEFORMATEX);
|
|
|
|
pwfx->wFormatTag = WAVE_FORMAT_UNKNOWN;
|
|
|
|
|
|
|
|
fd.cbStruct = sizeof(fd);
|
|
|
|
fd.pwfx = pwfx;
|
|
|
|
fd.cbwfx = dwSize;
|
|
|
|
fd.dwFormatTag = WAVE_FORMAT_UNKNOWN;
|
|
|
|
|
|
|
|
/* try valid parameters */
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmFormatEnumA(had, &fd, FormatEnumProc, 0, 0);
|
2004-05-03 22:17:43 +02:00
|
|
|
ok(rc == MMSYSERR_NOERROR,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmFormatEnumA(): rc = %08x, should be %08x\n",
|
2004-05-03 22:17:43 +02:00
|
|
|
rc, MMSYSERR_NOERROR);
|
|
|
|
|
2004-05-10 21:56:53 +02:00
|
|
|
/* try bad pointer */
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmFormatTagEnumA(had, 0, FormatTagEnumProc, 0, 0);
|
2004-05-10 21:56:53 +02:00
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmFormatTagEnumA(): rc = %08x, should be %08x\n",
|
2004-05-10 21:56:53 +02:00
|
|
|
rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
/* try bad structure size */
|
2005-04-25 12:48:38 +02:00
|
|
|
ZeroMemory(&aftd, sizeof(aftd));
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmFormatTagEnumA(had, &aftd, FormatTagEnumProc, 0, 0);
|
2004-05-10 21:56:53 +02:00
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmFormatTagEnumA(): rc = %08x, should be %08x\n",
|
2004-05-10 21:56:53 +02:00
|
|
|
rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
aftd.cbStruct = sizeof(aftd) - 1;
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmFormatTagEnumA(had, &aftd, FormatTagEnumProc, 0, 0);
|
2004-05-10 21:56:53 +02:00
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmFormatTagEnumA(): rc = %08x, should be %08x\n",
|
2004-05-10 21:56:53 +02:00
|
|
|
rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
aftd.cbStruct = sizeof(aftd);
|
|
|
|
aftd.dwFormatTag = WAVE_FORMAT_UNKNOWN;
|
|
|
|
|
|
|
|
/* try bad flag */
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmFormatTagEnumA(had, &aftd, FormatTagEnumProc, 0, 1);
|
2004-05-10 21:56:53 +02:00
|
|
|
ok(rc == MMSYSERR_INVALFLAG,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmFormatTagEnumA(): rc = %08x, should be %08x\n",
|
2004-05-10 21:56:53 +02:00
|
|
|
rc, MMSYSERR_INVALFLAG);
|
|
|
|
|
|
|
|
/* try valid parameters */
|
2013-10-23 22:38:41 +02:00
|
|
|
rc = acmFormatTagEnumA(had, &aftd, FormatTagEnumProc, 0, 0);
|
2004-05-10 21:56:53 +02:00
|
|
|
ok(rc == MMSYSERR_NOERROR,
|
2013-10-23 22:38:41 +02:00
|
|
|
"acmFormatTagEnumA(): rc = %08x, should be %08x\n",
|
2004-05-10 21:56:53 +02:00
|
|
|
rc, MMSYSERR_NOERROR);
|
|
|
|
|
2007-06-26 01:05:19 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, pwfx);
|
2004-05-03 22:17:43 +02:00
|
|
|
|
|
|
|
/* try invalid handle */
|
|
|
|
rc = acmDriverClose((HACMDRIVER)1, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALHANDLE,
|
|
|
|
"acmDriverClose(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALHANDLE);
|
|
|
|
|
|
|
|
/* try invalid flag */
|
|
|
|
rc = acmDriverClose(had, 1);
|
|
|
|
ok(rc == MMSYSERR_INVALFLAG,
|
|
|
|
"acmDriverClose(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALFLAG);
|
|
|
|
|
|
|
|
/* try valid parameters */
|
|
|
|
rc = acmDriverClose(had, 0);
|
|
|
|
ok(rc == MMSYSERR_NOERROR,
|
|
|
|
"acmDriverClose(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_NOERROR);
|
|
|
|
|
|
|
|
/* try closing again */
|
|
|
|
rc = acmDriverClose(had, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALHANDLE,
|
|
|
|
"acmDriverClose(): rc = %08x, should be %08x\n",
|
|
|
|
rc, MMSYSERR_INVALHANDLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char * get_metric(UINT uMetric)
|
|
|
|
{
|
|
|
|
switch (uMetric) {
|
|
|
|
case ACM_METRIC_COUNT_CODECS:
|
|
|
|
return "ACM_METRIC_COUNT_CODECS";
|
|
|
|
case ACM_METRIC_COUNT_CONVERTERS:
|
|
|
|
return "ACM_METRIC_COUNT_CONVERTERS";
|
|
|
|
case ACM_METRIC_COUNT_DISABLED:
|
|
|
|
return "ACM_METRIC_COUNT_DISABLED";
|
|
|
|
case ACM_METRIC_COUNT_DRIVERS:
|
|
|
|
return "ACM_METRIC_COUNT_DRIVERS";
|
|
|
|
case ACM_METRIC_COUNT_FILTERS:
|
|
|
|
return "ACM_METRIC_COUNT_FILTERS";
|
|
|
|
case ACM_METRIC_COUNT_HARDWARE:
|
|
|
|
return "ACM_METRIC_COUNT_HARDWARE";
|
|
|
|
case ACM_METRIC_COUNT_LOCAL_CODECS:
|
|
|
|
return "ACM_METRIC_COUNT_LOCAL_CODECS";
|
|
|
|
case ACM_METRIC_COUNT_LOCAL_CONVERTERS:
|
|
|
|
return "ACM_METRIC_COUNT_LOCAL_CONVERTERS";
|
|
|
|
case ACM_METRIC_COUNT_LOCAL_DISABLED:
|
|
|
|
return "ACM_METRIC_COUNT_LOCAL_DISABLED";
|
|
|
|
case ACM_METRIC_COUNT_LOCAL_DRIVERS:
|
|
|
|
return "ACM_METRIC_COUNT_LOCAL_DRIVERS";
|
|
|
|
case ACM_METRIC_COUNT_LOCAL_FILTERS:
|
|
|
|
return "ACM_METRIC_COUNT_LOCAL_FILTERS";
|
|
|
|
case ACM_METRIC_DRIVER_PRIORITY:
|
|
|
|
return "ACM_METRIC_DRIVER_PRIORITY";
|
|
|
|
case ACM_METRIC_DRIVER_SUPPORT:
|
|
|
|
return "ACM_METRIC_DRIVER_SUPPORT";
|
|
|
|
case ACM_METRIC_HARDWARE_WAVE_INPUT:
|
|
|
|
return "ACM_METRIC_HARDWARE_WAVE_INPUT";
|
|
|
|
case ACM_METRIC_HARDWARE_WAVE_OUTPUT:
|
|
|
|
return "ACM_METRIC_HARDWARE_WAVE_OUTPUT";
|
|
|
|
case ACM_METRIC_MAX_SIZE_FILTER:
|
|
|
|
return "ACM_METRIC_MAX_SIZE_FILTER";
|
|
|
|
case ACM_METRIC_MAX_SIZE_FORMAT:
|
|
|
|
return "ACM_METRIC_MAX_SIZE_FORMAT";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
|
|
|
|
2010-05-01 01:39:29 +02:00
|
|
|
static void check_count(UINT uMetric)
|
2004-05-03 22:17:43 +02:00
|
|
|
{
|
|
|
|
DWORD dwMetric;
|
|
|
|
MMRESULT rc;
|
|
|
|
|
|
|
|
/* try invalid result pointer */
|
|
|
|
rc = acmMetrics(NULL, uMetric, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM,
|
|
|
|
"acmMetrics(NULL, %s, 0): rc = 0x%08x, should be 0x%08x\n",
|
|
|
|
get_metric(uMetric), rc, MMSYSERR_INVALPARAM);
|
|
|
|
|
|
|
|
/* try invalid handle */
|
|
|
|
rc = acmMetrics((HACMOBJ)1, uMetric, &dwMetric);
|
|
|
|
ok(rc == MMSYSERR_INVALHANDLE,
|
|
|
|
"acmMetrics(1, %s, %p): rc = 0x%08x, should be 0x%08x\n",
|
|
|
|
get_metric(uMetric), &dwMetric, rc, MMSYSERR_INVALHANDLE);
|
|
|
|
|
|
|
|
/* try invalid result pointer and handle */
|
|
|
|
rc = acmMetrics((HACMOBJ)1, uMetric, 0);
|
|
|
|
ok(rc == MMSYSERR_INVALHANDLE,
|
|
|
|
"acmMetrics(1, %s, 0): rc = 0x%08x, should be 0x%08x\n",
|
|
|
|
get_metric(uMetric), rc, MMSYSERR_INVALHANDLE);
|
|
|
|
|
|
|
|
/* try valid parameters */
|
|
|
|
rc = acmMetrics(NULL, uMetric, &dwMetric);
|
|
|
|
ok(rc == MMSYSERR_NOERROR, "acmMetrics() failed: rc = 0x%08x\n", rc);
|
|
|
|
|
2004-08-11 20:49:52 +02:00
|
|
|
if (rc == MMSYSERR_NOERROR && winetest_interactive)
|
2006-10-05 22:05:58 +02:00
|
|
|
trace("%s: %u\n", get_metric(uMetric), dwMetric);
|
2004-05-03 22:17:43 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 17:06:02 +01:00
|
|
|
static void driver_tests(void)
|
2004-05-03 22:17:43 +02:00
|
|
|
{
|
|
|
|
MMRESULT rc;
|
|
|
|
DWORD dwACMVersion = acmGetVersion();
|
|
|
|
|
2004-08-11 20:49:52 +02:00
|
|
|
if (winetest_interactive) {
|
|
|
|
trace("ACM version = %u.%02u build %u%s\n",
|
|
|
|
HIWORD(dwACMVersion) >> 8,
|
|
|
|
HIWORD(dwACMVersion) & 0xff,
|
|
|
|
LOWORD(dwACMVersion),
|
|
|
|
LOWORD(dwACMVersion) == 0 ? " (Retail)" : "");
|
|
|
|
}
|
2004-05-03 22:17:43 +02:00
|
|
|
|
2010-05-01 01:39:29 +02:00
|
|
|
check_count(ACM_METRIC_COUNT_CODECS);
|
|
|
|
check_count(ACM_METRIC_COUNT_CONVERTERS);
|
|
|
|
check_count(ACM_METRIC_COUNT_DISABLED);
|
|
|
|
check_count(ACM_METRIC_COUNT_DRIVERS);
|
|
|
|
check_count(ACM_METRIC_COUNT_FILTERS);
|
|
|
|
check_count(ACM_METRIC_COUNT_HARDWARE);
|
|
|
|
check_count(ACM_METRIC_COUNT_LOCAL_CODECS);
|
|
|
|
check_count(ACM_METRIC_COUNT_LOCAL_CONVERTERS);
|
|
|
|
check_count(ACM_METRIC_COUNT_LOCAL_DISABLED);
|
|
|
|
check_count(ACM_METRIC_COUNT_LOCAL_DRIVERS);
|
|
|
|
check_count(ACM_METRIC_COUNT_LOCAL_FILTERS);
|
2004-05-03 22:17:43 +02:00
|
|
|
|
2004-08-11 20:49:52 +02:00
|
|
|
if (winetest_interactive)
|
|
|
|
trace("enabled drivers:\n");
|
|
|
|
|
2004-05-03 22:17:43 +02:00
|
|
|
rc = acmDriverEnum(DriverEnumProc, 0, 0);
|
|
|
|
ok(rc == MMSYSERR_NOERROR,
|
|
|
|
"acmDriverEnum() failed, rc=%08x, should be 0x%08x\n",
|
|
|
|
rc, MMSYSERR_NOERROR);
|
|
|
|
}
|
|
|
|
|
2013-11-04 17:06:02 +01:00
|
|
|
static void test_prepareheader(void)
|
|
|
|
{
|
|
|
|
HACMSTREAM has;
|
|
|
|
ADPCMWAVEFORMAT *src;
|
|
|
|
WAVEFORMATEX dst;
|
|
|
|
MMRESULT mr;
|
|
|
|
ACMSTREAMHEADER hdr;
|
2015-11-24 10:08:00 +01:00
|
|
|
BYTE buf[sizeof(WAVEFORMATEX) + 32], pcm[2048], input[512];
|
2013-11-04 17:06:02 +01:00
|
|
|
ADPCMCOEFSET *coef;
|
|
|
|
|
|
|
|
src = (ADPCMWAVEFORMAT*)buf;
|
|
|
|
coef = src->aCoef;
|
|
|
|
src->wfx.cbSize = 32;
|
|
|
|
src->wfx.wFormatTag = WAVE_FORMAT_ADPCM;
|
|
|
|
src->wfx.nSamplesPerSec = 22050;
|
|
|
|
src->wfx.wBitsPerSample = 4;
|
|
|
|
src->wfx.nChannels = 1;
|
|
|
|
src->wfx.nBlockAlign = 512;
|
|
|
|
src->wfx.nAvgBytesPerSec = 11025;
|
|
|
|
src->wSamplesPerBlock = 0x3f4;
|
|
|
|
src->wNumCoef = 7;
|
|
|
|
coef[0].iCoef1 = 0x0100;
|
|
|
|
coef[0].iCoef2 = 0x0000;
|
|
|
|
coef[1].iCoef1 = 0x0200;
|
|
|
|
coef[1].iCoef2 = 0xff00;
|
|
|
|
coef[2].iCoef1 = 0x0000;
|
|
|
|
coef[2].iCoef2 = 0x0000;
|
|
|
|
coef[3].iCoef1 = 0x00c0;
|
|
|
|
coef[3].iCoef2 = 0x0040;
|
|
|
|
coef[4].iCoef1 = 0x00f0;
|
|
|
|
coef[4].iCoef2 = 0x0000;
|
|
|
|
coef[5].iCoef1 = 0x01cc;
|
|
|
|
coef[5].iCoef2 = 0xff30;
|
|
|
|
coef[6].iCoef1 = 0x0188;
|
|
|
|
coef[6].iCoef2 = 0xff18;
|
|
|
|
|
|
|
|
dst.cbSize = 0;
|
|
|
|
dst.wFormatTag = WAVE_FORMAT_PCM;
|
|
|
|
dst.nSamplesPerSec = 22050;
|
|
|
|
dst.wBitsPerSample = 8;
|
|
|
|
dst.nChannels = 1;
|
|
|
|
dst.nBlockAlign = dst.wBitsPerSample * dst.nChannels / 8;
|
|
|
|
dst.nAvgBytesPerSec = dst.nSamplesPerSec * dst.nBlockAlign;
|
|
|
|
|
|
|
|
mr = acmStreamOpen(&has, NULL, (WAVEFORMATEX*)src, &dst, NULL, 0, 0, 0);
|
|
|
|
ok(mr == MMSYSERR_NOERROR, "open failed: 0x%x\n", mr);
|
|
|
|
|
2015-11-24 10:08:00 +01:00
|
|
|
memset(input, 0, sizeof(input));
|
2013-11-04 17:06:02 +01:00
|
|
|
memset(&hdr, 0, sizeof(hdr));
|
|
|
|
hdr.cbStruct = sizeof(hdr);
|
|
|
|
hdr.pbSrc = input;
|
|
|
|
hdr.cbSrcLength = sizeof(input);
|
|
|
|
hdr.pbDst = pcm;
|
|
|
|
hdr.cbDstLength = sizeof(pcm);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
mr = acmStreamUnprepareHeader(has, &hdr, 0);
|
|
|
|
ok(mr == MMSYSERR_NOERROR, "unprepare failed: 0x%x\n", mr);
|
|
|
|
ok(hdr.fdwStatus == 0, "header wasn't unprepared: 0x%x\n", hdr.fdwStatus);
|
|
|
|
|
2015-11-27 14:10:04 +01:00
|
|
|
memset(&hdr, 0, sizeof(hdr));
|
|
|
|
hdr.cbStruct = sizeof(hdr);
|
|
|
|
hdr.pbSrc = input;
|
|
|
|
hdr.cbSrcLength = 0; /* invalid source length */
|
|
|
|
hdr.pbDst = pcm;
|
|
|
|
hdr.cbDstLength = sizeof(pcm);
|
|
|
|
|
|
|
|
mr = acmStreamPrepareHeader(has, &hdr, 0);
|
|
|
|
todo_wine
|
|
|
|
ok(mr == MMSYSERR_INVALPARAM, "expected 0x0b, got 0x%x\n", mr);
|
|
|
|
|
|
|
|
hdr.cbSrcLength = src->wfx.nBlockAlign - 1; /* less than block align */
|
|
|
|
mr = acmStreamPrepareHeader(has, &hdr, 0);
|
|
|
|
todo_wine
|
|
|
|
ok(mr == ACMERR_NOTPOSSIBLE, "expected 0x200, got 0x%x\n", mr);
|
|
|
|
|
|
|
|
hdr.cbSrcLength = src->wfx.nBlockAlign;
|
|
|
|
mr = acmStreamPrepareHeader(has, &hdr, 1); /* invalid use of reserved parameter */
|
|
|
|
todo_wine
|
|
|
|
ok(mr == MMSYSERR_INVALFLAG, "expected 0x0a, got 0x%x\n", mr);
|
|
|
|
|
|
|
|
mr = acmStreamPrepareHeader(has, &hdr, 0);
|
|
|
|
ok(mr == MMSYSERR_NOERROR, "prepare failed: 0x%x\n", mr);
|
|
|
|
|
|
|
|
mr = acmStreamUnprepareHeader(has, &hdr, 0);
|
|
|
|
ok(mr == MMSYSERR_NOERROR, "unprepare failed: 0x%x\n", mr);
|
|
|
|
|
2013-11-04 17:06:02 +01:00
|
|
|
memset(&hdr, 0, sizeof(hdr));
|
|
|
|
hdr.cbStruct = sizeof(hdr);
|
|
|
|
hdr.pbSrc = input;
|
|
|
|
hdr.cbSrcLength = sizeof(input);
|
|
|
|
hdr.pbDst = pcm;
|
|
|
|
hdr.cbDstLength = sizeof(pcm);
|
|
|
|
hdr.fdwStatus = ACMSTREAMHEADER_STATUSF_DONE;
|
|
|
|
|
|
|
|
mr = acmStreamPrepareHeader(has, &hdr, 0);
|
|
|
|
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);
|
|
|
|
|
2015-11-24 10:08:00 +01:00
|
|
|
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
|
2015-11-27 14:10:04 +01:00
|
|
|
todo_wine
|
|
|
|
ok(mr == MMSYSERR_INVALPARAM, "expected 0x0b, got 0x%x\n", mr);
|
2015-11-24 10:08:00 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2013-11-04 17:06:02 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
mr = acmStreamClose(has, 0);
|
|
|
|
ok(mr == MMSYSERR_NOERROR, "close failed: 0x%x\n", mr);
|
|
|
|
}
|
|
|
|
|
2015-09-09 06:10:39 +02:00
|
|
|
static void test_acmFormatSuggest(void)
|
|
|
|
{
|
|
|
|
WAVEFORMATEX src, dst;
|
|
|
|
DWORD suggest;
|
|
|
|
MMRESULT rc;
|
|
|
|
|
|
|
|
/* Test a valid PCM format */
|
|
|
|
src.wFormatTag = WAVE_FORMAT_PCM;
|
|
|
|
src.nChannels = 1;
|
|
|
|
src.nSamplesPerSec = 8000;
|
|
|
|
src.nAvgBytesPerSec = 16000;
|
|
|
|
src.nBlockAlign = 2;
|
|
|
|
src.wBitsPerSample = 16;
|
|
|
|
src.cbSize = 0;
|
|
|
|
suggest = 0;
|
|
|
|
memset(&dst, 0, sizeof(dst));
|
|
|
|
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst), suggest);
|
|
|
|
ok(rc == MMSYSERR_NOERROR, "failed with error 0x%x\n", rc);
|
|
|
|
todo_wine
|
|
|
|
ok(src.wFormatTag == dst.wFormatTag, "expected %d, got %d\n", src.wFormatTag, dst.wFormatTag);
|
|
|
|
ok(src.nChannels == dst.nChannels, "expected %d, got %d\n", src.nChannels, dst.nChannels);
|
|
|
|
ok(src.nSamplesPerSec == dst.nSamplesPerSec, "expected %d, got %d\n", src.nSamplesPerSec, dst.nSamplesPerSec);
|
|
|
|
todo_wine
|
|
|
|
ok(src.nAvgBytesPerSec == dst.nAvgBytesPerSec, "expected %d, got %d\n", src.nAvgBytesPerSec, dst.nAvgBytesPerSec);
|
|
|
|
todo_wine
|
|
|
|
ok(src.nBlockAlign == dst.nBlockAlign, "expected %d, got %d\n", src.nBlockAlign, dst.nBlockAlign);
|
|
|
|
todo_wine
|
|
|
|
ok(src.wBitsPerSample == dst.wBitsPerSample, "expected %d, got %d\n", src.wBitsPerSample, dst.wBitsPerSample);
|
|
|
|
|
|
|
|
/* All parameters from destination are valid */
|
|
|
|
suggest = ACM_FORMATSUGGESTF_NCHANNELS
|
|
|
|
| ACM_FORMATSUGGESTF_NSAMPLESPERSEC
|
|
|
|
| ACM_FORMATSUGGESTF_WBITSPERSAMPLE
|
|
|
|
| ACM_FORMATSUGGESTF_WFORMATTAG;
|
|
|
|
dst = src;
|
|
|
|
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst), suggest);
|
|
|
|
ok(rc == MMSYSERR_NOERROR, "failed with error 0x%x\n", rc);
|
|
|
|
ok(src.wFormatTag == dst.wFormatTag, "expected %d, got %d\n", src.wFormatTag, dst.wFormatTag);
|
|
|
|
ok(src.nChannels == dst.nChannels, "expected %d, got %d\n", src.nChannels, dst.nChannels);
|
|
|
|
ok(src.nSamplesPerSec == dst.nSamplesPerSec, "expected %d, got %d\n", src.nSamplesPerSec, dst.nSamplesPerSec);
|
|
|
|
ok(src.nAvgBytesPerSec == dst.nAvgBytesPerSec, "expected %d, got %d\n", src.nAvgBytesPerSec, dst.nAvgBytesPerSec);
|
|
|
|
ok(src.nBlockAlign == dst.nBlockAlign, "expected %d, got %d\n", src.nBlockAlign, dst.nBlockAlign);
|
|
|
|
ok(src.wBitsPerSample == dst.wBitsPerSample, "expected %d, got %d\n", src.wBitsPerSample, dst.wBitsPerSample);
|
|
|
|
|
|
|
|
/* Test for WAVE_FORMAT_MSRT24 used in Monster Truck Madness 2 */
|
|
|
|
src.wFormatTag = WAVE_FORMAT_MSRT24;
|
|
|
|
src.nChannels = 1;
|
|
|
|
src.nSamplesPerSec = 8000;
|
|
|
|
src.nAvgBytesPerSec = 16000;
|
|
|
|
src.nBlockAlign = 2;
|
|
|
|
src.wBitsPerSample = 16;
|
|
|
|
src.cbSize = 0;
|
|
|
|
dst = src;
|
|
|
|
suggest = ACM_FORMATSUGGESTF_NCHANNELS
|
|
|
|
| ACM_FORMATSUGGESTF_NSAMPLESPERSEC
|
|
|
|
| ACM_FORMATSUGGESTF_WBITSPERSAMPLE
|
|
|
|
| ACM_FORMATSUGGESTF_WFORMATTAG;
|
|
|
|
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst), suggest);
|
|
|
|
ok(rc == ACMERR_NOTPOSSIBLE, "failed with error 0x%x\n", rc);
|
|
|
|
memset(&dst, 0, sizeof(dst));
|
|
|
|
suggest = 0;
|
|
|
|
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst), suggest);
|
|
|
|
todo_wine
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
|
|
|
|
|
|
|
|
/* Invalid struct size */
|
|
|
|
src.wFormatTag = WAVE_FORMAT_PCM;
|
|
|
|
rc = acmFormatSuggest(NULL, &src, &dst, 0, suggest);
|
|
|
|
todo_wine
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
|
|
|
|
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst) / 2, suggest);
|
|
|
|
todo_wine
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
|
|
|
|
/* cbSize is the last parameter and not required for PCM */
|
|
|
|
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst) - 1, suggest);
|
|
|
|
ok(rc == MMSYSERR_NOERROR, "failed with error 0x%x\n", rc);
|
|
|
|
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst) - sizeof(dst.cbSize), suggest);
|
|
|
|
ok(rc == MMSYSERR_NOERROR, "failed with error 0x%x\n", rc);
|
|
|
|
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst) - sizeof(dst.cbSize) - 1, suggest);
|
|
|
|
todo_wine
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
|
|
|
|
/* cbSize is required for others */
|
|
|
|
src.wFormatTag = WAVE_FORMAT_ADPCM;
|
|
|
|
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst) - sizeof(dst.cbSize), suggest);
|
|
|
|
todo_wine
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
|
|
|
|
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst) - 1, suggest);
|
|
|
|
todo_wine
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
|
|
|
|
|
|
|
|
/* Invalid suggest flags */
|
|
|
|
src.wFormatTag = WAVE_FORMAT_PCM;
|
|
|
|
suggest = 0xFFFFFFFF;
|
|
|
|
rc = acmFormatSuggest(NULL, &src, &dst, sizeof(dst), suggest);
|
|
|
|
ok(rc == MMSYSERR_INVALFLAG, "failed with error 0x%x\n", rc);
|
|
|
|
|
|
|
|
/* Invalid source and destination */
|
|
|
|
suggest = 0;
|
|
|
|
rc = acmFormatSuggest(NULL, NULL, &dst, sizeof(dst), suggest);
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
|
|
|
|
rc = acmFormatSuggest(NULL, &src, NULL, sizeof(dst), suggest);
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
|
|
|
|
rc = acmFormatSuggest(NULL, NULL, NULL, sizeof(dst), suggest);
|
|
|
|
ok(rc == MMSYSERR_INVALPARAM, "failed with error 0x%x\n", rc);
|
|
|
|
}
|
|
|
|
|
2004-05-03 22:17:43 +02:00
|
|
|
START_TEST(msacm)
|
|
|
|
{
|
2013-11-04 17:06:02 +01:00
|
|
|
driver_tests();
|
|
|
|
test_prepareheader();
|
2015-09-09 06:10:39 +02:00
|
|
|
test_acmFormatSuggest();
|
2004-05-03 22:17:43 +02:00
|
|
|
}
|