mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
- add dsound winetest
svn path=/trunk/; revision=43918
This commit is contained in:
parent
7e3ee3137a
commit
12c4f5f3e4
10 changed files with 6336 additions and 0 deletions
709
rostests/winetests/dsound/capture.c
Normal file
709
rostests/winetests/dsound/capture.c
Normal file
|
@ -0,0 +1,709 @@
|
|||
/*
|
||||
* Unit tests for capture functions
|
||||
*
|
||||
* Copyright (c) 2002 Francois Gouget
|
||||
* Copyright (c) 2003 Robert Reif
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "initguid.h"
|
||||
#include "windows.h"
|
||||
#include "wine/test.h"
|
||||
#include "dsound.h"
|
||||
#include "mmreg.h"
|
||||
#include "dsconf.h"
|
||||
|
||||
#include "dsound_test.h"
|
||||
|
||||
#define NOTIFICATIONS 5
|
||||
|
||||
static HRESULT (WINAPI *pDirectSoundCaptureCreate)(LPCGUID,LPDIRECTSOUNDCAPTURE*,LPUNKNOWN)=NULL;
|
||||
static HRESULT (WINAPI *pDirectSoundCaptureEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
|
||||
|
||||
static const char * get_format_str(WORD format)
|
||||
{
|
||||
static char msg[32];
|
||||
#define WAVE_FORMAT(f) case f: return #f
|
||||
switch (format) {
|
||||
WAVE_FORMAT(WAVE_FORMAT_PCM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_ADPCM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_IBM_CVSD);
|
||||
WAVE_FORMAT(WAVE_FORMAT_ALAW);
|
||||
WAVE_FORMAT(WAVE_FORMAT_MULAW);
|
||||
WAVE_FORMAT(WAVE_FORMAT_OKI_ADPCM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_IMA_ADPCM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_MEDIASPACE_ADPCM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_SIERRA_ADPCM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_G723_ADPCM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_DIGISTD);
|
||||
WAVE_FORMAT(WAVE_FORMAT_DIGIFIX);
|
||||
WAVE_FORMAT(WAVE_FORMAT_DIALOGIC_OKI_ADPCM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_YAMAHA_ADPCM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_SONARC);
|
||||
WAVE_FORMAT(WAVE_FORMAT_DSPGROUP_TRUESPEECH);
|
||||
WAVE_FORMAT(WAVE_FORMAT_ECHOSC1);
|
||||
WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF36);
|
||||
WAVE_FORMAT(WAVE_FORMAT_APTX);
|
||||
WAVE_FORMAT(WAVE_FORMAT_AUDIOFILE_AF10);
|
||||
WAVE_FORMAT(WAVE_FORMAT_DOLBY_AC2);
|
||||
WAVE_FORMAT(WAVE_FORMAT_GSM610);
|
||||
WAVE_FORMAT(WAVE_FORMAT_ANTEX_ADPCME);
|
||||
WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_VQLPC);
|
||||
WAVE_FORMAT(WAVE_FORMAT_DIGIREAL);
|
||||
WAVE_FORMAT(WAVE_FORMAT_DIGIADPCM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_CONTROL_RES_CR10);
|
||||
WAVE_FORMAT(WAVE_FORMAT_NMS_VBXADPCM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_G721_ADPCM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_MPEG);
|
||||
WAVE_FORMAT(WAVE_FORMAT_MPEGLAYER3);
|
||||
WAVE_FORMAT(WAVE_FORMAT_CREATIVE_ADPCM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH8);
|
||||
WAVE_FORMAT(WAVE_FORMAT_CREATIVE_FASTSPEECH10);
|
||||
WAVE_FORMAT(WAVE_FORMAT_FM_TOWNS_SND);
|
||||
WAVE_FORMAT(WAVE_FORMAT_OLIGSM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_OLIADPCM);
|
||||
WAVE_FORMAT(WAVE_FORMAT_OLICELP);
|
||||
WAVE_FORMAT(WAVE_FORMAT_OLISBC);
|
||||
WAVE_FORMAT(WAVE_FORMAT_OLIOPR);
|
||||
WAVE_FORMAT(WAVE_FORMAT_DEVELOPMENT);
|
||||
WAVE_FORMAT(WAVE_FORMAT_EXTENSIBLE);
|
||||
}
|
||||
#undef WAVE_FORMAT
|
||||
sprintf(msg, "Unknown(0x%04x)", format);
|
||||
return msg;
|
||||
}
|
||||
|
||||
const char * format_string(const WAVEFORMATEX* wfx)
|
||||
{
|
||||
static char str[64];
|
||||
|
||||
sprintf(str, "%5dx%2dx%d %s",
|
||||
wfx->nSamplesPerSec, wfx->wBitsPerSample, wfx->nChannels,
|
||||
get_format_str(wfx->wFormatTag));
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
static void IDirectSoundCapture_test(LPDIRECTSOUNDCAPTURE dsco,
|
||||
BOOL initialized, LPCGUID lpGuid)
|
||||
{
|
||||
HRESULT rc;
|
||||
DSCCAPS dsccaps;
|
||||
int ref;
|
||||
IUnknown * unknown;
|
||||
IDirectSoundCapture * dsc;
|
||||
|
||||
/* Try to Query for objects */
|
||||
rc=IDirectSoundCapture_QueryInterface(dsco, &IID_IUnknown,
|
||||
(LPVOID*)&unknown);
|
||||
ok(rc==DS_OK, "IDirectSoundCapture_QueryInterface(IID_IUnknown) "
|
||||
"failed: %08x\n", rc);
|
||||
if (rc==DS_OK)
|
||||
IDirectSoundCapture_Release(unknown);
|
||||
|
||||
rc=IDirectSoundCapture_QueryInterface(dsco, &IID_IDirectSoundCapture,
|
||||
(LPVOID*)&dsc);
|
||||
ok(rc==DS_OK, "IDirectSoundCapture_QueryInterface(IID_IDirectSoundCapture) "
|
||||
"failed: %08x\n", rc);
|
||||
if (rc==DS_OK)
|
||||
IDirectSoundCapture_Release(dsc);
|
||||
|
||||
if (initialized == FALSE) {
|
||||
/* try uninitialized object */
|
||||
rc=IDirectSoundCapture_GetCaps(dsco,0);
|
||||
ok(rc==DSERR_UNINITIALIZED||rc==E_INVALIDARG,
|
||||
"IDirectSoundCapture_GetCaps(NULL) should have returned "
|
||||
"DSERR_UNINITIALIZED or E_INVALIDARG, returned: %08x\n", rc);
|
||||
|
||||
rc=IDirectSoundCapture_GetCaps(dsco, &dsccaps);
|
||||
ok(rc==DSERR_UNINITIALIZED,"IDirectSoundCapture_GetCaps() "
|
||||
"should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
|
||||
|
||||
rc=IDirectSoundCapture_Initialize(dsco, lpGuid);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||
|
||||
rc==E_FAIL||rc==E_INVALIDARG,
|
||||
"IDirectSoundCapture_Initialize() failed: %08x\n", rc);
|
||||
if (rc==DSERR_NODRIVER||rc==E_INVALIDARG) {
|
||||
trace(" No Driver\n");
|
||||
goto EXIT;
|
||||
} else if (rc==E_FAIL) {
|
||||
trace(" No Device\n");
|
||||
goto EXIT;
|
||||
} else if (rc==DSERR_ALLOCATED) {
|
||||
trace(" Already In Use\n");
|
||||
goto EXIT;
|
||||
}
|
||||
}
|
||||
|
||||
rc=IDirectSoundCapture_Initialize(dsco, lpGuid);
|
||||
ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSoundCapture_Initialize() "
|
||||
"should have returned DSERR_ALREADYINITIALIZED: %08x\n", rc);
|
||||
|
||||
/* DSOUND: Error: Invalid caps buffer */
|
||||
rc=IDirectSoundCapture_GetCaps(dsco, 0);
|
||||
ok(rc==DSERR_INVALIDPARAM, "IDirectSoundCapture_GetCaps(NULL) "
|
||||
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
|
||||
ZeroMemory(&dsccaps, sizeof(dsccaps));
|
||||
|
||||
/* DSOUND: Error: Invalid caps buffer */
|
||||
rc=IDirectSound_GetCaps(dsco, &dsccaps);
|
||||
ok(rc==DSERR_INVALIDPARAM, "IDirectSound_GetCaps() "
|
||||
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
|
||||
dsccaps.dwSize=sizeof(dsccaps);
|
||||
|
||||
/* DSOUND: Running on a certified driver */
|
||||
rc=IDirectSoundCapture_GetCaps(dsco, &dsccaps);
|
||||
ok(rc==DS_OK, "IDirectSoundCapture_GetCaps() failed: %08x\n", rc);
|
||||
|
||||
EXIT:
|
||||
ref=IDirectSoundCapture_Release(dsco);
|
||||
ok(ref==0, "IDirectSoundCapture_Release() has %d references, "
|
||||
"should have 0\n", ref);
|
||||
}
|
||||
|
||||
static void IDirectSoundCapture_tests(void)
|
||||
{
|
||||
HRESULT rc;
|
||||
LPDIRECTSOUNDCAPTURE dsco=NULL;
|
||||
LPCLASSFACTORY cf=NULL;
|
||||
|
||||
trace("Testing IDirectSoundCapture\n");
|
||||
|
||||
rc=CoGetClassObject(&CLSID_DirectSoundCapture, CLSCTX_INPROC_SERVER, NULL,
|
||||
&IID_IClassFactory, (void**)&cf);
|
||||
ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSoundCapture, IID_IClassFactory) "
|
||||
"failed: %08x\n", rc);
|
||||
|
||||
rc=CoGetClassObject(&CLSID_DirectSoundCapture, CLSCTX_INPROC_SERVER, NULL,
|
||||
&IID_IUnknown, (void**)&cf);
|
||||
ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSoundCapture, IID_IUnknown) "
|
||||
"failed: %08x\n", rc);
|
||||
|
||||
/* try the COM class factory method of creation with no device specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IDirectSoundCapture, (void**)&dsco);
|
||||
ok(rc==S_OK||rc==REGDB_E_CLASSNOTREG,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %08x\n", rc);
|
||||
if (rc==REGDB_E_CLASSNOTREG) {
|
||||
trace(" Class Not Registered\n");
|
||||
return;
|
||||
}
|
||||
if (dsco)
|
||||
IDirectSoundCapture_test(dsco, FALSE, NULL);
|
||||
|
||||
/* try the COM class factory method of creation with default capture
|
||||
* device specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IDirectSoundCapture, (void**)&dsco);
|
||||
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %08x\n", rc);
|
||||
if (dsco)
|
||||
IDirectSoundCapture_test(dsco, FALSE, &DSDEVID_DefaultCapture);
|
||||
|
||||
/* try the COM class factory method of creation with default voice
|
||||
* capture device specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IDirectSoundCapture, (void**)&dsco);
|
||||
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundCapture) failed: %08x\n", rc);
|
||||
if (dsco)
|
||||
IDirectSoundCapture_test(dsco, FALSE, &DSDEVID_DefaultVoiceCapture);
|
||||
|
||||
/* try the COM class factory method of creation with a bad
|
||||
* IID specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSoundCapture, NULL, CLSCTX_INPROC_SERVER,
|
||||
&CLSID_DirectSoundPrivate, (void**)&dsco);
|
||||
ok(rc==E_NOINTERFACE,
|
||||
"CoCreateInstance(CLSID_DirectSoundCapture,CLSID_DirectSoundPrivate) "
|
||||
"should have failed: %08x\n",rc);
|
||||
|
||||
/* try with no device specified */
|
||||
rc=pDirectSoundCaptureCreate(NULL,&dsco,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
||||
"DirectSoundCaptureCreate(NULL) failed: %08x\n",rc);
|
||||
if (rc==S_OK && dsco)
|
||||
IDirectSoundCapture_test(dsco, TRUE, NULL);
|
||||
|
||||
/* try with default capture device specified */
|
||||
rc=pDirectSoundCaptureCreate(&DSDEVID_DefaultCapture,&dsco,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
||||
"DirectSoundCaptureCreate(DSDEVID_DefaultCapture) failed: %08x\n", rc);
|
||||
if (rc==DS_OK && dsco)
|
||||
IDirectSoundCapture_test(dsco, TRUE, NULL);
|
||||
|
||||
/* try with default voice capture device specified */
|
||||
rc=pDirectSoundCaptureCreate(&DSDEVID_DefaultVoiceCapture,&dsco,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
||||
"DirectSoundCaptureCreate(DSDEVID_DefaultVoiceCapture) failed: %08x\n", rc);
|
||||
if (rc==DS_OK && dsco)
|
||||
IDirectSoundCapture_test(dsco, TRUE, NULL);
|
||||
|
||||
/* try with a bad device specified */
|
||||
rc=pDirectSoundCaptureCreate(&DSDEVID_DefaultVoicePlayback,&dsco,NULL);
|
||||
ok(rc==DSERR_NODRIVER,
|
||||
"DirectSoundCaptureCreate(DSDEVID_DefaultVoicePlatback) "
|
||||
"should have failed: %08x\n",rc);
|
||||
if (rc==DS_OK && dsco)
|
||||
IDirectSoundCapture_Release(dsco);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char* wave;
|
||||
DWORD wave_len;
|
||||
|
||||
LPDIRECTSOUNDCAPTUREBUFFER dscbo;
|
||||
LPWAVEFORMATEX wfx;
|
||||
DSBPOSITIONNOTIFY posnotify[NOTIFICATIONS];
|
||||
HANDLE event[NOTIFICATIONS];
|
||||
LPDIRECTSOUNDNOTIFY notify;
|
||||
|
||||
DWORD buffer_size;
|
||||
DWORD read;
|
||||
DWORD offset;
|
||||
DWORD size;
|
||||
|
||||
DWORD last_pos;
|
||||
} capture_state_t;
|
||||
|
||||
static int capture_buffer_service(capture_state_t* state)
|
||||
{
|
||||
HRESULT rc;
|
||||
LPVOID ptr1,ptr2;
|
||||
DWORD len1,len2;
|
||||
DWORD capture_pos,read_pos;
|
||||
|
||||
rc=IDirectSoundCaptureBuffer_GetCurrentPosition(state->dscbo,&capture_pos,
|
||||
&read_pos);
|
||||
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetCurrentPosition() failed: %08x\n", rc);
|
||||
if (rc!=DS_OK)
|
||||
return 0;
|
||||
|
||||
rc=IDirectSoundCaptureBuffer_Lock(state->dscbo,state->offset,state->size,
|
||||
&ptr1,&len1,&ptr2,&len2,0);
|
||||
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Lock() failed: %08x\n", rc);
|
||||
if (rc!=DS_OK)
|
||||
return 0;
|
||||
|
||||
rc=IDirectSoundCaptureBuffer_Unlock(state->dscbo,ptr1,len1,ptr2,len2);
|
||||
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Unlock() failed: %08x\n", rc);
|
||||
if (rc!=DS_OK)
|
||||
return 0;
|
||||
|
||||
state->offset = (state->offset + state->size) % state->buffer_size;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void test_capture_buffer(LPDIRECTSOUNDCAPTURE dsco,
|
||||
LPDIRECTSOUNDCAPTUREBUFFER dscbo, int record)
|
||||
{
|
||||
HRESULT rc;
|
||||
DSCBCAPS dscbcaps;
|
||||
WAVEFORMATEX wfx;
|
||||
DWORD size,status;
|
||||
capture_state_t state;
|
||||
int i, ref;
|
||||
|
||||
/* Private dsound.dll: Error: Invalid caps pointer */
|
||||
rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,0);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetCaps() should "
|
||||
"have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
|
||||
/* Private dsound.dll: Error: Invalid caps pointer */
|
||||
dscbcaps.dwSize=0;
|
||||
rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,&dscbcaps);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetCaps() should "
|
||||
"have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
|
||||
dscbcaps.dwSize=sizeof(dscbcaps);
|
||||
rc=IDirectSoundCaptureBuffer_GetCaps(dscbo,&dscbcaps);
|
||||
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetCaps() failed: %08x\n", rc);
|
||||
if (rc==DS_OK && winetest_debug > 1) {
|
||||
trace(" Caps: size = %d flags=0x%08x buffer size=%d\n",
|
||||
dscbcaps.dwSize,dscbcaps.dwFlags,dscbcaps.dwBufferBytes);
|
||||
}
|
||||
|
||||
/* Query the format size. Note that it may not match sizeof(wfx) */
|
||||
/* Private dsound.dll: Error: Either pwfxFormat or pdwSizeWritten must
|
||||
* be non-NULL */
|
||||
rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,NULL,0,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetFormat() should "
|
||||
"have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
|
||||
size=0;
|
||||
rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,NULL,0,&size);
|
||||
ok(rc==DS_OK && size!=0,"IDirectSoundCaptureBuffer_GetFormat() should "
|
||||
"have returned the needed size: rc=%08x, size=%d\n", rc,size);
|
||||
|
||||
rc=IDirectSoundCaptureBuffer_GetFormat(dscbo,&wfx,sizeof(wfx),NULL);
|
||||
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetFormat() failed: %08x\n", rc);
|
||||
if (rc==DS_OK && winetest_debug > 1) {
|
||||
trace(" Format: tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
|
||||
wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
|
||||
wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
|
||||
}
|
||||
|
||||
/* Private dsound.dll: Error: Invalid status pointer */
|
||||
rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,0);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCaptureBuffer_GetStatus() should "
|
||||
"have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
|
||||
rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status);
|
||||
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %08x\n", rc);
|
||||
if (rc==DS_OK && winetest_debug > 1) {
|
||||
trace(" Status=0x%04x\n",status);
|
||||
}
|
||||
|
||||
ZeroMemory(&state, sizeof(state));
|
||||
state.dscbo=dscbo;
|
||||
state.wfx=&wfx;
|
||||
state.buffer_size = dscbcaps.dwBufferBytes;
|
||||
for (i = 0; i < NOTIFICATIONS; i++)
|
||||
state.event[i] = CreateEvent( NULL, FALSE, FALSE, NULL );
|
||||
state.size = dscbcaps.dwBufferBytes / NOTIFICATIONS;
|
||||
|
||||
rc=IDirectSoundCaptureBuffer_QueryInterface(dscbo,&IID_IDirectSoundNotify,
|
||||
(void **)&(state.notify));
|
||||
ok((rc==DS_OK)&&(state.notify!=NULL),
|
||||
"IDirectSoundCaptureBuffer_QueryInterface() failed: %08x\n", rc);
|
||||
if (rc!=DS_OK)
|
||||
return;
|
||||
|
||||
for (i = 0; i < NOTIFICATIONS; i++) {
|
||||
state.posnotify[i].dwOffset = (i * state.size) + state.size - 1;
|
||||
state.posnotify[i].hEventNotify = state.event[i];
|
||||
}
|
||||
|
||||
rc=IDirectSoundNotify_SetNotificationPositions(state.notify,NOTIFICATIONS,
|
||||
state.posnotify);
|
||||
ok(rc==DS_OK,"IDirectSoundNotify_SetNotificationPositions() failed: %08x\n", rc);
|
||||
if (rc!=DS_OK)
|
||||
return;
|
||||
|
||||
ref=IDirectSoundNotify_Release(state.notify);
|
||||
ok(ref==0,"IDirectSoundNotify_Release(): has %d references, should have "
|
||||
"0\n",ref);
|
||||
if (ref!=0)
|
||||
return;
|
||||
|
||||
if (record) {
|
||||
rc=IDirectSoundCaptureBuffer_Start(dscbo,DSCBSTART_LOOPING);
|
||||
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %08x\n", rc);
|
||||
if (rc!=DS_OK)
|
||||
return;
|
||||
|
||||
rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status);
|
||||
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %08x\n", rc);
|
||||
ok(status==(DSCBSTATUS_CAPTURING|DSCBSTATUS_LOOPING),
|
||||
"GetStatus: bad status: %x\n",status);
|
||||
if (rc!=DS_OK)
|
||||
return;
|
||||
|
||||
/* wait for the notifications */
|
||||
for (i = 0; i < (NOTIFICATIONS * 2); i++) {
|
||||
rc=WaitForMultipleObjects(NOTIFICATIONS,state.event,FALSE,3000);
|
||||
ok(rc==(WAIT_OBJECT_0+(i%NOTIFICATIONS)),
|
||||
"WaitForMultipleObjects failed: 0x%x\n",rc);
|
||||
if (rc!=(WAIT_OBJECT_0+(i%NOTIFICATIONS))) {
|
||||
ok((rc==WAIT_TIMEOUT)||(rc==WAIT_FAILED),
|
||||
"Wrong notification: should be %d, got %d\n",
|
||||
i%NOTIFICATIONS,rc-WAIT_OBJECT_0);
|
||||
}
|
||||
if (!capture_buffer_service(&state))
|
||||
break;
|
||||
}
|
||||
|
||||
rc=IDirectSoundCaptureBuffer_Stop(dscbo);
|
||||
ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc);
|
||||
if (rc!=DS_OK)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
|
||||
LPCSTR lpcstrModule, LPVOID lpContext)
|
||||
{
|
||||
HRESULT rc;
|
||||
LPDIRECTSOUNDCAPTURE dsco=NULL;
|
||||
LPDIRECTSOUNDCAPTUREBUFFER dscbo=NULL;
|
||||
DSCBUFFERDESC bufdesc;
|
||||
WAVEFORMATEX wfx;
|
||||
DSCCAPS dsccaps;
|
||||
DWORD f;
|
||||
int ref;
|
||||
|
||||
/* Private dsound.dll: Error: Invalid interface buffer */
|
||||
trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
|
||||
rc=pDirectSoundCaptureCreate(lpGuid,NULL,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM,"DirectSoundCaptureCreate() should have "
|
||||
"returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
||||
|
||||
rc=pDirectSoundCaptureCreate(lpGuid,&dsco,NULL);
|
||||
ok((rc==DS_OK)||(rc==DSERR_NODRIVER)||(rc==E_FAIL)||(rc==DSERR_ALLOCATED),
|
||||
"DirectSoundCaptureCreate() failed: %08x\n",rc);
|
||||
if (rc!=DS_OK) {
|
||||
if (rc==DSERR_NODRIVER)
|
||||
trace(" No Driver\n");
|
||||
else if (rc==E_FAIL)
|
||||
trace(" No Device\n");
|
||||
else if (rc==DSERR_ALLOCATED)
|
||||
trace(" Already In Use\n");
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
/* Private dsound.dll: Error: Invalid caps buffer */
|
||||
rc=IDirectSoundCapture_GetCaps(dsco,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_GetCaps() should have "
|
||||
"returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
||||
|
||||
/* Private dsound.dll: Error: Invalid caps buffer */
|
||||
dsccaps.dwSize=0;
|
||||
rc=IDirectSoundCapture_GetCaps(dsco,&dsccaps);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_GetCaps() should have "
|
||||
"returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
||||
|
||||
dsccaps.dwSize=sizeof(dsccaps);
|
||||
rc=IDirectSoundCapture_GetCaps(dsco,&dsccaps);
|
||||
ok(rc==DS_OK,"IDirectSoundCapture_GetCaps() failed: %08x\n", rc);
|
||||
if (rc==DS_OK && winetest_debug > 1) {
|
||||
trace(" Caps: size=%d flags=0x%08x formats=%05x channels=%d\n",
|
||||
dsccaps.dwSize,dsccaps.dwFlags,dsccaps.dwFormats,
|
||||
dsccaps.dwChannels);
|
||||
}
|
||||
|
||||
/* Private dsound.dll: Error: Invalid size */
|
||||
/* Private dsound.dll: Error: Invalid capture buffer description */
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=0;
|
||||
bufdesc.dwFlags=0;
|
||||
bufdesc.dwBufferBytes=0;
|
||||
bufdesc.dwReserved=0;
|
||||
bufdesc.lpwfxFormat=NULL;
|
||||
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
|
||||
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
if (rc==DS_OK) {
|
||||
ref=IDirectSoundCaptureBuffer_Release(dscbo);
|
||||
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
|
||||
"should have 0\n",ref);
|
||||
}
|
||||
|
||||
/* Private dsound.dll: Error: Invalid buffer size */
|
||||
/* Private dsound.dll: Error: Invalid capture buffer description */
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=0;
|
||||
bufdesc.dwBufferBytes=0;
|
||||
bufdesc.dwReserved=0;
|
||||
bufdesc.lpwfxFormat=NULL;
|
||||
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
|
||||
"should have returned DSERR_INVALIDPARAM, returned %08x\n", rc);
|
||||
if (rc==DS_OK) {
|
||||
ref=IDirectSoundCaptureBuffer_Release(dscbo);
|
||||
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
|
||||
"should have 0\n",ref);
|
||||
}
|
||||
|
||||
/* Private dsound.dll: Error: Invalid buffer size */
|
||||
/* Private dsound.dll: Error: Invalid capture buffer description */
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
ZeroMemory(&wfx, sizeof(wfx));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=0;
|
||||
bufdesc.dwBufferBytes=0;
|
||||
bufdesc.dwReserved=0;
|
||||
bufdesc.lpwfxFormat=&wfx;
|
||||
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
|
||||
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
if (rc==DS_OK) {
|
||||
ref=IDirectSoundCaptureBuffer_Release(dscbo);
|
||||
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
|
||||
"should have 0\n",ref);
|
||||
}
|
||||
|
||||
/* Private dsound.dll: Error: Invalid buffer size */
|
||||
/* Private dsound.dll: Error: Invalid capture buffer description */
|
||||
init_format(&wfx,WAVE_FORMAT_PCM,11025,8,1);
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=0;
|
||||
bufdesc.dwBufferBytes=0;
|
||||
bufdesc.dwReserved=0;
|
||||
bufdesc.lpwfxFormat=&wfx;
|
||||
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundCapture_CreateCaptureBuffer() "
|
||||
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
if (rc==DS_OK) {
|
||||
ref=IDirectSoundCaptureBuffer_Release(dscbo);
|
||||
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
|
||||
"should have 0\n",ref);
|
||||
}
|
||||
|
||||
for (f=0;f<NB_FORMATS;f++) {
|
||||
dscbo=NULL;
|
||||
init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
|
||||
formats[f][2]);
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=0;
|
||||
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
|
||||
bufdesc.dwReserved=0;
|
||||
bufdesc.lpwfxFormat=&wfx;
|
||||
if (winetest_interactive)
|
||||
trace(" Testing the capture buffer at %s\n", format_string(&wfx));
|
||||
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
|
||||
ok(((rc==DS_OK)&&(dscbo!=NULL))
|
||||
|| rc==DSERR_BADFORMAT || rc==DSERR_INVALIDCALL || rc==DSERR_NODRIVER
|
||||
|| rc==DSERR_ALLOCATED || rc==E_INVALIDARG || rc==E_FAIL,
|
||||
"IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
|
||||
"%s capture buffer: %08x\n",format_string(&wfx),rc);
|
||||
if (rc==DS_OK) {
|
||||
test_capture_buffer(dsco, dscbo, winetest_interactive);
|
||||
ref=IDirectSoundCaptureBuffer_Release(dscbo);
|
||||
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
|
||||
"should have 0\n",ref);
|
||||
} else if (rc==DSERR_BADFORMAT) {
|
||||
ok(!(dsccaps.dwFormats & formats[f][3]),
|
||||
"IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
|
||||
"capture buffer: format listed as supported but using it failed\n");
|
||||
if (!(dsccaps.dwFormats & formats[f][3]))
|
||||
trace(" Format not supported: %s\n", format_string(&wfx));
|
||||
} else if (rc==DSERR_NODRIVER) {
|
||||
trace(" No Driver\n");
|
||||
} else if (rc==DSERR_ALLOCATED) {
|
||||
trace(" Already In Use\n");
|
||||
} else if (rc==E_INVALIDARG) { /* try the old version struct */
|
||||
DSCBUFFERDESC1 bufdesc1;
|
||||
ZeroMemory(&bufdesc1, sizeof(bufdesc1));
|
||||
bufdesc1.dwSize=sizeof(bufdesc1);
|
||||
bufdesc1.dwFlags=0;
|
||||
bufdesc1.dwBufferBytes=wfx.nAvgBytesPerSec;
|
||||
bufdesc1.dwReserved=0;
|
||||
bufdesc1.lpwfxFormat=&wfx;
|
||||
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,
|
||||
(DSCBUFFERDESC*)&bufdesc1,&dscbo,NULL);
|
||||
ok(rc==DS_OK || broken(rc==DSERR_INVALIDPARAM),
|
||||
"IDirectSoundCapture_CreateCaptureBuffer() failed to create a "
|
||||
"%s capture buffer: %08x\n",format_string(&wfx), rc);
|
||||
if (rc==DSERR_INVALIDPARAM) {
|
||||
skip("broken driver\n");
|
||||
goto EXIT;
|
||||
}
|
||||
if (rc==DS_OK) {
|
||||
test_capture_buffer(dsco, dscbo, winetest_interactive);
|
||||
ref=IDirectSoundCaptureBuffer_Release(dscbo);
|
||||
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d "
|
||||
"references, should have 0\n",ref);
|
||||
}
|
||||
} else if (rc==E_FAIL) {
|
||||
/* WAVE_FORMAT_PCM only allows 8 and 16 bits per sample, so only
|
||||
* report a failure if the bits per sample is 8 or 16
|
||||
*/
|
||||
if (wfx.wBitsPerSample == 8 || wfx.wBitsPerSample == 16)
|
||||
ok(FALSE,"Should not fail for 8 or 16 bits per sample\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* try a non PCM format */
|
||||
if (0)
|
||||
{
|
||||
/* FIXME: Why is this commented out? */
|
||||
init_format(&wfx,WAVE_FORMAT_MULAW,8000,8,1);
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=DSCBCAPS_WAVEMAPPED;
|
||||
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
|
||||
bufdesc.dwReserved=0;
|
||||
bufdesc.lpwfxFormat=&wfx;
|
||||
if (winetest_interactive)
|
||||
trace(" Testing the capture buffer at %s\n", format_string(&wfx));
|
||||
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
|
||||
ok((rc==DS_OK)&&(dscbo!=NULL),"IDirectSoundCapture_CreateCaptureBuffer() "
|
||||
"failed to create a capture buffer: %08x\n",rc);
|
||||
if ((rc==DS_OK)&&(dscbo!=NULL)) {
|
||||
test_capture_buffer(dsco, dscbo, winetest_interactive);
|
||||
ref=IDirectSoundCaptureBuffer_Release(dscbo);
|
||||
ok(ref==0,"IDirectSoundCaptureBuffer_Release() has %d references, "
|
||||
"should have 0\n",ref);
|
||||
}
|
||||
}
|
||||
|
||||
/* Try an invalid format to test error handling */
|
||||
if (0)
|
||||
{
|
||||
/* FIXME: Remove this test altogether? */
|
||||
init_format(&wfx,WAVE_FORMAT_PCM,2000000,16,2);
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=DSCBCAPS_WAVEMAPPED;
|
||||
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
|
||||
bufdesc.dwReserved=0;
|
||||
bufdesc.lpwfxFormat=&wfx;
|
||||
if (winetest_interactive)
|
||||
trace(" Testing the capture buffer at %s\n", format_string(&wfx));
|
||||
rc=IDirectSoundCapture_CreateCaptureBuffer(dsco,&bufdesc,&dscbo,NULL);
|
||||
ok(rc!=DS_OK,"IDirectSoundCapture_CreateCaptureBuffer() should have failed "
|
||||
"at 2 MHz %08x\n",rc);
|
||||
}
|
||||
|
||||
EXIT:
|
||||
if (dsco!=NULL) {
|
||||
ref=IDirectSoundCapture_Release(dsco);
|
||||
ok(ref==0,"IDirectSoundCapture_Release() has %d references, should "
|
||||
"have 0\n",ref);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void capture_tests(void)
|
||||
{
|
||||
HRESULT rc;
|
||||
rc=pDirectSoundCaptureEnumerateA(&dscenum_callback,NULL);
|
||||
ok(rc==DS_OK,"DirectSoundCaptureEnumerateA() failed: %08x\n", rc);
|
||||
}
|
||||
|
||||
START_TEST(capture)
|
||||
{
|
||||
HMODULE hDsound;
|
||||
|
||||
CoInitialize(NULL);
|
||||
|
||||
hDsound = LoadLibrary("dsound.dll");
|
||||
if (hDsound)
|
||||
{
|
||||
|
||||
pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound,
|
||||
"DirectSoundCaptureCreate");
|
||||
pDirectSoundCaptureEnumerateA=(void*)GetProcAddress(hDsound,
|
||||
"DirectSoundCaptureEnumerateA");
|
||||
if (pDirectSoundCaptureCreate && pDirectSoundCaptureEnumerateA)
|
||||
{
|
||||
IDirectSoundCapture_tests();
|
||||
capture_tests();
|
||||
}
|
||||
else
|
||||
skip("capture test skipped\n");
|
||||
|
||||
FreeLibrary(hDsound);
|
||||
}
|
||||
else
|
||||
skip("dsound.dll not found!\n");
|
||||
|
||||
CoUninitialize();
|
||||
}
|
1297
rostests/winetests/dsound/ds3d.c
Normal file
1297
rostests/winetests/dsound/ds3d.c
Normal file
File diff suppressed because it is too large
Load diff
1154
rostests/winetests/dsound/ds3d8.c
Normal file
1154
rostests/winetests/dsound/ds3d8.c
Normal file
File diff suppressed because it is too large
Load diff
1103
rostests/winetests/dsound/dsound.c
Normal file
1103
rostests/winetests/dsound/dsound.c
Normal file
File diff suppressed because it is too large
Load diff
22
rostests/winetests/dsound/dsound.rbuild
Normal file
22
rostests/winetests/dsound/dsound.rbuild
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
|
||||
<group>
|
||||
<module name="dsound_winetest" type="win32cui" installbase="bin" installname="dsound_winetest.exe" allowwarnings="true">
|
||||
<include base="dsound_winetest">.</include>
|
||||
<define name="__ROS_LONG64__" />
|
||||
<library>wine</library>
|
||||
<library>uuid</library>
|
||||
<library>dsound</library>
|
||||
<library>dxguid</library>
|
||||
<library>ole32</library>
|
||||
<library>user32</library>
|
||||
<file>capture.c</file>
|
||||
<file>ds3d8.c</file>
|
||||
<file>ds3d.c</file>
|
||||
<file>dsound8.c</file>
|
||||
<file>dsound.c</file>
|
||||
<file>duplex.c</file>
|
||||
<file>propset.c</file>
|
||||
<file>testlist.c</file>
|
||||
</module>
|
||||
</group>
|
940
rostests/winetests/dsound/dsound8.c
Normal file
940
rostests/winetests/dsound/dsound8.c
Normal file
|
@ -0,0 +1,940 @@
|
|||
/*
|
||||
* Tests basic sound playback in DirectSound.
|
||||
* In particular we test each standard Windows sound format to make sure
|
||||
* we handle the sound card/driver quirks correctly.
|
||||
*
|
||||
* Part of this test involves playing test tones. But this only makes
|
||||
* sense if someone is going to carefully listen to it, and would only
|
||||
* bother everyone else.
|
||||
* So this is only done if the test is being run in interactive mode.
|
||||
*
|
||||
* Copyright (c) 2002-2004 Francois Gouget
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "dsound.h"
|
||||
#include "dsconf.h"
|
||||
#include "mmreg.h"
|
||||
#include "ks.h"
|
||||
#include "ksmedia.h"
|
||||
|
||||
#include "dsound_test.h"
|
||||
|
||||
static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
|
||||
static HRESULT (WINAPI *pDirectSoundCreate8)(LPCGUID,LPDIRECTSOUND8*,LPUNKNOWN)=NULL;
|
||||
|
||||
int align(int length, int align)
|
||||
{
|
||||
return (length / align) * align;
|
||||
}
|
||||
|
||||
static void IDirectSound8_test(LPDIRECTSOUND8 dso, BOOL initialized,
|
||||
LPCGUID lpGuid)
|
||||
{
|
||||
HRESULT rc;
|
||||
DSCAPS dscaps;
|
||||
int ref;
|
||||
IUnknown * unknown;
|
||||
IDirectSound * ds;
|
||||
IDirectSound8 * ds8;
|
||||
DWORD speaker_config, new_speaker_config;
|
||||
DWORD certified;
|
||||
|
||||
/* Try to Query for objects */
|
||||
rc=IDirectSound8_QueryInterface(dso,&IID_IUnknown,(LPVOID*)&unknown);
|
||||
ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IUnknown) failed: %08x\n", rc);
|
||||
if (rc==DS_OK)
|
||||
IDirectSound8_Release(unknown);
|
||||
|
||||
rc=IDirectSound8_QueryInterface(dso,&IID_IDirectSound,(LPVOID*)&ds);
|
||||
ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IDirectSound) failed: %08x\n", rc);
|
||||
if (rc==DS_OK)
|
||||
IDirectSound_Release(ds);
|
||||
|
||||
rc=IDirectSound8_QueryInterface(dso,&IID_IDirectSound8,(LPVOID*)&ds8);
|
||||
ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IDirectSound8) "
|
||||
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
if (rc==DS_OK)
|
||||
IDirectSound8_Release(ds8);
|
||||
|
||||
if (initialized == FALSE) {
|
||||
/* try uninitialized object */
|
||||
rc=IDirectSound8_GetCaps(dso,0);
|
||||
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetCaps(NULL) "
|
||||
"should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
|
||||
|
||||
rc=IDirectSound8_GetCaps(dso,&dscaps);
|
||||
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetCaps() "
|
||||
"should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
|
||||
|
||||
rc=IDirectSound8_Compact(dso);
|
||||
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_Compact() "
|
||||
"should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
|
||||
|
||||
rc=IDirectSound8_GetSpeakerConfig(dso,&speaker_config);
|
||||
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_GetSpeakerConfig() "
|
||||
"should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
|
||||
|
||||
rc=IDirectSound8_VerifyCertification(dso, &certified);
|
||||
ok(rc==DSERR_UNINITIALIZED,"IDirectSound8_VerifyCertification() "
|
||||
"should have returned DSERR_UNINITIALIZED, returned: %08x\n", rc);
|
||||
|
||||
rc=IDirectSound8_Initialize(dso,lpGuid);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
||||
"IDirectSound8_Initialize() failed: %08x\n",rc);
|
||||
if (rc==DSERR_NODRIVER) {
|
||||
trace(" No Driver\n");
|
||||
goto EXIT;
|
||||
} else if (rc==E_FAIL) {
|
||||
trace(" No Device\n");
|
||||
goto EXIT;
|
||||
} else if (rc==DSERR_ALLOCATED) {
|
||||
trace(" Already In Use\n");
|
||||
goto EXIT;
|
||||
}
|
||||
}
|
||||
|
||||
rc=IDirectSound8_Initialize(dso,lpGuid);
|
||||
ok(rc==DSERR_ALREADYINITIALIZED, "IDirectSound8_Initialize() "
|
||||
"should have returned DSERR_ALREADYINITIALIZED: %08x\n", rc);
|
||||
|
||||
/* DSOUND: Error: Invalid caps buffer */
|
||||
rc=IDirectSound8_GetCaps(dso,0);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetCaps() "
|
||||
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
|
||||
ZeroMemory(&dscaps, sizeof(dscaps));
|
||||
|
||||
/* DSOUND: Error: Invalid caps buffer */
|
||||
rc=IDirectSound8_GetCaps(dso,&dscaps);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetCaps() "
|
||||
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
|
||||
dscaps.dwSize=sizeof(dscaps);
|
||||
|
||||
/* DSOUND: Running on a certified driver */
|
||||
rc=IDirectSound8_GetCaps(dso,&dscaps);
|
||||
ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %08x\n",rc);
|
||||
|
||||
rc=IDirectSound8_Compact(dso);
|
||||
ok(rc==DSERR_PRIOLEVELNEEDED,"IDirectSound8_Compact() failed: %08x\n", rc);
|
||||
|
||||
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
||||
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
||||
|
||||
rc=IDirectSound8_Compact(dso);
|
||||
ok(rc==DS_OK,"IDirectSound8_Compact() failed: %08x\n",rc);
|
||||
|
||||
rc=IDirectSound8_GetSpeakerConfig(dso,0);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_GetSpeakerConfig(NULL) "
|
||||
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
|
||||
rc=IDirectSound8_GetSpeakerConfig(dso,&speaker_config);
|
||||
ok(rc==DS_OK,"IDirectSound8_GetSpeakerConfig() failed: %08x\n", rc);
|
||||
|
||||
speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO,
|
||||
DSSPEAKER_GEOMETRY_WIDE);
|
||||
rc=IDirectSound8_SetSpeakerConfig(dso,speaker_config);
|
||||
ok(rc==DS_OK,"IDirectSound8_SetSpeakerConfig() failed: %08x\n", rc);
|
||||
if (rc==DS_OK) {
|
||||
rc=IDirectSound8_GetSpeakerConfig(dso,&new_speaker_config);
|
||||
ok(rc==DS_OK,"IDirectSound8_GetSpeakerConfig() failed: %08x\n", rc);
|
||||
if (rc==DS_OK && speaker_config!=new_speaker_config)
|
||||
trace("IDirectSound8_GetSpeakerConfig() failed to set speaker "
|
||||
"config: expected 0x%08x, got 0x%08x\n",
|
||||
speaker_config,new_speaker_config);
|
||||
}
|
||||
|
||||
rc=IDirectSound8_VerifyCertification(dso, &certified);
|
||||
ok(rc==DS_OK||rc==E_NOTIMPL,"IDirectSound8_VerifyCertification() failed: %08x\n", rc);
|
||||
|
||||
EXIT:
|
||||
ref=IDirectSound8_Release(dso);
|
||||
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
|
||||
}
|
||||
|
||||
static void IDirectSound8_tests(void)
|
||||
{
|
||||
HRESULT rc;
|
||||
LPDIRECTSOUND8 dso=NULL;
|
||||
LPCLASSFACTORY cf=NULL;
|
||||
|
||||
trace("Testing IDirectSound8\n");
|
||||
|
||||
rc=CoGetClassObject(&CLSID_DirectSound8, CLSCTX_INPROC_SERVER, NULL,
|
||||
&IID_IClassFactory, (void**)&cf);
|
||||
ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSound8, IID_IClassFactory) "
|
||||
"failed: %08x\n", rc);
|
||||
|
||||
rc=CoGetClassObject(&CLSID_DirectSound8, CLSCTX_INPROC_SERVER, NULL,
|
||||
&IID_IUnknown, (void**)&cf);
|
||||
ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSound8, IID_IUnknown) "
|
||||
"failed: %08x\n", rc);
|
||||
|
||||
/* try the COM class factory method of creation with no device specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IDirectSound8, (void**)&dso);
|
||||
ok(rc==S_OK||rc==REGDB_E_CLASSNOTREG,"CoCreateInstance() failed: %08x\n", rc);
|
||||
if (rc==REGDB_E_CLASSNOTREG) {
|
||||
trace(" Class Not Registered\n");
|
||||
return;
|
||||
}
|
||||
if (dso)
|
||||
IDirectSound8_test(dso, FALSE, NULL);
|
||||
|
||||
/* try the COM class factory method of creation with default playback
|
||||
* device specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IDirectSound8, (void**)&dso);
|
||||
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound8) failed: %08x\n", rc);
|
||||
if (dso)
|
||||
IDirectSound8_test(dso, FALSE, &DSDEVID_DefaultPlayback);
|
||||
|
||||
/* try the COM class factory method of creation with default voice
|
||||
* playback device specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IDirectSound8, (void**)&dso);
|
||||
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound8) failed: %08x\n", rc);
|
||||
if (dso)
|
||||
IDirectSound8_test(dso, FALSE, &DSDEVID_DefaultVoicePlayback);
|
||||
|
||||
/* try the COM class factory method of creation with a bad
|
||||
* IID specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
|
||||
&CLSID_DirectSoundPrivate, (void**)&dso);
|
||||
ok(rc==E_NOINTERFACE,
|
||||
"CoCreateInstance(CLSID_DirectSound8,CLSID_DirectSoundPrivate) "
|
||||
"should have failed: %08x\n",rc);
|
||||
|
||||
/* try the COM class factory method of creation with a bad
|
||||
* GUID and IID specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSoundPrivate, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IDirectSound8, (void**)&dso);
|
||||
ok(rc==REGDB_E_CLASSNOTREG,
|
||||
"CoCreateInstance(CLSID_DirectSoundPrivate,IID_IDirectSound8) "
|
||||
"should have failed: %08x\n",rc);
|
||||
|
||||
/* try with no device specified */
|
||||
rc=pDirectSoundCreate8(NULL,&dso,NULL);
|
||||
ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
||||
"DirectSoundCreate8() failed: %08x\n",rc);
|
||||
if (rc==DS_OK && dso)
|
||||
IDirectSound8_test(dso, TRUE, NULL);
|
||||
|
||||
/* try with default playback device specified */
|
||||
rc=pDirectSoundCreate8(&DSDEVID_DefaultPlayback,&dso,NULL);
|
||||
ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
||||
"DirectSoundCreate8() failed: %08x\n",rc);
|
||||
if (rc==DS_OK && dso)
|
||||
IDirectSound8_test(dso, TRUE, NULL);
|
||||
|
||||
/* try with default voice playback device specified */
|
||||
rc=pDirectSoundCreate8(&DSDEVID_DefaultVoicePlayback,&dso,NULL);
|
||||
ok(rc==S_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
||||
"DirectSoundCreate8() failed: %08x\n",rc);
|
||||
if (rc==DS_OK && dso)
|
||||
IDirectSound8_test(dso, TRUE, NULL);
|
||||
|
||||
/* try with a bad device specified */
|
||||
rc=pDirectSoundCreate8(&DSDEVID_DefaultVoiceCapture,&dso,NULL);
|
||||
ok(rc==DSERR_NODRIVER,"DirectSoundCreate8(DSDEVID_DefaultVoiceCapture) "
|
||||
"should have failed: %08x\n",rc);
|
||||
}
|
||||
|
||||
static HRESULT test_dsound8(LPGUID lpGuid)
|
||||
{
|
||||
HRESULT rc;
|
||||
LPDIRECTSOUND8 dso=NULL;
|
||||
int ref;
|
||||
|
||||
/* DSOUND: Error: Invalid interface buffer */
|
||||
rc=pDirectSoundCreate8(lpGuid,0,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM,"DirectSoundCreate8() should have returned "
|
||||
"DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
||||
|
||||
/* Create the DirectSound8 object */
|
||||
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
||||
"DirectSoundCreate8() failed: %08x\n",rc);
|
||||
if (rc!=DS_OK)
|
||||
return rc;
|
||||
|
||||
/* Try the enumerated device */
|
||||
IDirectSound8_test(dso, TRUE, lpGuid);
|
||||
|
||||
/* Try the COM class factory method of creation with enumerated device */
|
||||
rc=CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IDirectSound8, (void**)&dso);
|
||||
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSound) failed: %08x\n", rc);
|
||||
if (dso)
|
||||
IDirectSound8_test(dso, FALSE, lpGuid);
|
||||
|
||||
/* Create a DirectSound8 object */
|
||||
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
|
||||
ok(rc==DS_OK,"DirectSoundCreate8() failed: %08x\n",rc);
|
||||
if (rc==DS_OK) {
|
||||
LPDIRECTSOUND8 dso1=NULL;
|
||||
|
||||
/* Create a second DirectSound8 object */
|
||||
rc=pDirectSoundCreate8(lpGuid,&dso1,NULL);
|
||||
ok(rc==DS_OK,"DirectSoundCreate8() failed: %08x\n",rc);
|
||||
if (rc==DS_OK) {
|
||||
/* Release the second DirectSound8 object */
|
||||
ref=IDirectSound8_Release(dso1);
|
||||
ok(ref==0,"IDirectSound8_Release() has %d references, "
|
||||
"should have 0\n",ref);
|
||||
ok(dso!=dso1,"DirectSound8 objects should be unique: "
|
||||
"dso=%p,dso1=%p\n",dso,dso1);
|
||||
}
|
||||
|
||||
/* Release the first DirectSound8 object */
|
||||
ref=IDirectSound8_Release(dso);
|
||||
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",
|
||||
ref);
|
||||
if (ref!=0)
|
||||
return DSERR_GENERIC;
|
||||
} else
|
||||
return rc;
|
||||
|
||||
/* Create a DirectSound8 object */
|
||||
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
|
||||
ok(rc==DS_OK,"DirectSoundCreate8() failed: %08x\n",rc);
|
||||
if (rc==DS_OK) {
|
||||
LPDIRECTSOUNDBUFFER secondary;
|
||||
DSBUFFERDESC bufdesc;
|
||||
WAVEFORMATEX wfx;
|
||||
|
||||
init_format(&wfx,WAVE_FORMAT_PCM,11025,8,1);
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRL3D;
|
||||
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
|
||||
wfx.nBlockAlign);
|
||||
bufdesc.lpwfxFormat=&wfx;
|
||||
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
||||
ok(rc==DS_OK && secondary!=NULL,
|
||||
"IDirectSound8_CreateSoundBuffer() failed to create a secondary "
|
||||
"buffer: %08x\n",rc);
|
||||
if (rc==DS_OK && secondary!=NULL) {
|
||||
LPDIRECTSOUND3DBUFFER buffer3d;
|
||||
LPDIRECTSOUNDBUFFER8 buffer8;
|
||||
rc=IDirectSound8_QueryInterface(secondary,
|
||||
&IID_IDirectSound3DBuffer,
|
||||
(void **)&buffer3d);
|
||||
ok(rc==DS_OK && buffer3d!=NULL,
|
||||
"IDirectSound8_QueryInterface() failed: %08x\n", rc);
|
||||
if (rc==DS_OK && buffer3d!=NULL) {
|
||||
ref=IDirectSound3DBuffer_AddRef(buffer3d);
|
||||
ok(ref==2,"IDirectSound3DBuffer_AddRef() has %d references, "
|
||||
"should have 2\n",ref);
|
||||
}
|
||||
rc=IDirectSound8_QueryInterface(secondary,
|
||||
&IID_IDirectSoundBuffer8,
|
||||
(void **)&buffer8);
|
||||
if (rc==DS_OK && buffer8!=NULL) {
|
||||
ref=IDirectSoundBuffer8_AddRef(buffer8);
|
||||
ok(ref==3,"IDirectSoundBuffer8_AddRef() has %d references, "
|
||||
"should have 3\n",ref);
|
||||
}
|
||||
ref=IDirectSoundBuffer_AddRef(secondary);
|
||||
ok(ref==4,"IDirectSoundBuffer_AddRef() has %d references, "
|
||||
"should have 4\n",ref);
|
||||
}
|
||||
/* release with buffer */
|
||||
ref=IDirectSound8_Release(dso);
|
||||
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",
|
||||
ref);
|
||||
if (ref!=0)
|
||||
return DSERR_GENERIC;
|
||||
} else
|
||||
return rc;
|
||||
|
||||
return DS_OK;
|
||||
}
|
||||
|
||||
static HRESULT test_primary8(LPGUID lpGuid)
|
||||
{
|
||||
HRESULT rc;
|
||||
LPDIRECTSOUND8 dso=NULL;
|
||||
LPDIRECTSOUNDBUFFER primary=NULL,second=NULL,third=NULL;
|
||||
LPDIRECTSOUNDBUFFER8 pb8 = NULL;
|
||||
DSBUFFERDESC bufdesc;
|
||||
DSCAPS dscaps;
|
||||
WAVEFORMATEX wfx;
|
||||
int ref;
|
||||
|
||||
/* Create the DirectSound object */
|
||||
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
|
||||
"DirectSoundCreate8() failed: %08x\n",rc);
|
||||
if (rc!=DS_OK)
|
||||
return rc;
|
||||
|
||||
/* Get the device capabilities */
|
||||
ZeroMemory(&dscaps, sizeof(dscaps));
|
||||
dscaps.dwSize=sizeof(dscaps);
|
||||
rc=IDirectSound8_GetCaps(dso,&dscaps);
|
||||
ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %08x\n",rc);
|
||||
if (rc!=DS_OK)
|
||||
goto EXIT;
|
||||
|
||||
/* DSOUND: Error: Invalid buffer description pointer */
|
||||
rc=IDirectSound8_CreateSoundBuffer(dso,0,0,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM,
|
||||
"IDirectSound8_CreateSoundBuffer should have returned "
|
||||
"DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
||||
|
||||
/* DSOUND: Error: Invalid buffer description pointer */
|
||||
rc=IDirectSound8_CreateSoundBuffer(dso,0,&primary,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM && primary==0,
|
||||
"IDirectSound8_CreateSoundBuffer() should have returned "
|
||||
"DSERR_INVALIDPARAM, returned: rc=%08x,dsbo=%p\n",
|
||||
rc,primary);
|
||||
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize = sizeof(DSBUFFERDESC);
|
||||
|
||||
/* DSOUND: Error: Invalid dsound buffer interface pointer */
|
||||
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,0,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM && primary==0,
|
||||
"IDirectSound8_CreateSoundBuffer() should have failed: rc=%08x,"
|
||||
"dsbo=%p\n",rc,primary);
|
||||
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
|
||||
/* DSOUND: Error: Invalid size */
|
||||
/* DSOUND: Error: Invalid buffer description */
|
||||
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM && primary==0,
|
||||
"IDirectSound8_CreateSoundBuffer() should have failed: rc=%08x,"
|
||||
"primary=%p\n",rc,primary);
|
||||
|
||||
/* We must call SetCooperativeLevel before calling CreateSoundBuffer */
|
||||
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
|
||||
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
||||
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
||||
if (rc!=DS_OK)
|
||||
goto EXIT;
|
||||
|
||||
/* Testing the primary buffer */
|
||||
primary=NULL;
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
|
||||
bufdesc.lpwfxFormat = &wfx;
|
||||
init_format(&wfx,WAVE_FORMAT_PCM,11025,8,2);
|
||||
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_CreateSoundBuffer() should have "
|
||||
"returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
if (rc==DS_OK && primary!=NULL)
|
||||
IDirectSoundBuffer_Release(primary);
|
||||
|
||||
primary=NULL;
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRLVOLUME;
|
||||
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
||||
ok((rc==DS_OK && primary!=NULL) || (rc==DSERR_CONTROLUNAVAIL),
|
||||
"IDirectSound8_CreateSoundBuffer() failed to create a primary buffer: "
|
||||
"%08x\n",rc);
|
||||
if (rc==DSERR_CONTROLUNAVAIL)
|
||||
trace(" No Primary\n");
|
||||
else if (rc==DS_OK && primary!=NULL) {
|
||||
LONG vol;
|
||||
|
||||
/* Try to create a second primary buffer */
|
||||
/* DSOUND: Error: The primary buffer already exists.
|
||||
* Any changes made to the buffer description will be ignored. */
|
||||
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&second,NULL);
|
||||
ok(rc==DS_OK && second==primary,
|
||||
"IDirectSound8_CreateSoundBuffer() should have returned original "
|
||||
"primary buffer: %08x\n",rc);
|
||||
ref=IDirectSoundBuffer_Release(second);
|
||||
ok(ref==1,"IDirectSoundBuffer_Release() primary has %d references, "
|
||||
"should have 1\n",ref);
|
||||
|
||||
/* Try to duplicate a primary buffer */
|
||||
/* DSOUND: Error: Can't duplicate primary buffers */
|
||||
rc=IDirectSound8_DuplicateSoundBuffer(dso,primary,&third);
|
||||
/* rc=0x88780032 */
|
||||
ok(rc!=DS_OK,"IDirectSound8_DuplicateSoundBuffer() primary buffer "
|
||||
"should have failed %08x\n",rc);
|
||||
|
||||
/* Primary buffers don't have an IDirectSoundBuffer8 */
|
||||
rc = IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSoundBuffer8, (LPVOID*)&pb8);
|
||||
ok(FAILED(rc), "Primary buffer does have an IDirectSoundBuffer8: %08x\n", rc);
|
||||
|
||||
rc=IDirectSoundBuffer_GetVolume(primary,&vol);
|
||||
ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %08x\n", rc);
|
||||
|
||||
if (winetest_interactive) {
|
||||
trace("Playing a 5 seconds reference tone at the current volume.\n");
|
||||
if (rc==DS_OK)
|
||||
trace("(the current volume is %d according to DirectSound)\n",
|
||||
vol);
|
||||
trace("All subsequent tones should be identical to this one.\n");
|
||||
trace("Listen for stutter, changes in pitch, volume, etc.\n");
|
||||
}
|
||||
test_buffer8(dso,&primary,1,FALSE,0,FALSE,0,winetest_interactive &&
|
||||
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),5.0,0,0,0,0);
|
||||
|
||||
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=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
||||
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
||||
|
||||
EXIT:
|
||||
ref=IDirectSound8_Release(dso);
|
||||
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
|
||||
if (ref!=0)
|
||||
return DSERR_GENERIC;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test the primary buffer at different formats while keeping the
|
||||
* secondary buffer at a constant format.
|
||||
*/
|
||||
static HRESULT test_primary_secondary8(LPGUID lpGuid)
|
||||
{
|
||||
HRESULT rc;
|
||||
LPDIRECTSOUND8 dso=NULL;
|
||||
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
|
||||
DSBUFFERDESC bufdesc;
|
||||
DSCAPS dscaps;
|
||||
WAVEFORMATEX wfx, wfx2;
|
||||
int ref;
|
||||
unsigned int f;
|
||||
|
||||
/* Create the DirectSound object */
|
||||
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
|
||||
"DirectSoundCreate8() failed: %08x\n",rc);
|
||||
if (rc!=DS_OK)
|
||||
return rc;
|
||||
|
||||
/* Get the device capabilities */
|
||||
ZeroMemory(&dscaps, sizeof(dscaps));
|
||||
dscaps.dwSize=sizeof(dscaps);
|
||||
rc=IDirectSound8_GetCaps(dso,&dscaps);
|
||||
ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %08x\n",rc);
|
||||
if (rc!=DS_OK)
|
||||
goto EXIT;
|
||||
|
||||
/* We must call SetCooperativeLevel before creating primary buffer */
|
||||
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
|
||||
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
||||
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
||||
if (rc!=DS_OK)
|
||||
goto EXIT;
|
||||
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
||||
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
||||
ok(rc==DS_OK && primary!=NULL,
|
||||
"IDirectSound8_CreateSoundBuffer() failed to create a primary buffer "
|
||||
"%08x\n",rc);
|
||||
|
||||
if (rc==DS_OK && primary!=NULL) {
|
||||
for (f=0;f<NB_FORMATS;f++) {
|
||||
/* We must call SetCooperativeLevel to be allowed to call
|
||||
* SetFormat */
|
||||
/* DSOUND: Setting DirectSound cooperative level to
|
||||
* DSSCL_PRIORITY */
|
||||
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
||||
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
||||
if (rc!=DS_OK)
|
||||
goto EXIT;
|
||||
|
||||
init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
|
||||
formats[f][2]);
|
||||
wfx2=wfx;
|
||||
rc=IDirectSoundBuffer_SetFormat(primary,&wfx);
|
||||
ok(rc==DS_OK
|
||||
|| rc==DSERR_INVALIDPARAM, /* 2003 */
|
||||
"IDirectSoundBuffer_SetFormat(%s) failed: %08x\n",
|
||||
format_string(&wfx), rc);
|
||||
|
||||
/* There is no guarantee that SetFormat will actually change the
|
||||
* 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);
|
||||
ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %08x\n", rc);
|
||||
if (rc==DS_OK &&
|
||||
(wfx.wFormatTag!=wfx2.wFormatTag ||
|
||||
wfx.nSamplesPerSec!=wfx2.nSamplesPerSec ||
|
||||
wfx.wBitsPerSample!=wfx2.wBitsPerSample ||
|
||||
wfx.nChannels!=wfx2.nChannels)) {
|
||||
trace("Requested primary format tag=0x%04x %dx%dx%d "
|
||||
"avg.B/s=%d align=%d\n",
|
||||
wfx2.wFormatTag,wfx2.nSamplesPerSec,wfx2.wBitsPerSample,
|
||||
wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign);
|
||||
trace("Got tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
|
||||
wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
|
||||
wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
|
||||
}
|
||||
|
||||
/* Set the CooperativeLevel back to normal */
|
||||
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
||||
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
||||
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
||||
|
||||
init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2);
|
||||
|
||||
secondary=NULL;
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
|
||||
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
|
||||
wfx.nBlockAlign);
|
||||
bufdesc.lpwfxFormat=&wfx2;
|
||||
if (winetest_interactive) {
|
||||
trace(" Testing a primary buffer at %dx%dx%d with a "
|
||||
"secondary buffer at %dx%dx%d\n",
|
||||
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
|
||||
wfx2.nSamplesPerSec,wfx2.wBitsPerSample,wfx2.nChannels);
|
||||
}
|
||||
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
||||
ok(rc==DS_OK && secondary!=NULL,
|
||||
"IDirectSound_CreateSoundBuffer() failed to create a secondary "
|
||||
"buffer %08x\n",rc);
|
||||
|
||||
if (rc==DS_OK && secondary!=NULL) {
|
||||
test_buffer8(dso,&secondary,0,FALSE,0,FALSE,0,
|
||||
winetest_interactive,1.0,0,NULL,0,0);
|
||||
|
||||
ref=IDirectSoundBuffer_Release(secondary);
|
||||
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
|
||||
"should have 0\n",ref);
|
||||
}
|
||||
}
|
||||
|
||||
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=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
||||
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
||||
|
||||
EXIT:
|
||||
ref=IDirectSound8_Release(dso);
|
||||
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
|
||||
if (ref!=0)
|
||||
return DSERR_GENERIC;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static HRESULT test_secondary8(LPGUID lpGuid)
|
||||
{
|
||||
HRESULT rc;
|
||||
LPDIRECTSOUND8 dso=NULL;
|
||||
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
|
||||
DSBUFFERDESC bufdesc;
|
||||
DSCAPS dscaps;
|
||||
WAVEFORMATEX wfx, wfx1;
|
||||
DWORD f;
|
||||
int ref;
|
||||
|
||||
/* Create the DirectSound object */
|
||||
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
|
||||
"DirectSoundCreate8() failed: %08x\n",rc);
|
||||
if (rc!=DS_OK)
|
||||
return rc;
|
||||
|
||||
/* Get the device capabilities */
|
||||
ZeroMemory(&dscaps, sizeof(dscaps));
|
||||
dscaps.dwSize=sizeof(dscaps);
|
||||
rc=IDirectSound8_GetCaps(dso,&dscaps);
|
||||
ok(rc==DS_OK,"IDirectSound8_GetCaps() failed: %08x\n",rc);
|
||||
if (rc!=DS_OK)
|
||||
goto EXIT;
|
||||
|
||||
/* We must call SetCooperativeLevel before creating primary buffer */
|
||||
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
|
||||
rc=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
||||
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
||||
if (rc!=DS_OK)
|
||||
goto EXIT;
|
||||
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
||||
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
||||
ok(rc==DS_OK && primary!=NULL,
|
||||
"IDirectSound8_CreateSoundBuffer() failed to create a primary buffer "
|
||||
"%08x\n",rc);
|
||||
|
||||
if (rc==DS_OK && primary!=NULL) {
|
||||
rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
|
||||
ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %08x\n", rc);
|
||||
if (rc!=DS_OK)
|
||||
goto EXIT1;
|
||||
|
||||
for (f=0;f<NB_FORMATS;f++) {
|
||||
WAVEFORMATEXTENSIBLE wfxe;
|
||||
init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
|
||||
formats[f][2]);
|
||||
secondary=NULL;
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
|
||||
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
|
||||
wfx.nBlockAlign);
|
||||
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_CreateSoundBuffer() "
|
||||
"should have returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
||||
if (rc==DS_OK && secondary!=NULL)
|
||||
IDirectSoundBuffer_Release(secondary);
|
||||
|
||||
secondary=NULL;
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
|
||||
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
|
||||
wfx.nBlockAlign);
|
||||
bufdesc.lpwfxFormat=&wfx;
|
||||
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
||||
if (wfx.wBitsPerSample != 8 && wfx.wBitsPerSample != 16)
|
||||
ok(((rc == DSERR_CONTROLUNAVAIL || rc == DSERR_INVALIDCALL || rc == DSERR_INVALIDPARAM /* 2003 */) && !secondary)
|
||||
|| rc == DS_OK, /* driver dependent? */
|
||||
"IDirectSound_CreateSoundBuffer() "
|
||||
"should have returned (DSERR_CONTROLUNAVAIL or DSERR_INVALIDCALL) "
|
||||
"and NULL, returned: %08x %p\n", rc, secondary);
|
||||
else
|
||||
ok(rc==DS_OK && secondary!=NULL,
|
||||
"IDirectSound_CreateSoundBuffer() failed to create a secondary "
|
||||
"buffer %08x\n",rc);
|
||||
if (secondary)
|
||||
IDirectSoundBuffer_Release(secondary);
|
||||
secondary = NULL;
|
||||
|
||||
bufdesc.lpwfxFormat=(WAVEFORMATEX*)&wfxe;
|
||||
wfxe.Format = wfx;
|
||||
wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
|
||||
wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
|
||||
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);
|
||||
ok(rc==DSERR_INVALIDPARAM && !secondary,
|
||||
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
||||
rc, secondary);
|
||||
if (secondary)
|
||||
{
|
||||
IDirectSoundBuffer_Release(secondary);
|
||||
secondary=NULL;
|
||||
}
|
||||
|
||||
wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx) + 1;
|
||||
|
||||
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
||||
ok(((rc==DSERR_CONTROLUNAVAIL || rc==DSERR_INVALIDCALL /* 2003 */) && !secondary)
|
||||
|| rc==DS_OK /* driver dependent? */,
|
||||
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
||||
rc, secondary);
|
||||
if (secondary)
|
||||
{
|
||||
IDirectSoundBuffer_Release(secondary);
|
||||
secondary=NULL;
|
||||
}
|
||||
|
||||
wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx);
|
||||
wfxe.SubFormat = GUID_NULL;
|
||||
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
||||
ok((rc==DSERR_INVALIDPARAM || rc==DSERR_INVALIDCALL) && !secondary,
|
||||
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
||||
rc, secondary);
|
||||
if (secondary)
|
||||
{
|
||||
IDirectSoundBuffer_Release(secondary);
|
||||
secondary=NULL;
|
||||
}
|
||||
|
||||
wfxe.Format.cbSize = sizeof(wfxe);
|
||||
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
||||
ok((rc==DSERR_CONTROLUNAVAIL || rc==DSERR_INVALIDCALL || rc==E_INVALIDARG) && !secondary,
|
||||
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
||||
rc, secondary);
|
||||
if (secondary)
|
||||
{
|
||||
IDirectSoundBuffer_Release(secondary);
|
||||
secondary=NULL;
|
||||
}
|
||||
|
||||
wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
|
||||
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
||||
ok(rc==DS_OK && secondary,
|
||||
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
||||
rc, secondary);
|
||||
if (secondary)
|
||||
{
|
||||
IDirectSoundBuffer_Release(secondary);
|
||||
secondary=NULL;
|
||||
}
|
||||
|
||||
wfxe.Format.cbSize = sizeof(wfxe) + 1;
|
||||
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
||||
ok(((rc==DSERR_CONTROLUNAVAIL || rc==DSERR_INVALIDCALL /* 2003 */) && !secondary)
|
||||
|| rc==DS_OK /* driver dependent? */,
|
||||
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
||||
rc, secondary);
|
||||
if (secondary)
|
||||
{
|
||||
IDirectSoundBuffer_Release(secondary);
|
||||
secondary=NULL;
|
||||
}
|
||||
|
||||
wfxe.Format.cbSize = sizeof(wfxe) - sizeof(wfx);
|
||||
++wfxe.Samples.wValidBitsPerSample;
|
||||
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM && !secondary,
|
||||
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
||||
rc, secondary);
|
||||
if (secondary)
|
||||
{
|
||||
IDirectSoundBuffer_Release(secondary);
|
||||
secondary=NULL;
|
||||
}
|
||||
--wfxe.Samples.wValidBitsPerSample;
|
||||
|
||||
wfxe.Samples.wValidBitsPerSample = 0;
|
||||
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
||||
ok(rc==DS_OK && secondary,
|
||||
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
|
||||
rc, secondary);
|
||||
if (secondary)
|
||||
{
|
||||
IDirectSoundBuffer_Release(secondary);
|
||||
secondary=NULL;
|
||||
}
|
||||
wfxe.Samples.wValidBitsPerSample = wfxe.Format.wBitsPerSample;
|
||||
|
||||
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
||||
ok(rc==DS_OK && secondary!=NULL,
|
||||
"IDirectSound_CreateSoundBuffer() failed to create a secondary "
|
||||
"buffer %08x\n",rc);
|
||||
|
||||
if (rc==DS_OK && secondary!=NULL) {
|
||||
if (winetest_interactive) {
|
||||
trace(" Testing a secondary buffer at %dx%dx%d "
|
||||
"with a primary buffer at %dx%dx%d\n",
|
||||
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
|
||||
wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
|
||||
}
|
||||
test_buffer8(dso,&secondary,0,FALSE,0,FALSE,0,
|
||||
winetest_interactive,1.0,0,NULL,0,0);
|
||||
|
||||
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=IDirectSound8_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
||||
ok(rc==DS_OK,"IDirectSound8_SetCooperativeLevel() failed: %08x\n", rc);
|
||||
|
||||
EXIT:
|
||||
ref=IDirectSound8_Release(dso);
|
||||
ok(ref==0,"IDirectSound8_Release() has %d references, should have 0\n",ref);
|
||||
if (ref!=0)
|
||||
return DSERR_GENERIC;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
|
||||
LPCSTR lpcstrModule, LPVOID lpContext)
|
||||
{
|
||||
HRESULT rc;
|
||||
trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
|
||||
rc = test_dsound8(lpGuid);
|
||||
if (rc == DSERR_NODRIVER)
|
||||
trace(" No Driver\n");
|
||||
else if (rc == DSERR_ALLOCATED)
|
||||
trace(" Already In Use\n");
|
||||
else if (rc == E_FAIL)
|
||||
trace(" No Device\n");
|
||||
else {
|
||||
test_primary8(lpGuid);
|
||||
test_primary_secondary8(lpGuid);
|
||||
test_secondary8(lpGuid);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void dsound8_tests(void)
|
||||
{
|
||||
HRESULT rc;
|
||||
rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
|
||||
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc);
|
||||
}
|
||||
|
||||
|
||||
START_TEST(dsound8)
|
||||
{
|
||||
HMODULE hDsound;
|
||||
|
||||
CoInitialize(NULL);
|
||||
|
||||
hDsound = LoadLibrary("dsound.dll");
|
||||
if (hDsound)
|
||||
{
|
||||
|
||||
pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
|
||||
"DirectSoundEnumerateA");
|
||||
pDirectSoundCreate8 = (void*)GetProcAddress(hDsound,
|
||||
"DirectSoundCreate8");
|
||||
if (pDirectSoundCreate8)
|
||||
{
|
||||
IDirectSound8_tests();
|
||||
dsound8_tests();
|
||||
}
|
||||
else
|
||||
skip("dsound8 test skipped\n");
|
||||
|
||||
FreeLibrary(hDsound);
|
||||
}
|
||||
else
|
||||
skip("dsound.dll not found!\n");
|
||||
|
||||
CoUninitialize();
|
||||
}
|
88
rostests/winetests/dsound/dsound_test.h
Normal file
88
rostests/winetests/dsound/dsound_test.h
Normal file
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Unit tests for dsound functions
|
||||
*
|
||||
* Copyright (c) 2004 Francois Gouget
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
static const unsigned int formats[][4]={
|
||||
{ 8000, 8, 1, 0 },
|
||||
{ 8000, 8, 2, 0 },
|
||||
{ 8000, 16, 1, 0 },
|
||||
{ 8000, 16, 2, 0 },
|
||||
{ 8000, 24, 1, 0 },
|
||||
{ 8000, 24, 2, 0 },
|
||||
{ 8000, 32, 1, 0 },
|
||||
{ 8000, 32, 2, 0 },
|
||||
{11025, 8, 1, WAVE_FORMAT_1M08 },
|
||||
{11025, 8, 2, WAVE_FORMAT_1S08 },
|
||||
{11025, 16, 1, WAVE_FORMAT_1M16 },
|
||||
{11025, 16, 2, WAVE_FORMAT_1S16 },
|
||||
{11025, 24, 1, 0 },
|
||||
{11025, 24, 2, 0 },
|
||||
{11025, 32, 1, 0 },
|
||||
{11025, 32, 2, 0 },
|
||||
{22050, 8, 1, WAVE_FORMAT_2M08 },
|
||||
{22050, 8, 2, WAVE_FORMAT_2S08 },
|
||||
{22050, 16, 1, WAVE_FORMAT_2M16 },
|
||||
{22050, 16, 2, WAVE_FORMAT_2S16 },
|
||||
{22050, 24, 1, 0 },
|
||||
{22050, 24, 2, 0 },
|
||||
{22050, 32, 1, 0 },
|
||||
{22050, 32, 2, 0 },
|
||||
{44100, 8, 1, WAVE_FORMAT_4M08 },
|
||||
{44100, 8, 2, WAVE_FORMAT_4S08 },
|
||||
{44100, 16, 1, WAVE_FORMAT_4M16 },
|
||||
{44100, 16, 2, WAVE_FORMAT_4S16 },
|
||||
{44100, 24, 1, 0 },
|
||||
{44100, 24, 2, 0 },
|
||||
{44100, 32, 1, 0 },
|
||||
{44100, 32, 2, 0 },
|
||||
{48000, 8, 1, WAVE_FORMAT_48M08 },
|
||||
{48000, 8, 2, WAVE_FORMAT_48S08 },
|
||||
{48000, 16, 1, WAVE_FORMAT_48M16 },
|
||||
{48000, 16, 2, WAVE_FORMAT_48S16 },
|
||||
{48000, 24, 1, 0 },
|
||||
{48000, 24, 2, 0 },
|
||||
{48000, 32, 1, 0 },
|
||||
{48000, 32, 2, 0 },
|
||||
{96000, 8, 1, WAVE_FORMAT_96M08 },
|
||||
{96000, 8, 2, WAVE_FORMAT_96S08 },
|
||||
{96000, 16, 1, WAVE_FORMAT_96M16 },
|
||||
{96000, 16, 2, WAVE_FORMAT_96S16 },
|
||||
{96000, 24, 1, 0 },
|
||||
{96000, 24, 2, 0 },
|
||||
{96000, 32, 1, 0 },
|
||||
{96000, 32, 2, 0 }
|
||||
};
|
||||
#define NB_FORMATS (sizeof(formats)/sizeof(*formats))
|
||||
|
||||
/* The time slice determines how often we will service the buffer */
|
||||
#define TIME_SLICE 31
|
||||
#define BUFFER_LEN 400
|
||||
|
||||
extern char* wave_generate_la(WAVEFORMATEX*,double,DWORD*);
|
||||
extern HWND get_hwnd(void);
|
||||
extern void init_format(WAVEFORMATEX*,int,int,int,int);
|
||||
extern void test_buffer(LPDIRECTSOUND,LPDIRECTSOUNDBUFFER*,
|
||||
BOOL,BOOL,LONG,BOOL,LONG,BOOL,double,BOOL,
|
||||
LPDIRECTSOUND3DLISTENER,BOOL,BOOL,BOOL,DWORD);
|
||||
extern void test_buffer8(LPDIRECTSOUND8,LPDIRECTSOUNDBUFFER*,
|
||||
BOOL,BOOL,LONG,BOOL,LONG,BOOL,double,BOOL,
|
||||
LPDIRECTSOUND3DLISTENER,BOOL,BOOL);
|
||||
extern const char * getDSBCAPS(DWORD xmask);
|
||||
extern int align(int length, int align);
|
||||
extern const char * format_string(const WAVEFORMATEX* wfx);
|
248
rostests/winetests/dsound/duplex.c
Normal file
248
rostests/winetests/dsound/duplex.c
Normal file
|
@ -0,0 +1,248 @@
|
|||
/*
|
||||
* Unit tests for duplex functions
|
||||
*
|
||||
* Copyright (c) 2006 Robert Reif
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "dsound.h"
|
||||
#include "mmreg.h"
|
||||
#include "dsconf.h"
|
||||
|
||||
#include "dsound_test.h"
|
||||
|
||||
static HRESULT (WINAPI *pDirectSoundFullDuplexCreate)(LPCGUID, LPCGUID,
|
||||
LPCDSCBUFFERDESC, LPCDSBUFFERDESC, HWND, DWORD, LPDIRECTSOUNDFULLDUPLEX *,
|
||||
LPDIRECTSOUNDCAPTUREBUFFER8*, LPDIRECTSOUNDBUFFER8*, LPUNKNOWN)=NULL;
|
||||
|
||||
static void IDirectSoundFullDuplex_test(LPDIRECTSOUNDFULLDUPLEX dsfdo,
|
||||
BOOL initialized, LPCGUID lpGuidCapture,
|
||||
LPCGUID lpGuidRender)
|
||||
{
|
||||
HRESULT rc;
|
||||
int ref;
|
||||
IUnknown * unknown;
|
||||
IDirectSound * ds;
|
||||
IDirectSound8 * ds8;
|
||||
IDirectSoundCapture * dsc;
|
||||
IDirectSoundFullDuplex * dsfd;
|
||||
|
||||
/* Try to Query for objects */
|
||||
rc=IDirectSoundFullDuplex_QueryInterface(dsfdo,&IID_IUnknown,(LPVOID*)&unknown);
|
||||
ok(rc==DS_OK,"IDirectSoundFullDuplex_QueryInterface(IID_IUnknown) failed: %08x\n", rc);
|
||||
if (rc==DS_OK) {
|
||||
ref=IDirectSoundFullDuplex_Release(unknown);
|
||||
ok(ref==0, "IDirectSoundFullDuplex_Release() has %d references, "
|
||||
"should have 0\n", ref);
|
||||
}
|
||||
|
||||
rc=IDirectSoundFullDuplex_QueryInterface(dsfdo,&IID_IDirectSound,(LPVOID*)&ds);
|
||||
ok(rc==(initialized?DS_OK:E_NOINTERFACE),"IDirectSoundFullDuplex_QueryInterface(IID_IDirectSound) failed: %08x\n", rc);
|
||||
if (rc==DS_OK) {
|
||||
ref=IDirectSound_Release(ds);
|
||||
ok(ref==0, "IDirectSound_Release() has %d references, "
|
||||
"should have 0\n", ref);
|
||||
}
|
||||
|
||||
rc=IDirectSoundFullDuplex_QueryInterface(dsfdo,&IID_IDirectSound8,(LPVOID*)&ds8);
|
||||
ok(rc==(initialized?DS_OK:E_NOINTERFACE),"IDirectSoundFullDuplex_QueryInterface(IID_IDirectSound8) "
|
||||
"failed: %08x\n",rc);
|
||||
if (rc==DS_OK) {
|
||||
IDirectSoundFullDuplex * dsfd1;
|
||||
rc=IDirectSound8_QueryInterface(ds8,&IID_IDirectSoundFullDuplex,(LPVOID*)&dsfd1);
|
||||
ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IDirectSoundFullDuplex) "
|
||||
"failed: %08x\n",rc);
|
||||
if (rc==DS_OK) {
|
||||
ref=IDirectSoundFullDuplex_Release(dsfd1);
|
||||
ok(ref==1, "IDirectSoundFullDuplex_Release() has %d references, "
|
||||
"should have 1\n", ref);
|
||||
}
|
||||
ref=IDirectSound8_Release(ds8);
|
||||
ok(ref==0, "IDirectSound8_Release() has %d references, "
|
||||
"should have 0\n", ref);
|
||||
}
|
||||
|
||||
rc=IDirectSoundFullDuplex_QueryInterface(dsfdo,&IID_IDirectSoundCapture,(LPVOID*)&dsc);
|
||||
ok(rc==(initialized?DS_OK:E_NOINTERFACE),"IDirectSoundFullDuplex_QueryInterface(IID_IDirectSoundCapture) "
|
||||
"failed: %08x\n",rc);
|
||||
if (rc==DS_OK) {
|
||||
ref=IDirectSoundCapture_Release(dsc);
|
||||
ok(ref==0, "IDirectSoundCapture_Release() has %d references, "
|
||||
"should have 0\n", ref);
|
||||
}
|
||||
|
||||
rc=IDirectSoundFullDuplex_QueryInterface(dsfdo,&IID_IDirectSoundFullDuplex,(LPVOID*)&dsfd);
|
||||
ok(rc==DS_OK,"IDirectSoundFullDuplex_QueryInterface(IID_IDirectSoundFullDuplex) "
|
||||
"failed: %08x\n",rc);
|
||||
if (rc==DS_OK) {
|
||||
ok (dsfdo==dsfd, "different interfaces\n");
|
||||
ref=IDirectSound8_Release(dsfd);
|
||||
}
|
||||
|
||||
ref=IDirectSoundFullDuplex_Release(dsfdo);
|
||||
ok(ref==0, "IDirectSoundFullDuplex_Release() has %d references, "
|
||||
"should have 0\n", ref);
|
||||
}
|
||||
|
||||
static void IDirectSoundFullDuplex_tests(void)
|
||||
{
|
||||
HRESULT rc;
|
||||
LPDIRECTSOUNDFULLDUPLEX dsfdo = NULL;
|
||||
DSCBUFFERDESC DSCBufferDesc;
|
||||
DSBUFFERDESC DSBufferDesc;
|
||||
LPDIRECTSOUNDCAPTUREBUFFER8 pDSCBuffer8;
|
||||
LPDIRECTSOUNDBUFFER8 pDSBuffer8;
|
||||
WAVEFORMATEX wfex;
|
||||
|
||||
trace("Testing IDirectSoundFullDuplex\n");
|
||||
|
||||
/* try the COM class factory method of creation with no devices specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL,
|
||||
CLSCTX_INPROC_SERVER, &IID_IDirectSoundFullDuplex,
|
||||
(void**)&dsfdo);
|
||||
ok(rc==S_OK||rc==REGDB_E_CLASSNOTREG||rc==CLASS_E_CLASSNOTAVAILABLE,
|
||||
"CoCreateInstance(CLSID_DirectSoundFullDuplex) failed: 0x%08x\n", rc);
|
||||
if (rc==REGDB_E_CLASSNOTREG) {
|
||||
trace(" Class Not Registered\n");
|
||||
return;
|
||||
} else if (rc==CLASS_E_CLASSNOTAVAILABLE) {
|
||||
trace(" Class Not Available\n");
|
||||
return;
|
||||
}
|
||||
if (dsfdo)
|
||||
IDirectSoundFullDuplex_test(dsfdo, FALSE, NULL, NULL);
|
||||
|
||||
/* try the COM class factory method of creation with default devices
|
||||
* specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL,
|
||||
CLSCTX_INPROC_SERVER, &IID_IDirectSoundFullDuplex,
|
||||
(void**)&dsfdo);
|
||||
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundFullDuplex) failed: 0x%08x\n", rc);
|
||||
if (dsfdo)
|
||||
IDirectSoundFullDuplex_test(dsfdo, FALSE, &DSDEVID_DefaultCapture,
|
||||
&DSDEVID_DefaultPlayback);
|
||||
|
||||
/* try the COM class factory method of creation with default voice
|
||||
* devices specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL,
|
||||
CLSCTX_INPROC_SERVER, &IID_IDirectSoundFullDuplex,
|
||||
(void**)&dsfdo);
|
||||
ok(rc==S_OK,"CoCreateInstance(CLSID_DirectSoundFullDuplex) failed: 0x%08x\n", rc);
|
||||
if (dsfdo)
|
||||
IDirectSoundFullDuplex_test(dsfdo, FALSE, &DSDEVID_DefaultVoiceCapture,
|
||||
&DSDEVID_DefaultVoicePlayback);
|
||||
|
||||
/* try the COM class factory method of creation with a bad
|
||||
* IID specified */
|
||||
rc=CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL,
|
||||
CLSCTX_INPROC_SERVER, &CLSID_DirectSoundPrivate,
|
||||
(void**)&dsfdo);
|
||||
ok(rc==E_NOINTERFACE,
|
||||
"CoCreateInstance(CLSID_DirectSoundFullDuplex,CLSID_DirectSoundPrivate) "
|
||||
"should have failed: 0x%08x\n", rc);
|
||||
|
||||
ZeroMemory(&wfex, sizeof(wfex));
|
||||
wfex.wFormatTag = WAVE_FORMAT_PCM;
|
||||
wfex.nChannels = 1;
|
||||
wfex.nSamplesPerSec = 8000;
|
||||
wfex.wBitsPerSample = 16;
|
||||
wfex.nBlockAlign = (wfex.wBitsPerSample * wfex.nChannels) / 8;
|
||||
wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign;
|
||||
|
||||
ZeroMemory(&DSCBufferDesc, sizeof(DSCBufferDesc));
|
||||
DSCBufferDesc.dwSize = sizeof(DSCBufferDesc);
|
||||
DSCBufferDesc.dwFlags = DSCBCAPS_WAVEMAPPED;
|
||||
DSCBufferDesc.dwBufferBytes = 8192;
|
||||
DSCBufferDesc.lpwfxFormat = &wfex;
|
||||
|
||||
ZeroMemory(&DSBufferDesc, sizeof(DSBufferDesc));
|
||||
DSBufferDesc.dwSize = sizeof(DSBufferDesc);
|
||||
DSBufferDesc.dwFlags = DSBCAPS_GLOBALFOCUS;
|
||||
DSBufferDesc.dwBufferBytes = 8192;
|
||||
DSBufferDesc.lpwfxFormat = &wfex;
|
||||
|
||||
/* try with no device specified */
|
||||
rc=pDirectSoundFullDuplexCreate(NULL,NULL,&DSCBufferDesc,&DSBufferDesc,
|
||||
get_hwnd(),DSSCL_EXCLUSIVE ,&dsfdo,&pDSCBuffer8,
|
||||
&pDSBuffer8,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL||rc==DSERR_INVALIDCALL,
|
||||
"DirectSoundFullDuplexCreate(NULL,NULL) failed: %08x\n",rc);
|
||||
if (rc==S_OK && dsfdo)
|
||||
IDirectSoundFullDuplex_test(dsfdo, TRUE, NULL, NULL);
|
||||
|
||||
/* try with default devices specified */
|
||||
rc=pDirectSoundFullDuplexCreate(&DSDEVID_DefaultCapture,
|
||||
&DSDEVID_DefaultPlayback,&DSCBufferDesc,
|
||||
&DSBufferDesc,get_hwnd(),DSSCL_EXCLUSIVE,&dsfdo,
|
||||
&pDSCBuffer8,&pDSBuffer8,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL||rc==DSERR_INVALIDCALL,
|
||||
"DirectSoundFullDuplexCreate(DSDEVID_DefaultCapture,"
|
||||
"DSDEVID_DefaultPlayback) failed: %08x\n", rc);
|
||||
if (rc==DS_OK && dsfdo)
|
||||
IDirectSoundFullDuplex_test(dsfdo, TRUE, NULL, NULL);
|
||||
|
||||
/* try with default voice devices specified */
|
||||
rc=pDirectSoundFullDuplexCreate(&DSDEVID_DefaultVoiceCapture,
|
||||
&DSDEVID_DefaultVoicePlayback,
|
||||
&DSCBufferDesc,&DSBufferDesc,get_hwnd(),DSSCL_EXCLUSIVE,
|
||||
&dsfdo,&pDSCBuffer8,&pDSBuffer8,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL||rc==DSERR_INVALIDCALL,
|
||||
"DirectSoundFullDuplexCreate(DSDEVID_DefaultVoiceCapture,"
|
||||
"DSDEVID_DefaultVoicePlayback) failed: %08x\n", rc);
|
||||
if (rc==DS_OK && dsfdo)
|
||||
IDirectSoundFullDuplex_test(dsfdo, TRUE, NULL, NULL);
|
||||
|
||||
/* try with bad devices specified */
|
||||
rc=pDirectSoundFullDuplexCreate(&DSDEVID_DefaultVoicePlayback,
|
||||
&DSDEVID_DefaultVoiceCapture,
|
||||
&DSCBufferDesc,&DSBufferDesc,get_hwnd(),DSSCL_EXCLUSIVE,
|
||||
&dsfdo,&pDSCBuffer8,&pDSBuffer8,NULL);
|
||||
ok(rc==DSERR_NODRIVER||rc==DSERR_INVALIDCALL,
|
||||
"DirectSoundFullDuplexCreate(DSDEVID_DefaultVoicePlayback,"
|
||||
"DSDEVID_DefaultVoiceCapture) should have failed: %08x\n", rc);
|
||||
if (rc==DS_OK && dsfdo)
|
||||
IDirectSoundFullDuplex_Release(dsfdo);
|
||||
}
|
||||
|
||||
START_TEST(duplex)
|
||||
{
|
||||
HMODULE hDsound;
|
||||
|
||||
CoInitialize(NULL);
|
||||
|
||||
hDsound = LoadLibrary("dsound.dll");
|
||||
if (hDsound)
|
||||
{
|
||||
|
||||
pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound,
|
||||
"DirectSoundFullDuplexCreate");
|
||||
if (pDirectSoundFullDuplexCreate)
|
||||
IDirectSoundFullDuplex_tests();
|
||||
else
|
||||
skip("duplex test skipped\n");
|
||||
|
||||
FreeLibrary(hDsound);
|
||||
}
|
||||
else
|
||||
skip("dsound.dll not found!\n");
|
||||
|
||||
CoUninitialize();
|
||||
}
|
748
rostests/winetests/dsound/propset.c
Normal file
748
rostests/winetests/dsound/propset.c
Normal file
|
@ -0,0 +1,748 @@
|
|||
/*
|
||||
* Unit tests for CLSID_DirectSoundPrivate property set functions
|
||||
* (used by dxdiag)
|
||||
*
|
||||
* Copyright (c) 2003 Robert Reif
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#define COBJMACROS
|
||||
#include <windows.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
#include "dsound.h"
|
||||
#include "dsconf.h"
|
||||
|
||||
#include "dsound_test.h"
|
||||
|
||||
#ifndef DSBCAPS_CTRLDEFAULT
|
||||
#define DSBCAPS_CTRLDEFAULT \
|
||||
DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME
|
||||
#endif
|
||||
|
||||
#include "initguid.h"
|
||||
|
||||
DEFINE_GUID(DSPROPSETID_VoiceManager,
|
||||
0x62A69BAE,0xDF9D,0x11D1,0x99,0xA6,0x00,0xC0,0x4F,0xC9,0x9D,0x46);
|
||||
DEFINE_GUID(DSPROPSETID_EAX20_ListenerProperties,
|
||||
0x306a6a8,0xb224,0x11d2,0x99,0xe5,0x0,0x0,0xe8,0xd8,0xc7,0x22);
|
||||
DEFINE_GUID(DSPROPSETID_EAX20_BufferProperties,
|
||||
0x306a6a7,0xb224,0x11d2,0x99,0xe5,0x0,0x0,0xe8,0xd8,0xc7,0x22);
|
||||
DEFINE_GUID(DSPROPSETID_I3DL2_ListenerProperties,
|
||||
0xDA0F0520,0x300A,0x11D3,0x8A,0x2B,0x00,0x60,0x97,0x0D,0xB0,0x11);
|
||||
DEFINE_GUID(DSPROPSETID_I3DL2_BufferProperties,
|
||||
0xDA0F0521,0x300A,0x11D3,0x8A,0x2B,0x00,0x60,0x97,0x0D,0xB0,0x11);
|
||||
DEFINE_GUID(DSPROPSETID_ZOOMFX_BufferProperties,
|
||||
0xCD5368E0,0x3450,0x11D3,0x8B,0x6E,0x00,0x10,0x5A,0x9B,0x7B,0xBC);
|
||||
|
||||
static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
|
||||
static HRESULT (WINAPI *pDllGetClassObject)(REFCLSID,REFIID,LPVOID*)=NULL;
|
||||
static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID,LPDIRECTSOUND*,
|
||||
LPUNKNOWN)=NULL;
|
||||
static HRESULT (WINAPI *pDirectSoundCreate8)(LPCGUID,LPDIRECTSOUND8*,
|
||||
LPUNKNOWN)=NULL;
|
||||
static HRESULT (WINAPI *pDirectSoundCaptureCreate)(LPCGUID,
|
||||
LPDIRECTSOUNDCAPTURE*,LPUNKNOWN)=NULL;
|
||||
static HRESULT (WINAPI *pDirectSoundCaptureCreate8)(LPCGUID,
|
||||
LPDIRECTSOUNDCAPTURE8*,LPUNKNOWN)=NULL;
|
||||
static HRESULT (WINAPI *pDirectSoundFullDuplexCreate)(LPCGUID,LPCGUID,
|
||||
LPCDSCBUFFERDESC,LPCDSBUFFERDESC,HWND,DWORD,LPDIRECTSOUNDFULLDUPLEX*,
|
||||
LPDIRECTSOUNDCAPTUREBUFFER8*,LPDIRECTSOUNDBUFFER8*,LPUNKNOWN)=NULL;
|
||||
|
||||
static BOOL CALLBACK callback(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA data,
|
||||
LPVOID context)
|
||||
{
|
||||
trace(" found device:\n");
|
||||
trace(" Type: %s\n",
|
||||
data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
|
||||
data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
|
||||
data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
|
||||
trace(" DataFlow: %s\n",
|
||||
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
|
||||
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
|
||||
"Capture" : "Unknown");
|
||||
trace(" DeviceId: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
|
||||
data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
|
||||
data->DeviceId.Data4[0],data->DeviceId.Data4[1],
|
||||
data->DeviceId.Data4[2],data->DeviceId.Data4[3],
|
||||
data->DeviceId.Data4[4],data->DeviceId.Data4[5],
|
||||
data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
|
||||
trace(" Description: %s\n", data->Description);
|
||||
trace(" Module: %s\n", data->Module);
|
||||
trace(" Interface: %s\n", data->Interface);
|
||||
trace(" WaveDeviceId: %d\n", data->WaveDeviceId);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK callback1(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1_DATA data,
|
||||
LPVOID context)
|
||||
{
|
||||
char descriptionA[0x100];
|
||||
char moduleA[MAX_PATH];
|
||||
|
||||
trace(" found device:\n");
|
||||
trace(" Type: %s\n",
|
||||
data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
|
||||
data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
|
||||
data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
|
||||
trace(" DataFlow: %s\n",
|
||||
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
|
||||
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
|
||||
"Capture" : "Unknown");
|
||||
trace(" DeviceId: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
|
||||
data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
|
||||
data->DeviceId.Data4[0],data->DeviceId.Data4[1],
|
||||
data->DeviceId.Data4[2],data->DeviceId.Data4[3],
|
||||
data->DeviceId.Data4[4],data->DeviceId.Data4[5],
|
||||
data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
|
||||
trace(" DescriptionA: %s\n", data->DescriptionA);
|
||||
WideCharToMultiByte(CP_ACP, 0, data->DescriptionW, -1, descriptionA, sizeof(descriptionA), NULL, NULL);
|
||||
trace(" DescriptionW: %s\n", descriptionA);
|
||||
trace(" ModuleA: %s\n", data->ModuleA);
|
||||
WideCharToMultiByte(CP_ACP, 0, data->ModuleW, -1, moduleA, sizeof(moduleA), NULL, NULL);
|
||||
trace(" ModuleW: %s\n", moduleA);
|
||||
trace(" WaveDeviceId: %d\n", data->WaveDeviceId);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK callbackA(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A_DATA data,
|
||||
LPVOID context)
|
||||
{
|
||||
trace(" found device:\n");
|
||||
trace(" Type: %s\n",
|
||||
data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
|
||||
data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
|
||||
data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
|
||||
trace(" DataFlow: %s\n",
|
||||
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
|
||||
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
|
||||
"Capture" : "Unknown");
|
||||
trace(" DeviceId: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
|
||||
data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
|
||||
data->DeviceId.Data4[0],data->DeviceId.Data4[1],
|
||||
data->DeviceId.Data4[2],data->DeviceId.Data4[3],
|
||||
data->DeviceId.Data4[4],data->DeviceId.Data4[5],
|
||||
data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
|
||||
trace(" Description: %s\n", data->Description);
|
||||
trace(" Module: %s\n", data->Module);
|
||||
trace(" Interface: %s\n", data->Interface);
|
||||
trace(" WaveDeviceId: %d\n", data->WaveDeviceId);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK callbackW(PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W_DATA data,
|
||||
LPVOID context)
|
||||
{
|
||||
char descriptionA[0x100];
|
||||
char moduleA[MAX_PATH];
|
||||
char interfaceA[MAX_PATH];
|
||||
|
||||
trace("found device:\n");
|
||||
trace("\tType: %s\n",
|
||||
data->Type == DIRECTSOUNDDEVICE_TYPE_EMULATED ? "Emulated" :
|
||||
data->Type == DIRECTSOUNDDEVICE_TYPE_VXD ? "VxD" :
|
||||
data->Type == DIRECTSOUNDDEVICE_TYPE_WDM ? "WDM" : "Unknown");
|
||||
trace("\tDataFlow: %s\n",
|
||||
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_RENDER ? "Render" :
|
||||
data->DataFlow == DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE ?
|
||||
"Capture" : "Unknown");
|
||||
trace("\tDeviceId: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
|
||||
data->DeviceId.Data1,data->DeviceId.Data2,data->DeviceId.Data3,
|
||||
data->DeviceId.Data4[0],data->DeviceId.Data4[1],
|
||||
data->DeviceId.Data4[2],data->DeviceId.Data4[3],
|
||||
data->DeviceId.Data4[4],data->DeviceId.Data4[5],
|
||||
data->DeviceId.Data4[6],data->DeviceId.Data4[7]);
|
||||
WideCharToMultiByte(CP_ACP, 0, data->Description, -1, descriptionA, sizeof(descriptionA), NULL, NULL);
|
||||
WideCharToMultiByte(CP_ACP, 0, data->Module, -1, moduleA, sizeof(moduleA), NULL, NULL);
|
||||
WideCharToMultiByte(CP_ACP, 0, data->Interface, -1, interfaceA, sizeof(interfaceA), NULL, NULL);
|
||||
trace("\tDescription: %s\n", descriptionA);
|
||||
trace("\tModule: %s\n", moduleA);
|
||||
trace("\tInterface: %s\n", interfaceA);
|
||||
trace("\tWaveDeviceId: %d\n", data->WaveDeviceId);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void propset_private_tests(void)
|
||||
{
|
||||
HRESULT rc;
|
||||
IClassFactory * pcf;
|
||||
IKsPropertySet * pps;
|
||||
ULONG support;
|
||||
|
||||
/* try direct sound first */
|
||||
/* DSOUND: Error: Invalid interface buffer */
|
||||
rc = (pDllGetClassObject)(&CLSID_DirectSound, &IID_IClassFactory, NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM,"DllGetClassObject(CLSID_DirectSound, "
|
||||
"IID_IClassFactory) should have returned DSERR_INVALIDPARAM, "
|
||||
"returned: %08x\n",rc);
|
||||
|
||||
rc = (pDllGetClassObject)(&CLSID_DirectSound, &IID_IDirectSound, (void **)(&pcf));
|
||||
ok(rc==E_NOINTERFACE,"DllGetClassObject(CLSID_DirectSound, "
|
||||
"IID_IDirectSound) should have returned E_NOINTERFACE, "
|
||||
"returned: %08x\n",rc);
|
||||
|
||||
rc = (pDllGetClassObject)(&CLSID_DirectSound, &IID_IUnknown, (void **)(&pcf));
|
||||
ok(rc==DS_OK,"DllGetClassObject(CLSID_DirectSound, "
|
||||
"IID_IUnknown) failed: %08x\n",rc);
|
||||
|
||||
rc = (pDllGetClassObject)(&CLSID_DirectSound, &IID_IClassFactory, (void **)(&pcf));
|
||||
ok(pcf!=0, "DllGetClassObject(CLSID_DirectSound, IID_IClassFactory) "
|
||||
"failed: %08x\n",rc);
|
||||
if (pcf==0)
|
||||
return;
|
||||
|
||||
/* direct sound doesn't have an IKsPropertySet */
|
||||
/* DSOUND: Error: Invalid interface buffer */
|
||||
rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
|
||||
NULL);
|
||||
ok(rc==DSERR_INVALIDPARAM, "CreateInstance(IID_IKsPropertySet) should have "
|
||||
"returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
||||
|
||||
rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
|
||||
(void **)(&pps));
|
||||
ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
|
||||
"returned E_NOINTERFACE, returned: %08x\n",rc);
|
||||
|
||||
/* and the direct sound 8 version */
|
||||
if (pDirectSoundCreate8) {
|
||||
rc = (pDllGetClassObject)(&CLSID_DirectSound8, &IID_IClassFactory, (void **)(&pcf));
|
||||
ok(pcf!=0, "DllGetClassObject(CLSID_DirectSound8, IID_IClassFactory) "
|
||||
"failed: %08x\n",rc);
|
||||
if (pcf==0)
|
||||
return;
|
||||
|
||||
/* direct sound 8 doesn't have an IKsPropertySet */
|
||||
rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
|
||||
(void **)(&pps));
|
||||
ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
|
||||
"returned E_NOINTERFACE, returned: %08x\n",rc);
|
||||
}
|
||||
|
||||
/* try direct sound capture next */
|
||||
if (pDirectSoundCaptureCreate) {
|
||||
rc = (pDllGetClassObject)(&CLSID_DirectSoundCapture, &IID_IClassFactory,
|
||||
(void **)(&pcf));
|
||||
ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundCapture, IID_IClassFactory) "
|
||||
"failed: %08x\n",rc);
|
||||
if (pcf==0)
|
||||
return;
|
||||
|
||||
/* direct sound capture doesn't have an IKsPropertySet */
|
||||
rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
|
||||
(void **)(&pps));
|
||||
ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
|
||||
"returned E_NOINTERFACE,returned: %08x\n",rc);
|
||||
}
|
||||
|
||||
/* and the direct sound capture 8 version */
|
||||
if (pDirectSoundCaptureCreate8) {
|
||||
rc = (pDllGetClassObject)(&CLSID_DirectSoundCapture8, &IID_IClassFactory,
|
||||
(void **)(&pcf));
|
||||
ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundCapture8, "
|
||||
"IID_IClassFactory) failed: %08x\n",rc);
|
||||
if (pcf==0)
|
||||
return;
|
||||
|
||||
/* direct sound capture 8 doesn't have an IKsPropertySet */
|
||||
rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
|
||||
(void **)(&pps));
|
||||
ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
|
||||
"returned E_NOINTERFACE, returned: %08x\n",rc);
|
||||
}
|
||||
|
||||
/* try direct sound full duplex next */
|
||||
if (pDirectSoundFullDuplexCreate) {
|
||||
rc = (pDllGetClassObject)(&CLSID_DirectSoundFullDuplex, &IID_IClassFactory,
|
||||
(void **)(&pcf));
|
||||
ok(pcf!=0, "DllGetClassObject(CLSID_DirectSoundFullDuplex, "
|
||||
"IID_IClassFactory) failed: %08x\n",rc);
|
||||
if (pcf==0)
|
||||
return;
|
||||
|
||||
/* direct sound full duplex doesn't have an IKsPropertySet */
|
||||
rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
|
||||
(void **)(&pps));
|
||||
ok(rc==E_NOINTERFACE, "CreateInstance(IID_IKsPropertySet) should have "
|
||||
"returned NOINTERFACE, returned: %08x\n",rc);
|
||||
}
|
||||
|
||||
/* try direct sound private last */
|
||||
rc = (pDllGetClassObject)(&CLSID_DirectSoundPrivate, &IID_IClassFactory,
|
||||
(void **)(&pcf));
|
||||
|
||||
/* some early versions of Direct Sound do not have this */
|
||||
if (rc==CLASS_E_CLASSNOTAVAILABLE)
|
||||
return;
|
||||
|
||||
/* direct sound private does have an IKsPropertySet */
|
||||
rc = IClassFactory_CreateInstance(pcf, NULL, &IID_IKsPropertySet,
|
||||
(void **)(&pps));
|
||||
ok(rc==DS_OK, "CreateInstance(IID_IKsPropertySet) failed: %08x\n",
|
||||
rc);
|
||||
if (rc!=DS_OK)
|
||||
return;
|
||||
|
||||
/* test generic DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION */
|
||||
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
|
||||
&support);
|
||||
ok(rc==DS_OK||rc==E_INVALIDARG,
|
||||
"QuerySupport(DSPROPSETID_DirectSoundDevice, "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION) failed: %08x\n",
|
||||
rc);
|
||||
if (rc!=DS_OK) {
|
||||
if (rc==E_INVALIDARG)
|
||||
trace(" Not Supported\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ok(support & KSPROPERTY_SUPPORT_GET,
|
||||
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
|
||||
"support = 0x%x\n",support);
|
||||
ok(!(support & KSPROPERTY_SUPPORT_SET),
|
||||
"Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION: "
|
||||
"support = 0x%x\n",support);
|
||||
|
||||
/* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1 */
|
||||
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1,
|
||||
&support);
|
||||
ok(rc==DS_OK||rc==E_INVALIDARG,
|
||||
"QuerySupport(DSPROPSETID_DirectSoundDevice, "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1) failed: %08x\n",
|
||||
rc);
|
||||
if (rc!=DS_OK) {
|
||||
if (rc==E_INVALIDARG)
|
||||
trace(" Not Supported\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ok(support & KSPROPERTY_SUPPORT_GET,
|
||||
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1: "
|
||||
"support = 0x%x\n",support);
|
||||
ok(!(support & KSPROPERTY_SUPPORT_SET),
|
||||
"Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1: "
|
||||
"support = 0x%x\n",support);
|
||||
|
||||
/* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A */
|
||||
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A,
|
||||
&support);
|
||||
ok(rc==DS_OK||rc==E_INVALIDARG,
|
||||
"QuerySupport(DSPROPSETID_DirectSoundDevice, "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A) failed: %08x\n",
|
||||
rc);
|
||||
if (rc!=DS_OK) {
|
||||
if (rc==E_INVALIDARG)
|
||||
trace(" Not Supported\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ok(support & KSPROPERTY_SUPPORT_GET,
|
||||
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A: "
|
||||
"support = 0x%x\n",support);
|
||||
ok(!(support & KSPROPERTY_SUPPORT_SET),
|
||||
"Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A: "
|
||||
"support = 0x%x\n",support);
|
||||
|
||||
/* test DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W */
|
||||
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W,
|
||||
&support);
|
||||
ok(rc==DS_OK||rc==E_INVALIDARG,
|
||||
"QuerySupport(DSPROPSETID_DirectSoundDevice, "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W) failed: %08x\n",
|
||||
rc);
|
||||
if (rc!=DS_OK) {
|
||||
if (rc==E_INVALIDARG)
|
||||
trace(" Not Supported\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ok(support & KSPROPERTY_SUPPORT_GET,
|
||||
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W: "
|
||||
"support = 0x%x\n",support);
|
||||
ok(!(support & KSPROPERTY_SUPPORT_SET),
|
||||
"Shouldn't be able to set DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W: "
|
||||
"support = 0x%x\n",support);
|
||||
|
||||
/* test generic DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING */
|
||||
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING, &support);
|
||||
ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING) failed: %08x\n",
|
||||
rc);
|
||||
if (rc!=DS_OK)
|
||||
return;
|
||||
|
||||
ok(support & KSPROPERTY_SUPPORT_GET,
|
||||
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: "
|
||||
"support = 0x%x\n",support);
|
||||
ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING: support = "
|
||||
"0x%x\n",support);
|
||||
|
||||
/* test DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A */
|
||||
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A, &support);
|
||||
ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A) failed: %08x\n",
|
||||
rc);
|
||||
if (rc!=DS_OK)
|
||||
return;
|
||||
|
||||
ok(support & KSPROPERTY_SUPPORT_GET,
|
||||
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A: "
|
||||
"support = 0x%x\n",support);
|
||||
ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A: support = "
|
||||
"0x%x\n",support);
|
||||
|
||||
/* test DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W */
|
||||
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W, &support);
|
||||
ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W) failed: %08x\n",
|
||||
rc);
|
||||
if (rc!=DS_OK)
|
||||
return;
|
||||
|
||||
ok(support & KSPROPERTY_SUPPORT_GET,
|
||||
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W: "
|
||||
"support = 0x%x\n",support);
|
||||
ok(!(support & KSPROPERTY_SUPPORT_SET), "Shouldn't be able to set "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W: support = "
|
||||
"0x%x\n",support);
|
||||
|
||||
/* test generic DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE */
|
||||
trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE ***\n");
|
||||
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
|
||||
&support);
|
||||
ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE) failed: %08x\n",
|
||||
rc);
|
||||
if (rc!=DS_OK)
|
||||
return;
|
||||
|
||||
ok(support & KSPROPERTY_SUPPORT_GET,
|
||||
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: "
|
||||
"support = 0x%x\n",support);
|
||||
ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE: support = 0x%x\n",support);
|
||||
|
||||
if (support & KSPROPERTY_SUPPORT_GET) {
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_DATA data;
|
||||
ULONG bytes;
|
||||
|
||||
data.Callback = callback;
|
||||
data.Context = 0;
|
||||
|
||||
rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE,
|
||||
NULL, 0, &data, sizeof(data), &bytes);
|
||||
ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
|
||||
}
|
||||
|
||||
/* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 */
|
||||
trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 ***\n");
|
||||
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1,
|
||||
&support);
|
||||
ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1) failed: %08x\n",
|
||||
rc);
|
||||
if (rc!=DS_OK)
|
||||
return;
|
||||
|
||||
ok(support & KSPROPERTY_SUPPORT_GET,
|
||||
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1: "
|
||||
"support = 0x%x\n",support);
|
||||
ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1: support = 0x%x\n",support);
|
||||
|
||||
if (support & KSPROPERTY_SUPPORT_GET) {
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1_DATA data;
|
||||
ULONG bytes;
|
||||
|
||||
data.Callback = callback1;
|
||||
data.Context = 0;
|
||||
|
||||
rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1,
|
||||
NULL, 0, &data, sizeof(data), &bytes);
|
||||
ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
|
||||
}
|
||||
|
||||
/* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A */
|
||||
trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A ***\n");
|
||||
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A,
|
||||
&support);
|
||||
ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A) failed: %08x\n",
|
||||
rc);
|
||||
if (rc!=DS_OK)
|
||||
return;
|
||||
|
||||
ok(support & KSPROPERTY_SUPPORT_GET,
|
||||
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A: "
|
||||
"support = 0x%x\n",support);
|
||||
ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A: support = 0x%x\n",support);
|
||||
|
||||
if (support & KSPROPERTY_SUPPORT_GET) {
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A_DATA data;
|
||||
ULONG bytes;
|
||||
|
||||
data.Callback = callbackA;
|
||||
data.Context = 0;
|
||||
|
||||
rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A,
|
||||
NULL, 0, &data, sizeof(data), &bytes);
|
||||
ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
|
||||
}
|
||||
|
||||
/* test DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W */
|
||||
trace("*** Testing DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W ***\n");
|
||||
rc = IKsPropertySet_QuerySupport(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W,
|
||||
&support);
|
||||
ok(rc==DS_OK, "QuerySupport(DSPROPSETID_DirectSoundDevice, "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W) failed: %08x\n",
|
||||
rc);
|
||||
if (rc!=DS_OK)
|
||||
return;
|
||||
|
||||
ok(support & KSPROPERTY_SUPPORT_GET,
|
||||
"Couldn't get DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W: "
|
||||
"support = 0x%x\n",support);
|
||||
ok(!(support & KSPROPERTY_SUPPORT_SET),"Shouldn't be able to set "
|
||||
"DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W: support = 0x%x\n",support);
|
||||
|
||||
if (support & KSPROPERTY_SUPPORT_GET) {
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W_DATA data;
|
||||
ULONG bytes;
|
||||
|
||||
data.Callback = callbackW;
|
||||
data.Context = 0;
|
||||
|
||||
rc = IKsPropertySet_Get(pps, &DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W,
|
||||
NULL, 0, &data, sizeof(data), &bytes);
|
||||
ok(rc==DS_OK, "Couldn't enumerate: 0x%x\n",rc);
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
|
||||
LPCSTR lpcstrModule, LPVOID lpContext)
|
||||
{
|
||||
HRESULT rc;
|
||||
LPDIRECTSOUND dso=NULL;
|
||||
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
|
||||
DSBUFFERDESC bufdesc;
|
||||
WAVEFORMATEX wfx;
|
||||
int ref;
|
||||
|
||||
trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
|
||||
|
||||
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
||||
"DirectSoundCreate() failed: %08x\n",rc);
|
||||
if (rc!=DS_OK) {
|
||||
if (rc==DSERR_NODRIVER)
|
||||
trace(" No Driver\n");
|
||||
else if (rc == DSERR_ALLOCATED)
|
||||
trace(" Already In Use\n");
|
||||
else if (rc == E_FAIL)
|
||||
trace(" No Device\n");
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
/* We must call SetCooperativeLevel before calling CreateSoundBuffer */
|
||||
/* 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;
|
||||
|
||||
/* Testing 3D buffers */
|
||||
primary=NULL;
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_LOCHARDWARE|DSBCAPS_CTRL3D;
|
||||
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
||||
ok((rc==DS_OK&&primary!=NULL)
|
||||
|| broken(rc==DSERR_INVALIDPARAM),
|
||||
"IDirectSound_CreateSoundBuffer() failed to "
|
||||
"create a hardware 3D primary buffer: %08x\n",rc);
|
||||
if(rc==DSERR_INVALIDPARAM) {
|
||||
skip("broken driver\n");
|
||||
goto EXIT;
|
||||
}
|
||||
if (rc==DS_OK&&primary!=NULL) {
|
||||
ZeroMemory(&wfx, sizeof(wfx));
|
||||
wfx.wFormatTag=WAVE_FORMAT_PCM;
|
||||
wfx.nChannels=1;
|
||||
wfx.wBitsPerSample=16;
|
||||
wfx.nSamplesPerSec=44100;
|
||||
wfx.nBlockAlign=wfx.nChannels*wfx.wBitsPerSample/8;
|
||||
wfx.nAvgBytesPerSec=wfx.nSamplesPerSec*wfx.nBlockAlign;
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=DSBCAPS_CTRLDEFAULT|DSBCAPS_GETCURRENTPOSITION2;
|
||||
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec;
|
||||
bufdesc.lpwfxFormat=&wfx;
|
||||
trace(" Testing a secondary buffer at %dx%dx%d\n",
|
||||
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
|
||||
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
||||
ok(rc==DS_OK&&secondary!=NULL,"IDirectSound_CreateSoundBuffer() "
|
||||
"failed to create a secondary buffer: %08x\n",rc);
|
||||
if (rc==DS_OK&&secondary!=NULL) {
|
||||
IKsPropertySet * pPropertySet=NULL;
|
||||
rc=IDirectSoundBuffer_QueryInterface(secondary,
|
||||
&IID_IKsPropertySet,
|
||||
(void **)&pPropertySet);
|
||||
/* it's not an error for this to fail */
|
||||
if(rc==DS_OK) {
|
||||
ULONG ulTypeSupport;
|
||||
trace(" Supports property sets\n");
|
||||
/* it's not an error for these to fail */
|
||||
rc=IKsPropertySet_QuerySupport(pPropertySet,
|
||||
&DSPROPSETID_VoiceManager,
|
||||
0,&ulTypeSupport);
|
||||
if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
|
||||
KSPROPERTY_SUPPORT_SET)))
|
||||
trace(" DSPROPSETID_VoiceManager supported\n");
|
||||
else
|
||||
trace(" DSPROPSETID_VoiceManager not supported\n");
|
||||
rc=IKsPropertySet_QuerySupport(pPropertySet,
|
||||
&DSPROPSETID_EAX20_ListenerProperties,0,&ulTypeSupport);
|
||||
if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
|
||||
KSPROPERTY_SUPPORT_SET)))
|
||||
trace(" DSPROPSETID_EAX20_ListenerProperties "
|
||||
"supported\n");
|
||||
else
|
||||
trace(" DSPROPSETID_EAX20_ListenerProperties not "
|
||||
"supported\n");
|
||||
rc=IKsPropertySet_QuerySupport(pPropertySet,
|
||||
&DSPROPSETID_EAX20_BufferProperties,0,&ulTypeSupport);
|
||||
if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
|
||||
KSPROPERTY_SUPPORT_SET)))
|
||||
trace(" DSPROPSETID_EAX20_BufferProperties supported\n");
|
||||
else
|
||||
trace(" DSPROPSETID_EAX20_BufferProperties not "
|
||||
"supported\n");
|
||||
rc=IKsPropertySet_QuerySupport(pPropertySet,
|
||||
&DSPROPSETID_I3DL2_ListenerProperties,0,&ulTypeSupport);
|
||||
if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
|
||||
KSPROPERTY_SUPPORT_SET)))
|
||||
trace(" DSPROPSETID_I3DL2_ListenerProperties "
|
||||
"supported\n");
|
||||
else
|
||||
trace(" DSPROPSETID_I3DL2_ListenerProperties not "
|
||||
"supported\n");
|
||||
rc=IKsPropertySet_QuerySupport(pPropertySet,
|
||||
&DSPROPSETID_I3DL2_BufferProperties,0,&ulTypeSupport);
|
||||
if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
|
||||
KSPROPERTY_SUPPORT_SET)))
|
||||
trace(" DSPROPSETID_I3DL2_BufferProperties supported\n");
|
||||
else
|
||||
trace(" DSPROPSETID_I3DL2_BufferProperties not "
|
||||
"supported\n");
|
||||
rc=IKsPropertySet_QuerySupport(pPropertySet,
|
||||
&DSPROPSETID_ZOOMFX_BufferProperties,0,&ulTypeSupport);
|
||||
if((rc==DS_OK)&&(ulTypeSupport&(KSPROPERTY_SUPPORT_GET|
|
||||
KSPROPERTY_SUPPORT_SET)))
|
||||
trace(" DSPROPSETID_ZOOMFX_BufferProperties "
|
||||
"supported\n");
|
||||
else
|
||||
trace(" DSPROPSETID_ZOOMFX_BufferProperties not "
|
||||
"supported\n");
|
||||
ref=IKsPropertySet_Release(pPropertySet);
|
||||
/* try a few common ones */
|
||||
ok(ref==0,"IKsPropertySet_Release() secondary has %d "
|
||||
"references, should have 0\n",ref);
|
||||
} else
|
||||
trace(" Doesn't support property sets\n");
|
||||
|
||||
ref=IDirectSoundBuffer_Release(secondary);
|
||||
ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d "
|
||||
"references, should have 0\n",ref);
|
||||
}
|
||||
|
||||
ref=IDirectSoundBuffer_Release(primary);
|
||||
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
||||
"should have 0\n",ref);
|
||||
}
|
||||
|
||||
EXIT:
|
||||
if (dso!=NULL) {
|
||||
ref=IDirectSound_Release(dso);
|
||||
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",
|
||||
ref);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void propset_buffer_tests(void)
|
||||
{
|
||||
HRESULT rc;
|
||||
rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
|
||||
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc);
|
||||
}
|
||||
|
||||
START_TEST(propset)
|
||||
{
|
||||
HMODULE hDsound;
|
||||
|
||||
CoInitialize(NULL);
|
||||
|
||||
hDsound = LoadLibrary("dsound.dll");
|
||||
if (hDsound)
|
||||
{
|
||||
|
||||
pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
|
||||
"DirectSoundEnumerateA");
|
||||
pDllGetClassObject = (void *)GetProcAddress(hDsound,
|
||||
"DllGetClassObject");
|
||||
pDirectSoundCreate = (void*)GetProcAddress(hDsound,
|
||||
"DirectSoundCreate");
|
||||
pDirectSoundCreate8 = (void*)GetProcAddress(hDsound,
|
||||
"DirectSoundCreate8");
|
||||
pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound,
|
||||
"DirectSoundCaptureCreate");
|
||||
pDirectSoundCaptureCreate8=(void*)GetProcAddress(hDsound,
|
||||
"DirectSoundCaptureCreate8");
|
||||
pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound,
|
||||
"DirectSoundFullDuplexCreate");
|
||||
|
||||
propset_private_tests();
|
||||
propset_buffer_tests();
|
||||
|
||||
FreeLibrary(hDsound);
|
||||
}
|
||||
else
|
||||
skip("dsound.dll not found!\n");
|
||||
|
||||
CoUninitialize();
|
||||
}
|
27
rostests/winetests/dsound/testlist.c
Normal file
27
rostests/winetests/dsound/testlist.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* Automatically generated file; DO NOT EDIT!! */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
#define STANDALONE
|
||||
#include "wine/test.h"
|
||||
|
||||
extern void func_capture(void);
|
||||
extern void func_ds3d8(void);
|
||||
extern void func_ds3d(void);
|
||||
extern void func_dsound8(void);
|
||||
extern void func_dsound(void);
|
||||
extern void func_duplex(void);
|
||||
extern void func_propset(void);
|
||||
|
||||
const struct test winetest_testlist[] =
|
||||
{
|
||||
{ "capture", func_capture },
|
||||
{ "ds3d8", func_ds3d8 },
|
||||
{ "ds3d", func_ds3d },
|
||||
{ "dsound8", func_dsound8 },
|
||||
{ "dsound", func_dsound },
|
||||
{ "duplex", func_duplex },
|
||||
{ "propset", func_propset },
|
||||
{ 0, 0 }
|
||||
};
|
Loading…
Reference in a new issue