2002-12-05 20:19:41 +01:00
|
|
|
/*
|
2004-06-18 01:03:11 +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.
|
2002-12-05 20:19:41 +01:00
|
|
|
*
|
2004-06-18 01:03:11 +02:00
|
|
|
* 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
|
2007-05-24 20:42:14 +02:00
|
|
|
* Copyright (c) 2007 Maarten Lankhorst
|
2002-12-05 20:19:41 +01:00
|
|
|
*
|
|
|
|
* 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
|
2002-12-05 20:19:41 +01:00
|
|
|
*/
|
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
#include <windows.h>
|
|
|
|
|
2002-12-05 20:19:41 +01:00
|
|
|
#include "wine/test.h"
|
2013-10-14 23:19:31 +02:00
|
|
|
#include "mmsystem.h"
|
2018-03-30 07:05:28 +02:00
|
|
|
#define COBJMACROS
|
2002-12-05 20:19:41 +01:00
|
|
|
#include "dsound.h"
|
2004-07-30 20:42:51 +02:00
|
|
|
#include "dsconf.h"
|
2007-11-05 23:23:28 +01:00
|
|
|
#include "initguid.h"
|
|
|
|
#include "ks.h"
|
|
|
|
#include "ksmedia.h"
|
2002-12-05 20:19:41 +01:00
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
#include "dsound_test.h"
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2008-07-08 16:17:17 +02:00
|
|
|
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
|
|
|
|
|
2007-01-15 15:00:39 +01:00
|
|
|
static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
|
|
|
|
static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID,LPDIRECTSOUND*,
|
|
|
|
LPUNKNOWN)=NULL;
|
|
|
|
|
2008-04-23 02:12:28 +02:00
|
|
|
static BOOL gotdx8;
|
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
static void IDirectSound_test(LPDIRECTSOUND dso, BOOL initialized,
|
|
|
|
LPCGUID lpGuid)
|
2004-07-12 21:45:28 +02:00
|
|
|
{
|
|
|
|
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-12 21:45:28 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
/* Try to Query for objects */
|
|
|
|
rc=IDirectSound_QueryInterface(dso,&IID_IUnknown,(LPVOID*)&unknown);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_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-12 21:45:28 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
rc=IDirectSound_QueryInterface(dso,&IID_IDirectSound,(LPVOID*)&ds);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_QueryInterface(IID_IDirectSound) failed: %08x\n", rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc==DS_OK)
|
|
|
|
IDirectSound_Release(ds);
|
2004-07-12 21:45:28 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
rc=IDirectSound_QueryInterface(dso,&IID_IDirectSound8,(LPVOID*)&ds8);
|
|
|
|
ok(rc==E_NOINTERFACE,"IDirectSound_QueryInterface(IID_IDirectSound8) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have failed: %08x\n",rc);
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc==DS_OK)
|
|
|
|
IDirectSound8_Release(ds8);
|
2004-07-12 21:45:28 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
if (initialized == FALSE) {
|
2006-11-12 19:51:37 +01:00
|
|
|
/* try uninitialized object */
|
2004-07-19 22:06:22 +02:00
|
|
|
rc=IDirectSound_GetCaps(dso,0);
|
2004-07-30 20:42:51 +02:00
|
|
|
ok(rc==DSERR_UNINITIALIZED,"IDirectSound_GetCaps(NULL) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
|
2004-07-12 21:45:28 +02:00
|
|
|
|
|
|
|
rc=IDirectSound_GetCaps(dso,&dscaps);
|
2004-07-30 20:42:51 +02:00
|
|
|
ok(rc==DSERR_UNINITIALIZED,"IDirectSound_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=IDirectSound_Compact(dso);
|
|
|
|
ok(rc==DSERR_UNINITIALIZED,"IDirectSound_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=IDirectSound_GetSpeakerConfig(dso,&speaker_config);
|
|
|
|
ok(rc==DSERR_UNINITIALIZED,"IDirectSound_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=IDirectSound_Initialize(dso,lpGuid);
|
2005-03-05 12:15:27 +01:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_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-05 12:15:27 +01:00
|
|
|
} else if (rc==E_FAIL) {
|
|
|
|
trace(" No Device\n");
|
2005-05-06 21:33:32 +02:00
|
|
|
goto EXIT;
|
2004-10-25 23:45:51 +02:00
|
|
|
} else if (rc==DSERR_ALLOCATED) {
|
2005-03-30 12:21:44 +02:00
|
|
|
trace(" Already In Use\n");
|
2005-05-06 21:33:32 +02:00
|
|
|
goto EXIT;
|
2004-10-25 23:45:51 +02:00
|
|
|
}
|
2004-07-12 21:45:28 +02:00
|
|
|
}
|
|
|
|
|
2005-05-06 21:33:32 +02:00
|
|
|
rc=IDirectSound_Initialize(dso,lpGuid);
|
|
|
|
ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSound_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=IDirectSound_GetCaps(dso,0);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetCaps(NULL) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2004-07-21 05:23:13 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
ZeroMemory(&dscaps, sizeof(dscaps));
|
2004-07-21 05:23:13 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
/* DSOUND: Error: Invalid caps buffer */
|
|
|
|
rc=IDirectSound_GetCaps(dso,&dscaps);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetCaps() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2004-07-21 05:23:13 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
dscaps.dwSize=sizeof(dscaps);
|
2004-07-21 05:23:13 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
/* DSOUND: Running on a certified driver */
|
|
|
|
rc=IDirectSound_GetCaps(dso,&dscaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %08x\n",rc);
|
2004-07-21 05:23:13 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
rc=IDirectSound_Compact(dso);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DSERR_PRIOLEVELNEEDED,"IDirectSound_Compact() failed: %08x\n", rc);
|
2004-07-21 05:23:13 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
|
2004-07-21 05:23:13 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
rc=IDirectSound_Compact(dso);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_Compact() failed: %08x\n",rc);
|
2004-07-21 05:23:13 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
rc=IDirectSound_GetSpeakerConfig(dso,0);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_GetSpeakerConfig(NULL) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2004-07-21 05:23:13 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
rc=IDirectSound_GetSpeakerConfig(dso,&speaker_config);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_GetSpeakerConfig() failed: %08x\n", rc);
|
2009-11-20 10:11:42 +01:00
|
|
|
ref_speaker_config = speaker_config;
|
2004-07-21 05:23:13 +02:00
|
|
|
|
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=IDirectSound_SetSpeakerConfig(dso,speaker_config);
|
|
|
|
ok(rc==DS_OK,"IDirectSound_SetSpeakerConfig() failed: %08x\n", rc);
|
|
|
|
}
|
2004-07-30 20:42:51 +02:00
|
|
|
if (rc==DS_OK) {
|
|
|
|
rc=IDirectSound_GetSpeakerConfig(dso,&new_speaker_config);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_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("IDirectSound_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
|
|
|
IDirectSound_SetSpeakerConfig(dso,ref_speaker_config);
|
2004-07-21 05:23:13 +02:00
|
|
|
}
|
|
|
|
|
2005-05-06 21:33:32 +02:00
|
|
|
EXIT:
|
2004-07-30 20:42:51 +02:00
|
|
|
ref=IDirectSound_Release(dso);
|
|
|
|
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
|
2004-07-12 21:45:28 +02:00
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void IDirectSound_tests(void)
|
2004-07-12 21:45:28 +02:00
|
|
|
{
|
|
|
|
HRESULT rc;
|
2012-07-19 10:48:26 +02:00
|
|
|
IDirectSound *dso=(IDirectSound*)0xdeadbeef;
|
2006-08-18 07:14:12 +02:00
|
|
|
LPCLASSFACTORY cf=NULL;
|
2004-07-12 21:45:28 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
trace("Testing IDirectSound\n");
|
|
|
|
|
2006-08-18 07:14:12 +02:00
|
|
|
rc=CoGetClassObject(&CLSID_DirectSound, CLSCTX_INPROC_SERVER, NULL,
|
|
|
|
&IID_IClassFactory, (void**)&cf);
|
|
|
|
ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSound, 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_DirectSound, CLSCTX_INPROC_SERVER, NULL,
|
|
|
|
&IID_IUnknown, (void**)&cf);
|
|
|
|
ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSound, IID_IUnknown) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n", rc);
|
2006-08-18 07:14:12 +02:00
|
|
|
|
2012-07-19 10:48:26 +02:00
|
|
|
/* COM aggregation */
|
2017-04-25 13:49:06 +02:00
|
|
|
rc=CoCreateInstance(&CLSID_DirectSound, (IUnknown*)0xdeadbeef, CLSCTX_INPROC_SERVER,
|
2012-07-19 10:48:26 +02:00
|
|
|
&IID_IDirectSound, (void**)&dso);
|
|
|
|
ok(rc==CLASS_E_NOAGGREGATION || broken(rc==DSERR_INVALIDPARAM),
|
|
|
|
"DirectMusicPerformance create failed: %08x, expected CLASS_E_NOAGGREGATION\n", rc);
|
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
/* try the COM class factory method of creation with no device specified */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectSound, (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)
|
|
|
|
IDirectSound_test(dso, FALSE, NULL);
|
|
|
|
|
|
|
|
/* try the COM class factory method of creation with default playback
|
|
|
|
* device specified */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectSound, (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)
|
|
|
|
IDirectSound_test(dso, FALSE, &DSDEVID_DefaultPlayback);
|
|
|
|
|
|
|
|
/* try the COM class factory method of creation with default voice
|
|
|
|
* playback device specified */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectSound, (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)
|
|
|
|
IDirectSound_test(dso, FALSE, &DSDEVID_DefaultVoicePlayback);
|
|
|
|
|
|
|
|
/* try the COM class factory method of creation with a bad
|
|
|
|
* IID specified */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&CLSID_DirectSoundPrivate, (void**)&dso);
|
|
|
|
ok(rc==E_NOINTERFACE,
|
|
|
|
"CoCreateInstance(CLSID_DirectSound,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_IDirectSound, (void**)&dso);
|
|
|
|
ok(rc==REGDB_E_CLASSNOTREG,
|
|
|
|
"CoCreateInstance(CLSID_DirectSoundPrivate,IID_IDirectSound) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have failed: %08x\n",rc);
|
2004-07-12 21:45:28 +02:00
|
|
|
|
2004-07-21 05:23:13 +02:00
|
|
|
/* try with no device specified */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(NULL,&dso,NULL);
|
2005-03-05 12:15:27 +01:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCreate(NULL) failed: %08x\n",rc);
|
2004-10-19 23:10:41 +02:00
|
|
|
if (rc==S_OK && dso)
|
2004-07-30 20:42:51 +02:00
|
|
|
IDirectSound_test(dso, TRUE, NULL);
|
2004-07-21 05:23:13 +02:00
|
|
|
|
|
|
|
/* try with default playback device specified */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(&DSDEVID_DefaultPlayback,&dso,NULL);
|
2005-03-05 12:15:27 +01:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCreate(DSDEVID_DefaultPlayback) 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
|
|
|
IDirectSound_test(dso, TRUE, NULL);
|
2004-07-21 05:23:13 +02:00
|
|
|
|
|
|
|
/* try with default voice playback device specified */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(&DSDEVID_DefaultVoicePlayback,&dso,NULL);
|
2005-03-05 12:15:27 +01:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCreate(DSDEVID_DefaultVoicePlayback) 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
|
|
|
IDirectSound_test(dso, TRUE, NULL);
|
|
|
|
|
|
|
|
/* try with a bad device specified */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(&DSDEVID_DefaultVoiceCapture,&dso,NULL);
|
2004-07-30 20:42:51 +02:00
|
|
|
ok(rc==DSERR_NODRIVER,"DirectSoundCreate(DSDEVID_DefaultVoiceCapture) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have failed: %08x\n",rc);
|
2005-05-06 21:33:32 +02:00
|
|
|
if (rc==DS_OK && dso)
|
|
|
|
IDirectSound_Release(dso);
|
2004-07-12 21:45:28 +02:00
|
|
|
}
|
2003-01-03 00:08:57 +01:00
|
|
|
|
2003-09-02 01:59:03 +02:00
|
|
|
static HRESULT test_dsound(LPGUID lpGuid)
|
2003-01-03 00:08:57 +01:00
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND dso=NULL;
|
2003-09-02 01:59:03 +02:00
|
|
|
int ref;
|
2003-06-28 00:22:15 +02:00
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid interface buffer */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(lpGuid,0,NULL);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"DirectSoundCreate() should have returned "
|
2008-07-08 17:49:20 +02:00
|
|
|
"DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2003-09-02 01:59:03 +02:00
|
|
|
/* Create the DirectSound object */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
|
2005-03-05 12:15:27 +01:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCreate() failed: %08x\n",rc);
|
2003-01-03 00:08:57 +01:00
|
|
|
if (rc!=DS_OK)
|
2004-06-18 01:03:11 +02:00
|
|
|
return rc;
|
2003-01-03 00:08:57 +01:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
/* Try the enumerated device */
|
|
|
|
IDirectSound_test(dso, TRUE, lpGuid);
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
/* Try the COM class factory method of creation with enumerated device */
|
|
|
|
rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDirectSound, (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)
|
|
|
|
IDirectSound_test(dso, FALSE, lpGuid);
|
2003-09-02 01:59:03 +02:00
|
|
|
|
|
|
|
/* Create a DirectSound object */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"DirectSoundCreate() failed: %08x\n",rc);
|
2003-09-02 01:59:03 +02:00
|
|
|
if (rc==DS_OK) {
|
2004-06-18 01:03:11 +02:00
|
|
|
LPDIRECTSOUND dso1=NULL;
|
|
|
|
|
|
|
|
/* Create a second DirectSound object */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(lpGuid,&dso1,NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"DirectSoundCreate() failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc==DS_OK) {
|
|
|
|
/* Release the second DirectSound object */
|
|
|
|
ref=IDirectSound_Release(dso1);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSound_Release() has %d references, should have "
|
|
|
|
"0\n",ref);
|
2005-09-12 12:30:05 +02:00
|
|
|
ok(dso!=dso1,"DirectSound objects should be unique: dso=%p,dso1=%p\n",dso,dso1);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Release the first DirectSound object */
|
|
|
|
ref=IDirectSound_Release(dso);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
|
2004-07-30 20:42:51 +02:00
|
|
|
ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
2003-09-02 01:59:03 +02:00
|
|
|
} else
|
2004-06-18 01:03:11 +02:00
|
|
|
return rc;
|
2004-07-04 02:13:44 +02:00
|
|
|
|
2004-07-14 01:35:09 +02:00
|
|
|
/* Create a DirectSound object */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"DirectSoundCreate() failed: %08x\n",rc);
|
2004-07-14 01:35:09 +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);
|
2004-07-19 21:34:44 +02:00
|
|
|
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-14 01:35:09 +02:00
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2010-09-30 11:31:11 +02:00
|
|
|
ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */
|
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-07-14 01:35:09 +02:00
|
|
|
if (rc==DS_OK && secondary!=NULL) {
|
2004-07-19 21:34:44 +02:00
|
|
|
LPDIRECTSOUND3DBUFFER buffer3d;
|
2018-03-30 07:05:28 +02:00
|
|
|
rc = IDirectSoundBuffer_QueryInterface(secondary, &IID_IDirectSound3DBuffer,
|
2004-07-30 20:42:51 +02:00
|
|
|
(void **)&buffer3d);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(rc==DS_OK && buffer3d!=NULL,"IDirectSound_QueryInterface() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n",rc);
|
2004-07-19 21:34:44 +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);
|
2004-07-19 21:34:44 +02:00
|
|
|
}
|
|
|
|
ref=IDirectSoundBuffer_AddRef(secondary);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==2,"IDirectSoundBuffer_AddRef() has %d references, "
|
2004-07-30 20:42:51 +02:00
|
|
|
"should have 2\n",ref);
|
2004-07-14 01:35:09 +02:00
|
|
|
}
|
|
|
|
/* release with buffer */
|
|
|
|
ref=IDirectSound_Release(dso);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
|
2004-07-30 20:42:51 +02:00
|
|
|
ref);
|
2004-07-14 01:35:09 +02:00
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
|
|
|
} else
|
|
|
|
return rc;
|
|
|
|
|
2003-09-02 01:59:03 +02:00
|
|
|
return DS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT test_primary(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND dso=NULL;
|
|
|
|
LPDIRECTSOUNDBUFFER primary=NULL,second=NULL,third=NULL;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
DSCAPS dscaps;
|
2004-08-25 04:09:00 +02:00
|
|
|
WAVEFORMATEX wfx;
|
2004-06-18 01:03:11 +02:00
|
|
|
int ref;
|
2003-09-02 01:59:03 +02:00
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(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
|
|
|
"DirectSoundCreate() failed: %08x\n",rc);
|
2003-09-02 01:59:03 +02:00
|
|
|
if (rc!=DS_OK)
|
2004-06-18 01:03:11 +02:00
|
|
|
return rc;
|
2003-09-02 01:59:03 +02:00
|
|
|
|
|
|
|
/* Get the device capabilities */
|
|
|
|
ZeroMemory(&dscaps, sizeof(dscaps));
|
|
|
|
dscaps.dwSize=sizeof(dscaps);
|
|
|
|
rc=IDirectSound_GetCaps(dso,&dscaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %08x\n",rc);
|
2003-09-02 01:59:03 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
/* DSOUND: Error: Invalid buffer description pointer */
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,0,0,NULL);
|
2004-07-30 20:42:51 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() should have failed: %08x\n", rc);
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2008-06-24 19:29:50 +02:00
|
|
|
/* DSOUND: Error: NULL pointer is invalid */
|
2003-06-28 00:22:15 +02:00
|
|
|
/* DSOUND: Error: Invalid buffer description pointer */
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,0,&primary,NULL);
|
2004-07-30 20:42:51 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM && primary==0,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() should have failed: rc=%08x,"
|
|
|
|
"dsbo=%p\n",rc,primary);
|
2003-06-28 00:22:15 +02:00
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid size */
|
|
|
|
/* DSOUND: Error: Invalid buffer description */
|
2008-06-24 19:29:50 +02:00
|
|
|
primary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc)-1;
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM && primary==0,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() should have failed: rc=%08x,"
|
|
|
|
"primary=%p\n",rc,primary);
|
2008-06-24 19:29:50 +02:00
|
|
|
|
|
|
|
/* DSOUND: Error: DSBCAPS_PRIMARYBUFFER flag with non-NULL lpwfxFormat */
|
|
|
|
/* DSOUND: Error: Invalid buffer description pointer */
|
|
|
|
primary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM && primary==0,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() should have failed: rc=%08x,"
|
|
|
|
"primary=%p\n",rc,primary);
|
2008-06-24 19:29:50 +02:00
|
|
|
|
|
|
|
/* DSOUND: Error: No DSBCAPS_PRIMARYBUFFER flag with NULL lpwfxFormat */
|
|
|
|
/* DSOUND: Error: Invalid buffer description pointer */
|
|
|
|
primary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=0;
|
|
|
|
bufdesc.lpwfxFormat=NULL;
|
2003-06-28 00:22:15 +02:00
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
2004-07-30 20:42:51 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM && primary==0,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() should have failed: rc=%08x,"
|
|
|
|
"primary=%p\n",rc,primary);
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2003-02-15 01:01:17 +01:00
|
|
|
/* We must call SetCooperativeLevel before calling CreateSoundBuffer */
|
2003-06-28 00:22:15 +02:00
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
|
2003-02-15 01:01:17 +01:00
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
|
2003-02-15 01:01:17 +01:00
|
|
|
if (rc!=DS_OK)
|
2004-06-18 01:03:11 +02:00
|
|
|
goto EXIT;
|
2003-02-15 01:01:17 +01:00
|
|
|
|
2003-01-03 00:08:57 +01:00
|
|
|
/* 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=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_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);
|
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
primary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
2003-01-03 00:08:57 +01:00
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
2004-07-17 01:42:44 +02:00
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
|
2003-06-28 00:22:15 +02:00
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
2005-06-05 19:55:08 +02:00
|
|
|
ok((rc==DS_OK && primary!=NULL) || (rc==DSERR_CONTROLUNAVAIL),
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create a primary buffer: %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-17 01:42:44 +02:00
|
|
|
LONG vol;
|
2018-11-14 22:49:50 +01:00
|
|
|
IDirectSoundNotify *notify;
|
2004-07-17 01:42:44 +02:00
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
/* Try to create a second primary buffer */
|
2004-07-30 20:42:51 +02:00
|
|
|
/* DSOUND: Error: The primary buffer already exists.
|
|
|
|
* Any changes made to the buffer description will be ignored. */
|
2004-06-18 01:03:11 +02:00
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&second,NULL);
|
2004-07-30 20:42:51 +02:00
|
|
|
ok(rc==DS_OK && second==primary,
|
2004-08-13 21:44:29 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() should have returned original "
|
2008-07-08 17:49:20 +02:00
|
|
|
"primary buffer: %08x\n",rc);
|
2004-06-18 01:03:11 +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);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
/* Try to duplicate a primary buffer */
|
|
|
|
/* DSOUND: Error: Can't duplicate primary buffers */
|
|
|
|
rc=IDirectSound_DuplicateSoundBuffer(dso,primary,&third);
|
|
|
|
/* rc=0x88780032 */
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(rc!=DS_OK,"IDirectSound_DuplicateSoundBuffer() primary buffer "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have failed %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2004-07-17 01:42:44 +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-17 01:42:44 +02:00
|
|
|
|
2004-07-30 20:42:51 +02:00
|
|
|
if (winetest_interactive) {
|
2004-08-23 19:50:31 +02:00
|
|
|
trace("Playing a 5 seconds reference tone at the current "
|
|
|
|
"volume.\n");
|
2004-07-17 01:42:44 +02:00
|
|
|
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);
|
2004-06-18 01:03:11 +02:00
|
|
|
trace("All subsequent tones should be identical to this one.\n");
|
|
|
|
trace("Listen for stutter, changes in pitch, volume, etc.\n");
|
|
|
|
}
|
2006-01-06 12:16:41 +01:00
|
|
|
test_buffer(dso,&primary,1,FALSE,0,FALSE,0,winetest_interactive &&
|
2005-02-25 20:17:11 +01:00
|
|
|
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),5.0,0,0,0,0,FALSE,0);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2012-05-09 15:48:56 +02:00
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references\n",ref);
|
|
|
|
|
|
|
|
ref=IDirectSoundBuffer_AddRef(primary);
|
|
|
|
ok(ref==1,"IDirectSoundBuffer_AddRef() primary has %d references\n",ref);
|
|
|
|
|
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references\n",ref);
|
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
2018-11-14 22:49:50 +01:00
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references\n",ref);
|
|
|
|
|
|
|
|
rc=IDirectSoundBuffer_QueryInterface(primary,&IID_IDirectSoundNotify,(void **)¬ify);
|
|
|
|
ok(rc==E_NOINTERFACE,"IDirectSoundBuffer_QueryInterface() failed %08x\n",rc);
|
2003-01-03 00:08:57 +01:00
|
|
|
}
|
2003-09-15 22:08:26 +02:00
|
|
|
|
2003-09-02 01:59:03 +02:00
|
|
|
/* Set the CooperativeLevel back to normal */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
|
2003-09-02 01:59:03 +02:00
|
|
|
|
|
|
|
EXIT:
|
|
|
|
ref=IDirectSound_Release(dso);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
|
2003-09-02 01:59:03 +02:00
|
|
|
if (ref!=0)
|
2004-06-18 01:03:11 +02:00
|
|
|
return DSERR_GENERIC;
|
2003-09-02 01:59:03 +02:00
|
|
|
|
|
|
|
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_secondary(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND dso=NULL;
|
|
|
|
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
DSCAPS dscaps;
|
|
|
|
WAVEFORMATEX wfx, wfx2;
|
2011-01-20 16:41:11 +01:00
|
|
|
int f,ref,tag;
|
2004-08-09 20:50:06 +02:00
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(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
|
|
|
"DirectSoundCreate() 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=IDirectSound_GetCaps(dso,&dscaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_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=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_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=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
|
|
|
ok(rc==DS_OK && primary!=NULL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create a primary buffer %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:11 +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=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
|
2004-08-09 20:50:06 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
|
2011-01-20 16:41:11 +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-04-23 02:12:28 +02:00
|
|
|
|
|
|
|
if (wfx.wBitsPerSample <= 16)
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_SetFormat(%s) failed: %08x\n",
|
|
|
|
format_string(&wfx), rc);
|
2008-04-23 02:12:28 +02:00
|
|
|
else
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK || rc == E_INVALIDARG, "SetFormat (%s) failed: %08x\n",
|
|
|
|
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=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_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-12 05:29:39 +02:00
|
|
|
if (winetest_interactive) {
|
2011-01-20 16:41:11 +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:11 +01:00
|
|
|
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,format_tags[tag],
|
2004-08-12 05:29:39 +02:00
|
|
|
wfx2.nSamplesPerSec,wfx2.wBitsPerSample,wfx2.nChannels);
|
|
|
|
}
|
2004-08-09 20:50:06 +02:00
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2010-09-30 11:31:11 +02:00
|
|
|
ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create a secondary buffer %08x\n",rc);
|
2004-08-09 20:50:06 +02:00
|
|
|
|
|
|
|
if (rc==DS_OK && secondary!=NULL) {
|
2006-01-06 12:16:41 +01:00
|
|
|
test_buffer(dso,&secondary,0,FALSE,0,FALSE,0,
|
2005-02-25 20:17:11 +01:00
|
|
|
winetest_interactive,1.0,0,NULL,0,0,FALSE,0);
|
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:11 +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=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
|
2004-08-09 20:50:06 +02:00
|
|
|
|
|
|
|
EXIT:
|
|
|
|
ref=IDirectSound_Release(dso);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSound_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-06-18 01:03:11 +02:00
|
|
|
static HRESULT test_secondary(LPGUID lpGuid)
|
2003-09-02 01:59:03 +02:00
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND dso=NULL;
|
2004-06-18 01:03:11 +02:00
|
|
|
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
|
2003-09-02 01:59:03 +02:00
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
DSCAPS dscaps;
|
2005-02-10 21:26:20 +01:00
|
|
|
WAVEFORMATEX wfx, wfx1;
|
2011-01-20 16:41:11 +01:00
|
|
|
DWORD f, tag;
|
2004-08-09 20:52:18 +02:00
|
|
|
int ref;
|
2003-09-02 01:59:03 +02:00
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(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
|
|
|
"DirectSoundCreate() failed: %08x\n",rc);
|
2003-09-02 01:59:03 +02:00
|
|
|
if (rc!=DS_OK)
|
2004-06-18 01:03:11 +02:00
|
|
|
return rc;
|
2003-09-02 01:59:03 +02:00
|
|
|
|
|
|
|
/* Get the device capabilities */
|
|
|
|
ZeroMemory(&dscaps, sizeof(dscaps));
|
|
|
|
dscaps.dwSize=sizeof(dscaps);
|
|
|
|
rc=IDirectSound_GetCaps(dso,&dscaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %08x\n",rc);
|
2003-09-02 01:59:03 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
2003-01-03 00:08:57 +01:00
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
/* We must call SetCooperativeLevel before creating primary buffer */
|
2003-09-02 01:59:03 +02:00
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
|
2003-09-02 01:59:03 +02:00
|
|
|
if (rc!=DS_OK)
|
2004-06-18 01:03:11 +02:00
|
|
|
goto EXIT;
|
2003-09-15 22:08:26 +02:00
|
|
|
|
2003-06-28 00:22:15 +02:00
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
2003-05-22 05:39:32 +02:00
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
2003-06-28 00:22:15 +02:00
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
2004-07-30 20:42:51 +02:00
|
|
|
ok(rc==DS_OK && primary!=NULL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create a primary buffer %08x\n",rc);
|
2004-06-18 01:03:11 +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:11 +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]);
|
2004-06-18 01:03:11 +02:00
|
|
|
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=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_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-06-18 01:03:11 +02:00
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
2007-11-05 23:23:28 +01:00
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2011-01-20 16:41:11 +01:00
|
|
|
if (gotdx8 || wfx.wBitsPerSample <= 16 || wfx.wFormatTag == WAVE_FORMAT_IEEE_FLOAT)
|
2008-04-23 02:12:28 +02:00
|
|
|
{
|
|
|
|
if (wfx.wBitsPerSample > 16)
|
2012-09-17 22:44:06 +02:00
|
|
|
ok(broken((rc == DSERR_CONTROLUNAVAIL || rc == DSERR_INVALIDCALL || rc == DSERR_INVALIDPARAM /* 2003 */) && !secondary)
|
2008-09-09 20:44:46 +02:00
|
|
|
|| 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);
|
2008-04-23 02:12:28 +02:00
|
|
|
else
|
2010-09-30 11:31:11 +02:00
|
|
|
ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create a secondary buffer %08x\n",rc);
|
2008-04-23 02:12:28 +02:00
|
|
|
}
|
2007-11-05 23:23:28 +01:00
|
|
|
else
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==E_INVALIDARG, "Creating %d bpp buffer on dx < 8 returned: %p %08x\n",
|
|
|
|
wfx.wBitsPerSample, secondary, rc);
|
2008-04-23 02:12:28 +02:00
|
|
|
|
|
|
|
if (!gotdx8)
|
|
|
|
{
|
2011-02-25 23:32:26 +01:00
|
|
|
win_skip("Not doing the WAVE_FORMAT_EXTENSIBLE tests\n");
|
2008-04-23 02:12:28 +02:00
|
|
|
/* Apparently they succeed with bogus values,
|
|
|
|
* which means that older dsound doesn't look at them
|
|
|
|
*/
|
|
|
|
goto no_wfe;
|
|
|
|
}
|
|
|
|
|
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:11 +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);
|
|
|
|
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2008-09-09 20:44:46 +02:00
|
|
|
ok((rc==DSERR_INVALIDPARAM || rc==DSERR_INVALIDCALL /* 2003 */) && !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;
|
|
|
|
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2008-09-19 07:26:57 +02:00
|
|
|
ok(((rc==DSERR_CONTROLUNAVAIL || rc==DSERR_INVALIDCALL || rc==DSERR_INVALIDPARAM)
|
|
|
|
&& !secondary)
|
|
|
|
|| rc==DS_OK, /* 2003 / 2008 */
|
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;
|
|
|
|
rc=IDirectSound_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;
|
|
|
|
}
|
2011-01-20 16:41:11 +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.Samples.wValidBitsPerSample;
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
|
|
|
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;
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
|
|
|
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;
|
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2004-07-30 20:42:51 +02:00
|
|
|
ok(rc==DS_OK && secondary!=NULL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create a secondary buffer %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2008-04-23 02:12:28 +02:00
|
|
|
no_wfe:
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc==DS_OK && secondary!=NULL) {
|
2007-11-05 23:23:28 +01:00
|
|
|
if (winetest_interactive) {
|
2011-01-20 16:41:11 +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:11 +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);
|
|
|
|
}
|
2006-01-06 12:16:41 +01:00
|
|
|
test_buffer(dso,&secondary,0,FALSE,0,FALSE,0,
|
2005-02-25 20:17:11 +01:00
|
|
|
winetest_interactive,1.0,0,NULL,0,0,FALSE,0);
|
2004-06-18 01:03:11 +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);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
2011-01-20 16:41:11 +01:00
|
|
|
}
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
2005-02-10 21:26:20 +01:00
|
|
|
EXIT1:
|
2004-06-18 01:03:11 +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);
|
2003-05-22 05:39:32 +02:00
|
|
|
}
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2003-09-02 01:59:03 +02:00
|
|
|
/* Set the CooperativeLevel back to normal */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2003-09-02 01:59:03 +02:00
|
|
|
EXIT:
|
|
|
|
ref=IDirectSound_Release(dso);
|
2004-08-13 21:44:29 +02:00
|
|
|
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
|
2003-09-02 01:59:03 +02:00
|
|
|
if (ref!=0)
|
2004-06-18 01:03:11 +02:00
|
|
|
return DSERR_GENERIC;
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2003-09-02 01:59:03 +02:00
|
|
|
return rc;
|
|
|
|
}
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2005-02-16 17:09:02 +01:00
|
|
|
static HRESULT test_block_align(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND dso=NULL;
|
|
|
|
LPDIRECTSOUNDBUFFER secondary=NULL;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
DSBCAPS dsbcaps;
|
|
|
|
WAVEFORMATEX wfx;
|
2007-05-24 20:42:14 +02:00
|
|
|
DWORD pos, pos2;
|
2005-02-16 17:09:02 +01:00
|
|
|
int ref;
|
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
|
2005-02-16 17:09:02 +01:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCreate() failed: %08x\n",rc);
|
2005-02-16 17:09:02 +01:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
init_format(&wfx,WAVE_FORMAT_PCM,11025,16,2);
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
|
|
|
|
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec + 1;
|
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2010-09-30 11:31:11 +02:00
|
|
|
ok(rc == DS_OK || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */
|
|
|
|
"IDirectSound_CreateSoundBuffer() should have returned DS_OK, returned: %08x\n", rc);
|
2005-02-16 17:09:02 +01:00
|
|
|
|
|
|
|
if (rc==DS_OK && secondary!=NULL) {
|
2005-02-18 13:51:43 +01:00
|
|
|
ZeroMemory(&dsbcaps, sizeof(dsbcaps));
|
|
|
|
dsbcaps.dwSize = sizeof(dsbcaps);
|
2005-02-16 17:09:02 +01:00
|
|
|
rc=IDirectSoundBuffer_GetCaps(secondary,&dsbcaps);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() should have returned DS_OK, "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned: %08x\n", rc);
|
2007-05-24 20:42:14 +02:00
|
|
|
if (rc==DS_OK && wfx.nBlockAlign > 1)
|
|
|
|
{
|
2005-02-18 13:51:43 +01:00
|
|
|
ok(dsbcaps.dwBufferBytes==(wfx.nAvgBytesPerSec + wfx.nBlockAlign),
|
2006-10-10 01:07:36 +02:00
|
|
|
"Buffer size not a multiple of nBlockAlign: requested %d, "
|
|
|
|
"got %d, should be %d\n", bufdesc.dwBufferBytes,
|
2005-02-18 13:51:43 +01:00
|
|
|
dsbcaps.dwBufferBytes, wfx.nAvgBytesPerSec + wfx.nBlockAlign);
|
2007-05-24 20:42:14 +02:00
|
|
|
|
|
|
|
rc = IDirectSoundBuffer_SetCurrentPosition(secondary, 0);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc == DS_OK, "Could not set position to 0: %08x\n", rc);
|
2007-05-24 20:42:14 +02:00
|
|
|
rc = IDirectSoundBuffer_GetCurrentPosition(secondary, &pos, NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc == DS_OK, "Could not get position: %08x\n", rc);
|
2007-05-24 20:42:14 +02:00
|
|
|
rc = IDirectSoundBuffer_SetCurrentPosition(secondary, 1);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc == DS_OK, "Could not set position to 1: %08x\n", rc);
|
2007-05-24 20:42:14 +02:00
|
|
|
rc = IDirectSoundBuffer_GetCurrentPosition(secondary, &pos2, NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc == DS_OK, "Could not get new position: %08x\n", rc);
|
2007-05-24 20:42:14 +02:00
|
|
|
ok(pos == pos2, "Positions not the same! Old position: %d, new position: %d\n", pos, pos2);
|
|
|
|
}
|
2005-02-16 17:09:02 +01:00
|
|
|
ref=IDirectSoundBuffer_Release(secondary);
|
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d references, "
|
|
|
|
"should have 0\n",ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
ref=IDirectSound_Release(dso);
|
|
|
|
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
|
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-02-25 20:17:11 +01:00
|
|
|
static struct fmt {
|
|
|
|
int bits;
|
|
|
|
int channels;
|
|
|
|
} fmts[] = { { 8, 1 }, { 8, 2 }, { 16, 1 }, {16, 2 } };
|
|
|
|
|
|
|
|
static HRESULT test_frequency(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND dso=NULL;
|
|
|
|
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
DSCAPS dscaps;
|
|
|
|
WAVEFORMATEX wfx, wfx1;
|
|
|
|
DWORD f, r;
|
|
|
|
int ref;
|
|
|
|
int rates[] = { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100,
|
|
|
|
48000, 96000 };
|
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
|
2005-02-25 20:17:11 +01:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCreate() failed: %08x\n",rc);
|
2005-02-25 20:17:11 +01:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* Get the device capabilities */
|
|
|
|
ZeroMemory(&dscaps, sizeof(dscaps));
|
|
|
|
dscaps.dwSize=sizeof(dscaps);
|
|
|
|
rc=IDirectSound_GetCaps(dso,&dscaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %08x\n",rc);
|
2005-02-25 20:17:11 +01:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
|
|
|
|
/* We must call SetCooperativeLevel before creating primary buffer */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
|
2005-02-25 20:17:11 +01:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
|
|
|
ok(rc==DS_OK && primary!=NULL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create a primary buffer %08x\n",rc);
|
2005-02-25 20:17:11 +01:00
|
|
|
|
|
|
|
if (rc==DS_OK && primary!=NULL) {
|
|
|
|
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-25 20:17:11 +01:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT1;
|
|
|
|
|
2018-06-13 20:30:24 +02:00
|
|
|
for (f = 0; f < ARRAY_SIZE(fmts); f++) {
|
|
|
|
for (r = 0; r < ARRAY_SIZE(rates); r++) {
|
2005-02-25 20:17:11 +01:00
|
|
|
init_format(&wfx,WAVE_FORMAT_PCM,11025,fmts[f].bits,
|
|
|
|
fmts[f].channels);
|
|
|
|
secondary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_CTRLFREQUENCY;
|
|
|
|
bufdesc.dwBufferBytes=align((wfx.nAvgBytesPerSec*rates[r]/11025)*
|
|
|
|
BUFFER_LEN/1000,wfx.nBlockAlign);
|
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
|
|
|
if (winetest_interactive) {
|
2006-10-10 01:07:36 +02:00
|
|
|
trace(" Testing a secondary buffer at %dx%dx%d "
|
|
|
|
"with a primary buffer at %dx%dx%d\n",
|
2005-02-25 20:17:11 +01:00
|
|
|
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
|
|
|
|
wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
|
|
|
|
}
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2010-09-30 11:31:11 +02:00
|
|
|
ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create a secondary buffer %08x\n",rc);
|
2005-02-25 20:17:11 +01:00
|
|
|
|
|
|
|
if (rc==DS_OK && secondary!=NULL) {
|
2006-01-06 12:16:41 +01:00
|
|
|
test_buffer(dso,&secondary,0,FALSE,0,FALSE,0,
|
2005-02-25 20:17:11 +01:00
|
|
|
winetest_interactive,1.0,0,NULL,0,0,TRUE,rates[r]);
|
|
|
|
|
|
|
|
ref=IDirectSoundBuffer_Release(secondary);
|
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
|
|
|
|
"should have 0\n",ref);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXIT1:
|
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
|
|
|
"should have 0\n",ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the CooperativeLevel back to normal */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
|
2005-02-25 20:17:11 +01:00
|
|
|
|
|
|
|
EXIT:
|
|
|
|
ref=IDirectSound_Release(dso);
|
|
|
|
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
|
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-07-21 14:53:43 +02:00
|
|
|
static HRESULT test_notify(LPDIRECTSOUNDBUFFER dsb,
|
|
|
|
DWORD count, LPHANDLE event,
|
|
|
|
DWORD expected)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
2019-09-30 03:00:24 +02:00
|
|
|
DWORD ret, status;
|
2011-07-21 14:53:43 +02:00
|
|
|
|
|
|
|
rc=IDirectSoundBuffer_SetCurrentPosition(dsb,0);
|
|
|
|
ok(rc==DS_OK,
|
|
|
|
"IDirectSoundBuffer_SetCurrentPosition failed %08x\n",rc);
|
|
|
|
if(rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
rc=IDirectSoundBuffer_Play(dsb,0,0,0);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_Play failed %08x\n",rc);
|
|
|
|
if(rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
2019-09-30 03:00:24 +02:00
|
|
|
rc = IDirectSoundBuffer_GetStatus(dsb, &status);
|
|
|
|
ok(rc == DS_OK,"Failed %08x\n",rc);
|
|
|
|
ok(status == DSBSTATUS_PLAYING,"got %08x\n", status);
|
|
|
|
|
2011-07-21 14:53:43 +02:00
|
|
|
rc=IDirectSoundBuffer_Stop(dsb);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_Stop failed %08x\n",rc);
|
|
|
|
if(rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
2019-09-30 03:00:24 +02:00
|
|
|
rc = IDirectSoundBuffer_GetStatus(dsb, &status);
|
|
|
|
ok(rc == DS_OK,"Failed %08x\n",rc);
|
|
|
|
ok(status == 0 /* Stopped */,"got %08x\n", status);
|
|
|
|
|
2019-10-03 06:55:07 +02:00
|
|
|
ret = WaitForMultipleObjects(count, event, FALSE, 3000);
|
2011-07-21 14:53:48 +02:00
|
|
|
ok(ret==expected,"expected %d. got %d\n",expected,ret);
|
2019-09-30 03:00:24 +02:00
|
|
|
|
2011-07-21 14:53:43 +02:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT test_duplicate(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND dso=NULL;
|
|
|
|
LPDIRECTSOUNDBUFFER primary=NULL;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
int ref;
|
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
|
|
|
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
|
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
|
|
|
|
"DirectSoundCreate() failed: %08x\n",rc);
|
|
|
|
if (rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* We must call SetCooperativeLevel before creating primary buffer */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
|
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
|
|
|
ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() failed "
|
|
|
|
"to create a primary buffer %08x\n",rc);
|
|
|
|
|
|
|
|
if (rc==DS_OK && primary!=NULL) {
|
|
|
|
LPDIRECTSOUNDBUFFER original=NULL;
|
|
|
|
WAVEFORMATEX wfx;
|
|
|
|
|
|
|
|
init_format(&wfx,WAVE_FORMAT_PCM,22050,16,1);
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_CTRLPOSITIONNOTIFY;
|
|
|
|
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec/100; /* very short buffer */
|
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&original,NULL);
|
|
|
|
ok(rc==DS_OK && original!=NULL,
|
2013-12-03 14:25:04 +01:00
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create an original "
|
2011-07-21 14:53:43 +02:00
|
|
|
"buffer %08x\n",rc);
|
|
|
|
if (rc==DS_OK && original!=NULL) {
|
|
|
|
LPDIRECTSOUNDBUFFER duplicated=NULL;
|
|
|
|
LPDIRECTSOUNDNOTIFY notify=NULL;
|
|
|
|
HANDLE event[2];
|
|
|
|
LPVOID buf=NULL;
|
|
|
|
DWORD bufsize;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Prepare notify events */
|
2018-06-13 20:30:24 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(event); i++) {
|
2013-10-14 23:19:31 +02:00
|
|
|
event[i] = CreateEventW(NULL, FALSE, FALSE, NULL);
|
2011-07-21 14:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Make silent buffer */
|
|
|
|
rc=IDirectSoundBuffer_Lock(original,0,0,&buf,&bufsize,
|
|
|
|
NULL,NULL,DSBLOCK_ENTIREBUFFER);
|
|
|
|
ok(rc==DS_OK && buf!=NULL,
|
|
|
|
"IDirectSoundBuffer_Lock failed to lock the buffer %08x\n",rc);
|
|
|
|
if (rc==DS_OK && buf!=NULL) {
|
2020-03-06 13:52:44 +01:00
|
|
|
if (sizeof(void*)==4) { /* crashes on 64-bit */
|
|
|
|
/* broken apps like Asuka 120% Return BURNING Fest,
|
|
|
|
pass the pointer to GlobalHandle. */
|
|
|
|
HGLOBAL hmem = GlobalHandle(buf);
|
2020-03-06 13:52:46 +01:00
|
|
|
ok(!hmem,"GlobalHandle should return NULL "
|
2020-03-06 13:52:44 +01:00
|
|
|
"for buffer %p, got %p\n",buf,hmem);
|
|
|
|
}
|
2011-07-21 14:53:43 +02:00
|
|
|
ZeroMemory(buf,bufsize);
|
|
|
|
rc=IDirectSoundBuffer_Unlock(original,buf,bufsize,
|
|
|
|
NULL,0);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_Unlock failed to unlock "
|
|
|
|
"%08x\n",rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
rc=IDirectSoundBuffer_QueryInterface(original,
|
|
|
|
&IID_IDirectSoundNotify,
|
|
|
|
(void**)¬ify);
|
|
|
|
ok(rc==DS_OK && notify!=NULL,
|
|
|
|
"IDirectSoundBuffer_QueryInterface() failed to create a "
|
|
|
|
"notification %08x\n",rc);
|
|
|
|
if (rc==DS_OK && notify!=NULL) {
|
|
|
|
DSBPOSITIONNOTIFY dsbpn;
|
|
|
|
LPDIRECTSOUNDNOTIFY dup_notify=NULL;
|
|
|
|
|
|
|
|
dsbpn.dwOffset=DSBPN_OFFSETSTOP;
|
|
|
|
dsbpn.hEventNotify=event[0];
|
|
|
|
rc=IDirectSoundNotify_SetNotificationPositions(notify,
|
|
|
|
1,&dsbpn);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundNotify_SetNotificationPositions "
|
|
|
|
"failed %08x\n",rc);
|
|
|
|
|
|
|
|
rc=IDirectSound_DuplicateSoundBuffer(dso,original,&duplicated);
|
|
|
|
ok(rc==DS_OK && duplicated!=NULL,
|
|
|
|
"IDirectSound_DuplicateSoundBuffer failed %08x\n",rc);
|
|
|
|
|
|
|
|
trace("testing duplicated buffer without notifications.\n");
|
2018-06-13 20:30:24 +02:00
|
|
|
test_notify(duplicated, ARRAY_SIZE(event), event, WAIT_TIMEOUT);
|
2011-07-21 14:53:43 +02:00
|
|
|
|
|
|
|
rc=IDirectSoundBuffer_QueryInterface(duplicated,
|
|
|
|
&IID_IDirectSoundNotify,
|
|
|
|
(void**)&dup_notify);
|
|
|
|
ok(rc==DS_OK&&dup_notify!=NULL,
|
|
|
|
"IDirectSoundBuffer_QueryInterface() failed to create a "
|
|
|
|
"notification %08x\n",rc);
|
|
|
|
if(rc==DS_OK&&dup_notify!=NULL) {
|
|
|
|
dsbpn.dwOffset=DSBPN_OFFSETSTOP;
|
|
|
|
dsbpn.hEventNotify=event[1];
|
|
|
|
rc=IDirectSoundNotify_SetNotificationPositions(dup_notify,
|
|
|
|
1,&dsbpn);
|
|
|
|
ok(rc==DS_OK,"IDirectSoundNotify_SetNotificationPositions "
|
|
|
|
"failed %08x\n",rc);
|
|
|
|
|
|
|
|
trace("testing duplicated buffer with a notification.\n");
|
2018-06-13 20:30:24 +02:00
|
|
|
test_notify(duplicated, ARRAY_SIZE(event), event, WAIT_OBJECT_0 + 1);
|
2011-07-21 14:53:43 +02:00
|
|
|
|
|
|
|
ref=IDirectSoundNotify_Release(dup_notify);
|
|
|
|
ok(ref==0,"IDirectSoundNotify_Release() has %d references, "
|
|
|
|
"should have 0\n",ref);
|
|
|
|
}
|
|
|
|
ref=IDirectSoundNotify_Release(notify);
|
|
|
|
ok(ref==0,"IDirectSoundNotify_Release() has %d references, "
|
|
|
|
"should have 0\n",ref);
|
|
|
|
|
|
|
|
trace("testing original buffer with a notification.\n");
|
2018-06-13 20:30:24 +02:00
|
|
|
test_notify(original, ARRAY_SIZE(event), event, WAIT_OBJECT_0);
|
2011-07-21 14:53:43 +02:00
|
|
|
|
|
|
|
ref=IDirectSoundBuffer_Release(duplicated);
|
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
|
|
|
|
"should have 0\n",ref);
|
|
|
|
}
|
|
|
|
ref=IDirectSoundBuffer_Release(original);
|
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
|
|
|
|
"should have 0\n",ref);
|
|
|
|
}
|
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
|
|
|
|
"should have 0\n",ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the CooperativeLevel back to normal */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
|
|
|
|
|
|
|
|
EXIT:
|
|
|
|
ref=IDirectSound_Release(dso);
|
|
|
|
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
|
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2015-04-13 18:25:23 +02:00
|
|
|
static HRESULT do_invalid_fmt_test(IDirectSound *dso,
|
|
|
|
IDirectSoundBuffer *buf, WAVEFORMATEX *wfx, IDirectSoundBuffer **out_buf)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
*out_buf = NULL;
|
|
|
|
if(!buf){
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize = sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags = DSBCAPS_CTRLPOSITIONNOTIFY;
|
|
|
|
bufdesc.dwBufferBytes = 4096;
|
|
|
|
bufdesc.lpwfxFormat = wfx;
|
|
|
|
rc = IDirectSound_CreateSoundBuffer(dso, &bufdesc, out_buf, NULL);
|
|
|
|
}else{
|
|
|
|
rc = IDirectSoundBuffer_SetFormat(buf, wfx);
|
|
|
|
if(SUCCEEDED(rc)){
|
|
|
|
IDirectSoundBuffer_AddRef(buf);
|
|
|
|
*out_buf = buf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if no buffer is given, use CreateSoundBuffer instead of SetFormat */
|
|
|
|
static void perform_invalid_fmt_tests(const char *testname, IDirectSound *dso, IDirectSoundBuffer *buf)
|
|
|
|
{
|
|
|
|
WAVEFORMATEX wfx;
|
|
|
|
WAVEFORMATEXTENSIBLE fmtex;
|
|
|
|
HRESULT rc;
|
|
|
|
IDirectSoundBuffer *got_buf;
|
|
|
|
|
|
|
|
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
|
|
|
wfx.nChannels = 0;
|
|
|
|
wfx.nSamplesPerSec = 44100;
|
|
|
|
wfx.wBitsPerSample = 16;
|
|
|
|
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
|
|
|
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, &wfx, &got_buf);
|
|
|
|
ok(rc == E_INVALIDARG, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
wfx.nChannels = 2;
|
|
|
|
wfx.nSamplesPerSec = 44100;
|
|
|
|
wfx.wBitsPerSample = 0;
|
|
|
|
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
|
|
|
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, &wfx, &got_buf);
|
|
|
|
ok(rc == E_INVALIDARG, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
wfx.nChannels = 2;
|
|
|
|
wfx.nSamplesPerSec = 44100;
|
|
|
|
wfx.wBitsPerSample = 2;
|
|
|
|
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
|
|
|
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, &wfx, &got_buf);
|
|
|
|
ok(rc == E_INVALIDARG, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
wfx.nChannels = 2;
|
|
|
|
wfx.nSamplesPerSec = 44100;
|
|
|
|
wfx.wBitsPerSample = 12;
|
|
|
|
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
|
|
|
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, &wfx, &got_buf);
|
|
|
|
ok(rc == E_INVALIDARG, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
wfx.nChannels = 2;
|
|
|
|
wfx.nSamplesPerSec = 0;
|
|
|
|
wfx.wBitsPerSample = 16;
|
|
|
|
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
|
|
|
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, &wfx, &got_buf);
|
|
|
|
ok(rc == E_INVALIDARG, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
wfx.nChannels = 2;
|
|
|
|
wfx.nSamplesPerSec = 44100;
|
|
|
|
wfx.wBitsPerSample = 16;
|
|
|
|
wfx.nBlockAlign = 0;
|
|
|
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, &wfx, &got_buf);
|
|
|
|
ok(rc == E_INVALIDARG, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
wfx.nChannels = 2;
|
|
|
|
wfx.nSamplesPerSec = 44100;
|
|
|
|
wfx.wBitsPerSample = 16;
|
|
|
|
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
|
|
|
|
wfx.nAvgBytesPerSec = 0;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, &wfx, &got_buf);
|
|
|
|
ok(rc == E_INVALIDARG, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
wfx.nChannels = 2;
|
|
|
|
wfx.nSamplesPerSec = 44100;
|
|
|
|
wfx.wBitsPerSample = 16;
|
|
|
|
wfx.nBlockAlign = (wfx.nChannels * wfx.wBitsPerSample / 8) - 1;
|
|
|
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, &wfx, &got_buf);
|
|
|
|
ok(rc == E_INVALIDARG, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
wfx.nChannels = 2;
|
|
|
|
wfx.nSamplesPerSec = 44100;
|
|
|
|
wfx.wBitsPerSample = 16;
|
|
|
|
wfx.nBlockAlign = (wfx.nChannels * wfx.wBitsPerSample / 8) + 1;
|
|
|
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, &wfx, &got_buf);
|
|
|
|
ok(rc == E_INVALIDARG, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
wfx.nChannels = 2;
|
|
|
|
wfx.nSamplesPerSec = 44100;
|
|
|
|
wfx.wBitsPerSample = 16;
|
|
|
|
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
|
|
|
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign + 1;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, &wfx, &got_buf);
|
|
|
|
ok(rc == S_OK, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer_GetFormat(got_buf, &wfx, sizeof(wfx), NULL);
|
|
|
|
ok(rc == S_OK, "%s: GetFormat: %08x\n", testname, rc);
|
|
|
|
ok(wfx.wFormatTag == WAVE_FORMAT_PCM, "%s: format: 0x%x\n", testname, wfx.wFormatTag);
|
|
|
|
ok(wfx.nChannels == 2, "%s: channels: %u\n", testname, wfx.nChannels);
|
|
|
|
ok(wfx.nSamplesPerSec == 44100, "%s: rate: %u\n", testname, wfx.nSamplesPerSec);
|
|
|
|
ok(wfx.wBitsPerSample == 16, "%s: bps: %u\n", testname, wfx.wBitsPerSample);
|
|
|
|
ok(wfx.nBlockAlign == 4, "%s: blockalign: %u\n", testname, wfx.nBlockAlign);
|
|
|
|
ok(wfx.nAvgBytesPerSec == 44100 * 4 + 1, "%s: avgbytes: %u\n", testname, wfx.nAvgBytesPerSec);
|
|
|
|
IDirectSoundBuffer_Release(got_buf);
|
|
|
|
|
|
|
|
wfx.nChannels = 2;
|
|
|
|
wfx.nSamplesPerSec = 44100;
|
|
|
|
wfx.wBitsPerSample = 16;
|
|
|
|
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
|
|
|
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign - 1;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, &wfx, &got_buf);
|
|
|
|
ok(rc == S_OK, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer_GetFormat(got_buf, &wfx, sizeof(wfx), NULL);
|
|
|
|
ok(rc == S_OK, "%s: GetFormat: %08x\n", testname, rc);
|
|
|
|
ok(wfx.wFormatTag == WAVE_FORMAT_PCM, "%s: format: 0x%x\n", testname, wfx.wFormatTag);
|
|
|
|
ok(wfx.nChannels == 2, "%s: channels: %u\n", testname, wfx.nChannels);
|
|
|
|
ok(wfx.nSamplesPerSec == 44100, "%s: rate: %u\n", testname, wfx.nSamplesPerSec);
|
|
|
|
ok(wfx.wBitsPerSample == 16, "%s: bps: %u\n", testname, wfx.wBitsPerSample);
|
|
|
|
ok(wfx.nBlockAlign == 4, "%s: blockalign: %u\n", testname, wfx.nBlockAlign);
|
|
|
|
ok(wfx.nAvgBytesPerSec == 44100 * 4 - 1, "%s: avgbytes: %u\n", testname, wfx.nAvgBytesPerSec);
|
|
|
|
IDirectSoundBuffer_Release(got_buf);
|
|
|
|
|
|
|
|
wfx.nChannels = 2;
|
|
|
|
wfx.nSamplesPerSec = 44100;
|
|
|
|
wfx.wBitsPerSample = 16;
|
|
|
|
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
|
|
|
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign + 1;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, &wfx, &got_buf);
|
|
|
|
ok(rc == S_OK, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer_GetFormat(got_buf, &wfx, sizeof(wfx), NULL);
|
|
|
|
ok(rc == S_OK, "%s: GetFormat: %08x\n", testname, rc);
|
|
|
|
ok(wfx.wFormatTag == WAVE_FORMAT_PCM, "%s: format: 0x%x\n", testname, wfx.wFormatTag);
|
|
|
|
ok(wfx.nChannels == 2, "%s: channels: %u\n", testname, wfx.nChannels);
|
|
|
|
ok(wfx.nSamplesPerSec == 44100, "%s: rate: %u\n", testname, wfx.nSamplesPerSec);
|
|
|
|
ok(wfx.wBitsPerSample == 16, "%s: bps: %u\n", testname, wfx.wBitsPerSample);
|
|
|
|
ok(wfx.nBlockAlign == 4, "%s: blockalign: %u\n", testname, wfx.nBlockAlign);
|
|
|
|
ok(wfx.nAvgBytesPerSec == 44100 * 4 + 1, "%s: avgbytes: %u\n", testname, wfx.nAvgBytesPerSec);
|
|
|
|
IDirectSoundBuffer_Release(got_buf);
|
|
|
|
|
2015-04-14 21:10:49 +02:00
|
|
|
if(buf){
|
|
|
|
wfx.wFormatTag = WAVE_FORMAT_ALAW;
|
|
|
|
wfx.nChannels = 2;
|
|
|
|
wfx.nSamplesPerSec = 44100;
|
|
|
|
wfx.wBitsPerSample = 16;
|
|
|
|
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
|
|
|
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, &wfx, &got_buf);
|
|
|
|
ok(rc == S_OK, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
if(got_buf){
|
|
|
|
rc = IDirectSoundBuffer_GetFormat(got_buf, &wfx, sizeof(wfx), NULL);
|
|
|
|
ok(rc == S_OK, "%s: GetFormat: %08x\n", testname, rc);
|
|
|
|
ok(wfx.wFormatTag == WAVE_FORMAT_ALAW, "%s: format: 0x%x\n", testname, wfx.wFormatTag);
|
|
|
|
ok(wfx.nChannels == 2, "%s: channels: %u\n", testname, wfx.nChannels);
|
|
|
|
ok(wfx.nSamplesPerSec == 44100, "%s: rate: %u\n", testname, wfx.nSamplesPerSec);
|
|
|
|
ok(wfx.wBitsPerSample == 16, "%s: bps: %u\n", testname, wfx.wBitsPerSample);
|
|
|
|
ok(wfx.nBlockAlign == 4, "%s: blockalign: %u\n", testname, wfx.nBlockAlign);
|
|
|
|
ok(wfx.nAvgBytesPerSec == 44100 * 4, "%s: avgbytes: %u\n", testname, wfx.nAvgBytesPerSec);
|
|
|
|
IDirectSoundBuffer_Release(got_buf);
|
|
|
|
}
|
2015-04-13 18:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!gotdx8){
|
|
|
|
win_skip("Not doing the WAVE_FORMAT_EXTENSIBLE tests\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fmtex.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
|
|
|
|
fmtex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
|
|
|
|
fmtex.Format.nChannels = 2;
|
|
|
|
fmtex.Format.nSamplesPerSec = 44100;
|
|
|
|
fmtex.Format.wBitsPerSample = 16;
|
|
|
|
fmtex.Format.nBlockAlign = fmtex.Format.nChannels * fmtex.Format.wBitsPerSample / 8;
|
|
|
|
fmtex.Format.nAvgBytesPerSec = fmtex.Format.nSamplesPerSec * fmtex.Format.nBlockAlign;
|
|
|
|
fmtex.Samples.wValidBitsPerSample = 0;
|
|
|
|
fmtex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
|
|
|
|
fmtex.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, (WAVEFORMATEX*)&fmtex, &got_buf);
|
|
|
|
ok(rc == S_OK, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer_GetFormat(got_buf, (WAVEFORMATEX*)&fmtex, sizeof(fmtex), NULL);
|
|
|
|
ok(rc == S_OK, "%s: GetFormat: %08x\n", testname, rc);
|
|
|
|
ok(fmtex.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE, "%s: format: 0x%x\n", testname, fmtex.Format.wFormatTag);
|
|
|
|
ok(fmtex.Format.nChannels == 2, "%s: channels: %u\n", testname, fmtex.Format.nChannels);
|
|
|
|
ok(fmtex.Format.nSamplesPerSec == 44100, "%s: rate: %u\n", testname, fmtex.Format.nSamplesPerSec);
|
|
|
|
ok(fmtex.Format.wBitsPerSample == 16, "%s: bps: %u\n", testname, fmtex.Format.wBitsPerSample);
|
|
|
|
ok(fmtex.Format.nBlockAlign == 4, "%s: blockalign: %u\n", testname, fmtex.Format.nBlockAlign);
|
|
|
|
ok(fmtex.Format.nAvgBytesPerSec == 44100 * 4, "%s: avgbytes: %u\n", testname, fmtex.Format.nAvgBytesPerSec);
|
|
|
|
ok(fmtex.Samples.wValidBitsPerSample == 0 || /* <= XP */
|
|
|
|
fmtex.Samples.wValidBitsPerSample == 16, /* >= Vista */
|
|
|
|
"%s: validbits: %u\n", testname, fmtex.Samples.wValidBitsPerSample);
|
|
|
|
ok(IsEqualGUID(&fmtex.SubFormat, &KSDATAFORMAT_SUBTYPE_PCM), "%s: subtype incorrect\n", testname);
|
|
|
|
IDirectSoundBuffer_Release(got_buf);
|
|
|
|
|
|
|
|
fmtex.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
|
|
|
|
fmtex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
|
|
|
|
fmtex.Format.nChannels = 2;
|
|
|
|
fmtex.Format.nSamplesPerSec = 44100;
|
|
|
|
fmtex.Format.wBitsPerSample = 24;
|
|
|
|
fmtex.Format.nBlockAlign = fmtex.Format.nChannels * fmtex.Format.wBitsPerSample / 8;
|
|
|
|
fmtex.Format.nAvgBytesPerSec = fmtex.Format.nSamplesPerSec * fmtex.Format.nBlockAlign;
|
|
|
|
fmtex.Samples.wValidBitsPerSample = 20;
|
|
|
|
fmtex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
|
|
|
|
fmtex.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, (WAVEFORMATEX*)&fmtex, &got_buf);
|
|
|
|
ok(rc == S_OK, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer_GetFormat(got_buf, (WAVEFORMATEX*)&fmtex, sizeof(fmtex), NULL);
|
|
|
|
ok(rc == S_OK, "%s: GetFormat: %08x\n", testname, rc);
|
|
|
|
ok(fmtex.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE, "%s: format: 0x%x\n", testname, fmtex.Format.wFormatTag);
|
|
|
|
ok(fmtex.Format.nChannels == 2, "%s: channels: %u\n", testname, fmtex.Format.nChannels);
|
|
|
|
ok(fmtex.Format.nSamplesPerSec == 44100, "%s: rate: %u\n", testname, fmtex.Format.nSamplesPerSec);
|
|
|
|
ok(fmtex.Format.wBitsPerSample == 24, "%s: bps: %u\n", testname, fmtex.Format.wBitsPerSample);
|
|
|
|
ok(fmtex.Format.nBlockAlign == 6, "%s: blockalign: %u\n", testname, fmtex.Format.nBlockAlign);
|
|
|
|
ok(fmtex.Format.nAvgBytesPerSec == 44100 * 6, "%s: avgbytes: %u\n", testname, fmtex.Format.nAvgBytesPerSec);
|
|
|
|
ok(fmtex.Samples.wValidBitsPerSample == 20, "%s: validbits: %u\n", testname, fmtex.Samples.wValidBitsPerSample);
|
|
|
|
ok(IsEqualGUID(&fmtex.SubFormat, &KSDATAFORMAT_SUBTYPE_PCM), "%s: subtype incorrect\n", testname);
|
|
|
|
IDirectSoundBuffer_Release(got_buf);
|
|
|
|
|
|
|
|
fmtex.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
|
|
|
|
fmtex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
|
|
|
|
fmtex.Format.nChannels = 2;
|
|
|
|
fmtex.Format.nSamplesPerSec = 44100;
|
|
|
|
fmtex.Format.wBitsPerSample = 24;
|
|
|
|
fmtex.Format.nBlockAlign = fmtex.Format.nChannels * fmtex.Format.wBitsPerSample / 8;
|
|
|
|
fmtex.Format.nAvgBytesPerSec = fmtex.Format.nSamplesPerSec * fmtex.Format.nBlockAlign;
|
|
|
|
fmtex.Samples.wValidBitsPerSample = 32;
|
|
|
|
fmtex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
|
|
|
|
fmtex.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
|
|
|
|
rc = do_invalid_fmt_test(dso, buf, (WAVEFORMATEX*)&fmtex, &got_buf);
|
|
|
|
ok(rc == E_INVALIDARG, "%s: SetFormat: %08x\n", testname, rc);
|
|
|
|
}
|
|
|
|
|
2011-12-02 18:53:14 +01:00
|
|
|
static HRESULT test_invalid_fmts(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND dso=NULL;
|
2015-04-13 18:25:23 +02:00
|
|
|
LPDIRECTSOUNDBUFFER buffer=NULL;
|
2011-12-02 18:53:14 +01:00
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
|
|
|
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
|
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
|
|
|
|
"DirectSoundCreate() failed: %08x\n",rc);
|
|
|
|
if (rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* We must call SetCooperativeLevel before creating primary buffer */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
|
|
|
|
if (rc!=DS_OK){
|
|
|
|
IDirectSound_Release(dso);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
2015-04-13 18:25:23 +02:00
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&buffer,NULL);
|
|
|
|
ok(rc==DS_OK && buffer!=NULL,"IDirectSound_CreateSoundBuffer() failed "
|
2011-12-02 18:53:14 +01:00
|
|
|
"to create a primary buffer %08x\n",rc);
|
2015-04-13 18:25:23 +02:00
|
|
|
if (rc==DS_OK && buffer!=NULL) {
|
|
|
|
perform_invalid_fmt_tests("primary", dso, buffer);
|
|
|
|
IDirectSoundBuffer_Release(buffer);
|
2011-12-02 18:53:14 +01:00
|
|
|
}
|
|
|
|
|
2015-04-13 18:25:23 +02:00
|
|
|
perform_invalid_fmt_tests("secondary", dso, NULL);
|
|
|
|
|
2011-12-02 18:53:14 +01:00
|
|
|
IDirectSound_Release(dso);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-12-03 21:06:38 +01:00
|
|
|
static void test_notifications(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
IDirectSound *dso;
|
|
|
|
IDirectSoundBuffer *buf;
|
|
|
|
IDirectSoundNotify *buf_notif;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
WAVEFORMATEX wfx;
|
|
|
|
DSBPOSITIONNOTIFY notifies[2];
|
|
|
|
HANDLE handles[2];
|
2019-09-30 03:00:24 +02:00
|
|
|
DWORD expect, status;
|
2014-12-03 21:06:38 +01:00
|
|
|
int cycles;
|
|
|
|
|
|
|
|
rc = pDirectSoundCreate(lpGuid, &dso, NULL);
|
|
|
|
ok(rc == DS_OK || rc == DSERR_NODRIVER || rc == DSERR_ALLOCATED,
|
|
|
|
"DirectSoundCreate() failed: %08x\n", rc);
|
|
|
|
if(rc != DS_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
rc = IDirectSound_SetCooperativeLevel(dso, get_hwnd(), DSSCL_PRIORITY);
|
|
|
|
ok(rc == DS_OK, "IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
|
|
|
|
if(rc != DS_OK){
|
|
|
|
IDirectSound_Release(dso);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
|
|
|
wfx.nChannels = 1;
|
|
|
|
wfx.nSamplesPerSec = 44100;
|
|
|
|
wfx.wBitsPerSample = 16;
|
|
|
|
wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
|
|
|
|
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
|
|
|
wfx.cbSize = 0;
|
|
|
|
|
2019-02-13 02:56:16 +01:00
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize = sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2;
|
|
|
|
bufdesc.dwBufferBytes = wfx.nSamplesPerSec * wfx.nBlockAlign / 2; /* 0.5s */
|
|
|
|
bufdesc.lpwfxFormat = &wfx;
|
|
|
|
rc = IDirectSound_CreateSoundBuffer(dso, &bufdesc, &buf, NULL);
|
|
|
|
ok(rc == DS_OK && buf != NULL, "IDirectSound_CreateSoundBuffer() failed "
|
|
|
|
"to create a buffer %08x\n", rc);
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer_QueryInterface(buf, &IID_IDirectSoundNotify, (void**)&buf_notif);
|
|
|
|
ok(rc == E_NOINTERFACE, "QueryInterface(IID_IDirectSoundNotify): %08x\n", rc);
|
|
|
|
IDirectSoundBuffer_Release(buf);
|
|
|
|
|
2014-12-03 21:06:38 +01:00
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize = sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags = DSBCAPS_CTRLPOSITIONNOTIFY;
|
|
|
|
bufdesc.dwBufferBytes = wfx.nSamplesPerSec * wfx.nBlockAlign / 2; /* 0.5s */
|
|
|
|
bufdesc.lpwfxFormat = &wfx;
|
|
|
|
rc = IDirectSound_CreateSoundBuffer(dso, &bufdesc, &buf, NULL);
|
|
|
|
ok(rc == DS_OK && buf != NULL, "IDirectSound_CreateSoundBuffer() failed "
|
|
|
|
"to create a buffer %08x\n", rc);
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer_QueryInterface(buf, &IID_IDirectSoundNotify, (void**)&buf_notif);
|
|
|
|
ok(rc == DS_OK, "QueryInterface(IID_IDirectSoundNotify): %08x\n", rc);
|
|
|
|
|
|
|
|
notifies[0].dwOffset = 0;
|
|
|
|
handles[0] = notifies[0].hEventNotify = CreateEventW(NULL, FALSE, FALSE, NULL);
|
2014-12-19 16:10:46 +01:00
|
|
|
notifies[1].dwOffset = bufdesc.dwBufferBytes / 2;
|
2014-12-03 21:06:38 +01:00
|
|
|
handles[1] = notifies[1].hEventNotify = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
|
|
|
|
rc = IDirectSoundNotify_SetNotificationPositions(buf_notif, 2, notifies);
|
|
|
|
ok(rc == DS_OK, "SetNotificationPositions: %08x\n", rc);
|
|
|
|
|
|
|
|
IDirectSoundNotify_Release(buf_notif);
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer_Play(buf, 0, 0, DSBPLAY_LOOPING);
|
|
|
|
ok(rc == DS_OK, "Play: %08x\n", rc);
|
|
|
|
|
|
|
|
expect = 0;
|
|
|
|
for(cycles = 0; cycles < 6 /* 1.5s */; ++cycles){
|
|
|
|
DWORD wait;
|
|
|
|
|
|
|
|
wait = WaitForMultipleObjects(2, handles, FALSE, 1000);
|
|
|
|
ok(wait <= WAIT_OBJECT_0 + 1 && wait - WAIT_OBJECT_0 == expect,
|
|
|
|
"Got unexpected notification order or timeout: %u\n", wait);
|
|
|
|
|
2019-09-30 03:00:24 +02:00
|
|
|
rc = IDirectSoundBuffer_GetStatus(buf, &status);
|
|
|
|
ok(rc == DS_OK,"Failed %08x\n",rc);
|
|
|
|
ok(status == (DSBSTATUS_PLAYING | DSBSTATUS_LOOPING),"got %08x\n", status);
|
|
|
|
|
2014-12-03 21:06:38 +01:00
|
|
|
expect = !expect;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = IDirectSoundBuffer_Stop(buf);
|
|
|
|
ok(rc == DS_OK, "Stop: %08x\n", rc);
|
|
|
|
|
2019-09-30 03:00:24 +02:00
|
|
|
rc = IDirectSoundBuffer_GetStatus(buf, &status);
|
|
|
|
ok(rc == DS_OK,"Failed %08x\n",rc);
|
|
|
|
ok(status == 0,"got %08x\n", status);
|
|
|
|
|
2014-12-03 21:06:38 +01:00
|
|
|
CloseHandle(notifies[0].hEventNotify);
|
|
|
|
CloseHandle(notifies[1].hEventNotify);
|
|
|
|
|
|
|
|
IDirectSoundBuffer_Release(buf);
|
|
|
|
IDirectSound_Release(dso);
|
|
|
|
}
|
|
|
|
|
2008-04-20 07:01:36 +02:00
|
|
|
static unsigned int number;
|
|
|
|
|
2003-09-02 01:59:03 +02:00
|
|
|
static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
|
2004-06-18 01:03:11 +02:00
|
|
|
LPCSTR lpcstrModule, LPVOID lpContext)
|
2003-09-02 01:59:03 +02:00
|
|
|
{
|
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);
|
2008-04-20 07:01:36 +02:00
|
|
|
|
|
|
|
/* Don't test the primary device */
|
|
|
|
if (!number++)
|
|
|
|
{
|
|
|
|
ok (!lpcstrModule[0], "lpcstrModule(%s) != NULL\n", lpcstrModule);
|
2013-11-12 22:11:12 +01:00
|
|
|
return TRUE;
|
2008-04-20 07:01:36 +02:00
|
|
|
}
|
|
|
|
|
2004-10-19 23:10:41 +02:00
|
|
|
rc = test_dsound(lpGuid);
|
|
|
|
if (rc == DSERR_NODRIVER)
|
2004-10-21 21:51:10 +02:00
|
|
|
trace(" No Driver\n");
|
|
|
|
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 {
|
2005-02-16 17:09:02 +01:00
|
|
|
test_block_align(lpGuid);
|
2004-10-19 23:10:41 +02:00
|
|
|
test_primary(lpGuid);
|
|
|
|
test_primary_secondary(lpGuid);
|
|
|
|
test_secondary(lpGuid);
|
2005-02-25 20:17:11 +01:00
|
|
|
test_frequency(lpGuid);
|
2011-07-21 14:53:43 +02:00
|
|
|
test_duplicate(lpGuid);
|
2011-12-02 18:53:14 +01:00
|
|
|
test_invalid_fmts(lpGuid);
|
2014-12-03 21:06:38 +01:00
|
|
|
test_notifications(lpGuid);
|
2004-10-19 23:10:41 +02:00
|
|
|
}
|
2003-06-28 00:22:15 +02:00
|
|
|
|
2013-11-12 22:11:12 +01:00
|
|
|
return TRUE;
|
2002-12-05 20:19:41 +01:00
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void dsound_tests(void)
|
2002-12-05 20:19:41 +01:00
|
|
|
{
|
|
|
|
HRESULT rc;
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc);
|
2002-12-05 20:19:41 +01:00
|
|
|
}
|
|
|
|
|
2011-10-19 22:07:18 +02:00
|
|
|
static void test_hw_buffers(void)
|
|
|
|
{
|
|
|
|
IDirectSound *ds;
|
|
|
|
IDirectSoundBuffer *primary, *primary2, **secondaries, *secondary;
|
|
|
|
IDirectSoundBuffer8 *buf8;
|
|
|
|
DSCAPS caps;
|
|
|
|
DSBCAPS bufcaps;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
WAVEFORMATEX fmt;
|
|
|
|
UINT i;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = pDirectSoundCreate(NULL, &ds, NULL);
|
|
|
|
ok(hr == S_OK || hr == DSERR_NODRIVER || hr == DSERR_ALLOCATED || hr == E_FAIL,
|
|
|
|
"DirectSoundCreate failed: %08x\n", hr);
|
|
|
|
if(hr != S_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
caps.dwSize = sizeof(caps);
|
|
|
|
|
|
|
|
hr = IDirectSound_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 = IDirectSound_CreateSoundBuffer(ds, &bufdesc, &primary, NULL);
|
|
|
|
ok(hr == S_OK, "CreateSoundBuffer failed: %08x\n", hr);
|
|
|
|
if(hr != S_OK){
|
|
|
|
IDirectSound_Release(ds);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCSOFTWARE |
|
|
|
|
DSBCAPS_PRIMARYBUFFER;
|
|
|
|
|
|
|
|
hr = IDirectSound_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 = IDirectSound_CreateSoundBuffer(ds, &bufdesc, &secondaries[i], NULL);
|
2012-10-14 23:39:46 +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 = IDirectSound_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:39:46 +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:39:46 +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);
|
|
|
|
IDirectSound_Release(ds);
|
|
|
|
}
|
|
|
|
|
2002-12-05 20:19:41 +01:00
|
|
|
START_TEST(dsound)
|
|
|
|
{
|
2007-01-15 15:00:39 +01:00
|
|
|
HMODULE hDsound;
|
|
|
|
|
2004-07-12 21:45:28 +02:00
|
|
|
CoInitialize(NULL);
|
|
|
|
|
2013-10-01 23:09:53 +02:00
|
|
|
hDsound = LoadLibraryA("dsound.dll");
|
2007-08-30 14:50:32 +02:00
|
|
|
if (hDsound)
|
|
|
|
{
|
2008-09-21 18:59:34 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2010-12-29 19:41:17 +01:00
|
|
|
ret = FreeLibrary(hDsound);
|
|
|
|
ok( ret, "FreeLibrary(1) returned %d\n", GetLastError());
|
2007-08-30 14:50:32 +02:00
|
|
|
}
|
|
|
|
|
2013-10-01 23:09:53 +02:00
|
|
|
hDsound = LoadLibraryA("dsound.dll");
|
2007-01-15 15:00:39 +01:00
|
|
|
if (hDsound)
|
|
|
|
{
|
|
|
|
|
|
|
|
pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
|
|
|
|
"DirectSoundEnumerateA");
|
|
|
|
pDirectSoundCreate = (void*)GetProcAddress(hDsound,
|
|
|
|
"DirectSoundCreate");
|
2005-03-05 11:49:08 +01:00
|
|
|
|
2008-04-23 02:12:28 +02:00
|
|
|
gotdx8 = !!GetProcAddress(hDsound, "DirectSoundCreate8");
|
|
|
|
|
2007-01-15 15:00:39 +01:00
|
|
|
IDirectSound_tests();
|
|
|
|
dsound_tests();
|
2011-10-19 22:07:18 +02:00
|
|
|
test_hw_buffers();
|
2007-01-15 15:00:39 +01:00
|
|
|
|
|
|
|
FreeLibrary(hDsound);
|
|
|
|
}
|
|
|
|
else
|
2012-08-13 00:15:33 +02:00
|
|
|
win_skip("dsound.dll not found - skipping all tests\n");
|
2005-01-09 17:34:00 +01:00
|
|
|
|
|
|
|
CoUninitialize();
|
2002-12-05 20:19:41 +01:00
|
|
|
}
|