DirectSound8 doesn't accept 3D stereo secondary buffers but

DirectSound does.
Added tests.
This commit is contained in:
Robert Reif 2004-08-25 02:09:00 +00:00 committed by Alexandre Julliard
parent a1a37ce163
commit f01b871898
6 changed files with 193 additions and 42 deletions

View File

@ -320,7 +320,19 @@ static HRESULT WINAPI IDirectSoundImpl_CreateSoundBuffer(
LPUNKNOWN lpunk)
{
ICOM_THIS(IDirectSoundImpl,iface);
LPWAVEFORMATEX wfex;
TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
FIXME("shouldn't be called directly\n");
return DSERR_GENERIC;
}
static HRESULT WINAPI DSOUND_CreateSoundBuffer(
LPDIRECTSOUND8 iface,
LPCDSBUFFERDESC dsbd,
LPLPDIRECTSOUNDBUFFER ppdsb,
LPUNKNOWN lpunk,
BOOL from8)
{
ICOM_THIS(IDirectSoundImpl,iface);
HRESULT hres = DS_OK;
TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
@ -339,7 +351,8 @@ static HRESULT WINAPI IDirectSoundImpl_CreateSoundBuffer(
return DSERR_INVALIDPARAM;
}
if (dsbd->dwSize != sizeof(DSBUFFERDESC) && dsbd->dwSize != sizeof(DSBUFFERDESC1)) {
if (dsbd->dwSize != sizeof(DSBUFFERDESC) &&
dsbd->dwSize != sizeof(DSBUFFERDESC1)) {
WARN("invalid parameter: dsbd\n");
return DSERR_INVALIDPARAM;
}
@ -358,16 +371,13 @@ static HRESULT WINAPI IDirectSoundImpl_CreateSoundBuffer(
TRACE("(lpwfxFormat=%p)\n",dsbd->lpwfxFormat);
}
wfex = dsbd->lpwfxFormat;
if (wfex)
TRACE("(formattag=0x%04x,chans=%d,samplerate=%ld,"
"bytespersec=%ld,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
wfex->wFormatTag, wfex->nChannels, wfex->nSamplesPerSec,
wfex->nAvgBytesPerSec, wfex->nBlockAlign,
wfex->wBitsPerSample, wfex->cbSize);
if (dsbd->dwFlags & DSBCAPS_PRIMARYBUFFER) {
if (dsbd->lpwfxFormat != NULL) {
WARN("invalid parameter: dsbd->lpwfxFormat must be NULL for "
"primary buffer\n");
return DSERR_INVALIDPARAM;
}
if (This->primary) {
WARN("Primary Buffer already created\n");
IDirectSoundBuffer_AddRef((LPDIRECTSOUNDBUFFER8)(This->primary));
@ -383,6 +393,26 @@ static HRESULT WINAPI IDirectSoundImpl_CreateSoundBuffer(
}
} else {
IDirectSoundBufferImpl * dsb;
if (dsbd->lpwfxFormat == NULL) {
WARN("invalid parameter: dsbd->lpwfxFormat can't be NULL for "
"secondary buffer\n");
return DSERR_INVALIDPARAM;
}
TRACE("(formattag=0x%04x,chans=%d,samplerate=%ld,"
"bytespersec=%ld,blockalign=%d,bitspersamp=%d,cbSize=%d)\n",
dsbd->lpwfxFormat->wFormatTag, dsbd->lpwfxFormat->nChannels,
dsbd->lpwfxFormat->nSamplesPerSec,
dsbd->lpwfxFormat->nAvgBytesPerSec,
dsbd->lpwfxFormat->nBlockAlign,
dsbd->lpwfxFormat->wBitsPerSample, dsbd->lpwfxFormat->cbSize);
if (from8 && (dsbd->dwFlags & DSBCAPS_CTRL3D) && (dsbd->lpwfxFormat->nChannels != 1)) {
WARN("invalid parameter: 3D buffer format must be mono\n");
return DSERR_INVALIDPARAM;
}
hres = IDirectSoundBufferImpl_Create(This, (IDirectSoundBufferImpl**)&dsb, dsbd);
if (dsb) {
hres = SecondaryBufferImpl_Create(dsb, (SecondaryBufferImpl**)ppdsb);
@ -1073,7 +1103,7 @@ static HRESULT WINAPI IDirectSound_IDirectSound_CreateSoundBuffer(
{
ICOM_THIS(IDirectSound_IDirectSound,iface);
TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
return IDirectSoundImpl_CreateSoundBuffer(This->pds,dsbd,ppdsb,lpunk);
return DSOUND_CreateSoundBuffer(This->pds,dsbd,ppdsb,lpunk,FALSE);
}
static HRESULT WINAPI IDirectSound_IDirectSound_GetCaps(
@ -1312,7 +1342,7 @@ static HRESULT WINAPI IDirectSound8_IDirectSound_CreateSoundBuffer(
{
ICOM_THIS(IDirectSound8_IDirectSound,iface);
TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
return IDirectSoundImpl_CreateSoundBuffer(This->pds,dsbd,ppdsb,lpunk);
return DSOUND_CreateSoundBuffer(This->pds,dsbd,ppdsb,lpunk,TRUE);
}
static HRESULT WINAPI IDirectSound8_IDirectSound_GetCaps(
@ -1473,7 +1503,7 @@ static HRESULT WINAPI IDirectSound8_IDirectSound8_CreateSoundBuffer(
{
ICOM_THIS(IDirectSound8_IDirectSound8,iface);
TRACE("(%p,%p,%p,%p)\n",This,dsbd,ppdsb,lpunk);
return IDirectSoundImpl_CreateSoundBuffer(This->pds,dsbd,ppdsb,lpunk);
return DSOUND_CreateSoundBuffer(This->pds,dsbd,ppdsb,lpunk,TRUE);
}
static HRESULT WINAPI IDirectSound8_IDirectSound8_GetCaps(

View File

@ -71,6 +71,47 @@ char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size)
return buf;
}
const char * getDSBCAPS(DWORD xmask) {
static struct {
DWORD mask;
char *name;
} flags[] = {
#define FE(x) { x, #x },
FE(DSBCAPS_PRIMARYBUFFER)
FE(DSBCAPS_STATIC)
FE(DSBCAPS_LOCHARDWARE)
FE(DSBCAPS_LOCSOFTWARE)
FE(DSBCAPS_CTRL3D)
FE(DSBCAPS_CTRLFREQUENCY)
FE(DSBCAPS_CTRLPAN)
FE(DSBCAPS_CTRLVOLUME)
FE(DSBCAPS_CTRLPOSITIONNOTIFY)
FE(DSBCAPS_CTRLALL)
FE(DSBCAPS_STICKYFOCUS)
FE(DSBCAPS_GLOBALFOCUS)
FE(DSBCAPS_GETCURRENTPOSITION2)
FE(DSBCAPS_MUTE3DATMAXDISTANCE)
#undef FE
};
static char buffer[512];
int i;
BOOL first = TRUE;
buffer[0] = 0;
for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++) {
if ((flags[i].mask & xmask) == flags[i].mask) {
if (first)
first = FALSE;
else
strcat(buffer, "|");
strcat(buffer, flags[i].name);
}
}
return buffer;
}
HWND get_hwnd()
{
HWND hwnd=GetForegroundWindow();
@ -616,14 +657,15 @@ static HRESULT test_secondary(LPGUID lpGuid, int play,
else
bufdesc.dwFlags|=(DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN);
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() failed "
"to create a %sprimary buffer: %s\n",has_3d?"3D ":"",
ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() "
"failed to create a %sprimary buffer: %s\n",has_3d?"3D ":"",
DXGetErrorString8(rc));
if (rc==DS_OK && primary!=NULL) {
if (has_listener) {
rc=IDirectSoundBuffer_QueryInterface(primary,
&IID_IDirectSound3DListener,(void **)&listener);
&IID_IDirectSound3DListener,
(void **)&listener);
ok(rc==DS_OK && listener!=NULL,
"IDirectSoundBuffer_QueryInterface() failed to get a 3D "
"listener: %s\n",DXGetErrorString8(rc));
@ -636,14 +678,16 @@ static HRESULT test_secondary(LPGUID lpGuid, int play,
/* DSOUND: Error: Invalid buffer */
rc=IDirectSound3DListener_GetAllParameters(listener,0);
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound3dListener_GetAllParameters() failed: %s\n",
"IDirectSound3dListener_GetAllParameters() should have "
"returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
/* DSOUND: Error: Invalid buffer */
rc=IDirectSound3DListener_GetAllParameters(listener,
&listener_param);
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound3dListener_GetAllParameters() failed: %s\n",
"IDirectSound3dListener_GetAllParameters() should have "
"returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
listener_param.dwSize=sizeof(listener_param);
@ -681,11 +725,16 @@ static HRESULT test_secondary(LPGUID lpGuid, int play,
}
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DS_OK && secondary!=NULL,"IDirectSound_CreateSoundBuffer() "
"failed to create a 3D secondary buffer: %s\n",
DXGetErrorString8(rc));
"failed to create a %s%ssecondary buffer %s%s%s%sat %ldx%dx%d (%s): %s\n",
has_3dbuffer?"3D ":"", has_duplicate?"duplicated ":"",
listener!=NULL||move_sound?"with ":"", move_listener?"moving ":"",
listener!=NULL?"listener ":"",
listener&&move_sound?"and moving sound ":move_sound?
"moving sound ":"",
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
getDSBCAPS(bufdesc.dwFlags),DXGetErrorString8(rc));
if (rc==DS_OK && secondary!=NULL) {
if (!has_3d)
{
if (!has_3d) {
DWORD refpan,pan;
LONG refvol,vol;
@ -749,24 +798,25 @@ static HRESULT test_secondary(LPGUID lpGuid, int play,
/* DSOUND: Error: Invalid source buffer */
rc=IDirectSound_DuplicateSoundBuffer(dso,0,0);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_DuplicateSoundBuffer() "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound_DuplicateSoundBuffer() should have returned "
"DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
/* DSOUND: Error: Invalid dest buffer */
rc=IDirectSound_DuplicateSoundBuffer(dso,secondary,0);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_DuplicateSoundBuffer() "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound_DuplicateSoundBuffer() should have returned "
"DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
/* DSOUND: Error: Invalid source buffer */
rc=IDirectSound_DuplicateSoundBuffer(dso,0,&duplicated);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_DuplicateSoundBuffer() "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound_DuplicateSoundBuffer() should have returned "
"DSERR_INVALIDPARAM, returned: %s\n",DXGetErrorString8(rc));
duplicated=NULL;
rc=IDirectSound_DuplicateSoundBuffer(dso,secondary,&duplicated);
rc=IDirectSound_DuplicateSoundBuffer(dso,secondary,
&duplicated);
ok(rc==DS_OK && duplicated!=NULL,
"IDirectSound_DuplicateSoundBuffer() failed to duplicate "
"a secondary buffer: %s\n",DXGetErrorString8(rc));

View File

@ -577,14 +577,16 @@ static HRESULT test_secondary8(LPGUID lpGuid, int play,
/* DSOUND: Error: Invalid buffer */
rc=IDirectSound3DListener_GetAllParameters(listener,0);
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound3dListener_GetAllParameters() failed: %s\n",
"IDirectSound3dListener_GetAllParameters() should have "
"returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
/* DSOUND: Error: Invalid buffer */
rc=IDirectSound3DListener_GetAllParameters(listener,
&listener_param);
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound3dListener_GetAllParameters() failed: %s\n",
"IDirectSound3dListener_GetAllParameters() should have "
"returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(rc));
listener_param.dwSize=sizeof(listener_param);
@ -605,10 +607,22 @@ static HRESULT test_secondary8(LPGUID lpGuid, int play,
if (has_3d)
bufdesc.dwFlags|=DSBCAPS_CTRL3D;
else
bufdesc.dwFlags|=(DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLVOLUME|
DSBCAPS_CTRLPAN);
bufdesc.dwFlags|=
(DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN);
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec*BUFFER_LEN/1000;
bufdesc.lpwfxFormat=&wfx;
if (has_3d) {
/* a stereo 3D buffer should fail */
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DSERR_INVALIDPARAM,
"IDirectSound8_CreateSoundBuffer(secondary) should have "
"returned DSERR_INVALIDPARAM, returned %s\n",
DXGetErrorString8(rc));
if (secondary)
ref=IDirectSoundBuffer_Release(secondary);
init_format(&wfx,WAVE_FORMAT_PCM,22050,16,1);
}
if (winetest_interactive) {
trace(" Testing a %s%ssecondary buffer %s%s%s%sat %ldx%dx%d\n",
has_3dbuffer?"3D ":"",
@ -622,12 +636,18 @@ static HRESULT test_secondary8(LPGUID lpGuid, int play,
}
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DS_OK && secondary!=NULL,"IDirectSound8_CreateSoundBuffer() "
"failed to create a 3D secondary buffer: %s\n",
DXGetErrorString8(rc));
"failed to create a %s%ssecondary buffer %s%s%s%sat %ldx%dx%d (%s): %s\n",
has_3dbuffer?"3D ":"", has_duplicate?"duplicated ":"",
listener!=NULL||move_sound?"with ":"", move_listener?"moving ":"",
listener!=NULL?"listener ":"",
listener&&move_sound?"and moving sound ":move_sound?
"moving sound ":"",
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
getDSBCAPS(bufdesc.dwFlags),DXGetErrorString8(rc));
if (rc==DS_OK && secondary!=NULL) {
if (!has_3d)
{
LONG refvol,refpan,vol,pan;
if (!has_3d) {
DWORD refpan,pan;
LONG refvol,vol;
/* Check the initial secondary buffer's volume and pan */
rc=IDirectSoundBuffer_GetVolume(secondary,&vol);

View File

@ -339,6 +339,7 @@ static HRESULT test_primary(LPGUID lpGuid)
LPDIRECTSOUNDBUFFER primary=NULL,second=NULL,third=NULL;
DSBUFFERDESC bufdesc;
DSCAPS dscaps;
WAVEFORMATEX wfx;
int ref;
/* Create the DirectSound object */
@ -391,6 +392,18 @@ static HRESULT test_primary(LPGUID lpGuid)
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=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_CreateSoundBuffer() should have "
"returned DSERR_INVALIDPARAM, returned: %s\n", DXGetErrorString8(rc));
if (rc==DS_OK && primary!=NULL)
IDirectSoundBuffer_Release(primary);
primary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
@ -645,6 +658,18 @@ static HRESULT test_secondary(LPGUID lpGuid)
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec*BUFFER_LEN/1000;
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound_CreateSoundBuffer() "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(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=wfx.nAvgBytesPerSec*BUFFER_LEN/1000;
bufdesc.lpwfxFormat=&wfx;
if (winetest_interactive) {
trace(" Testing a secondary buffer at %ldx%dx%d\n",

View File

@ -358,6 +358,7 @@ static HRESULT test_primary8(LPGUID lpGuid)
LPDIRECTSOUNDBUFFER primary=NULL,second=NULL,third=NULL;
DSBUFFERDESC bufdesc;
DSCAPS dscaps;
WAVEFORMATEX wfx;
int ref;
/* Create the DirectSound object */
@ -411,6 +412,18 @@ static HRESULT test_primary8(LPGUID lpGuid)
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: %s\n", DXGetErrorString8(rc));
if (rc==DS_OK && primary!=NULL)
IDirectSoundBuffer_Release(primary);
primary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
@ -664,6 +677,18 @@ static HRESULT test_secondary8(LPGUID lpGuid)
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec*BUFFER_LEN/1000;
rc=IDirectSound8_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DSERR_INVALIDPARAM,"IDirectSound8_CreateSoundBuffer() "
"should have returned DSERR_INVALIDPARAM, returned: %s\n",
DXGetErrorString8(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=wfx.nAvgBytesPerSec*BUFFER_LEN/1000;
bufdesc.lpwfxFormat=&wfx;
if (winetest_interactive) {
trace(" Testing a secondary buffer at %ldx%dx%d\n",

View File

@ -60,3 +60,4 @@ extern void test_buffer(LPDIRECTSOUND,LPDIRECTSOUNDBUFFER,
extern void test_buffer8(LPDIRECTSOUND8,LPDIRECTSOUNDBUFFER,
BOOL,BOOL,LONG,BOOL,LONG,BOOL,double,BOOL,
LPDIRECTSOUND3DLISTENER,BOOL,BOOL);
extern const char * getDSBCAPS(DWORD xmask);