2004-07-30 20:42:51 +02:00
|
|
|
/*
|
|
|
|
* Tests basic sound playback in DirectSound.
|
|
|
|
* In particular we test each standard Windows sound format to make sure
|
|
|
|
* we handle the sound card/driver quirks correctly.
|
|
|
|
*
|
|
|
|
* Part of this test involves playing test tones. But this only makes
|
|
|
|
* sense if someone is going to carefully listen to it, and would only
|
|
|
|
* bother everyone else.
|
|
|
|
* So this is only done if the test is being run in interactive mode.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2002-2004 Francois Gouget
|
|
|
|
*
|
|
|
|
* 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-07-30 20:42:51 +02:00
|
|
|
*/
|
|
|
|
|
2011-10-20 22:15:09 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
#define NONAMELESSUNION
|
2004-07-30 20:42:51 +02:00
|
|
|
#include <windows.h>
|
2005-03-05 11:49:08 +01:00
|
|
|
#include <stdio.h>
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
2013-10-14 23:19:31 +02:00
|
|
|
#include "mmsystem.h"
|
2004-07-30 20:42:51 +02:00
|
|
|
#include "dsound.h"
|
|
|
|
#include "dsconf.h"
|
2007-11-05 23:23:28 +01:00
|
|
|
#include "ks.h"
|
|
|
|
#include "ksmedia.h"
|
2004-07-30 20:42:51 +02:00
|
|
|
|
2011-10-20 22:15:09 +02:00
|
|
|
#include "initguid.h"
|
2015-03-03 08:46:15 +01:00
|
|
|
|
|
|
|
#include "mediaobj.h"
|
2011-10-20 22:15:09 +02:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "mmdeviceapi.h"
|
|
|
|
#include "audioclient.h"
|
|
|
|
#include "propkey.h"
|
|
|
|
#include "devpkey.h"
|
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
#include "dsound_test.h"
|
|
|
|
|
2005-02-16 17:09:02 +01:00
|
|
|
int align(int length, int align)
|
|
|
|
{
|
|
|
|
return (length / align) * align;
|
|
|
|
}
|
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
static void IDirectSound8_test(LPDIRECTSOUND8 dso, BOOL initialized,
|
|
|
|
LPCGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
DSCAPS dscaps;
|
|
|
|
int ref;
|
|
|
|
IUnknown * unknown;
|
|
|
|
IDirectSound * ds;
|
|
|
|
IDirectSound8 * ds8;
|
2009-11-20 10:11:42 +01:00
|
|
|
DWORD speaker_config, new_speaker_config, ref_speaker_config;
|
2004-07-30 20:42:51 +02:00
|
|
|
DWORD certified;
|
|
|
|
|
|
|
|
/* Try to Query for objects */
|
|
|
|
rc=IDirectSound8_QueryInterface(dso,&IID_IUnknown,(LPVOID*)&unknown);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IUnknown) failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc==DS_OK)
|
2018-03-30 07:05:28 +02:00
|
|
|
IUnknown_Release(unknown);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
rc=IDirectSound8_QueryInterface(dso,&IID_IDirectSound,(LPVOID*)&ds);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IDirectSound) failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc==DS_OK)
|
|
|
|
IDirectSound_Release(ds);
|
|
|
|
|
|
|
|
rc=IDirectSound8_QueryInterface(dso,&IID_IDirectSound8,(LPVOID*)&ds8);
|
|
|
|
ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IDirectSound8) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc==DS_OK)
|
|
|
|
IDirectSound8_Release(ds8);
|
|
|
|
|
|
|
|
if (initialized == FALSE) {
|
2006-11-12 19:51:37 +01:00
|
|
|
/* try uninitialized object */
|
2004-07-30 20:42:51 +02:00
|
|
|
rc=IDirectSound8_GetCaps(dso,0);
|
|
|
|
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetCaps(NULL) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
rc=IDirectSound8_GetCaps(dso,&dscaps);
|
|
|
|
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetCaps() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
rc=IDirectSound8_Compact(dso);
|
|
|
|
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_Compact() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
rc=IDirectSound8_GetSpeakerConfig(dso,&speaker_config);
|
|
|
|
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetSpeakerConfig() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
rc=IDirectSound8_VerifyCertification(dso, &certified);
|
|
|
|
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_VerifyCertification() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
rc=IDirectSound8_Initialize(dso,lpGuid);
|
2005-03-30 12:21:44 +02:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound8_Initialize() failed: %08x\n",rc);
|
2004-10-25 23:45:51 +02:00
|
|
|
if (rc==DSERR_NODRIVER) {
|
|
|
|
trace(" No Driver\n");
|
2005-05-06 21:33:32 +02:00
|
|
|
goto EXIT;
|
2005-03-30 12:21:44 +02:00
|
|
|
} else if (rc==E_FAIL) {
|
|
|
|
trace(" No Device\n");
|
2005-05-06 21:33:32 +02:00
|
|
|
goto EXIT;
|
2005-03-30 12:21:44 +02:00
|
|
|
} else if (rc==DSERR_ALLOCATED) {
|
2004-10-25 23:45:51 +02:00
|
|
|
trace(" Already In Use\n");
|
2005-05-06 21:33:32 +02:00
|
|
|
goto EXIT;
|
2005-03-22 22:16:04 +01:00
|
|
|
}
|
2004-07-30 20:42:51 +02:00
|
|
|
}
|
|
|
|
|
2005-05-06 21:33:32 +02:00
|
|
|
rc=IDirectSound8_Initialize(dso,lpGuid);
|
|
|
|
ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSound8_Initialize() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_ALREADYINITIALIZED: %08x\n", rc);
|
2005-05-06 21:33:32 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
/* DSOUND: Error: Invalid caps buffer */
|
|
|
|
rc=IDirectSound8_GetCaps(dso,0);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetCaps() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
ZeroMemory(&dscaps, sizeof(dscaps));
|
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid caps buffer */
|
|
|
|
rc=IDirectSound8_GetCaps(dso,&dscaps);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetCaps() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
dscaps.dwSize=sizeof(dscaps);
|
|
|
|
|
|
|
|
/* DSOUND: Running on a certified driver */
|
|
|
|
rc=IDirectSound8_GetCaps(dso,&dscaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
rc=IDirectSound8_Compact(dso);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DSERR_PRIOLEVELNEEDED,"IDirectSound8_Compact() failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
rc=IDirectSound8_Compact(dso);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_Compact() failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
rc=IDirectSound8_GetSpeakerConfig(dso,0);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetSpeakerConfig(NULL) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
rc=IDirectSound8_GetSpeakerConfig(dso,&speaker_config);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_GetSpeakerConfig() failed: %08x\n", rc);
|
2009-11-20 10:11:42 +01:00
|
|
|
ref_speaker_config = speaker_config;
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO,
|
|
|
|
DSSPEAKER_GEOMETRY_WIDE);
|
2009-11-20 10:11:42 +01:00
|
|
|
if (speaker_config == ref_speaker_config)
|
|
|
|
speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO,
|
|
|
|
DSSPEAKER_GEOMETRY_NARROW);
|
|
|
|
if(rc==DS_OK) {
|
|
|
|
rc=IDirectSound8_SetSpeakerConfig(dso,speaker_config);
|
|
|
|
ok(rc==DS_OK,"IDirectSound8_SetSpeakerConfig() failed: %08x\n", rc);
|
|
|
|
}
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc==DS_OK) {
|
|
|
|
rc=IDirectSound8_GetSpeakerConfig(dso,&new_speaker_config);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_GetSpeakerConfig() failed: %08x\n", rc);
|
2014-12-31 19:53:06 +01:00
|
|
|
if (rc==DS_OK && speaker_config!=new_speaker_config && ref_speaker_config!=new_speaker_config)
|
2004-08-23 19:50:31 +02:00
|
|
|
trace("IDirectSound8_GetSpeakerConfig() failed to set speaker "
|
2014-12-31 19:53:06 +01:00
|
|
|
"config: expected 0x%08x or 0x%08x, got 0x%08x\n",
|
|
|
|
speaker_config,ref_speaker_config,new_speaker_config);
|
2009-11-20 10:11:42 +01:00
|
|
|
IDirectSound8_SetSpeakerConfig(dso,ref_speaker_config);
|
2004-07-30 20:42:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
rc=IDirectSound8_VerifyCertification(dso, &certified);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK||rc==E_NOTIMPL,"IDirectSound8_VerifyCertification() failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
2005-05-06 21:33:32 +02:00
|
|
|
EXIT:
|
2004-07-30 20:42:51 +02:00
|
|
|
ref=IDirectSound8_Release(dso);
|
|
|
|
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
|
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void IDirectSound8_tests(void)
|
2004-07-30 20:42:51 +02:00
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND8 dso=NULL;
|
2006-08-18 07:14:12 +02:00
|
|
|
LPCLASSFACTORY cf=NULL;
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
trace("Testing IDirectSound8\n");
|
|
|
|
|
2006-08-18 07:14:12 +02:00
|
|
|
rc=CoGetClassObject(&CLSID_DirectSound8, CLSCTX_INPROC_SERVER, NULL,
|
|
|
|
&IID_IClassFactory, (void**)&cf);
|
|
|
|
ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSound8, IID_IClassFactory) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n", rc);
|
2006-08-18 07:14:12 +02:00
|
|
|
|
|
|
|
rc=CoGetClassObject(&CLSID_DirectSound8, CLSCTX_INPROC_SERVER, NULL,
|
|
|
|
&IID_IUnknown, (void**)&cf);
|
|
|
|
ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSound8, IID_IUnknown) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n", rc);
|
2006-08-18 07:14:12 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
/* try the COM class factory method of creation with no device specified */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectSound8, (void**)&dso);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==S_OK||rc==REGDB_E_CLASSNOTREG,"CoCreateInstance() failed: %08x\n", rc);
|
2005-10-10 12:27:50 +02:00
|
|
|
if (rc==REGDB_E_CLASSNOTREG) {
|
|
|
|
trace(" Class Not Registered\n");
|
|
|
|
return;
|
|
|
|
}
|
2004-07-30 20:42:51 +02:00
|
|
|
if (dso)
|
|
|
|
IDirectSound8_test(dso, FALSE, NULL);
|
|
|
|
|
|
|
|
/* try the COM class factory method of creation with default playback
|
|
|
|
* device specified */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectSound8, (void**)&dso);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound8) failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (dso)
|
|
|
|
IDirectSound8_test(dso, FALSE, &DSDEVID_DefaultPlayback);
|
|
|
|
|
|
|
|
/* try the COM class factory method of creation with default voice
|
|
|
|
* playback device specified */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectSound8, (void**)&dso);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound8) failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (dso)
|
|
|
|
IDirectSound8_test(dso, FALSE, &DSDEVID_DefaultVoicePlayback);
|
|
|
|
|
|
|
|
/* try the COM class factory method of creation with a bad
|
|
|
|
* IID specified */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&CLSID_DirectSoundPrivate, (void**)&dso);
|
|
|
|
ok(rc==E_NOINTERFACE,
|
|
|
|
"CoCreateInstance(CLSID_DirectSound8,CLSID_DirectSoundPrivate) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
/* try the COM class factory method of creation with a bad
|
|
|
|
* GUID and IID specified */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSoundPrivate, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectSound8, (void**)&dso);
|
|
|
|
ok(rc==REGDB_E_CLASSNOTREG,
|
|
|
|
"CoCreateInstance(CLSID_DirectSoundPrivate,IID_IDirectSound8) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
/* try with no device specified */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(NULL, &dso, NULL);
|
2005-03-30 12:21:44 +02:00
|
|
|
ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCreate8() failed: %08x\n",rc);
|
2004-10-19 23:10:41 +02:00
|
|
|
if (rc==DS_OK && dso)
|
2004-07-30 20:42:51 +02:00
|
|
|
IDirectSound8_test(dso, TRUE, NULL);
|
|
|
|
|
|
|
|
/* try with default playback device specified */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(&DSDEVID_DefaultPlayback, &dso, NULL);
|
2005-03-30 12:21:44 +02:00
|
|
|
ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCreate8() failed: %08x\n",rc);
|
2004-10-19 23:10:41 +02:00
|
|
|
if (rc==DS_OK && dso)
|
2004-07-30 20:42:51 +02:00
|
|
|
IDirectSound8_test(dso, TRUE, NULL);
|
|
|
|
|
|
|
|
/* try with default voice playback device specified */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(&DSDEVID_DefaultVoicePlayback, &dso, NULL);
|
2005-03-30 12:21:44 +02:00
|
|
|
ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCreate8() failed: %08x\n",rc);
|
2004-10-19 23:10:41 +02:00
|
|
|
if (rc==DS_OK && dso)
|
2004-07-30 20:42:51 +02:00
|
|
|
IDirectSound8_test(dso, TRUE, NULL);
|
|
|
|
|
|
|
|
/* try with a bad device specified */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(&DSDEVID_DefaultVoiceCapture, &dso, NULL);
|
2004-07-30 20:42:51 +02:00
|
|
|
ok(rc==DSERR_NODRIVER,"DirectSoundCreate8(DSDEVID_DefaultVoiceCapture) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT test_dsound8(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND8 dso=NULL;
|
|
|
|
int ref;
|
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid interface buffer */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(lpGuid, 0, NULL);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"DirectSoundCreate8() should have returned "
|
2008-07-08 17:49:20 +02:00
|
|
|
"DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
/* Create the DirectSound8 object */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(lpGuid, &dso, NULL);
|
2005-03-30 12:21:44 +02:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCreate8() failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* Try the enumerated device */
|
|
|
|
IDirectSound8_test(dso, TRUE, lpGuid);
|
|
|
|
|
|
|
|
/* Try the COM class factory method of creation with enumerated device */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectSound8, (void**)&dso);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (dso)
|
|
|
|
IDirectSound8_test(dso, FALSE, lpGuid);
|
|
|
|
|
|
|
|
/* Create a DirectSound8 object */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(lpGuid, &dso, NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"DirectSoundCreate8() failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc==DS_OK) {
|
|
|
|
LPDIRECTSOUND8 dso1=NULL;
|
|
|
|
|
|
|
|
/* Create a second DirectSound8 object */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(lpGuid, &dso1, NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"DirectSoundCreate8() failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc==DS_OK) {
|
|
|
|
/* Release the second DirectSound8 object */
|
|
|
|
ref=IDirectSound8_Release(dso1);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSound8_Release() has %d references, "
|
2004-07-30 20:42:51 +02:00
|
|
|
"should have 0\n",ref);
|
|
|
|
ok(dso!=dso1,"DirectSound8 objects should be unique: "
|
2005-09-12 12:30:05 +02:00
|
|
|
"dso=%p,dso1=%p\n",dso,dso1);
|
2004-07-30 20:42:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Release the first DirectSound8 object */
|
|
|
|
ref=IDirectSound8_Release(dso);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",
|
2004-07-30 20:42:51 +02:00
|
|
|
ref);
|
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
|
|
|
} else
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* Create a DirectSound8 object */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(lpGuid, &dso, NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"DirectSoundCreate8() failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc==DS_OK) {
|
|
|
|
LPDIRECTSOUNDBUFFER secondary;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
WAVEFORMATEX wfx;
|
|
|
|
|
|
|
|
init_format(&wfx,WAVE_FORMAT_PCM,11025,8,1);
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRL3D;
|
2005-02-16 17:09:02 +01:00
|
|
|
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
|
|
|
|
wfx.nBlockAlign);
|
2004-07-30 20:42:51 +02:00
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
|
|
|
ok(rc==DS_OK && secondary!=NULL,
|
2004-08-13 21:44:29 +02:00
|
|
|
"IDirectSound8_CreateSoundBuffer() failed to create a secondary "
|
2008-07-08 17:49:20 +02:00
|
|
|
"buffer: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc==DS_OK && secondary!=NULL) {
|
|
|
|
LPDIRECTSOUND3DBUFFER buffer3d;
|
|
|
|
LPDIRECTSOUNDBUFFER8 buffer8;
|
2018-03-30 07:05:28 +02:00
|
|
|
rc=IDirectSoundBuffer_QueryInterface(secondary,
|
2004-07-30 20:42:51 +02:00
|
|
|
&IID_IDirectSound3DBuffer,
|
|
|
|
(void **)&buffer3d);
|
|
|
|
ok(rc==DS_OK && buffer3d!=NULL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound8_QueryInterface() failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc==DS_OK && buffer3d!=NULL) {
|
|
|
|
ref=IDirectSound3DBuffer_AddRef(buffer3d);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==2,"IDirectSound3DBuffer_AddRef() has %d references, "
|
2004-07-30 20:42:51 +02:00
|
|
|
"should have 2\n",ref);
|
|
|
|
}
|
2018-03-30 07:05:28 +02:00
|
|
|
rc=IDirectSoundBuffer_QueryInterface(secondary,
|
2004-07-30 20:42:51 +02:00
|
|
|
&IID_IDirectSoundBuffer8,
|
|
|
|
(void **)&buffer8);
|
|
|
|
if (rc==DS_OK && buffer8!=NULL) {
|
2011-08-24 02:29:22 +02:00
|
|
|
ok(buffer8==(IDirectSoundBuffer8*)secondary,
|
|
|
|
"IDirectSoundBuffer8 iface different from IDirectSoundBuffer.\n");
|
2004-07-30 20:42:51 +02:00
|
|
|
ref=IDirectSoundBuffer8_AddRef(buffer8);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==3,"IDirectSoundBuffer8_AddRef() has %d references, "
|
2004-07-30 20:42:51 +02:00
|
|
|
"should have 3\n",ref);
|
|
|
|
}
|
|
|
|
ref=IDirectSoundBuffer_AddRef(secondary);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==4,"IDirectSoundBuffer_AddRef() has %d references, "
|
2004-07-30 20:42:51 +02:00
|
|
|
"should have 4\n",ref);
|
|
|
|
}
|
|
|
|
/* release with buffer */
|
|
|
|
ref=IDirectSound8_Release(dso);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",
|
2004-07-30 20:42:51 +02:00
|
|
|
ref);
|
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
|
|
|
} else
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT test_primary8(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND8 dso=NULL;
|
|
|
|
LPDIRECTSOUNDBUFFER primary=NULL,second=NULL,third=NULL;
|
2007-05-13 12:58:36 +02:00
|
|
|
LPDIRECTSOUNDBUFFER8 pb8 = NULL;
|
2004-07-30 20:42:51 +02:00
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
DSCAPS dscaps;
|
2004-08-25 04:09:00 +02:00
|
|
|
WAVEFORMATEX wfx;
|
2004-07-30 20:42:51 +02:00
|
|
|
int ref;
|
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(lpGuid, &dso, NULL);
|
2004-10-21 21:51:10 +02:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCreate8() failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* Get the device capabilities */
|
|
|
|
ZeroMemory(&dscaps, sizeof(dscaps));
|
|
|
|
dscaps.dwSize=sizeof(dscaps);
|
|
|
|
rc=IDirectSound8_GetCaps(dso,&dscaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid buffer description pointer */
|
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,0,0,NULL);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM,
|
2004-08-13 21:44:29 +02:00
|
|
|
"IDirectSound8_CreateSoundBuffer should have returned "
|
2008-07-08 17:49:20 +02:00
|
|
|
"DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid buffer description pointer */
|
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,0,&primary,NULL);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM && primary==0,
|
2004-08-13 21:44:29 +02:00
|
|
|
"IDirectSound8_CreateSoundBuffer() should have returned "
|
2008-07-08 17:49:20 +02:00
|
|
|
"DSERR_INVALIDPARAM, returned: rc=%08x,dsbo=%p\n",
|
|
|
|
rc,primary);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
2008-06-10 22:08:33 +02:00
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize = sizeof(DSBUFFERDESC);
|
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid dsound buffer interface pointer */
|
2004-07-30 20:42:51 +02:00
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,0,NULL);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM && primary==0,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound8_CreateSoundBuffer() should have failed: rc=%08x,"
|
|
|
|
"dsbo=%p\n",rc,primary);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid size */
|
|
|
|
/* DSOUND: Error: Invalid buffer description */
|
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM && primary==0,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound8_CreateSoundBuffer() should have failed: rc=%08x,"
|
|
|
|
"primary=%p\n",rc,primary);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
/* We must call SetCooperativeLevel before calling CreateSoundBuffer */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
|
|
|
|
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
|
|
|
|
/* Testing the primary buffer */
|
2004-08-25 04:09:00 +02:00
|
|
|
primary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
|
|
|
|
bufdesc.lpwfxFormat = &wfx;
|
|
|
|
init_format(&wfx,WAVE_FORMAT_PCM,11025,8,2);
|
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_CreateSoundBuffer() should have "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2004-08-25 04:09:00 +02:00
|
|
|
if (rc==DS_OK && primary!=NULL)
|
|
|
|
IDirectSoundBuffer_Release(primary);
|
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
primary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
|
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
2005-06-05 19:55:08 +02:00
|
|
|
ok((rc==DS_OK && primary!=NULL) || (rc==DSERR_CONTROLUNAVAIL),
|
2004-08-13 21:44:29 +02:00
|
|
|
"IDirectSound8_CreateSoundBuffer() failed to create a primary buffer: "
|
2008-07-08 17:49:20 +02:00
|
|
|
"%08x\n",rc);
|
2005-06-05 19:55:08 +02:00
|
|
|
if (rc==DSERR_CONTROLUNAVAIL)
|
|
|
|
trace(" No Primary\n");
|
|
|
|
else if (rc==DS_OK && primary!=NULL) {
|
2004-07-30 20:42:51 +02:00
|
|
|
LONG vol;
|
|
|
|
|
|
|
|
/* Try to create a second primary buffer */
|
|
|
|
/* DSOUND: Error: The primary buffer already exists.
|
|
|
|
* Any changes made to the buffer description will be ignored. */
|
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&second,NULL);
|
|
|
|
ok(rc==DS_OK && second==primary,
|
2004-08-13 21:44:29 +02:00
|
|
|
"IDirectSound8_CreateSoundBuffer() should have returned original "
|
2008-07-08 17:49:20 +02:00
|
|
|
"primary buffer: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
ref=IDirectSoundBuffer_Release(second);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==1,"IDirectSoundBuffer_Release() primary has %d references, "
|
2004-07-30 20:42:51 +02:00
|
|
|
"should have 1\n",ref);
|
|
|
|
|
|
|
|
/* Try to duplicate a primary buffer */
|
|
|
|
/* DSOUND: Error: Can't duplicate primary buffers */
|
|
|
|
rc=IDirectSound8_DuplicateSoundBuffer(dso,primary,&third);
|
|
|
|
/* rc=0x88780032 */
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(rc!=DS_OK,"IDirectSound8_DuplicateSoundBuffer() primary buffer "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have failed %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
2007-05-13 12:58:36 +02:00
|
|
|
/* Primary buffers don't have an IDirectSoundBuffer8 */
|
|
|
|
rc = IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSoundBuffer8, (LPVOID*)&pb8);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(FAILED(rc), "Primary buffer does have an IDirectSoundBuffer8: %08x\n", rc);
|
2007-05-13 12:58:36 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
rc=IDirectSoundBuffer_GetVolume(primary,&vol);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
if (winetest_interactive) {
|
|
|
|
trace("Playing a 5 seconds reference tone at the current volume.\n");
|
|
|
|
if (rc==DS_OK)
|
2006-10-10 01:07:36 +02:00
|
|
|
trace("(the current volume is %d according to DirectSound)\n",
|
2004-07-30 20:42:51 +02:00
|
|
|
vol);
|
|
|
|
trace("All subsequent tones should be identical to this one.\n");
|
|
|
|
trace("Listen for stutter, changes in pitch, volume, etc.\n");
|
|
|
|
}
|
2013-11-12 22:11:12 +01:00
|
|
|
test_buffer8(dso,&primary,TRUE,FALSE,0,FALSE,0,
|
|
|
|
winetest_interactive && !(dscaps.dwFlags & DSCAPS_EMULDRIVER),
|
|
|
|
5.0,FALSE,NULL,FALSE,FALSE);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
2004-07-30 20:42:51 +02:00
|
|
|
"should have 0\n",ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the CooperativeLevel back to normal */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
|
|
|
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
EXIT:
|
|
|
|
ref=IDirectSound8_Release(dso);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2004-08-09 20:50:06 +02:00
|
|
|
/*
|
|
|
|
* Test the primary buffer at different formats while keeping the
|
|
|
|
* secondary buffer at a constant format.
|
|
|
|
*/
|
|
|
|
static HRESULT test_primary_secondary8(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND8 dso=NULL;
|
|
|
|
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
DSCAPS dscaps;
|
|
|
|
WAVEFORMATEX wfx, wfx2;
|
2005-07-15 18:34:04 +02:00
|
|
|
int ref;
|
2011-01-20 16:41:59 +01:00
|
|
|
unsigned int f, tag;
|
2004-08-09 20:50:06 +02:00
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(lpGuid, &dso, NULL);
|
2004-10-21 21:51:10 +02:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCreate8() failed: %08x\n",rc);
|
2004-08-09 20:50:06 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* Get the device capabilities */
|
|
|
|
ZeroMemory(&dscaps, sizeof(dscaps));
|
|
|
|
dscaps.dwSize=sizeof(dscaps);
|
|
|
|
rc=IDirectSound8_GetCaps(dso,&dscaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %08x\n",rc);
|
2004-08-09 20:50:06 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
|
|
|
|
/* We must call SetCooperativeLevel before creating primary buffer */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
|
|
|
|
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
2004-08-09 20:50:06 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
|
|
|
ok(rc==DS_OK && primary!=NULL,
|
2004-08-13 21:44:29 +02:00
|
|
|
"IDirectSound8_CreateSoundBuffer() failed to create a primary buffer "
|
2008-07-08 17:49:20 +02:00
|
|
|
"%08x\n",rc);
|
2004-08-09 20:50:06 +02:00
|
|
|
|
|
|
|
if (rc==DS_OK && primary!=NULL) {
|
2018-06-13 20:30:23 +02:00
|
|
|
for (f = 0; f < ARRAY_SIZE(formats); f++) {
|
|
|
|
for (tag = 0; tag < ARRAY_SIZE(format_tags); tag++) {
|
2011-01-20 16:41:59 +01:00
|
|
|
/* if float, we only want to test 32-bit */
|
|
|
|
if ((format_tags[tag] == WAVE_FORMAT_IEEE_FLOAT) && (formats[f][1] != 32))
|
|
|
|
continue;
|
|
|
|
|
2004-08-23 19:50:31 +02:00
|
|
|
/* We must call SetCooperativeLevel to be allowed to call
|
|
|
|
* SetFormat */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to
|
|
|
|
* DSSCL_PRIORITY */
|
2004-08-09 20:50:06 +02:00
|
|
|
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
2004-08-09 20:50:06 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
|
2011-01-20 16:41:59 +01:00
|
|
|
init_format(&wfx,format_tags[tag],formats[f][0],formats[f][1],
|
2004-08-09 20:50:06 +02:00
|
|
|
formats[f][2]);
|
|
|
|
wfx2=wfx;
|
|
|
|
rc=IDirectSoundBuffer_SetFormat(primary,&wfx);
|
2008-09-09 20:44:46 +02:00
|
|
|
ok(rc==DS_OK
|
|
|
|
|| rc==DSERR_INVALIDPARAM, /* 2003 */
|
|
|
|
"IDirectSoundBuffer_SetFormat(%s) failed: %08x\n",
|
2008-07-08 17:49:20 +02:00
|
|
|
format_string(&wfx), rc);
|
2004-08-09 20:50:06 +02:00
|
|
|
|
2006-11-07 00:37:42 +01:00
|
|
|
/* There is no guarantee that SetFormat will actually change the
|
2004-08-09 20:50:06 +02:00
|
|
|
* format to what we asked for. It depends on what the soundcard
|
|
|
|
* supports. So we must re-query the format.
|
|
|
|
*/
|
|
|
|
rc=IDirectSoundBuffer_GetFormat(primary,&wfx,sizeof(wfx),NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %08x\n", rc);
|
2004-08-09 20:50:06 +02:00
|
|
|
if (rc==DS_OK &&
|
|
|
|
(wfx.wFormatTag!=wfx2.wFormatTag ||
|
|
|
|
wfx.nSamplesPerSec!=wfx2.nSamplesPerSec ||
|
|
|
|
wfx.wBitsPerSample!=wfx2.wBitsPerSample ||
|
|
|
|
wfx.nChannels!=wfx2.nChannels)) {
|
2006-10-10 01:07:36 +02:00
|
|
|
trace("Requested primary format tag=0x%04x %dx%dx%d "
|
|
|
|
"avg.B/s=%d align=%d\n",
|
2004-08-09 20:50:06 +02:00
|
|
|
wfx2.wFormatTag,wfx2.nSamplesPerSec,wfx2.wBitsPerSample,
|
|
|
|
wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign);
|
2006-10-10 01:07:36 +02:00
|
|
|
trace("Got tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
|
2004-08-09 20:50:06 +02:00
|
|
|
wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
|
|
|
|
wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the CooperativeLevel back to normal */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
|
|
|
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
2004-08-09 20:50:06 +02:00
|
|
|
|
|
|
|
init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2);
|
|
|
|
|
|
|
|
secondary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
|
2005-02-16 17:09:02 +01:00
|
|
|
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
|
|
|
|
wfx.nBlockAlign);
|
2004-08-09 20:50:06 +02:00
|
|
|
bufdesc.lpwfxFormat=&wfx2;
|
2004-08-13 21:44:29 +02:00
|
|
|
if (winetest_interactive) {
|
2011-01-20 16:41:59 +01:00
|
|
|
trace(" Testing a primary buffer at %dx%dx%d (fmt=%d) with a "
|
2006-10-10 01:07:36 +02:00
|
|
|
"secondary buffer at %dx%dx%d\n",
|
2011-01-20 16:41:59 +01:00
|
|
|
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,format_tags[tag],
|
2004-08-13 21:44:29 +02:00
|
|
|
wfx2.nSamplesPerSec,wfx2.wBitsPerSample,wfx2.nChannels);
|
|
|
|
}
|
2018-03-30 07:05:28 +02:00
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2004-08-09 20:50:06 +02:00
|
|
|
ok(rc==DS_OK && secondary!=NULL,
|
2004-08-13 21:44:29 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create a secondary "
|
2008-07-08 17:49:20 +02:00
|
|
|
"buffer %08x\n",rc);
|
2004-08-09 20:50:06 +02:00
|
|
|
|
|
|
|
if (rc==DS_OK && secondary!=NULL) {
|
2013-11-12 22:11:12 +01:00
|
|
|
test_buffer8(dso,&secondary,FALSE,FALSE,0,FALSE,0,
|
|
|
|
winetest_interactive,1.0,FALSE,NULL,FALSE,FALSE);
|
2004-08-09 20:50:06 +02:00
|
|
|
|
|
|
|
ref=IDirectSoundBuffer_Release(secondary);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
|
2004-08-09 20:50:06 +02:00
|
|
|
"should have 0\n",ref);
|
|
|
|
}
|
2011-01-20 16:41:59 +01:00
|
|
|
}
|
2004-08-09 20:50:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
2004-08-09 20:50:06 +02:00
|
|
|
"should have 0\n",ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the CooperativeLevel back to normal */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
|
|
|
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
2004-08-09 20:50:06 +02:00
|
|
|
|
|
|
|
EXIT:
|
|
|
|
ref=IDirectSound8_Release(dso);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
|
2004-08-09 20:50:06 +02:00
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
static HRESULT test_secondary8(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND8 dso=NULL;
|
|
|
|
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
DSCAPS dscaps;
|
2005-02-10 21:26:20 +01:00
|
|
|
WAVEFORMATEX wfx, wfx1;
|
2011-01-20 16:41:59 +01:00
|
|
|
DWORD f, tag;
|
2004-08-09 20:52:18 +02:00
|
|
|
int ref;
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(lpGuid, &dso, NULL);
|
2004-10-21 21:51:10 +02:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCreate8() failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* Get the device capabilities */
|
|
|
|
ZeroMemory(&dscaps, sizeof(dscaps));
|
|
|
|
dscaps.dwSize=sizeof(dscaps);
|
|
|
|
rc=IDirectSound8_GetCaps(dso,&dscaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
|
|
|
|
/* We must call SetCooperativeLevel before creating primary buffer */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
|
|
|
|
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
|
|
|
ok(rc==DS_OK && primary!=NULL,
|
2004-08-13 21:44:29 +02:00
|
|
|
"IDirectSound8_CreateSoundBuffer() failed to create a primary buffer "
|
2008-07-08 17:49:20 +02:00
|
|
|
"%08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
if (rc==DS_OK && primary!=NULL) {
|
2005-02-10 21:26:20 +01:00
|
|
|
rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %08x\n", rc);
|
2005-02-10 21:26:20 +01:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT1;
|
|
|
|
|
2018-06-13 20:30:23 +02:00
|
|
|
for (f = 0; f < ARRAY_SIZE(formats); f++) {
|
|
|
|
for (tag = 0; tag < ARRAY_SIZE(format_tags); tag++) {
|
2007-11-05 23:23:28 +01:00
|
|
|
WAVEFORMATEXTENSIBLE wfxe;
|
2011-01-20 16:41:59 +01:00
|
|
|
|
|
|
|
/* if float, we only want to test 32-bit */
|
|
|
|
if ((format_tags[tag] == WAVE_FORMAT_IEEE_FLOAT) && (formats[f][1] != 32))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
init_format(&wfx,format_tags[tag],formats[f][0],formats[f][1],
|
2004-07-30 20:42:51 +02:00
|
|
|
formats[f][2]);
|
|
|
|
secondary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
|
2005-02-16 17:09:02 +01:00
|
|
|
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
|
|
|
|
wfx.nBlockAlign);
|
2004-08-25 04:09:00 +02:00
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_CreateSoundBuffer() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2004-08-25 04:09:00 +02:00
|
|
|
if (rc==DS_OK && secondary!=NULL)
|
|
|
|
IDirectSoundBuffer_Release(secondary);
|
|
|
|
|
|
|
|
secondary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
|
2005-02-16 17:09:02 +01:00
|
|
|
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
|
|
|
|
wfx.nBlockAlign);
|
2004-07-30 20:42:51 +02:00
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
2018-03-30 07:05:28 +02:00
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2007-11-05 23:23:28 +01:00
|
|
|
if (wfx.wBitsPerSample != 8 && wfx.wBitsPerSample != 16)
|
2008-09-09 20:44:46 +02:00
|
|
|
ok(((rc == DSERR_CONTROLUNAVAIL || rc == DSERR_INVALIDCALL || rc == DSERR_INVALIDPARAM /* 2003 */) && !secondary)
|
|
|
|
|| rc == DS_OK, /* driver dependent? */
|
|
|
|
"IDirectSound_CreateSoundBuffer() "
|
2008-07-08 20:48:44 +02:00
|
|
|
"should have returned (DSERR_CONTROLUNAVAIL or DSERR_INVALIDCALL) "
|
|
|
|
"and NULL, returned: %08x %p\n", rc, secondary);
|
2007-11-05 23:23:28 +01:00
|
|
|
else
|
|
|
|
ok(rc==DS_OK && secondary!=NULL,
|
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create a secondary "
|
2008-07-08 17:49:20 +02:00
|
|
|
"buffer %08x\n",rc);
|
2007-11-05 23:23:28 +01:00
|
|
|
if (secondary)
|
|
|
|
IDirectSoundBuffer_Release(secondary);
|
|
|
|
secondary = NULL;
|
|
|
|
|
|
|
|
bufdesc.lpwfxFormat=(WAVEFORMATEX*)&wfxe;
|
|
|
|
wfxe.Format = wfx;
|
|
|
|
wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
|
2011-01-20 16:41:59 +01:00
|
|
|
wfxe.SubFormat = (format_tags[tag] == WAVE_FORMAT_PCM ? KSDATAFORMAT_SUBTYPE_PCM : KSDATAFORMAT_SUBTYPE_IEEE_FLOAT);
|
2007-11-05 23:23:28 +01:00
|
|
|
wfxe.Format.cbSize = 1;
|
|
|
|
wfxe.Samples.wValidBitsPerSample = wfx.wBitsPerSample;
|
|
|
|
wfxe.dwChannelMask = (wfx.nChannels == 1 ? KSAUDIO_SPEAKER_MONO : KSAUDIO_SPEAKER_STEREO);
|
|
|
|
|
2018-03-30 07:05:28 +02:00
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2007-11-05 23:23:28 +01:00
|
|
|
ok(rc==DSERR_INVALIDPARAM && !secondary,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
|
|
|
rc, secondary);
|
2007-11-05 23:23:28 +01:00
|
|
|
if (secondary)
|
2008-09-09 20:44:46 +02:00
|
|
|
{
|
2007-11-05 23:23:28 +01:00
|
|
|
IDirectSoundBuffer_Release(secondary);
|
2008-09-09 20:44:46 +02:00
|
|
|
secondary=NULL;
|
|
|
|
}
|
2007-11-05 23:23:28 +01:00
|
|
|
|
|
|
|
wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx) + 1;
|
|
|
|
|
2018-03-30 07:05:28 +02:00
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2014-06-15 09:48:20 +02:00
|
|
|
ok(((rc==DSERR_CONTROLUNAVAIL || rc==DSERR_INVALIDCALL /* 2003 */ || rc==DSERR_INVALIDPARAM) && !secondary)
|
2008-09-09 20:44:46 +02:00
|
|
|
|| rc==DS_OK /* driver dependent? */,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
|
|
|
rc, secondary);
|
2007-11-05 23:23:28 +01:00
|
|
|
if (secondary)
|
2008-09-09 20:44:46 +02:00
|
|
|
{
|
2007-11-05 23:23:28 +01:00
|
|
|
IDirectSoundBuffer_Release(secondary);
|
2008-09-09 20:44:46 +02:00
|
|
|
secondary=NULL;
|
|
|
|
}
|
2007-11-05 23:23:28 +01:00
|
|
|
|
|
|
|
wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx);
|
|
|
|
wfxe.SubFormat = GUID_NULL;
|
2018-03-30 07:05:28 +02:00
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2008-07-08 20:48:44 +02:00
|
|
|
ok((rc==DSERR_INVALIDPARAM || rc==DSERR_INVALIDCALL) && !secondary,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
|
|
|
rc, secondary);
|
2007-11-05 23:23:28 +01:00
|
|
|
if (secondary)
|
2008-09-09 20:44:46 +02:00
|
|
|
{
|
2007-11-05 23:23:28 +01:00
|
|
|
IDirectSoundBuffer_Release(secondary);
|
2008-09-09 20:44:46 +02:00
|
|
|
secondary=NULL;
|
|
|
|
}
|
2009-04-21 06:41:21 +02:00
|
|
|
|
|
|
|
wfxe.Format.cbSize = sizeof(wfxe);
|
2018-03-30 07:05:28 +02:00
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2014-06-15 09:48:20 +02:00
|
|
|
ok((rc==DSERR_CONTROLUNAVAIL || rc==DSERR_INVALIDCALL || rc==DSERR_INVALIDPARAM) && !secondary,
|
2009-04-21 06:41:21 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
|
|
|
rc, secondary);
|
|
|
|
if (secondary)
|
|
|
|
{
|
|
|
|
IDirectSoundBuffer_Release(secondary);
|
|
|
|
secondary=NULL;
|
|
|
|
}
|
|
|
|
|
2011-01-20 16:41:59 +01:00
|
|
|
wfxe.SubFormat = (format_tags[tag] == WAVE_FORMAT_PCM ? KSDATAFORMAT_SUBTYPE_PCM : KSDATAFORMAT_SUBTYPE_IEEE_FLOAT);
|
2018-03-30 07:05:28 +02:00
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2009-04-21 06:41:21 +02:00
|
|
|
ok(rc==DS_OK && secondary,
|
|
|
|
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
|
|
|
rc, secondary);
|
|
|
|
if (secondary)
|
|
|
|
{
|
|
|
|
IDirectSoundBuffer_Release(secondary);
|
|
|
|
secondary=NULL;
|
|
|
|
}
|
2007-11-05 23:23:28 +01:00
|
|
|
|
2009-04-21 06:41:21 +02:00
|
|
|
wfxe.Format.cbSize = sizeof(wfxe) + 1;
|
2018-03-30 07:05:28 +02:00
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2014-06-15 09:48:20 +02:00
|
|
|
ok(((rc==DSERR_CONTROLUNAVAIL || rc==DSERR_INVALIDCALL /* 2003 */ || rc==DSERR_INVALIDPARAM) && !secondary)
|
2009-04-21 06:41:21 +02:00
|
|
|
|| rc==DS_OK /* driver dependent? */,
|
|
|
|
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
|
|
|
rc, secondary);
|
|
|
|
if (secondary)
|
|
|
|
{
|
|
|
|
IDirectSoundBuffer_Release(secondary);
|
|
|
|
secondary=NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx);
|
2007-11-05 23:23:28 +01:00
|
|
|
++wfxe.Samples.wValidBitsPerSample;
|
2018-03-30 07:05:28 +02:00
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2007-11-05 23:23:28 +01:00
|
|
|
ok(rc==DSERR_INVALIDPARAM && !secondary,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
|
|
|
rc, secondary);
|
2007-11-05 23:23:28 +01:00
|
|
|
if (secondary)
|
2008-09-09 20:44:46 +02:00
|
|
|
{
|
2007-11-05 23:23:28 +01:00
|
|
|
IDirectSoundBuffer_Release(secondary);
|
2008-09-09 20:44:46 +02:00
|
|
|
secondary=NULL;
|
|
|
|
}
|
2007-11-05 23:23:28 +01:00
|
|
|
--wfxe.Samples.wValidBitsPerSample;
|
|
|
|
|
|
|
|
wfxe.Samples.wValidBitsPerSample = 0;
|
2018-03-30 07:05:28 +02:00
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2007-11-05 23:23:28 +01:00
|
|
|
ok(rc==DS_OK && secondary,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
|
|
|
rc, secondary);
|
2007-11-05 23:23:28 +01:00
|
|
|
if (secondary)
|
2008-09-09 20:44:46 +02:00
|
|
|
{
|
2007-11-05 23:23:28 +01:00
|
|
|
IDirectSoundBuffer_Release(secondary);
|
2008-09-09 20:44:46 +02:00
|
|
|
secondary=NULL;
|
|
|
|
}
|
2007-11-05 23:23:28 +01:00
|
|
|
wfxe.Samples.wValidBitsPerSample = wfxe.Format.wBitsPerSample;
|
|
|
|
|
2018-03-30 07:05:28 +02:00
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2004-07-30 20:42:51 +02:00
|
|
|
ok(rc==DS_OK && secondary!=NULL,
|
2007-11-05 23:23:28 +01:00
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create a secondary "
|
2008-07-08 17:49:20 +02:00
|
|
|
"buffer %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
if (rc==DS_OK && secondary!=NULL) {
|
2007-11-05 23:23:28 +01:00
|
|
|
if (winetest_interactive) {
|
2011-01-20 16:41:59 +01:00
|
|
|
trace(" Testing a secondary buffer at %dx%dx%d (fmt=%d) "
|
2007-11-05 23:23:28 +01:00
|
|
|
"with a primary buffer at %dx%dx%d\n",
|
2011-01-20 16:41:59 +01:00
|
|
|
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,format_tags[tag],
|
2007-11-05 23:23:28 +01:00
|
|
|
wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
|
|
|
|
}
|
2013-11-12 22:11:12 +01:00
|
|
|
test_buffer8(dso,&secondary,FALSE,FALSE,0,FALSE,0,
|
|
|
|
winetest_interactive,1.0,FALSE,NULL,FALSE,FALSE);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
ref=IDirectSoundBuffer_Release(secondary);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
|
2004-07-30 20:42:51 +02:00
|
|
|
"should have 0\n",ref);
|
|
|
|
}
|
2011-01-20 16:41:59 +01:00
|
|
|
}
|
2004-07-30 20:42:51 +02:00
|
|
|
}
|
2005-02-10 21:26:20 +01:00
|
|
|
EXIT1:
|
2004-07-30 20:42:51 +02:00
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
2004-07-30 20:42:51 +02:00
|
|
|
"should have 0\n",ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the CooperativeLevel back to normal */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
|
|
|
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
|
|
|
|
EXIT:
|
|
|
|
ref=IDirectSound8_Release(dso);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
|
|
|
|
LPCSTR lpcstrModule, LPVOID lpContext)
|
|
|
|
{
|
2004-10-19 23:10:41 +02:00
|
|
|
HRESULT rc;
|
2004-08-23 19:50:31 +02:00
|
|
|
trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
|
2004-10-19 23:10:41 +02:00
|
|
|
rc = test_dsound8(lpGuid);
|
|
|
|
if (rc == DSERR_NODRIVER)
|
|
|
|
trace(" No Driver\n");
|
2004-10-21 21:51:10 +02:00
|
|
|
else if (rc == DSERR_ALLOCATED)
|
|
|
|
trace(" Already In Use\n");
|
2005-02-23 13:43:38 +01:00
|
|
|
else if (rc == E_FAIL)
|
|
|
|
trace(" No Device\n");
|
2004-10-19 23:10:41 +02:00
|
|
|
else {
|
|
|
|
test_primary8(lpGuid);
|
|
|
|
test_primary_secondary8(lpGuid);
|
|
|
|
test_secondary8(lpGuid);
|
|
|
|
}
|
2004-07-30 20:42:51 +02:00
|
|
|
|
2013-11-12 22:11:12 +01:00
|
|
|
return TRUE;
|
2004-07-30 20:42:51 +02:00
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void dsound8_tests(void)
|
2004-07-30 20:42:51 +02:00
|
|
|
{
|
|
|
|
HRESULT rc;
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundEnumerateA(dsenum_callback, NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
}
|
|
|
|
|
2011-10-19 22:07:18 +02:00
|
|
|
static void test_hw_buffers(void)
|
|
|
|
{
|
|
|
|
IDirectSound8 *ds;
|
|
|
|
IDirectSoundBuffer *primary, *primary2, **secondaries, *secondary;
|
|
|
|
IDirectSoundBuffer8 *buf8;
|
|
|
|
DSCAPS caps;
|
|
|
|
DSBCAPS bufcaps;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
WAVEFORMATEX fmt;
|
|
|
|
UINT i;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2020-07-23 18:46:59 +02:00
|
|
|
hr = DirectSoundCreate8(NULL, &ds, NULL);
|
2011-10-19 22:07:18 +02:00
|
|
|
ok(hr == S_OK || hr == DSERR_NODRIVER || hr == DSERR_ALLOCATED || hr == E_FAIL,
|
|
|
|
"DirectSoundCreate8 failed: %08x\n", hr);
|
|
|
|
if(hr != S_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
caps.dwSize = sizeof(caps);
|
|
|
|
|
|
|
|
hr = IDirectSound8_GetCaps(ds, &caps);
|
|
|
|
ok(hr == S_OK, "GetCaps failed: %08x\n", hr);
|
|
|
|
|
|
|
|
ok(caps.dwPrimaryBuffers == 1, "Got wrong number of primary buffers: %u\n",
|
|
|
|
caps.dwPrimaryBuffers);
|
|
|
|
|
|
|
|
/* DSBCAPS_LOC* is ignored for primary buffers */
|
|
|
|
bufdesc.dwSize = sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCHARDWARE |
|
|
|
|
DSBCAPS_PRIMARYBUFFER;
|
|
|
|
bufdesc.dwBufferBytes = 0;
|
|
|
|
bufdesc.dwReserved = 0;
|
|
|
|
bufdesc.lpwfxFormat = NULL;
|
|
|
|
bufdesc.guid3DAlgorithm = GUID_NULL;
|
|
|
|
|
|
|
|
hr = IDirectSound8_CreateSoundBuffer(ds, &bufdesc, &primary, NULL);
|
|
|
|
ok(hr == S_OK, "CreateSoundBuffer failed: %08x\n", hr);
|
|
|
|
if(hr != S_OK){
|
|
|
|
IDirectSound8_Release(ds);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCSOFTWARE |
|
|
|
|
DSBCAPS_PRIMARYBUFFER;
|
|
|
|
|
|
|
|
hr = IDirectSound8_CreateSoundBuffer(ds, &bufdesc, &primary2, NULL);
|
|
|
|
ok(hr == S_OK, "CreateSoundBuffer failed: %08x\n", hr);
|
|
|
|
ok(primary == primary2, "Got different primary buffers: %p, %p\n", primary, primary2);
|
|
|
|
if(hr == S_OK)
|
|
|
|
IDirectSoundBuffer_Release(primary2);
|
|
|
|
|
|
|
|
buf8 = (IDirectSoundBuffer8 *)0xDEADBEEF;
|
|
|
|
hr = IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSoundBuffer8,
|
|
|
|
(void**)&buf8);
|
|
|
|
ok(hr == E_NOINTERFACE, "QueryInterface gave wrong failure: %08x\n", hr);
|
|
|
|
ok(buf8 == NULL, "Pointer didn't get set to NULL\n");
|
|
|
|
|
|
|
|
fmt.wFormatTag = WAVE_FORMAT_PCM;
|
|
|
|
fmt.nChannels = 2;
|
|
|
|
fmt.nSamplesPerSec = 48000;
|
|
|
|
fmt.wBitsPerSample = 16;
|
|
|
|
fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8;
|
|
|
|
fmt.nAvgBytesPerSec = fmt.nBlockAlign * fmt.nSamplesPerSec;
|
|
|
|
fmt.cbSize = 0;
|
|
|
|
|
|
|
|
bufdesc.lpwfxFormat = &fmt;
|
|
|
|
bufdesc.dwBufferBytes = fmt.nSamplesPerSec * fmt.nBlockAlign / 10;
|
|
|
|
bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCHARDWARE |
|
|
|
|
DSBCAPS_CTRLVOLUME;
|
|
|
|
|
|
|
|
secondaries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(IDirectSoundBuffer *) * caps.dwMaxHwMixingAllBuffers);
|
|
|
|
|
|
|
|
/* try to fill all of the hw buffers */
|
|
|
|
trace("dwMaxHwMixingAllBuffers: %u\n", caps.dwMaxHwMixingAllBuffers);
|
|
|
|
trace("dwMaxHwMixingStaticBuffers: %u\n", caps.dwMaxHwMixingStaticBuffers);
|
|
|
|
trace("dwMaxHwMixingStreamingBuffers: %u\n", caps.dwMaxHwMixingStreamingBuffers);
|
|
|
|
for(i = 0; i < caps.dwMaxHwMixingAllBuffers; ++i){
|
|
|
|
hr = IDirectSound8_CreateSoundBuffer(ds, &bufdesc, &secondaries[i], NULL);
|
2012-10-14 23:38:13 +02:00
|
|
|
ok(hr == S_OK || hr == E_NOTIMPL || broken(hr == DSERR_CONTROLUNAVAIL) || broken(hr == E_FAIL),
|
2011-10-19 22:07:18 +02:00
|
|
|
"CreateSoundBuffer(%u) failed: %08x\n", i, hr);
|
|
|
|
if(hr != S_OK)
|
|
|
|
break;
|
|
|
|
|
|
|
|
bufcaps.dwSize = sizeof(bufcaps);
|
|
|
|
hr = IDirectSoundBuffer_GetCaps(secondaries[i], &bufcaps);
|
|
|
|
ok(hr == S_OK, "GetCaps failed: %08x\n", hr);
|
|
|
|
ok((bufcaps.dwFlags & DSBCAPS_LOCHARDWARE) != 0,
|
|
|
|
"Buffer wasn't allocated in hardware, dwFlags: %x\n", bufcaps.dwFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* see if we can create one more */
|
|
|
|
hr = IDirectSound8_CreateSoundBuffer(ds, &bufdesc, &secondary, NULL);
|
|
|
|
ok((i == caps.dwMaxHwMixingAllBuffers && hr == DSERR_ALLOCATED) || /* out of hw buffers */
|
|
|
|
(caps.dwMaxHwMixingAllBuffers == 0 && hr == DSERR_INVALIDCALL) || /* no hw buffers at all */
|
|
|
|
hr == E_NOTIMPL || /* don't support hw buffers */
|
|
|
|
broken(hr == DSERR_CONTROLUNAVAIL) || /* vmware winxp, others? */
|
2012-10-14 23:38:13 +02:00
|
|
|
broken(hr == E_FAIL) || /* broken AC97 driver */
|
2011-10-19 22:07:18 +02:00
|
|
|
broken(hr == S_OK) /* broken driver allows more hw bufs than dscaps claims */,
|
2012-10-14 23:38:13 +02:00
|
|
|
"CreateSoundBuffer(%u) gave wrong error: %08x\n", i, hr);
|
2011-10-19 22:07:18 +02:00
|
|
|
if(hr == S_OK)
|
|
|
|
IDirectSoundBuffer_Release(secondary);
|
|
|
|
|
|
|
|
for(i = 0; i < caps.dwMaxHwMixingAllBuffers; ++i)
|
|
|
|
if(secondaries[i])
|
|
|
|
IDirectSoundBuffer_Release(secondaries[i]);
|
|
|
|
|
2012-10-27 00:39:26 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, secondaries);
|
|
|
|
|
2011-10-19 22:07:18 +02:00
|
|
|
IDirectSoundBuffer_Release(primary);
|
|
|
|
IDirectSound8_Release(ds);
|
|
|
|
}
|
2005-03-05 11:49:08 +01:00
|
|
|
|
2011-10-20 22:15:09 +02:00
|
|
|
static struct {
|
|
|
|
UINT dev_count;
|
|
|
|
GUID guid;
|
|
|
|
} default_info = { 0 };
|
|
|
|
|
|
|
|
static BOOL WINAPI default_device_cb(GUID *guid, const char *desc,
|
|
|
|
const char *module, void *user)
|
|
|
|
{
|
|
|
|
trace("guid: %p, desc: %s\n", guid, desc);
|
|
|
|
if(!guid)
|
|
|
|
ok(default_info.dev_count == 0, "Got NULL GUID not in first position\n");
|
|
|
|
else{
|
|
|
|
if(default_info.dev_count == 0){
|
|
|
|
ok(IsEqualGUID(guid, &default_info.guid), "Expected default device GUID\n");
|
|
|
|
}else{
|
|
|
|
ok(!IsEqualGUID(guid, &default_info.guid), "Got default GUID at unexpected location: %u\n",
|
|
|
|
default_info.dev_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only count real devices */
|
|
|
|
++default_info.dev_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_first_device(void)
|
|
|
|
{
|
|
|
|
IMMDeviceEnumerator *devenum;
|
|
|
|
IMMDevice *defdev;
|
|
|
|
IPropertyStore *ps;
|
|
|
|
PROPVARIANT pv;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL,
|
|
|
|
CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&devenum);
|
|
|
|
if(FAILED(hr)){
|
|
|
|
win_skip("MMDevAPI is not available, skipping default device test\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum, eRender,
|
|
|
|
eMultimedia, &defdev);
|
2013-04-22 00:19:47 +02:00
|
|
|
if (hr == E_NOTFOUND) {
|
|
|
|
win_skip("No default device found\n");
|
|
|
|
return;
|
|
|
|
}
|
2011-10-20 22:15:09 +02:00
|
|
|
ok(hr == S_OK, "GetDefaultAudioEndpoint failed: %08x\n", hr);
|
|
|
|
|
|
|
|
hr = IMMDevice_OpenPropertyStore(defdev, STGM_READ, &ps);
|
|
|
|
ok(hr == S_OK, "OpenPropertyStore failed: %08x\n", hr);
|
|
|
|
|
|
|
|
PropVariantInit(&pv);
|
|
|
|
|
|
|
|
hr = IPropertyStore_GetValue(ps, &PKEY_AudioEndpoint_GUID, &pv);
|
|
|
|
ok(hr == S_OK, "GetValue failed: %08x\n", hr);
|
|
|
|
|
|
|
|
CLSIDFromString(pv.u.pwszVal, &default_info.guid);
|
|
|
|
|
|
|
|
PropVariantClear(&pv);
|
|
|
|
IPropertyStore_Release(ps);
|
|
|
|
IMMDevice_Release(defdev);
|
|
|
|
IMMDeviceEnumerator_Release(devenum);
|
|
|
|
|
2020-07-23 18:46:59 +02:00
|
|
|
hr = DirectSoundEnumerateA(default_device_cb, NULL);
|
2011-10-20 22:15:09 +02:00
|
|
|
ok(hr == S_OK, "DirectSoundEnumerateA failed: %08x\n", hr);
|
|
|
|
}
|
|
|
|
|
2012-07-19 10:48:26 +02:00
|
|
|
static void test_COM(void)
|
|
|
|
{
|
|
|
|
IDirectSound *ds;
|
|
|
|
IDirectSound8 *ds8 = (IDirectSound8*)0xdeadbeef;
|
|
|
|
IUnknown *unk, *unk8;
|
|
|
|
ULONG refcount;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* COM aggregation */
|
2017-04-25 13:49:06 +02:00
|
|
|
hr = CoCreateInstance(&CLSID_DirectSound8, (IUnknown*)0xdeadbeef, CLSCTX_INPROC_SERVER,
|
2012-07-19 10:48:26 +02:00
|
|
|
&IID_IUnknown, (void**)&ds8);
|
|
|
|
ok(hr == CLASS_E_NOAGGREGATION,
|
|
|
|
"DirectSound create failed: %08x, expected CLASS_E_NOAGGREGATION\n", hr);
|
|
|
|
ok(!ds8, "ds8 = %p\n", ds8);
|
|
|
|
|
|
|
|
/* Invalid RIID */
|
|
|
|
hr = CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectSound3DBuffer, (void**)&ds8);
|
|
|
|
ok(hr == E_NOINTERFACE,
|
|
|
|
"DirectSound create failed: %08x, expected E_NOINTERFACE\n", hr);
|
|
|
|
|
|
|
|
/* Same refcount for IDirectSound and IDirectSound8 */
|
|
|
|
hr = CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectSound8,
|
|
|
|
(void**)&ds8);
|
|
|
|
ok(hr == S_OK, "DirectSound create failed: %08x, expected S_OK\n", hr);
|
|
|
|
refcount = IDirectSound8_AddRef(ds8);
|
|
|
|
ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
|
|
|
|
hr = IDirectSound8_QueryInterface(ds8, &IID_IDirectSound, (void**)&ds);
|
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IDirectSound failed: %08x\n", hr);
|
|
|
|
refcount = IDirectSound8_AddRef(ds8);
|
2012-07-19 02:05:37 +02:00
|
|
|
ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
|
2012-07-19 10:48:26 +02:00
|
|
|
refcount = IDirectSound_AddRef(ds);
|
2012-07-19 02:05:37 +02:00
|
|
|
ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
|
2012-07-19 10:48:26 +02:00
|
|
|
|
|
|
|
/* Separate refcount for IUnknown */
|
|
|
|
hr = IDirectSound_QueryInterface(ds, &IID_IUnknown, (void**)&unk);
|
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
|
|
|
|
refcount = IUnknown_AddRef(unk);
|
|
|
|
ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
|
2018-03-30 07:05:28 +02:00
|
|
|
hr = IDirectSound8_QueryInterface(ds8, &IID_IUnknown, (void**)&unk8);
|
2012-07-19 10:48:26 +02:00
|
|
|
ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
|
|
|
|
refcount = IUnknown_AddRef(unk8);
|
|
|
|
ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
|
|
|
|
refcount = IDirectSound_AddRef(ds);
|
2012-07-19 02:05:37 +02:00
|
|
|
ok(refcount == 6, "refcount == %u, expected 6\n", refcount);
|
2012-07-19 10:48:26 +02:00
|
|
|
|
|
|
|
while (IDirectSound_Release(ds));
|
|
|
|
while (IUnknown_Release(unk));
|
|
|
|
}
|
|
|
|
|
2019-09-27 05:46:55 +02:00
|
|
|
static void test_primary_flags(void)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
IDirectSound8 *dso;
|
|
|
|
IDirectSoundBuffer *primary = NULL;
|
|
|
|
IDirectSoundFXI3DL2Reverb *reverb;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
DSCAPS dscaps;
|
|
|
|
|
|
|
|
/* Create a DirectSound8 object */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(NULL, &dso, NULL);
|
2019-09-27 05:46:55 +02:00
|
|
|
ok(rc == DS_OK || rc==DSERR_NODRIVER, "Failed: %08x\n",rc);
|
|
|
|
|
|
|
|
if (rc!=DS_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
rc = IDirectSound8_SetCooperativeLevel(dso, get_hwnd(), DSSCL_PRIORITY);
|
|
|
|
ok(rc == DS_OK,"Failed: %08x\n", rc);
|
|
|
|
if (rc != DS_OK) {
|
|
|
|
IDirectSound8_Release(dso);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dscaps.dwSize = sizeof(dscaps);
|
|
|
|
rc = IDirectSound8_GetCaps(dso, &dscaps);
|
|
|
|
ok(rc == DS_OK,"Failed: %08x\n", rc);
|
|
|
|
trace("0x%x\n", dscaps.dwFlags);
|
|
|
|
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize = sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLFX;
|
|
|
|
rc = IDirectSound8_CreateSoundBuffer(dso, &bufdesc, &primary, NULL);
|
|
|
|
ok(rc == E_INVALIDARG, "got %08x\n", rc);
|
|
|
|
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize = sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRL3D;
|
|
|
|
rc = IDirectSound8_CreateSoundBuffer(dso, &bufdesc, &primary, NULL);
|
|
|
|
ok((rc == DS_OK && primary != NULL), "Failed to create a primary buffer: %08x\n", rc);
|
|
|
|
if (rc == DS_OK) {
|
|
|
|
rc = IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSoundFXI3DL2Reverb, (LPVOID*)&reverb);
|
|
|
|
ok(rc==E_NOINTERFACE,"Failed: %08x\n", rc);
|
|
|
|
|
|
|
|
IDirectSoundBuffer_Release(primary);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDirectSound8_Release(dso);
|
|
|
|
}
|
|
|
|
|
2015-02-24 23:42:51 +01:00
|
|
|
static void test_effects(void)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND8 dso;
|
|
|
|
LPDIRECTSOUNDBUFFER primary, secondary;
|
|
|
|
LPDIRECTSOUNDBUFFER8 secondary8;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
WAVEFORMATEX wfx;
|
|
|
|
DSEFFECTDESC effects[2];
|
|
|
|
DWORD resultcodes[2];
|
|
|
|
|
|
|
|
/* Create a DirectSound8 object */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(NULL, &dso, NULL);
|
2015-02-24 23:42:51 +01:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate8() failed: %08x\n",rc);
|
|
|
|
|
|
|
|
if (rc!=DS_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
|
|
|
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
|
|
|
if (rc!=DS_OK) {
|
2018-03-30 07:05:28 +02:00
|
|
|
IDirectSound8_Release(dso);
|
2015-02-24 23:42:51 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
primary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
|
|
|
ok((rc==DS_OK && primary!=NULL),
|
|
|
|
"IDirectSound8_CreateSoundBuffer() failed to create a primary buffer: "
|
|
|
|
"%08x\n",rc);
|
|
|
|
if (rc==DS_OK) {
|
|
|
|
init_format(&wfx,WAVE_FORMAT_PCM,11025,8,1);
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=0;
|
|
|
|
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
|
|
|
|
wfx.nBlockAlign);
|
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
|
|
|
|
|
|
|
ZeroMemory(effects, sizeof(effects));
|
|
|
|
effects[0].dwSize=sizeof(effects[0]);
|
|
|
|
effects[0].guidDSFXClass=GUID_DSFX_STANDARD_ECHO;
|
|
|
|
effects[1].dwSize=sizeof(effects[1]);
|
|
|
|
effects[1].guidDSFXClass=GUID_NULL;
|
|
|
|
|
|
|
|
secondary=NULL;
|
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
|
|
|
ok(rc==DS_OK && secondary!=NULL,
|
|
|
|
"IDirectSound8_CreateSoundBuffer() failed to create a secondary "
|
|
|
|
"buffer: %08x\n",rc);
|
|
|
|
|
|
|
|
/* Call SetFX on buffer without DSBCAPS_CTRLFX */
|
|
|
|
if (rc==DS_OK && secondary!=NULL) {
|
|
|
|
secondary8=NULL;
|
|
|
|
rc=IDirectSoundBuffer_QueryInterface(secondary,&IID_IDirectSoundBuffer8,(LPVOID*)&secondary8);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_QueryInterface(IID_IDirectSoundBuffer8) failed: %08x\n", rc);
|
|
|
|
|
|
|
|
if (rc==DS_OK && secondary8) {
|
|
|
|
rc=IDirectSoundBuffer8_SetFX(secondary8,1,effects,resultcodes);
|
|
|
|
ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer8_SetFX() "
|
|
|
|
"should have returned DSERR_CONTROLUNAVAIL, returned: %08x\n", rc);
|
|
|
|
|
|
|
|
IDirectSoundBuffer8_Release(secondary8);
|
|
|
|
}
|
|
|
|
IDirectSoundBuffer_Release(secondary);
|
|
|
|
}
|
|
|
|
|
|
|
|
secondary=NULL;
|
|
|
|
bufdesc.dwFlags=DSBCAPS_CTRLFX;
|
|
|
|
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
|
|
|
ok(rc==DS_OK && secondary!=NULL,
|
|
|
|
"IDirectSound8_CreateSoundBuffer() failed to create a secondary "
|
|
|
|
"buffer: %08x\n",rc);
|
|
|
|
|
|
|
|
if (rc==DS_OK) {
|
|
|
|
secondary8=NULL;
|
|
|
|
rc=IDirectSoundBuffer_QueryInterface(secondary,&IID_IDirectSoundBuffer8,(LPVOID*)&secondary8);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_QueryInterface(IID_IDirectSoundBuffer8) failed: %08x\n", rc);
|
|
|
|
|
|
|
|
if (rc==DS_OK && secondary8) {
|
|
|
|
LPVOID ptr1,ptr2;
|
|
|
|
DWORD bytes1,bytes2;
|
2015-03-03 08:46:15 +01:00
|
|
|
IUnknown* obj = NULL;
|
|
|
|
HRESULT rc2;
|
2015-02-24 23:42:51 +01:00
|
|
|
|
|
|
|
/* Call SetFX with dwEffectsCount > 0 and pDSFXDesc == NULL */
|
|
|
|
rc=IDirectSoundBuffer8_SetFX(secondary8,1,NULL,NULL);
|
|
|
|
ok(rc==E_INVALIDARG||rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer8_SetFX() "
|
|
|
|
"should have returned E_INVALIDARG, returned: %08x\n", rc);
|
|
|
|
|
|
|
|
/* Call SetFX with dwEffectsCount == 0 and pDSFXDesc != NULL */
|
|
|
|
rc=IDirectSoundBuffer8_SetFX(secondary8,0,effects,NULL);
|
|
|
|
ok(rc==E_INVALIDARG||rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer8_SetFX() "
|
|
|
|
"should have returned E_INVALIDARG, returned: %08x\n", rc);
|
|
|
|
|
|
|
|
/* Call SetFX with dwEffectsCount == 0 and pdwResultCodes != NULL */
|
|
|
|
rc=IDirectSoundBuffer8_SetFX(secondary8,0,NULL,resultcodes);
|
|
|
|
ok(rc==E_INVALIDARG||rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer8_SetFX() "
|
|
|
|
"should have returned E_INVALIDARG, returned: %08x\n", rc);
|
|
|
|
|
|
|
|
rc=IDirectSoundBuffer8_Lock(secondary8,0,0,&ptr1,&bytes1,&ptr2,&bytes2,DSBLOCK_ENTIREBUFFER);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer8_Lock() failed: %08x\n",rc);
|
|
|
|
|
|
|
|
if (rc==DS_OK) {
|
|
|
|
/* Call SetFX when buffer is locked */
|
|
|
|
rc=IDirectSoundBuffer8_SetFX(secondary8,1,effects,resultcodes);
|
|
|
|
ok(rc==DSERR_INVALIDCALL||rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer8_SetFX() "
|
|
|
|
"should have returned DSERR_INVALIDCALL, returned: %08x\n", rc);
|
|
|
|
|
|
|
|
rc=IDirectSoundBuffer8_Unlock(secondary8,ptr1,bytes1,ptr2,bytes2);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer8_Unlock() failed: %08x\n",rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
rc=IDirectSoundBuffer8_Play(secondary8,0,0,DSBPLAY_LOOPING);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer8_Play() failed: %08x\n",rc);
|
|
|
|
|
|
|
|
if (rc==DS_OK) {
|
|
|
|
/* Call SetFX when buffer is playing */
|
|
|
|
rc=IDirectSoundBuffer8_SetFX(secondary8,1,effects,resultcodes);
|
|
|
|
ok(rc==DSERR_INVALIDCALL||rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer8_SetFX() "
|
|
|
|
"should have returned DSERR_INVALIDCALL, returned: %08x\n", rc);
|
|
|
|
|
|
|
|
rc=IDirectSoundBuffer8_Stop(secondary8);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer8_Stop() failed: %08x\n",rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call SetFX with non-existent filter */
|
|
|
|
rc=IDirectSoundBuffer8_SetFX(secondary8,1,&effects[1],resultcodes);
|
|
|
|
ok(rc==REGDB_E_CLASSNOTREG||rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer8_SetFX(GUID_NULL) "
|
|
|
|
"should have returned REGDB_E_CLASSNOTREG, returned: %08x\n",rc);
|
|
|
|
if (rc!=DSERR_CONTROLUNAVAIL) {
|
|
|
|
ok(resultcodes[0]==DSFXR_UNKNOWN,"result code == %08x, expected DSFXR_UNKNOWN\n",resultcodes[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call SetFX with standard echo */
|
2015-03-03 08:46:15 +01:00
|
|
|
rc2=IDirectSoundBuffer8_SetFX(secondary8,1,&effects[0],resultcodes);
|
|
|
|
ok(rc2==DS_OK||rc2==REGDB_E_CLASSNOTREG||rc2==DSERR_CONTROLUNAVAIL,
|
2015-02-24 23:42:51 +01:00
|
|
|
"IDirectSoundBuffer8_SetFX(GUID_DSFX_STANDARD_ECHO) failed: %08x\n",rc);
|
2015-03-03 08:46:15 +01:00
|
|
|
if (rc2!=DSERR_CONTROLUNAVAIL) {
|
2015-02-24 23:42:51 +01:00
|
|
|
ok(resultcodes[0]==DSFXR_UNKNOWN||resultcodes[0]==DSFXR_LOCHARDWARE||resultcodes[0]==DSFXR_LOCSOFTWARE,
|
|
|
|
"resultcode == %08x, expected DSFXR_UNKNOWN, DSFXR_LOCHARDWARE, or DSFXR_LOCSOFTWARE\n",resultcodes[0]);
|
|
|
|
}
|
|
|
|
|
2015-03-03 08:46:15 +01:00
|
|
|
/* Call GetObjectInPath for out-of-bounds DMO */
|
|
|
|
rc=IDirectSoundBuffer8_GetObjectInPath(secondary8,&GUID_All_Objects,2,&IID_IMediaObject,(void**)&obj);
|
|
|
|
ok(rc==DSERR_OBJECTNOTFOUND||rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer8_GetObjectInPath() "
|
|
|
|
"should have returned DSERR_OBJECTNOTFOUND, returned: %08x\n",rc);
|
|
|
|
|
|
|
|
/* Call GetObjectInPath with NULL ppObject */
|
|
|
|
rc=IDirectSoundBuffer8_GetObjectInPath(secondary8,&GUID_All_Objects,0,&IID_IMediaObject,NULL);
|
|
|
|
ok(rc==E_INVALIDARG||rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer8_GetObjectInPath() "
|
|
|
|
"should have returned E_INVALIDARG, returned: %08x\n",rc);
|
|
|
|
|
|
|
|
/* Call GetObjectInPath for unsupported interface */
|
|
|
|
rc=IDirectSoundBuffer8_GetObjectInPath(secondary8,&GUID_All_Objects,0,&GUID_NULL,(void**)&obj);
|
|
|
|
ok(rc==E_NOINTERFACE||rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer8_GetObjectInPath() "
|
|
|
|
"should have returned E_NOINTERFACE, returned: %08x\n",rc);
|
|
|
|
|
|
|
|
/* Call GetObjectInPath for unloaded DMO */
|
|
|
|
rc=IDirectSoundBuffer8_GetObjectInPath(secondary8,&GUID_NULL,0,&IID_IMediaObject,(void**)&obj);
|
|
|
|
ok(rc==DSERR_OBJECTNOTFOUND||rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer8_GetObjectInPath() "
|
|
|
|
"should have returned DSERR_OBJECTNOTFOUND, returned: %08x\n",rc);
|
|
|
|
|
|
|
|
/* Call GetObjectInPath for first DMO */
|
|
|
|
obj=NULL;
|
|
|
|
rc=IDirectSoundBuffer8_GetObjectInPath(secondary8,&GUID_All_Objects,0,&IID_IMediaObject,(void**)&obj);
|
|
|
|
if (rc2==DS_OK) {
|
|
|
|
ok(rc==DS_OK||rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer8_GetObjectInPath() "
|
|
|
|
"should have returned DS_OK, returned: %08x\n",rc);
|
|
|
|
if (obj) IUnknown_Release(obj);
|
|
|
|
} else {
|
|
|
|
ok(rc==DSERR_OBJECTNOTFOUND||rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer8_GetObjectInPath() "
|
|
|
|
"should have returned DSERR_OBJECTNOTFOUND, returned: %08x\n",rc);
|
|
|
|
}
|
|
|
|
|
2015-02-24 23:42:51 +01:00
|
|
|
/* Call SetFX with one real filter and one fake one */
|
|
|
|
rc=IDirectSoundBuffer8_SetFX(secondary8,2,effects,resultcodes);
|
|
|
|
ok(rc==REGDB_E_CLASSNOTREG||rc==DSERR_CONTROLUNAVAIL,
|
|
|
|
"IDirectSoundBuffer8_SetFX(GUID_DSFX_STANDARD_ECHO, GUID_NULL) "
|
|
|
|
"should have returned REGDB_E_CLASSNOTREG, returned: %08x\n",rc);
|
|
|
|
if (rc!=DSERR_CONTROLUNAVAIL) {
|
|
|
|
ok(resultcodes[0]==DSFXR_PRESENT||resultcodes[0]==DSFXR_UNKNOWN,
|
|
|
|
"resultcodes[0] == %08x, expected DSFXR_PRESENT or DSFXR_UNKNOWN\n",resultcodes[0]);
|
|
|
|
ok(resultcodes[1]==DSFXR_UNKNOWN,
|
|
|
|
"resultcodes[1] == %08x, expected DSFXR_UNKNOWN\n",resultcodes[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDirectSoundBuffer8_Release(secondary8);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDirectSoundBuffer_Release(secondary);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDirectSoundBuffer_Release(primary);
|
|
|
|
}
|
|
|
|
|
2018-03-30 07:05:28 +02:00
|
|
|
while (IDirectSound8_Release(dso));
|
2015-02-24 23:42:51 +01:00
|
|
|
}
|
|
|
|
|
2019-11-08 20:26:30 +01:00
|
|
|
static void test_dsfx_interfaces(const char *test_prefix, IUnknown *dmo, REFGUID refguid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
IMediaObject *mediaobject;
|
|
|
|
IMediaObjectInPlace *inplace;
|
|
|
|
IUnknown *parent;
|
|
|
|
|
|
|
|
rc = IUnknown_QueryInterface(dmo, &IID_IMediaObject, (void**)&mediaobject);
|
|
|
|
ok(rc == DS_OK, "%s: Failed: %08x\n", test_prefix, rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
rc = IMediaObject_QueryInterface(mediaobject, refguid, (void**)&parent);
|
|
|
|
ok(rc == S_OK, "%s: got: %08x\n", test_prefix, rc);
|
|
|
|
ok(dmo == parent, "%s: Objects not equal\n", test_prefix);
|
|
|
|
IUnknown_Release(parent);
|
|
|
|
|
|
|
|
IMediaObject_Release(mediaobject);
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = IUnknown_QueryInterface(dmo, &IID_IMediaObjectInPlace, (void**)&inplace);
|
|
|
|
ok(rc == DS_OK, "%s: Failed: %08x\n", test_prefix, rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
rc = IMediaObjectInPlace_QueryInterface(inplace, refguid, (void**)&parent);
|
|
|
|
ok(rc == S_OK, "%s: got: %08x\n", test_prefix, rc);
|
|
|
|
ok(dmo == parent, "%s: Objects not equal\n", test_prefix);
|
|
|
|
IUnknown_Release(parent);
|
|
|
|
|
|
|
|
IMediaObjectInPlace_Release(inplace);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-04 01:44:08 +02:00
|
|
|
static void test_echo_parameters(IDirectSoundBuffer8 *secondary8)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
IDirectSoundFXEcho *echo;
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_ECHO, 0, &IID_IDirectSoundFXEcho, (void**)&echo);
|
|
|
|
ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
DSFXEcho params;
|
|
|
|
|
|
|
|
rc = IDirectSoundFXEcho_GetAllParameters(echo, ¶ms);
|
|
|
|
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK )
|
|
|
|
{
|
|
|
|
ok(params.fWetDryMix == 50.0f, "got %f\n", params.fWetDryMix);
|
|
|
|
ok(params.fFeedback == 50.0f, "got %f\n", params.fFeedback);
|
|
|
|
ok(params.fLeftDelay == 500.0f,"got %f\n", params.fLeftDelay);
|
|
|
|
ok(params.fRightDelay == 500.0f,"got %f\n", params.fRightDelay);
|
|
|
|
ok(params.lPanDelay == 0, "got %d\n", params.lPanDelay);
|
|
|
|
}
|
|
|
|
|
2019-11-08 20:26:30 +01:00
|
|
|
test_dsfx_interfaces("FXEcho", (IUnknown *)echo, &IID_IDirectSoundFXEcho);
|
|
|
|
|
2019-09-04 01:44:08 +02:00
|
|
|
IDirectSoundFXEcho_Release(echo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_gargle_parameters(IDirectSoundBuffer8 *secondary8)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
IDirectSoundFXGargle *gargle;
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_GARGLE, 0, &IID_IDirectSoundFXGargle, (void**)&gargle);
|
|
|
|
todo_wine ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
DSFXGargle params;
|
|
|
|
|
|
|
|
rc = IDirectSoundFXGargle_GetAllParameters(gargle, ¶ms);
|
|
|
|
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
ok(params.dwRateHz == 20, "got %d\n", params.dwRateHz);
|
|
|
|
ok(params.dwWaveShape == DSFXGARGLE_WAVE_TRIANGLE, "got %d\n", params.dwWaveShape);
|
|
|
|
}
|
|
|
|
|
2019-11-08 20:26:30 +01:00
|
|
|
test_dsfx_interfaces("FXGargle", (IUnknown *)gargle, &IID_IDirectSoundFXGargle);
|
|
|
|
|
2019-09-04 01:44:08 +02:00
|
|
|
IDirectSoundFXGargle_Release(gargle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_chorus_parameters(IDirectSoundBuffer8 *secondary8)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
IDirectSoundFXChorus *chorus;
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_CHORUS, 0, &IID_IDirectSoundFXChorus,(void**)&chorus);
|
|
|
|
todo_wine ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
DSFXChorus params;
|
|
|
|
|
|
|
|
rc = IDirectSoundFXChorus_GetAllParameters(chorus, ¶ms);
|
|
|
|
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
ok(params.fWetDryMix == 50.0f, "got %f\n", params.fWetDryMix);
|
|
|
|
ok(params.fDepth == 10.0f, "got %f\n", params.fDepth);
|
|
|
|
ok(params.fFeedback == 25.0f, "got %f\n", params.fFeedback);
|
|
|
|
ok(params.fFrequency == 1.1f, "got %f\n", params.fFrequency);
|
|
|
|
ok(params.lWaveform == DSFXCHORUS_WAVE_SIN, "got %d\n", params.lWaveform);
|
|
|
|
ok(params.fDelay == 16.0f, "got %f\n", params.fDelay);
|
|
|
|
ok(params.lPhase == 3, "got %d\n", params.lPhase);
|
|
|
|
}
|
|
|
|
|
2019-11-08 20:26:30 +01:00
|
|
|
test_dsfx_interfaces("FXChorus", (IUnknown *)chorus, &IID_IDirectSoundFXChorus);
|
|
|
|
|
2019-09-04 01:44:08 +02:00
|
|
|
IDirectSoundFXChorus_Release(chorus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_flanger_parameters(IDirectSoundBuffer8 *secondary8)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
IDirectSoundFXFlanger *flanger;
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_FLANGER, 0, &IID_IDirectSoundFXFlanger,(void**)&flanger);
|
|
|
|
todo_wine ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
DSFXFlanger params;
|
|
|
|
|
|
|
|
rc = IDirectSoundFXFlanger_GetAllParameters(flanger, ¶ms);
|
|
|
|
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
ok(params.fWetDryMix == 50.0f, "got %f\n", params.fWetDryMix);
|
|
|
|
ok(params.fDepth == 100.0f, "got %f\n", params.fDepth);
|
|
|
|
ok(params.fFeedback == -50.0f, "got %f\n", params.fFeedback);
|
|
|
|
ok(params.fFrequency == 0.25f, "got %f\n", params.fFrequency);
|
|
|
|
ok(params.lWaveform == DSFXFLANGER_WAVE_SIN, "got %d\n", params.lWaveform);
|
|
|
|
ok(params.fDelay == 2.0f, "got %f\n", params.fDelay);
|
|
|
|
ok(params.lPhase == 2, "got %d\n", params.lPhase);
|
|
|
|
}
|
|
|
|
|
2019-11-08 20:26:30 +01:00
|
|
|
test_dsfx_interfaces("FXFlanger", (IUnknown *)flanger, &IID_IDirectSoundFXFlanger);
|
|
|
|
|
2019-09-04 01:44:08 +02:00
|
|
|
IDirectSoundFXFlanger_Release(flanger);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_distortion_parameters(IDirectSoundBuffer8 *secondary8)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
IDirectSoundFXDistortion *distortion;
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_DISTORTION, 0, &IID_IDirectSoundFXDistortion,(void**)&distortion);
|
|
|
|
todo_wine ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
DSFXDistortion params;
|
|
|
|
|
|
|
|
rc = IDirectSoundFXDistortion_GetAllParameters(distortion, ¶ms);
|
|
|
|
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
ok(params.fGain == -18.0f, "got %f\n", params.fGain);
|
|
|
|
ok(params.fEdge == 15.0f, "got %f\n", params.fEdge);
|
|
|
|
ok(params.fPostEQCenterFrequency == 2400.0f, "got %f\n", params.fPostEQCenterFrequency);
|
|
|
|
ok(params.fPostEQBandwidth == 2400.0f, "got %f\n", params.fPostEQBandwidth);
|
|
|
|
ok(params.fPreLowpassCutoff == 3675.0f, "got %f\n", params.fPreLowpassCutoff);
|
|
|
|
}
|
|
|
|
|
2019-11-08 20:26:30 +01:00
|
|
|
test_dsfx_interfaces("FXDistortion", (IUnknown *)distortion, &IID_IDirectSoundFXDistortion);
|
|
|
|
|
2019-09-04 01:44:08 +02:00
|
|
|
IDirectSoundFXDistortion_Release(distortion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_compressor_parameters(IDirectSoundBuffer8 *secondary8)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
IDirectSoundFXCompressor *compressor;
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_COMPRESSOR, 0, &IID_IDirectSoundFXCompressor,(void**)&compressor);
|
|
|
|
todo_wine ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
DSFXCompressor params;
|
|
|
|
|
|
|
|
rc = IDirectSoundFXCompressor_GetAllParameters(compressor, ¶ms);
|
|
|
|
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
ok(params.fGain == 0.0f, "got %f\n", params.fGain);
|
|
|
|
ok(params.fAttack == 10.0f, "got %f\n", params.fAttack);
|
|
|
|
ok(params.fThreshold == -20.0f, "got %f\n", params.fThreshold);
|
|
|
|
ok(params.fRatio == 3.0f, "got %f\n", params.fRatio);
|
|
|
|
ok(params.fPredelay == 4.0f, "got %f\n", params.fPredelay);
|
|
|
|
}
|
|
|
|
|
2019-11-08 20:26:30 +01:00
|
|
|
test_dsfx_interfaces("FXCompressor", (IUnknown *)compressor, &IID_IDirectSoundFXCompressor);
|
|
|
|
|
2019-09-04 01:44:08 +02:00
|
|
|
IDirectSoundFXCompressor_Release(compressor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_parameq_parameters(IDirectSoundBuffer8 *secondary8)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
IDirectSoundFXParamEq *parameq;
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_PARAMEQ, 0, &IID_IDirectSoundFXParamEq,(void**)¶meq);
|
|
|
|
todo_wine ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
DSFXParamEq params;
|
|
|
|
|
|
|
|
rc = IDirectSoundFXParamEq_GetAllParameters(parameq, ¶ms);
|
|
|
|
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
ok(params.fCenter == 3675.0f, "got %f\n", params.fCenter);
|
|
|
|
ok(params.fBandwidth == 12.0f, "got %f\n", params.fBandwidth);
|
|
|
|
ok(params.fGain == 0.0f, "got %f\n", params.fGain);
|
|
|
|
}
|
|
|
|
|
2019-11-08 20:26:30 +01:00
|
|
|
test_dsfx_interfaces("FXParamEq", (IUnknown *)parameq, &IID_IDirectSoundFXParamEq);
|
|
|
|
|
2019-09-04 01:44:08 +02:00
|
|
|
IDirectSoundFXParamEq_Release(parameq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_reverb_parameters(IDirectSoundBuffer8 *secondary8)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
IDirectSoundFXI3DL2Reverb *reverb;
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer8_GetObjectInPath(secondary8, &GUID_DSFX_STANDARD_I3DL2REVERB, 0, &IID_IDirectSoundFXI3DL2Reverb, (void**)&reverb);
|
|
|
|
todo_wine ok(rc == DS_OK, "GetObjectInPath failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
DSFXI3DL2Reverb params;
|
|
|
|
|
|
|
|
rc = IDirectSoundFXI3DL2Reverb_GetAllParameters(reverb, ¶ms);
|
|
|
|
todo_wine ok(rc == DS_OK, "Failed: %08x\n", rc);
|
|
|
|
if (rc == DS_OK)
|
|
|
|
{
|
|
|
|
ok(params.lRoom == -1000, "got %d\n", params.lRoom);
|
|
|
|
ok(params.flRoomRolloffFactor == 0.0f, "got %f\n", params.flRoomRolloffFactor);
|
|
|
|
ok(params.flDecayTime == 1.49f, "got %f\n", params.flDecayTime);
|
|
|
|
ok(params.flDecayHFRatio == 0.83f, "got %f\n", params.flDecayHFRatio);
|
|
|
|
ok(params.lReflections == -2602, "got %d\n", params.lReflections);
|
|
|
|
ok(params.lReverb == 200, "got %d\n", params.lReverb);
|
|
|
|
ok(params.flReverbDelay == 0.011f, "got %f\n", params.flReverbDelay);
|
|
|
|
ok(params.flDiffusion == 100.0f, "got %f\n", params.flDiffusion);
|
|
|
|
ok(params.flDensity == 100.0f, "got %f\n", params.flDensity);
|
|
|
|
ok(params.flHFReference == 5000.0f, "got %f\n", params.flHFReference);
|
|
|
|
}
|
|
|
|
|
2019-11-08 20:26:30 +01:00
|
|
|
test_dsfx_interfaces("FXI3DL2Reverb", (IUnknown *)reverb, &IID_IDirectSoundFXI3DL2Reverb);
|
|
|
|
|
2019-09-04 01:44:08 +02:00
|
|
|
IDirectSoundFXI3DL2Reverb_Release(reverb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_effects_parameters(void)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
IDirectSound8 *dso;
|
|
|
|
IDirectSoundBuffer *primary, *secondary = NULL;
|
|
|
|
IDirectSoundBuffer8 *secondary8 = NULL;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
WAVEFORMATEX wfx;
|
|
|
|
DSEFFECTDESC effects[8];
|
|
|
|
DWORD resultcodes[8];
|
|
|
|
|
|
|
|
/* Create a DirectSound8 object */
|
2020-07-23 18:46:59 +02:00
|
|
|
rc = DirectSoundCreate8(NULL, &dso, NULL);
|
2019-09-04 01:44:08 +02:00
|
|
|
ok(rc == DS_OK || rc == DSERR_NODRIVER, "DirectSoundCreate8() failed: %08x\n", rc);
|
|
|
|
if (rc != DS_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
rc = IDirectSound8_SetCooperativeLevel(dso, get_hwnd(), DSSCL_PRIORITY);
|
|
|
|
ok(rc == DS_OK, "IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
|
|
|
if (rc != DS_OK)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
primary = NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize = sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
|
|
|
rc = IDirectSound8_CreateSoundBuffer(dso, &bufdesc, &primary, NULL);
|
|
|
|
ok((rc == DS_OK && primary != NULL), "Failed to create a primary buffer: %08x\n", rc);
|
|
|
|
if (rc != DS_OK)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
init_format(&wfx, WAVE_FORMAT_PCM, 11025, 8, 1);
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize = sizeof(bufdesc);
|
|
|
|
bufdesc.dwBufferBytes = align(wfx.nAvgBytesPerSec * BUFFER_LEN / 1000, wfx.nBlockAlign);
|
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
|
|
|
|
|
|
|
ZeroMemory(effects, sizeof(effects));
|
|
|
|
effects[0].dwSize=sizeof(effects[0]);
|
|
|
|
effects[0].guidDSFXClass=GUID_DSFX_STANDARD_ECHO;
|
|
|
|
effects[1].dwSize=sizeof(effects[0]);
|
|
|
|
effects[1].guidDSFXClass=GUID_DSFX_STANDARD_GARGLE;
|
|
|
|
effects[2].dwSize=sizeof(effects[0]);
|
|
|
|
effects[2].guidDSFXClass=GUID_DSFX_STANDARD_CHORUS;
|
|
|
|
effects[3].dwSize=sizeof(effects[0]);
|
|
|
|
effects[3].guidDSFXClass=GUID_DSFX_STANDARD_FLANGER;
|
|
|
|
effects[4].dwSize=sizeof(effects[0]);
|
|
|
|
effects[4].guidDSFXClass=GUID_DSFX_STANDARD_DISTORTION;
|
|
|
|
effects[5].dwSize=sizeof(effects[0]);
|
|
|
|
effects[5].guidDSFXClass=GUID_DSFX_STANDARD_COMPRESSOR;
|
|
|
|
effects[6].dwSize=sizeof(effects[0]);
|
|
|
|
effects[6].guidDSFXClass=GUID_DSFX_STANDARD_PARAMEQ;
|
|
|
|
effects[7].dwSize=sizeof(effects[0]);
|
|
|
|
effects[7].guidDSFXClass=GUID_DSFX_STANDARD_I3DL2REVERB;
|
|
|
|
|
|
|
|
bufdesc.dwFlags = DSBCAPS_CTRLFX;
|
|
|
|
rc = IDirectSound8_CreateSoundBuffer(dso, &bufdesc, &secondary, NULL);
|
|
|
|
ok(rc == DS_OK && secondary != NULL, "Failed to create a secondary buffer: %08x\n",rc);
|
|
|
|
if (rc != DS_OK || !secondary)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer_QueryInterface(secondary, &IID_IDirectSoundBuffer8, (void**)&secondary8);
|
|
|
|
ok(rc == DS_OK, "Failed: %08x\n", rc);
|
|
|
|
if (rc != DS_OK)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer8_SetFX(secondary8, ARRAY_SIZE(effects), effects, resultcodes);
|
|
|
|
ok(rc == DS_OK || rc == REGDB_E_CLASSNOTREG || rc == DSERR_CONTROLUNAVAIL, "Failed: %08x\n", rc);
|
|
|
|
if (rc != DS_OK)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ok (resultcodes[0] == DSFXR_LOCSOFTWARE || resultcodes[0] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[0]);
|
|
|
|
test_echo_parameters(secondary8);
|
|
|
|
|
|
|
|
ok (resultcodes[1] == DSFXR_LOCSOFTWARE || resultcodes[1] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[1]);
|
|
|
|
test_gargle_parameters(secondary8);
|
|
|
|
|
|
|
|
ok (resultcodes[2] == DSFXR_LOCSOFTWARE || resultcodes[2] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[2]);
|
|
|
|
test_chorus_parameters(secondary8);
|
|
|
|
|
|
|
|
ok (resultcodes[3] == DSFXR_LOCSOFTWARE || resultcodes[3] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[3]);
|
|
|
|
test_flanger_parameters(secondary8);
|
|
|
|
|
|
|
|
ok (resultcodes[4] == DSFXR_LOCSOFTWARE || resultcodes[4] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[4]);
|
|
|
|
test_distortion_parameters(secondary8);
|
|
|
|
|
|
|
|
ok (resultcodes[5] == DSFXR_LOCSOFTWARE || resultcodes[5] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[5]);
|
|
|
|
test_compressor_parameters(secondary8);
|
|
|
|
|
|
|
|
ok (resultcodes[6] == DSFXR_LOCSOFTWARE || resultcodes[6] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[6]);
|
|
|
|
test_parameq_parameters(secondary8);
|
|
|
|
|
|
|
|
ok (resultcodes[7] == DSFXR_LOCSOFTWARE || resultcodes[7] == DSFXR_LOCHARDWARE, "Result: %08x\n", resultcodes[7]);
|
|
|
|
test_reverb_parameters(secondary8);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (secondary8)
|
|
|
|
IDirectSoundBuffer8_Release(secondary8);
|
|
|
|
if (primary)
|
|
|
|
IDirectSoundBuffer_Release(primary);
|
|
|
|
IDirectSound8_Release(dso);
|
|
|
|
}
|
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
START_TEST(dsound8)
|
|
|
|
{
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
2020-07-23 18:46:59 +02:00
|
|
|
test_COM();
|
|
|
|
IDirectSound8_tests();
|
|
|
|
dsound8_tests();
|
|
|
|
test_hw_buffers();
|
|
|
|
test_first_device();
|
|
|
|
test_primary_flags();
|
|
|
|
test_effects();
|
|
|
|
test_effects_parameters();
|
2005-01-09 17:34:00 +01:00
|
|
|
|
|
|
|
CoUninitialize();
|
2004-07-30 20:42:51 +02:00
|
|
|
}
|