2004-06-18 01:03:11 +02:00
|
|
|
/*
|
|
|
|
* Tests the panning and 3D functions of DirectSound
|
|
|
|
*
|
|
|
|
* Part of this test involves playing test tones. But this only makes
|
|
|
|
* sense if someone is going to carefully listen to it, and would only
|
|
|
|
* bother everyone else.
|
|
|
|
* So this is only done if the test is being run in interactive mode.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2002-2004 Francois Gouget
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-06-18 01:03:11 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
2013-10-14 23:19:31 +02:00
|
|
|
#include "mmsystem.h"
|
2004-06-18 01:03:11 +02:00
|
|
|
#include "dsound.h"
|
2011-01-20 16:41:11 +01:00
|
|
|
#include "ks.h"
|
|
|
|
#include "ksmedia.h"
|
2004-06-18 01:03:11 +02:00
|
|
|
#include "dsound_test.h"
|
|
|
|
|
|
|
|
#define PI 3.14159265358979323846
|
2007-01-15 15:00:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
|
|
|
|
static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID,LPDIRECTSOUND*,
|
|
|
|
LPUNKNOWN)=NULL;
|
|
|
|
|
2011-01-20 16:41:11 +01:00
|
|
|
char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size, BOOL ieee)
|
2004-06-18 01:03:11 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int nb_samples;
|
|
|
|
char* buf;
|
|
|
|
char* b;
|
|
|
|
|
|
|
|
nb_samples=(int)(duration*wfx->nSamplesPerSec);
|
|
|
|
*size=nb_samples*wfx->nBlockAlign;
|
2009-05-13 10:32:21 +02:00
|
|
|
b=buf=HeapAlloc(GetProcessHeap(), 0, *size);
|
2004-06-18 01:03:11 +02:00
|
|
|
for (i=0;i<nb_samples;i++) {
|
|
|
|
double y=sin(440.0*2*PI*i/wfx->nSamplesPerSec);
|
|
|
|
if (wfx->wBitsPerSample==8) {
|
2011-09-23 16:05:37 +02:00
|
|
|
unsigned char sample=127.5*(y+1.0);
|
2004-06-18 01:03:11 +02:00
|
|
|
*b++=sample;
|
|
|
|
if (wfx->nChannels==2)
|
|
|
|
*b++=sample;
|
2007-11-05 23:23:28 +01:00
|
|
|
} else if (wfx->wBitsPerSample == 16) {
|
2011-09-23 16:05:37 +02:00
|
|
|
signed short sample=32767.5*y-0.5;
|
2004-06-18 01:03:11 +02:00
|
|
|
b[0]=sample & 0xff;
|
|
|
|
b[1]=sample >> 8;
|
|
|
|
b+=2;
|
|
|
|
if (wfx->nChannels==2) {
|
|
|
|
b[0]=sample & 0xff;
|
|
|
|
b[1]=sample >> 8;
|
|
|
|
b+=2;
|
|
|
|
}
|
2007-11-05 23:23:28 +01:00
|
|
|
} else if (wfx->wBitsPerSample == 24) {
|
2011-09-23 16:05:37 +02:00
|
|
|
signed int sample=8388607.5*y-0.5;
|
2007-11-05 23:23:28 +01:00
|
|
|
b[0]=sample & 0xff;
|
|
|
|
b[1]=(sample >> 8)&0xff;
|
|
|
|
b[2]=sample >> 16;
|
|
|
|
b+=3;
|
|
|
|
if (wfx->nChannels==2) {
|
|
|
|
b[0]=sample & 0xff;
|
|
|
|
b[1]=(sample >> 8)&0xff;
|
|
|
|
b[2]=sample >> 16;
|
|
|
|
b+=3;
|
|
|
|
}
|
|
|
|
} else if (wfx->wBitsPerSample == 32) {
|
2011-01-20 16:41:11 +01:00
|
|
|
if (ieee) {
|
|
|
|
float *ptr = (float *) b;
|
|
|
|
*ptr = y;
|
|
|
|
|
|
|
|
ptr++;
|
|
|
|
b+=4;
|
|
|
|
|
|
|
|
if (wfx->nChannels==2) {
|
|
|
|
*ptr = y;
|
|
|
|
b+=4;
|
|
|
|
}
|
|
|
|
} else {
|
2011-09-23 16:05:37 +02:00
|
|
|
signed int sample=2147483647.5*y-0.5;
|
2007-11-05 23:23:28 +01:00
|
|
|
b[0]=sample & 0xff;
|
|
|
|
b[1]=(sample >> 8)&0xff;
|
|
|
|
b[2]=(sample >> 16)&0xff;
|
|
|
|
b[3]=sample >> 24;
|
|
|
|
b+=4;
|
2011-01-20 16:41:11 +01:00
|
|
|
if (wfx->nChannels==2) {
|
|
|
|
b[0]=sample & 0xff;
|
|
|
|
b[1]=(sample >> 8)&0xff;
|
|
|
|
b[2]=(sample >> 16)&0xff;
|
|
|
|
b[3]=sample >> 24;
|
|
|
|
b+=4;
|
|
|
|
}
|
2007-11-05 23:23:28 +01:00
|
|
|
}
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2004-08-25 04:09:00 +02:00
|
|
|
const char * getDSBCAPS(DWORD xmask) {
|
|
|
|
static struct {
|
|
|
|
DWORD mask;
|
2005-07-15 11:58:36 +02:00
|
|
|
const char *name;
|
2004-08-25 04:09:00 +02:00
|
|
|
} 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_STICKYFOCUS)
|
|
|
|
FE(DSBCAPS_GLOBALFOCUS)
|
|
|
|
FE(DSBCAPS_GETCURRENTPOSITION2)
|
|
|
|
FE(DSBCAPS_MUTE3DATMAXDISTANCE)
|
|
|
|
#undef FE
|
|
|
|
};
|
|
|
|
static char buffer[512];
|
2005-07-15 18:34:04 +02:00
|
|
|
unsigned int i;
|
2004-08-25 04:09:00 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2007-03-10 22:00:47 +01:00
|
|
|
HWND get_hwnd(void)
|
2004-06-18 01:03:11 +02:00
|
|
|
{
|
|
|
|
HWND hwnd=GetForegroundWindow();
|
|
|
|
if (!hwnd)
|
|
|
|
hwnd=GetDesktopWindow();
|
|
|
|
return hwnd;
|
|
|
|
}
|
|
|
|
|
2004-08-12 05:29:39 +02:00
|
|
|
void init_format(WAVEFORMATEX* wfx, int format, int rate, int depth,
|
|
|
|
int channels)
|
2004-06-18 01:03:11 +02:00
|
|
|
{
|
|
|
|
wfx->wFormatTag=format;
|
|
|
|
wfx->nChannels=channels;
|
|
|
|
wfx->wBitsPerSample=depth;
|
|
|
|
wfx->nSamplesPerSec=rate;
|
|
|
|
wfx->nBlockAlign=wfx->nChannels*wfx->wBitsPerSample/8;
|
|
|
|
/* FIXME: Shouldn't this test be if (format!=WAVE_FORMAT_PCM) */
|
|
|
|
if (wfx->nBlockAlign==0)
|
|
|
|
{
|
|
|
|
/* align compressed formats to byte boundary */
|
|
|
|
wfx->nBlockAlign=1;
|
|
|
|
}
|
|
|
|
wfx->nAvgBytesPerSec=wfx->nSamplesPerSec*wfx->nBlockAlign;
|
|
|
|
wfx->cbSize=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char* wave;
|
|
|
|
DWORD wave_len;
|
|
|
|
|
|
|
|
LPDIRECTSOUNDBUFFER dsbo;
|
|
|
|
LPWAVEFORMATEX wfx;
|
|
|
|
DWORD buffer_size;
|
|
|
|
DWORD written;
|
2004-07-17 01:42:32 +02:00
|
|
|
DWORD played;
|
2004-06-18 01:03:11 +02:00
|
|
|
DWORD offset;
|
|
|
|
} play_state_t;
|
|
|
|
|
|
|
|
static int buffer_refill(play_state_t* state, DWORD size)
|
|
|
|
{
|
|
|
|
LPVOID ptr1,ptr2;
|
|
|
|
DWORD len1,len2;
|
|
|
|
HRESULT rc;
|
|
|
|
|
|
|
|
if (size>state->wave_len-state->written)
|
|
|
|
size=state->wave_len-state->written;
|
|
|
|
|
2009-01-02 07:39:10 +01:00
|
|
|
/* some broken apps like Navyfield mistakenly pass NULL for a ppValue */
|
|
|
|
rc=IDirectSoundBuffer_Lock(state->dsbo,state->offset,size,
|
|
|
|
&ptr1,NULL,&ptr2,&len2,0);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM,"expected %08x got %08x\n",DSERR_INVALIDPARAM, rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
rc=IDirectSoundBuffer_Lock(state->dsbo,state->offset,size,
|
|
|
|
&ptr1,&len1,&ptr2,&len2,0);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_Lock() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
memcpy(ptr1,state->wave+state->written,len1);
|
|
|
|
state->written+=len1;
|
|
|
|
if (ptr2!=NULL) {
|
|
|
|
memcpy(ptr2,state->wave+state->written,len2);
|
|
|
|
state->written+=len2;
|
|
|
|
}
|
|
|
|
state->offset=state->written % state->buffer_size;
|
2008-09-02 23:08:21 +02:00
|
|
|
/* some apps blindly pass &ptr1 instead of ptr1 */
|
|
|
|
rc=IDirectSoundBuffer_Unlock(state->dsbo,&ptr1,len1,ptr2,len2);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM, "IDDirectSoundBuffer_Unlock(): expected %08x got %08x, %p %p\n",DSERR_INVALIDPARAM, rc, &ptr1, ptr1);
|
2004-06-18 01:03:11 +02:00
|
|
|
rc=IDirectSoundBuffer_Unlock(state->dsbo,ptr1,len1,ptr2,len2);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_Unlock() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return -1;
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int buffer_silence(play_state_t* state, DWORD size)
|
|
|
|
{
|
|
|
|
LPVOID ptr1,ptr2;
|
|
|
|
DWORD len1,len2;
|
|
|
|
HRESULT rc;
|
|
|
|
BYTE s;
|
|
|
|
|
|
|
|
rc=IDirectSoundBuffer_Lock(state->dsbo,state->offset,size,
|
|
|
|
&ptr1,&len1,&ptr2,&len2,0);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_Lock() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
s=(state->wfx->wBitsPerSample==8?0x80:0);
|
|
|
|
memset(ptr1,s,len1);
|
|
|
|
if (ptr2!=NULL) {
|
|
|
|
memset(ptr2,s,len2);
|
|
|
|
}
|
|
|
|
state->offset=(state->offset+size) % state->buffer_size;
|
|
|
|
rc=IDirectSoundBuffer_Unlock(state->dsbo,ptr1,len1,ptr2,len2);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_Unlock() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return -1;
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2013-11-12 22:11:12 +01:00
|
|
|
static BOOL buffer_service(play_state_t* state)
|
2004-06-18 01:03:11 +02:00
|
|
|
{
|
2004-07-17 01:42:32 +02:00
|
|
|
DWORD last_play_pos,play_pos,buf_free;
|
2004-06-18 01:03:11 +02:00
|
|
|
HRESULT rc;
|
|
|
|
|
2004-07-17 01:42:32 +02:00
|
|
|
rc=IDirectSoundBuffer_GetCurrentPosition(state->dsbo,&play_pos,NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetCurrentPosition() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK) {
|
|
|
|
goto STOP;
|
|
|
|
}
|
|
|
|
|
2004-07-17 01:42:32 +02:00
|
|
|
/* Update the amount played */
|
|
|
|
last_play_pos=state->played % state->buffer_size;
|
|
|
|
if (play_pos<last_play_pos)
|
|
|
|
state->played+=state->buffer_size-last_play_pos+play_pos;
|
|
|
|
else
|
|
|
|
state->played+=play_pos-last_play_pos;
|
|
|
|
|
|
|
|
if (winetest_debug > 1)
|
2006-10-10 01:07:36 +02:00
|
|
|
trace("buf size=%d last_play_pos=%d play_pos=%d played=%d / %d\n",
|
2004-08-12 05:29:39 +02:00
|
|
|
state->buffer_size,last_play_pos,play_pos,state->played,
|
|
|
|
state->wave_len);
|
2004-07-17 01:42:32 +02:00
|
|
|
|
|
|
|
if (state->played>state->wave_len)
|
|
|
|
{
|
|
|
|
/* Everything has been played */
|
|
|
|
goto STOP;
|
|
|
|
}
|
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
/* Refill the buffer */
|
2004-07-17 01:42:32 +02:00
|
|
|
if (state->offset<=play_pos)
|
2004-06-18 01:03:11 +02:00
|
|
|
buf_free=play_pos-state->offset;
|
2004-07-17 01:42:32 +02:00
|
|
|
else
|
2004-06-18 01:03:11 +02:00
|
|
|
buf_free=state->buffer_size-state->offset+play_pos;
|
2004-07-17 01:42:32 +02:00
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
if (winetest_debug > 1)
|
2006-10-10 01:07:36 +02:00
|
|
|
trace("offset=%d free=%d written=%d / %d\n",
|
2004-07-17 01:42:32 +02:00
|
|
|
state->offset,buf_free,state->written,state->wave_len);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (buf_free==0)
|
2013-11-12 22:11:12 +01:00
|
|
|
return TRUE;
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2004-07-17 01:42:32 +02:00
|
|
|
if (state->written<state->wave_len)
|
|
|
|
{
|
2004-06-18 01:03:11 +02:00
|
|
|
int w=buffer_refill(state,buf_free);
|
|
|
|
if (w==-1)
|
|
|
|
goto STOP;
|
|
|
|
buf_free-=w;
|
2004-07-17 01:42:32 +02:00
|
|
|
if (state->written==state->wave_len && winetest_debug > 1)
|
2006-10-10 01:07:36 +02:00
|
|
|
trace("last sound byte at %d\n",
|
2004-07-17 01:42:32 +02:00
|
|
|
(state->written % state->buffer_size));
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (buf_free>0) {
|
|
|
|
/* Fill with silence */
|
|
|
|
if (winetest_debug > 1)
|
2006-10-10 01:07:36 +02:00
|
|
|
trace("writing %d bytes of silence\n",buf_free);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (buffer_silence(state,buf_free)==-1)
|
|
|
|
goto STOP;
|
|
|
|
}
|
2013-11-12 22:11:12 +01:00
|
|
|
return TRUE;
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
STOP:
|
|
|
|
if (winetest_debug > 1)
|
|
|
|
trace("stopping playback\n");
|
|
|
|
rc=IDirectSoundBuffer_Stop(state->dsbo);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_Stop() failed: %08x\n", rc);
|
2013-11-12 22:11:12 +01:00
|
|
|
return FALSE;
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
|
2006-01-06 12:16:41 +01:00
|
|
|
void test_buffer(LPDIRECTSOUND dso, LPDIRECTSOUNDBUFFER *dsbo,
|
2004-06-18 01:03:11 +02:00
|
|
|
BOOL is_primary, BOOL set_volume, LONG volume,
|
|
|
|
BOOL set_pan, LONG pan, BOOL play, double duration,
|
|
|
|
BOOL buffer3d, LPDIRECTSOUND3DLISTENER listener,
|
2005-02-25 20:17:11 +01:00
|
|
|
BOOL move_listener, BOOL move_sound,
|
|
|
|
BOOL set_frequency, DWORD frequency)
|
2004-06-18 01:03:11 +02:00
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
DSBCAPS dsbcaps;
|
|
|
|
WAVEFORMATEX wfx,wfx2;
|
|
|
|
DWORD size,status,freq;
|
2011-01-20 16:41:11 +01:00
|
|
|
BOOL ieee = FALSE;
|
2004-06-18 01:03:11 +02:00
|
|
|
int ref;
|
|
|
|
|
2005-02-25 20:17:11 +01:00
|
|
|
if (set_frequency) {
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_SetFrequency(*dsbo,frequency);
|
2005-02-25 20:17:11 +01:00
|
|
|
ok(rc==DS_OK||rc==DSERR_CONTROLUNAVAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSoundBuffer_SetFrequency() failed to set frequency %08x\n",rc);
|
2005-02-25 20:17:11 +01:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
/* DSOUND: Error: Invalid caps pointer */
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_GetCaps(*dsbo,0);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetCaps() should have "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
ZeroMemory(&dsbcaps, sizeof(dsbcaps));
|
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid caps pointer */
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_GetCaps(*dsbo,&dsbcaps);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetCaps() should have "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
dsbcaps.dwSize=sizeof(dsbcaps);
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_GetCaps(*dsbo,&dsbcaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() failed: %08x\n", rc);
|
2004-08-12 05:29:39 +02:00
|
|
|
if (rc==DS_OK && winetest_debug > 1) {
|
2006-10-10 01:07:36 +02:00
|
|
|
trace(" Caps: flags=0x%08x size=%d\n",dsbcaps.dwFlags,
|
2004-06-18 01:03:11 +02:00
|
|
|
dsbcaps.dwBufferBytes);
|
|
|
|
}
|
|
|
|
|
2007-11-08 21:45:14 +01:00
|
|
|
/* Query the format size. */
|
2004-06-18 01:03:11 +02:00
|
|
|
size=0;
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_GetFormat(*dsbo,NULL,0,&size);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DS_OK && size!=0,"IDirectSoundBuffer_GetFormat() should have "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned the needed size: rc=%08x size=%d\n",rc,size);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2007-11-08 21:45:14 +01:00
|
|
|
ok(size == sizeof(WAVEFORMATEX) || size == sizeof(WAVEFORMATEXTENSIBLE),
|
|
|
|
"Expected a correct structure size, got %d\n", size);
|
|
|
|
|
|
|
|
if (size == sizeof(WAVEFORMATEX)) {
|
|
|
|
rc=IDirectSoundBuffer_GetFormat(*dsbo,&wfx,size,NULL);
|
2011-01-20 16:41:11 +01:00
|
|
|
ieee = (wfx.wFormatTag == WAVE_FORMAT_IEEE_FLOAT);
|
2007-11-08 21:45:14 +01:00
|
|
|
}
|
|
|
|
else if (size == sizeof(WAVEFORMATEXTENSIBLE)) {
|
2007-11-05 23:23:28 +01:00
|
|
|
WAVEFORMATEXTENSIBLE wfxe;
|
2007-11-08 21:45:14 +01:00
|
|
|
rc=IDirectSoundBuffer_GetFormat(*dsbo,(WAVEFORMATEX*)&wfxe,size,NULL);
|
2007-11-05 23:23:28 +01:00
|
|
|
wfx = wfxe.Format;
|
2011-01-20 16:41:11 +01:00
|
|
|
ieee = IsEqualGUID(&wfxe.SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT);
|
2012-10-03 16:01:25 +02:00
|
|
|
} else
|
|
|
|
return;
|
|
|
|
|
2007-11-05 23:23:28 +01:00
|
|
|
ok(rc==DS_OK,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSoundBuffer_GetFormat() failed: %08x\n", rc);
|
2004-08-18 02:30:12 +02:00
|
|
|
if (rc==DS_OK && winetest_debug > 1) {
|
2006-10-10 01:07:36 +02:00
|
|
|
trace(" Format: %s tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
|
2004-08-18 02:30:12 +02:00
|
|
|
is_primary ? "Primary" : "Secondary",
|
2004-06-18 01:03:11 +02:00
|
|
|
wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
|
|
|
|
wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid frequency buffer */
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_GetFrequency(*dsbo,0);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetFrequency() should have "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
/* DSOUND: Error: Primary buffers don't support CTRLFREQUENCY */
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_GetFrequency(*dsbo,&freq);
|
2004-06-18 01:03:11 +02:00
|
|
|
ok((rc==DS_OK && !is_primary) || (rc==DSERR_CONTROLUNAVAIL&&is_primary) ||
|
|
|
|
(rc==DSERR_CONTROLUNAVAIL&&!(dsbcaps.dwFlags&DSBCAPS_CTRLFREQUENCY)),
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSoundBuffer_GetFrequency() failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc==DS_OK) {
|
2005-02-25 20:17:11 +01:00
|
|
|
DWORD f = set_frequency?frequency:wfx.nSamplesPerSec;
|
|
|
|
ok(freq==f,"The frequency returned by GetFrequency "
|
2006-10-10 01:07:36 +02:00
|
|
|
"%d does not match the format %d\n",freq,f);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid status pointer */
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_GetStatus(*dsbo,0);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetStatus() should have "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_GetStatus(*dsbo,&status);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetStatus() failed: %08x\n", rc);
|
2006-10-10 01:07:36 +02:00
|
|
|
ok(status==0,"status=0x%x instead of 0\n",status);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
if (is_primary) {
|
2006-01-11 12:12:46 +01:00
|
|
|
DSBCAPS new_dsbcaps;
|
2004-06-18 01:03:11 +02:00
|
|
|
/* We must call SetCooperativeLevel to be allowed to call SetFormat */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_PRIORITY) failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid format pointer */
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_SetFormat(*dsbo,0);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_SetFormat() should have "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
init_format(&wfx2,WAVE_FORMAT_PCM,11025,16,2);
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_SetFormat(*dsbo,&wfx2);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_SetFormat(%s) failed: %08x\n",
|
|
|
|
format_string(&wfx2), rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2006-11-07 00:37:42 +01:00
|
|
|
/* There is no guarantee that SetFormat will actually change the
|
2004-06-18 01:03:11 +02:00
|
|
|
* format to what we asked for. It depends on what the soundcard
|
|
|
|
* supports. So we must re-query the format.
|
|
|
|
*/
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_GetFormat(*dsbo,&wfx,sizeof(wfx),NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc==DS_OK &&
|
|
|
|
(wfx.wFormatTag!=wfx2.wFormatTag ||
|
|
|
|
wfx.nSamplesPerSec!=wfx2.nSamplesPerSec ||
|
|
|
|
wfx.wBitsPerSample!=wfx2.wBitsPerSample ||
|
|
|
|
wfx.nChannels!=wfx2.nChannels)) {
|
2006-10-10 01:07:36 +02:00
|
|
|
trace("Requested format tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
|
2004-06-18 01:03:11 +02:00
|
|
|
wfx2.wFormatTag,wfx2.nSamplesPerSec,wfx2.wBitsPerSample,
|
|
|
|
wfx2.nChannels,wfx2.nAvgBytesPerSec,wfx2.nBlockAlign);
|
2006-10-10 01:07:36 +02:00
|
|
|
trace("Got tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
|
2004-06-18 01:03:11 +02:00
|
|
|
wfx.wFormatTag,wfx.nSamplesPerSec,wfx.wBitsPerSample,
|
|
|
|
wfx.nChannels,wfx.nAvgBytesPerSec,wfx.nBlockAlign);
|
|
|
|
}
|
|
|
|
|
2006-01-11 12:12:46 +01:00
|
|
|
ZeroMemory(&new_dsbcaps, sizeof(new_dsbcaps));
|
|
|
|
new_dsbcaps.dwSize = sizeof(new_dsbcaps);
|
|
|
|
rc=IDirectSoundBuffer_GetCaps(*dsbo,&new_dsbcaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() failed: %08x\n", rc);
|
2006-01-11 12:12:46 +01:00
|
|
|
if (rc==DS_OK && winetest_debug > 1) {
|
2006-10-10 01:07:36 +02:00
|
|
|
trace(" new Caps: flags=0x%08x size=%d\n",new_dsbcaps.dwFlags,
|
2006-01-11 12:12:46 +01:00
|
|
|
new_dsbcaps.dwBufferBytes);
|
|
|
|
}
|
2006-01-17 16:19:54 +01:00
|
|
|
|
2006-01-11 12:12:46 +01:00
|
|
|
/* Check for primary buffer size change */
|
2006-01-17 16:19:54 +01:00
|
|
|
ok(new_dsbcaps.dwBufferBytes == dsbcaps.dwBufferBytes,
|
|
|
|
" buffer size changed after SetFormat() - "
|
2006-10-10 01:07:36 +02:00
|
|
|
"previous size was %u, current size is %u\n",
|
2006-01-17 16:19:54 +01:00
|
|
|
dsbcaps.dwBufferBytes, new_dsbcaps.dwBufferBytes);
|
2007-06-25 19:55:36 +02:00
|
|
|
dsbcaps.dwBufferBytes = new_dsbcaps.dwBufferBytes;
|
2006-01-11 12:12:46 +01:00
|
|
|
|
|
|
|
/* Check for primary buffer flags change */
|
2006-01-17 16:19:54 +01:00
|
|
|
ok(new_dsbcaps.dwFlags == dsbcaps.dwFlags,
|
|
|
|
" flags changed after SetFormat() - "
|
2006-10-10 01:07:36 +02:00
|
|
|
"previous flags were %08x, current flags are %08x\n",
|
2006-01-17 16:19:54 +01:00
|
|
|
dsbcaps.dwFlags, new_dsbcaps.dwFlags);
|
2006-01-11 12:12:46 +01:00
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
/* Set the CooperativeLevel back to normal */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_NORMAL) failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (play) {
|
|
|
|
play_state_t state;
|
|
|
|
DS3DLISTENER listener_param;
|
|
|
|
LPDIRECTSOUND3DBUFFER buffer=NULL;
|
|
|
|
DS3DBUFFER buffer_param;
|
2004-07-17 01:42:32 +02:00
|
|
|
DWORD start_time,now;
|
2006-04-29 16:14:40 +02:00
|
|
|
LPVOID buffer1;
|
|
|
|
DWORD length1;
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2004-08-12 05:29:39 +02:00
|
|
|
if (winetest_interactive) {
|
2005-02-25 20:17:11 +01:00
|
|
|
if (set_frequency)
|
2006-10-10 01:07:36 +02:00
|
|
|
trace(" Playing %g second 440Hz tone at %dx%dx%d with a "
|
|
|
|
"frequency of %d (%dHz)\n", duration,
|
2005-02-25 20:17:11 +01:00
|
|
|
wfx.nSamplesPerSec, wfx.wBitsPerSample, wfx.nChannels,
|
|
|
|
frequency, (440 * frequency) / wfx.nSamplesPerSec);
|
|
|
|
else
|
2006-10-10 01:07:36 +02:00
|
|
|
trace(" Playing %g second 440Hz tone at %dx%dx%d\n", duration,
|
2005-02-25 20:17:11 +01:00
|
|
|
wfx.nSamplesPerSec, wfx.wBitsPerSample, wfx.nChannels);
|
2004-08-12 05:29:39 +02:00
|
|
|
}
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
if (is_primary) {
|
|
|
|
/* We must call SetCooperativeLevel to be allowed to call Lock */
|
2004-08-23 19:50:31 +02:00
|
|
|
/* DSOUND: Setting DirectSound cooperative level to
|
|
|
|
* DSSCL_WRITEPRIMARY */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),
|
|
|
|
DSSCL_WRITEPRIMARY);
|
2004-08-18 02:30:12 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_WRITEPRIMARY) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (buffer3d) {
|
|
|
|
LPDIRECTSOUNDBUFFER temp_buffer;
|
|
|
|
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_QueryInterface(*dsbo,&IID_IDirectSound3DBuffer,
|
2004-08-12 05:29:39 +02:00
|
|
|
(LPVOID *)&buffer);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_QueryInterface() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* check the COM interface */
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_QueryInterface(*dsbo, &IID_IDirectSoundBuffer,
|
2004-08-12 05:29:39 +02:00
|
|
|
(LPVOID *)&temp_buffer);
|
|
|
|
ok(rc==DS_OK && temp_buffer!=NULL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSoundBuffer_QueryInterface() failed: %08x\n", rc);
|
2006-01-06 12:16:41 +01:00
|
|
|
ok(temp_buffer==*dsbo,"COM interface broken: %p != %p\n",
|
|
|
|
temp_buffer,*dsbo);
|
2004-06-18 01:03:11 +02:00
|
|
|
ref=IDirectSoundBuffer_Release(temp_buffer);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
|
|
|
|
"should have 1\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
temp_buffer=NULL;
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSound3DBuffer_QueryInterface(*dsbo,
|
2004-08-23 19:50:31 +02:00
|
|
|
&IID_IDirectSoundBuffer,
|
2004-08-12 05:29:39 +02:00
|
|
|
(LPVOID *)&temp_buffer);
|
|
|
|
ok(rc==DS_OK && temp_buffer!=NULL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound3DBuffer_QueryInterface() failed: %08x\n", rc);
|
2006-01-06 12:16:41 +01:00
|
|
|
ok(temp_buffer==*dsbo,"COM interface broken: %p != %p\n",
|
|
|
|
temp_buffer,*dsbo);
|
2004-06-18 01:03:11 +02:00
|
|
|
ref=IDirectSoundBuffer_Release(temp_buffer);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
|
|
|
|
"should have 1\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2006-01-06 12:16:41 +01:00
|
|
|
ref=IDirectSoundBuffer_Release(*dsbo);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
|
|
|
|
"should have 0\n",ref);
|
|
|
|
|
|
|
|
rc=IDirectSound3DBuffer_QueryInterface(buffer,
|
|
|
|
&IID_IDirectSoundBuffer,
|
2006-01-06 12:16:41 +01:00
|
|
|
(LPVOID *)dsbo);
|
|
|
|
ok(rc==DS_OK && *dsbo!=NULL,"IDirectSound3DBuffer_QueryInterface() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid buffer */
|
|
|
|
rc=IDirectSound3DBuffer_GetAllParameters(buffer,0);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
ZeroMemory(&buffer_param, sizeof(buffer_param));
|
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid buffer */
|
|
|
|
rc=IDirectSound3DBuffer_GetAllParameters(buffer,&buffer_param);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,"IDirectSound3DBuffer_GetAllParameters() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
buffer_param.dwSize=sizeof(buffer_param);
|
|
|
|
rc=IDirectSound3DBuffer_GetAllParameters(buffer,&buffer_param);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound3DBuffer_GetAllParameters() failed: %08x\n", rc);
|
2004-07-17 01:42:32 +02:00
|
|
|
}
|
2004-06-18 01:03:11 +02:00
|
|
|
if (set_volume) {
|
|
|
|
if (dsbcaps.dwFlags & DSBCAPS_CTRLVOLUME) {
|
|
|
|
LONG val;
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_GetVolume(*dsbo,&val);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_SetVolume(*dsbo,volume);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
} else {
|
|
|
|
/* DSOUND: Error: Buffer does not have CTRLVOLUME */
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_GetVolume(*dsbo,&volume);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer_GetVolume() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_CONTROLUNAVAIL, returned: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (set_pan) {
|
|
|
|
if (dsbcaps.dwFlags & DSBCAPS_CTRLPAN) {
|
|
|
|
LONG val;
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_GetPan(*dsbo,&val);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetPan() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_SetPan(*dsbo,pan);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_SetPan() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
} else {
|
|
|
|
/* DSOUND: Error: Buffer does not have CTRLPAN */
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_GetPan(*dsbo,&pan);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DSERR_CONTROLUNAVAIL,"IDirectSoundBuffer_GetPan() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"should have returned DSERR_CONTROLUNAVAIL, returned: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-29 16:14:40 +02:00
|
|
|
/* try an offset past the end of the buffer */
|
2006-09-29 12:45:02 +02:00
|
|
|
rc = IDirectSoundBuffer_Lock(*dsbo, dsbcaps.dwBufferBytes, 0, &buffer1,
|
2006-04-29 16:14:40 +02:00
|
|
|
&length1, NULL, NULL,
|
|
|
|
DSBLOCK_ENTIREBUFFER);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM, "IDirectSoundBuffer_Lock() should have "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned DSERR_INVALIDPARAM, returned %08x\n", rc);
|
2006-04-29 16:14:40 +02:00
|
|
|
|
|
|
|
/* try a size larger than the buffer */
|
2006-09-29 12:45:02 +02:00
|
|
|
rc = IDirectSoundBuffer_Lock(*dsbo, 0, dsbcaps.dwBufferBytes + 1,
|
2006-04-29 16:14:40 +02:00
|
|
|
&buffer1, &length1, NULL, NULL,
|
|
|
|
DSBLOCK_FROMWRITECURSOR);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM, "IDirectSoundBuffer_Lock() should have "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned DSERR_INVALIDPARAM, returned %08x\n", rc);
|
2006-04-29 16:14:40 +02:00
|
|
|
|
2005-02-25 20:17:11 +01:00
|
|
|
if (set_frequency)
|
2011-01-20 16:41:11 +01:00
|
|
|
state.wave=wave_generate_la(&wfx,(duration*frequency)/wfx.nSamplesPerSec,&state.wave_len,ieee);
|
2005-02-25 20:17:11 +01:00
|
|
|
else
|
2011-01-20 16:41:11 +01:00
|
|
|
state.wave=wave_generate_la(&wfx,duration,&state.wave_len,ieee);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2006-01-06 12:16:41 +01:00
|
|
|
state.dsbo=*dsbo;
|
2004-06-18 01:03:11 +02:00
|
|
|
state.wfx=&wfx;
|
|
|
|
state.buffer_size=dsbcaps.dwBufferBytes;
|
2004-07-17 01:42:32 +02:00
|
|
|
state.played=state.written=state.offset=0;
|
2004-06-18 01:03:11 +02:00
|
|
|
buffer_refill(&state,state.buffer_size);
|
|
|
|
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_Play(*dsbo,0,0,DSBPLAY_LOOPING);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_Play() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2006-01-06 12:16:41 +01:00
|
|
|
rc=IDirectSoundBuffer_GetStatus(*dsbo,&status);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetStatus() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
ok(status==(DSBSTATUS_PLAYING|DSBSTATUS_LOOPING),
|
2006-10-10 01:07:36 +02:00
|
|
|
"GetStatus: bad status: %x\n",status);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
if (listener) {
|
|
|
|
ZeroMemory(&listener_param,sizeof(listener_param));
|
|
|
|
listener_param.dwSize=sizeof(listener_param);
|
2004-08-23 19:50:31 +02:00
|
|
|
rc=IDirectSound3DListener_GetAllParameters(listener,
|
|
|
|
&listener_param);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n",rc);
|
2004-08-18 02:30:12 +02:00
|
|
|
if (move_listener) {
|
2007-05-28 01:20:07 +02:00
|
|
|
listener_param.vPosition.x = -5.0f;
|
|
|
|
listener_param.vVelocity.x = (float)(10.0/duration);
|
2004-07-19 23:20:38 +02:00
|
|
|
}
|
2004-08-12 05:29:39 +02:00
|
|
|
rc=IDirectSound3DListener_SetAllParameters(listener,
|
|
|
|
&listener_param,
|
|
|
|
DS3D_IMMEDIATE);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound3dListener_SetPosition() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
if (buffer3d) {
|
2004-08-18 02:30:12 +02:00
|
|
|
if (move_sound) {
|
2007-05-28 01:20:07 +02:00
|
|
|
buffer_param.vPosition.x = 100.0f;
|
|
|
|
buffer_param.vVelocity.x = (float)(-200.0/duration);
|
2004-07-19 23:20:38 +02:00
|
|
|
}
|
|
|
|
buffer_param.flMinDistance = 10;
|
2004-08-12 05:29:39 +02:00
|
|
|
rc=IDirectSound3DBuffer_SetAllParameters(buffer,&buffer_param,
|
|
|
|
DS3D_IMMEDIATE);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
|
2004-07-17 01:42:32 +02:00
|
|
|
start_time=GetTickCount();
|
2004-06-18 01:03:11 +02:00
|
|
|
while (buffer_service(&state)) {
|
2004-07-17 01:42:32 +02:00
|
|
|
WaitForSingleObject(GetCurrentProcess(),TIME_SLICE);
|
2004-07-19 23:20:38 +02:00
|
|
|
now=GetTickCount();
|
2004-06-18 01:03:11 +02:00
|
|
|
if (listener && move_listener) {
|
2007-05-28 01:20:07 +02:00
|
|
|
listener_param.vPosition.x = (float)(-5.0+10.0*(now-start_time)/1000/duration);
|
2004-07-19 23:20:38 +02:00
|
|
|
if (winetest_debug>2)
|
|
|
|
trace("listener position=%g\n",listener_param.vPosition.x);
|
2004-08-12 05:29:39 +02:00
|
|
|
rc=IDirectSound3DListener_SetPosition(listener,
|
|
|
|
listener_param.vPosition.x,listener_param.vPosition.y,
|
|
|
|
listener_param.vPosition.z,DS3D_IMMEDIATE);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound3dListener_SetPosition() failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
if (buffer3d && move_sound) {
|
2007-05-28 01:20:07 +02:00
|
|
|
buffer_param.vPosition.x = (float)(100-200.0*(now-start_time)/1000/duration);
|
2004-07-19 23:20:38 +02:00
|
|
|
if (winetest_debug>2)
|
|
|
|
trace("sound position=%g\n",buffer_param.vPosition.x);
|
2004-08-12 05:29:39 +02:00
|
|
|
rc=IDirectSound3DBuffer_SetPosition(buffer,
|
|
|
|
buffer_param.vPosition.x,buffer_param.vPosition.y,
|
|
|
|
buffer_param.vPosition.z,DS3D_IMMEDIATE);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound3dBuffer_SetPosition() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
}
|
2004-07-17 01:42:32 +02:00
|
|
|
/* Check the sound duration was within 10% of the expected value */
|
|
|
|
now=GetTickCount();
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(fabs(1000*duration-now+start_time)<=100*duration,
|
2006-10-10 01:07:36 +02:00
|
|
|
"The sound played for %d ms instead of %g ms\n",
|
2004-08-12 05:29:39 +02:00
|
|
|
now-start_time,1000*duration);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2009-05-13 10:32:21 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, state.wave);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (is_primary) {
|
|
|
|
/* Set the CooperativeLevel back to normal */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
2004-08-18 02:30:12 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_NORMAL) "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
if (buffer3d) {
|
|
|
|
ref=IDirectSound3DBuffer_Release(buffer);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==0,"IDirectSound3DBuffer_Release() has %d references, "
|
|
|
|
"should have 0\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT test_secondary(LPGUID lpGuid, int play,
|
|
|
|
int has_3d, int has_3dbuffer,
|
|
|
|
int has_listener, int has_duplicate,
|
|
|
|
int move_listener, int move_sound)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND dso=NULL;
|
|
|
|
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
|
|
|
|
LPDIRECTSOUND3DLISTENER listener=NULL;
|
|
|
|
DSBUFFERDESC bufdesc;
|
2005-02-10 21:26:20 +01:00
|
|
|
WAVEFORMATEX wfx, wfx1;
|
2004-06-18 01:03:11 +02:00
|
|
|
int ref;
|
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* We must call SetCooperativeLevel before creating primary buffer */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_PRIORITY) failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
|
|
|
if (has_3d)
|
|
|
|
bufdesc.dwFlags|=DSBCAPS_CTRL3D;
|
|
|
|
else
|
|
|
|
bufdesc.dwFlags|=(DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN);
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
2005-06-05 19:55:08 +02:00
|
|
|
ok((rc==DS_OK && primary!=NULL) || (rc==DSERR_CONTROLUNAVAIL),
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create a %sprimary buffer: %08x\n",has_3d?"3D ":"", rc);
|
2005-06-05 19:55:08 +02:00
|
|
|
if (rc==DSERR_CONTROLUNAVAIL)
|
|
|
|
trace(" No Primary\n");
|
|
|
|
else if (rc==DS_OK && primary!=NULL) {
|
2005-02-10 21:26:20 +01:00
|
|
|
rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %08x\n", rc);
|
2005-02-10 21:26:20 +01:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT1;
|
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
if (has_listener) {
|
2004-08-12 05:29:39 +02:00
|
|
|
rc=IDirectSoundBuffer_QueryInterface(primary,
|
2004-08-25 04:09:00 +02:00
|
|
|
&IID_IDirectSound3DListener,
|
|
|
|
(void **)&listener);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DS_OK && listener!=NULL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSoundBuffer_QueryInterface() failed to get a 3D listener: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
|
|
|
"should have 0\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc==DS_OK && listener!=NULL) {
|
|
|
|
DS3DLISTENER listener_param;
|
|
|
|
ZeroMemory(&listener_param,sizeof(listener_param));
|
|
|
|
/* DSOUND: Error: Invalid buffer */
|
|
|
|
rc=IDirectSound3DListener_GetAllParameters(listener,0);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,
|
2004-08-25 04:09:00 +02:00
|
|
|
"IDirectSound3dListener_GetAllParameters() should have "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid buffer */
|
2004-08-12 05:29:39 +02:00
|
|
|
rc=IDirectSound3DListener_GetAllParameters(listener,
|
|
|
|
&listener_param);
|
|
|
|
ok(rc==DSERR_INVALIDPARAM,
|
2004-08-25 04:09:00 +02:00
|
|
|
"IDirectSound3dListener_GetAllParameters() should have "
|
2008-07-08 17:49:20 +02:00
|
|
|
"returned DSERR_INVALIDPARAM, returned: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
listener_param.dwSize=sizeof(listener_param);
|
2004-08-12 05:29:39 +02:00
|
|
|
rc=IDirectSound3DListener_GetAllParameters(listener,
|
|
|
|
&listener_param);
|
|
|
|
ok(rc==DS_OK,"IDirectSound3dListener_GetAllParameters() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed: %08x\n",rc);
|
2006-04-09 05:48:05 +02:00
|
|
|
} else {
|
|
|
|
ok(listener==NULL, "IDirectSoundBuffer_QueryInterface() "
|
|
|
|
"failed but returned a listener anyway\n");
|
|
|
|
ok(rc!=DS_OK, "IDirectSoundBuffer_QueryInterface() succeeded "
|
|
|
|
"but returned a NULL listener\n");
|
|
|
|
if (listener) {
|
|
|
|
ref=IDirectSound3DListener_Release(listener);
|
|
|
|
ok(ref==0,"IDirectSound3dListener_Release() listener has "
|
|
|
|
"%d references, should have 0\n",ref);
|
|
|
|
}
|
|
|
|
goto EXIT2;
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
init_format(&wfx,WAVE_FORMAT_PCM,22050,16,2);
|
|
|
|
secondary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
|
2012-06-14 16:25:48 +02:00
|
|
|
if (has_3dbuffer)
|
2004-06-18 01:03:11 +02:00
|
|
|
bufdesc.dwFlags|=DSBCAPS_CTRL3D;
|
2015-12-01 14:47:42 +01:00
|
|
|
bufdesc.dwFlags|= DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN;
|
2005-02-16 17:09:02 +01:00
|
|
|
bufdesc.dwBufferBytes=align(wfx.nAvgBytesPerSec*BUFFER_LEN/1000,
|
|
|
|
wfx.nBlockAlign);
|
2004-06-18 01:03:11 +02:00
|
|
|
bufdesc.lpwfxFormat=&wfx;
|
2004-08-12 05:29:39 +02:00
|
|
|
if (winetest_interactive) {
|
2006-10-10 01:07:36 +02:00
|
|
|
trace(" Testing a %s%ssecondary buffer %s%s%s%sat %dx%dx%d "
|
|
|
|
"with a primary buffer at %dx%dx%d\n",
|
2004-08-12 05:29:39 +02:00
|
|
|
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 ":"",
|
2005-02-10 21:26:20 +01:00
|
|
|
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
|
|
|
|
wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
|
2004-08-12 05:29:39 +02:00
|
|
|
}
|
2004-06-18 01:03:11 +02:00
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
2010-09-30 11:31:11 +02:00
|
|
|
ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */
|
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create a %s%ssecondary buffer %s%s%s%sat %dx%dx%d (%s): %08x\n",
|
2004-08-25 04:09:00 +02:00
|
|
|
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,
|
2008-07-08 17:49:20 +02:00
|
|
|
getDSBCAPS(bufdesc.dwFlags),rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc==DS_OK && secondary!=NULL) {
|
2012-06-14 16:25:48 +02:00
|
|
|
IDirectSound3DBuffer *ds3d;
|
|
|
|
|
|
|
|
rc=IDirectSoundBuffer_QueryInterface(secondary, &IID_IDirectSound3DBuffer, (void**)&ds3d);
|
|
|
|
ok((has_3dbuffer && rc==DS_OK) || (!has_3dbuffer && rc==E_NOINTERFACE),
|
|
|
|
"Wrong return trying to get 3D buffer on %s3D secondary interface: %08x\n", has_3dbuffer ? "" : "non-", rc);
|
|
|
|
if(rc==DS_OK)
|
|
|
|
IDirectSound3DBuffer_Release(ds3d);
|
|
|
|
|
2004-08-25 04:09:00 +02:00
|
|
|
if (!has_3d) {
|
2005-09-02 14:26:21 +02:00
|
|
|
LONG refvol,vol,refpan,pan;
|
2004-07-24 00:58:46 +02:00
|
|
|
|
|
|
|
/* Check the initial secondary buffer's volume and pan */
|
|
|
|
rc=IDirectSoundBuffer_GetVolume(secondary,&vol);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(secondary) failed: %08x\n",rc);
|
2006-10-10 01:07:36 +02:00
|
|
|
ok(vol==0,"wrong volume for a new secondary buffer: %d\n",vol);
|
2004-07-24 00:58:46 +02:00
|
|
|
rc=IDirectSoundBuffer_GetPan(secondary,&pan);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(secondary) failed: %08x\n",rc);
|
2006-10-10 01:07:36 +02:00
|
|
|
ok(pan==0,"wrong pan for a new secondary buffer: %d\n",pan);
|
2004-07-24 00:58:46 +02:00
|
|
|
|
|
|
|
/* Check that changing the secondary buffer's volume and pan
|
|
|
|
* does not impact the primary buffer's volume and pan
|
|
|
|
*/
|
|
|
|
rc=IDirectSoundBuffer_GetVolume(primary,&refvol);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(primary) failed: %08x\n",rc);
|
2004-07-24 00:58:46 +02:00
|
|
|
rc=IDirectSoundBuffer_GetPan(primary,&refpan);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(primary) failed: %08x\n", rc);
|
2004-07-24 00:58:46 +02:00
|
|
|
|
|
|
|
rc=IDirectSoundBuffer_SetVolume(secondary,-1000);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: %08x\n",rc);
|
2004-07-24 00:58:46 +02:00
|
|
|
rc=IDirectSoundBuffer_GetVolume(secondary,&vol);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: %08x\n",rc);
|
2006-10-10 01:07:36 +02:00
|
|
|
ok(vol==-1000,"secondary: wrong volume %d instead of -1000\n",
|
2004-08-12 05:29:39 +02:00
|
|
|
vol);
|
2004-07-24 00:58:46 +02:00
|
|
|
rc=IDirectSoundBuffer_SetPan(secondary,-1000);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: %08x\n",rc);
|
2004-07-24 00:58:46 +02:00
|
|
|
rc=IDirectSoundBuffer_GetPan(secondary,&pan);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: %08x\n",rc);
|
2006-10-10 01:07:36 +02:00
|
|
|
ok(pan==-1000,"secondary: wrong pan %d instead of -1000\n",
|
2004-08-12 05:29:39 +02:00
|
|
|
pan);
|
2004-07-24 00:58:46 +02:00
|
|
|
|
|
|
|
rc=IDirectSoundBuffer_GetVolume(primary,&vol);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetVolume(primary) failed: %08x\n",rc);
|
2006-10-10 01:07:36 +02:00
|
|
|
ok(vol==refvol,"The primary volume changed from %d to %d\n",
|
2004-08-12 05:29:39 +02:00
|
|
|
refvol,vol);
|
2004-07-24 00:58:46 +02:00
|
|
|
rc=IDirectSoundBuffer_GetPan(primary,&pan);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(primary) failed: %08x\n", rc);
|
2006-10-10 01:07:36 +02:00
|
|
|
ok(pan==refpan,"The primary pan changed from %d to %d\n",
|
2004-08-12 05:29:39 +02:00
|
|
|
refpan,pan);
|
2004-07-24 00:58:46 +02:00
|
|
|
|
|
|
|
rc=IDirectSoundBuffer_SetVolume(secondary,0);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_SetVolume(secondary) failed: %08x\n",rc);
|
2004-07-24 00:58:46 +02:00
|
|
|
rc=IDirectSoundBuffer_SetPan(secondary,0);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed: %08x\n",rc);
|
2004-07-24 00:58:46 +02:00
|
|
|
}
|
2004-06-18 01:03:11 +02:00
|
|
|
if (has_duplicate) {
|
|
|
|
LPDIRECTSOUNDBUFFER duplicated=NULL;
|
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid source buffer */
|
|
|
|
rc=IDirectSound_DuplicateSoundBuffer(dso,0,0);
|
2004-08-25 04:09:00 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,
|
|
|
|
"IDirectSound_DuplicateSoundBuffer() should have returned "
|
2008-07-08 17:49:20 +02:00
|
|
|
"DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid dest buffer */
|
|
|
|
rc=IDirectSound_DuplicateSoundBuffer(dso,secondary,0);
|
2004-08-25 04:09:00 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,
|
|
|
|
"IDirectSound_DuplicateSoundBuffer() should have returned "
|
2008-07-08 17:49:20 +02:00
|
|
|
"DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
/* DSOUND: Error: Invalid source buffer */
|
|
|
|
rc=IDirectSound_DuplicateSoundBuffer(dso,0,&duplicated);
|
2004-08-25 04:09:00 +02:00
|
|
|
ok(rc==DSERR_INVALIDPARAM,
|
|
|
|
"IDirectSound_DuplicateSoundBuffer() should have returned "
|
2008-07-08 17:49:20 +02:00
|
|
|
"DSERR_INVALIDPARAM, returned: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
duplicated=NULL;
|
2004-08-25 04:09:00 +02:00
|
|
|
rc=IDirectSound_DuplicateSoundBuffer(dso,secondary,
|
|
|
|
&duplicated);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DS_OK && duplicated!=NULL,
|
|
|
|
"IDirectSound_DuplicateSoundBuffer() failed to duplicate "
|
2008-07-08 17:49:20 +02:00
|
|
|
"a secondary buffer: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
if (rc==DS_OK && duplicated!=NULL) {
|
|
|
|
ref=IDirectSoundBuffer_Release(secondary);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d "
|
|
|
|
"references, should have 0\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
secondary=duplicated;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc==DS_OK && secondary!=NULL) {
|
|
|
|
double duration;
|
|
|
|
duration=(move_listener || move_sound?4.0:1.0);
|
2006-01-06 12:16:41 +01:00
|
|
|
test_buffer(dso,&secondary,0,FALSE,0,FALSE,0,
|
2004-08-12 05:29:39 +02:00
|
|
|
winetest_interactive,duration,has_3dbuffer,
|
2005-02-25 20:17:11 +01:00
|
|
|
listener,move_listener,move_sound,FALSE,0);
|
2004-06-18 01:03:11 +02:00
|
|
|
ref=IDirectSoundBuffer_Release(secondary);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() %s has %d references, "
|
2004-08-23 19:50:31 +02:00
|
|
|
"should have 0\n",has_duplicate?"duplicated":"secondary",
|
|
|
|
ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
}
|
2005-02-10 21:26:20 +01:00
|
|
|
EXIT1:
|
2006-04-09 05:48:05 +02:00
|
|
|
if (has_listener) {
|
|
|
|
ref=IDirectSound3DListener_Release(listener);
|
|
|
|
ok(ref==0,"IDirectSound3dListener_Release() listener has %d "
|
|
|
|
"references, should have 0\n",ref);
|
|
|
|
} else {
|
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
|
|
|
"should have 0\n",ref);
|
|
|
|
}
|
2004-06-18 01:03:11 +02:00
|
|
|
} else {
|
2006-04-09 05:48:05 +02:00
|
|
|
ok(primary==NULL,"IDirectSound_CreateSoundBuffer(primary) failed "
|
|
|
|
"but primary created anyway\n");
|
|
|
|
ok(rc!=DS_OK,"IDirectSound_CreateSoundBuffer(primary) succeeded "
|
|
|
|
"but primary not created\n");
|
|
|
|
if (primary) {
|
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
|
|
|
"should have 0\n",ref);
|
|
|
|
}
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
2006-04-09 05:48:05 +02:00
|
|
|
EXIT2:
|
2004-06-18 01:03:11 +02:00
|
|
|
/* Set the CooperativeLevel back to normal */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_NORMAL) failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
EXIT:
|
|
|
|
ref=IDirectSound_Release(dso);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2004-10-19 23:10:41 +02:00
|
|
|
static HRESULT test_for_driver(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND dso=NULL;
|
|
|
|
int ref;
|
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
|
2005-02-23 13:43:38 +01:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"DirectSoundCreate() failed: %08x\n",rc);
|
2004-10-19 23:10:41 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
ref=IDirectSound_Release(dso);
|
|
|
|
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
|
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
static HRESULT test_primary(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND dso=NULL;
|
|
|
|
LPDIRECTSOUNDBUFFER primary=NULL;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
DSCAPS dscaps;
|
|
|
|
int ref, i;
|
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* Get the device capabilities */
|
|
|
|
ZeroMemory(&dscaps, sizeof(dscaps));
|
|
|
|
dscaps.dwSize=sizeof(dscaps);
|
|
|
|
rc=IDirectSound_GetCaps(dso,&dscaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
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);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_PRIORITY) failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
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|DSBCAPS_CTRLPAN;
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
2005-06-05 19:55:08 +02:00
|
|
|
ok((rc==DS_OK && primary!=NULL) || (rc==DSERR_CONTROLUNAVAIL),
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSound_CreateSoundBuffer() failed to create a primary buffer: %08x\n",rc);
|
2005-06-05 19:55:08 +02:00
|
|
|
if (rc==DSERR_CONTROLUNAVAIL)
|
|
|
|
trace(" No Primary\n");
|
|
|
|
else if (rc==DS_OK && primary!=NULL) {
|
2006-01-06 12:16:41 +01:00
|
|
|
test_buffer(dso,&primary,1,TRUE,0,TRUE,0,winetest_interactive &&
|
2005-02-25 20:17:11 +01:00
|
|
|
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,NULL,0,0,
|
|
|
|
FALSE,0);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (winetest_interactive) {
|
|
|
|
LONG volume,pan;
|
|
|
|
|
|
|
|
volume = DSBVOLUME_MAX;
|
|
|
|
for (i = 0; i < 6; i++) {
|
2006-01-06 12:16:41 +01:00
|
|
|
test_buffer(dso,&primary,1,TRUE,volume,TRUE,0,
|
2004-08-12 05:29:39 +02:00
|
|
|
winetest_interactive &&
|
|
|
|
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),
|
2005-02-25 20:17:11 +01:00
|
|
|
1.0,0,NULL,0,0,FALSE,0);
|
2004-06-18 01:03:11 +02:00
|
|
|
volume -= ((DSBVOLUME_MAX-DSBVOLUME_MIN) / 40);
|
|
|
|
}
|
|
|
|
|
|
|
|
pan = DSBPAN_LEFT;
|
|
|
|
for (i = 0; i < 7; i++) {
|
2006-01-06 12:16:41 +01:00
|
|
|
test_buffer(dso,&primary,1,TRUE,0,TRUE,pan,
|
2004-08-12 05:29:39 +02:00
|
|
|
winetest_interactive &&
|
2005-02-25 20:17:11 +01:00
|
|
|
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0,FALSE,0);
|
2004-06-18 01:03:11 +02:00
|
|
|
pan += ((DSBPAN_RIGHT-DSBPAN_LEFT) / 6);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
|
|
|
"should have 0\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the CooperativeLevel back to normal */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_NORMAL) failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
EXIT:
|
|
|
|
ref=IDirectSound_Release(dso);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT test_primary_3d(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND dso=NULL;
|
|
|
|
LPDIRECTSOUNDBUFFER primary=NULL;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
DSCAPS dscaps;
|
|
|
|
int ref;
|
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* Get the device capabilities */
|
|
|
|
ZeroMemory(&dscaps, sizeof(dscaps));
|
|
|
|
dscaps.dwSize=sizeof(dscaps);
|
|
|
|
rc=IDirectSound_GetCaps(dso,&dscaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
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);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_PRIORITY) failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
|
|
|
|
primary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() failed "
|
2008-07-08 17:49:20 +02:00
|
|
|
"to create a primary buffer: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc==DS_OK && primary!=NULL) {
|
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
|
|
|
"should have 0\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
primary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRL3D;
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed to create a 3D primary buffer: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc==DS_OK && primary!=NULL) {
|
2006-01-06 12:16:41 +01:00
|
|
|
test_buffer(dso,&primary,1,FALSE,0,FALSE,0,winetest_interactive &&
|
2005-02-25 20:17:11 +01:00
|
|
|
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0,
|
|
|
|
FALSE,0);
|
2004-06-18 01:03:11 +02:00
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
|
|
|
"should have 0\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Set the CooperativeLevel back to normal */
|
|
|
|
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
|
|
|
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_NORMAL) failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
EXIT:
|
|
|
|
ref=IDirectSound_Release(dso);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT test_primary_3d_with_listener(LPGUID lpGuid)
|
|
|
|
{
|
|
|
|
HRESULT rc;
|
|
|
|
LPDIRECTSOUND dso=NULL;
|
|
|
|
LPDIRECTSOUNDBUFFER primary=NULL;
|
|
|
|
DSBUFFERDESC bufdesc;
|
|
|
|
DSCAPS dscaps;
|
|
|
|
int ref;
|
|
|
|
|
|
|
|
/* Create the DirectSound object */
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK||rc==DSERR_NODRIVER,"DirectSoundCreate() failed: %08x\n", rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* Get the device capabilities */
|
|
|
|
ZeroMemory(&dscaps, sizeof(dscaps));
|
|
|
|
dscaps.dwSize=sizeof(dscaps);
|
|
|
|
rc=IDirectSound_GetCaps(dso,&dscaps);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
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);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel(DSSCL_PRIORITY) failed: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc!=DS_OK)
|
|
|
|
goto EXIT;
|
|
|
|
primary=NULL;
|
|
|
|
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
|
|
|
bufdesc.dwSize=sizeof(bufdesc);
|
|
|
|
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER|DSBCAPS_CTRL3D;
|
|
|
|
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() failed "
|
2008-07-08 17:49:20 +02:00
|
|
|
"to create a 3D primary buffer: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc==DS_OK && primary!=NULL) {
|
|
|
|
LPDIRECTSOUND3DLISTENER listener=NULL;
|
2010-02-15 00:59:27 +01:00
|
|
|
LPDIRECTSOUNDBUFFER temp_buffer=NULL;
|
2004-08-12 05:29:39 +02:00
|
|
|
rc=IDirectSoundBuffer_QueryInterface(primary,
|
|
|
|
&IID_IDirectSound3DListener,(void **)&listener);
|
|
|
|
ok(rc==DS_OK && listener!=NULL,"IDirectSoundBuffer_QueryInterface() "
|
2008-07-08 17:49:20 +02:00
|
|
|
"failed to get a 3D listener: %08x\n",rc);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc==DS_OK && listener!=NULL) {
|
|
|
|
/* Checking the COM interface */
|
2004-08-12 05:29:39 +02:00
|
|
|
rc=IDirectSoundBuffer_QueryInterface(primary,
|
|
|
|
&IID_IDirectSoundBuffer,(LPVOID *)&temp_buffer);
|
|
|
|
ok(rc==DS_OK && temp_buffer!=NULL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSoundBuffer_QueryInterface() failed: %08x\n", rc);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(temp_buffer==primary,
|
2005-09-12 12:30:05 +02:00
|
|
|
"COM interface broken: %p != %p\n",
|
|
|
|
temp_buffer,primary);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (rc==DS_OK && temp_buffer!=NULL) {
|
|
|
|
ref=IDirectSoundBuffer_Release(temp_buffer);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
|
|
|
|
"should have 1\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
temp_buffer=NULL;
|
2004-08-12 05:29:39 +02:00
|
|
|
rc=IDirectSound3DListener_QueryInterface(listener,
|
|
|
|
&IID_IDirectSoundBuffer,(LPVOID *)&temp_buffer);
|
|
|
|
ok(rc==DS_OK && temp_buffer!=NULL,
|
2008-07-08 17:49:20 +02:00
|
|
|
"IDirectSoundBuffer_QueryInterface() failed: %08x\n", rc);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(temp_buffer==primary,
|
2005-09-12 12:30:05 +02:00
|
|
|
"COM interface broken: %p != %p\n",
|
|
|
|
temp_buffer,primary);
|
2004-06-18 01:03:11 +02:00
|
|
|
ref=IDirectSoundBuffer_Release(temp_buffer);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==1,"IDirectSoundBuffer_Release() has %d references, "
|
|
|
|
"should have 1\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
|
|
|
|
/* Testing the buffer */
|
2006-01-06 12:16:41 +01:00
|
|
|
test_buffer(dso,&primary,1,FALSE,0,FALSE,0,
|
2004-08-12 05:29:39 +02:00
|
|
|
winetest_interactive &&
|
|
|
|
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,
|
2005-02-25 20:17:11 +01:00
|
|
|
listener,0,0,FALSE,0);
|
2010-02-10 14:59:28 +01:00
|
|
|
|
2012-01-17 01:54:53 +01:00
|
|
|
temp_buffer = NULL;
|
|
|
|
rc = IDirectSound3DListener_QueryInterface(listener, &IID_IKsPropertySet,
|
|
|
|
(void **)&temp_buffer);
|
|
|
|
ok(rc==DS_OK && temp_buffer!=NULL,
|
|
|
|
"IDirectSound3DListener_QueryInterface didn't handle IKsPropertySet: ret = %08x\n", rc);
|
|
|
|
if(temp_buffer)
|
|
|
|
IKsPropertySet_Release(temp_buffer);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Testing the reference counting */
|
|
|
|
ref=IDirectSound3DListener_Release(listener);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==0,"IDirectSound3DListener_Release() listener has %d "
|
|
|
|
"references, should have 0\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
|
2012-01-17 01:54:53 +01:00
|
|
|
temp_buffer = NULL;
|
|
|
|
rc = IDirectSoundBuffer_QueryInterface(primary, &IID_IKsPropertySet, (void **)&temp_buffer);
|
|
|
|
ok(rc==DS_OK && temp_buffer!=NULL,
|
|
|
|
"IDirectSoundBuffer_QueryInterface didn't handle IKsPropertySet on primary buffer: ret = %08x\n", rc);
|
|
|
|
if(temp_buffer)
|
|
|
|
IKsPropertySet_Release(temp_buffer);
|
2010-02-15 00:59:27 +01:00
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
/* Testing the reference counting */
|
|
|
|
ref=IDirectSoundBuffer_Release(primary);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
|
|
|
"should have 0\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
EXIT:
|
|
|
|
ref=IDirectSound_Release(dso);
|
2004-08-12 05:29:39 +02:00
|
|
|
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
|
2004-06-18 01:03:11 +02:00
|
|
|
if (ref!=0)
|
|
|
|
return DSERR_GENERIC;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-08-13 00:16:13 +02:00
|
|
|
static unsigned driver_count = 0;
|
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
|
|
|
|
LPCSTR lpcstrModule, LPVOID lpContext)
|
|
|
|
{
|
2004-10-19 23:10:41 +02:00
|
|
|
HRESULT rc;
|
2004-08-23 19:50:31 +02:00
|
|
|
trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
|
2012-08-13 00:16:13 +02:00
|
|
|
driver_count++;
|
2004-06-18 01:03:11 +02:00
|
|
|
|
2004-10-19 23:10:41 +02:00
|
|
|
rc = test_for_driver(lpGuid);
|
|
|
|
if (rc == DSERR_NODRIVER) {
|
|
|
|
trace(" No Driver\n");
|
2013-11-12 22:11:12 +01:00
|
|
|
return TRUE;
|
2004-10-21 21:51:10 +02:00
|
|
|
} else if (rc == DSERR_ALLOCATED) {
|
|
|
|
trace(" Already In Use\n");
|
2013-11-12 22:11:12 +01:00
|
|
|
return TRUE;
|
2005-02-23 13:43:38 +01:00
|
|
|
} else if (rc == E_FAIL) {
|
|
|
|
trace(" No Device\n");
|
2013-11-12 22:11:12 +01:00
|
|
|
return TRUE;
|
2004-10-19 23:10:41 +02:00
|
|
|
}
|
|
|
|
|
2004-06-18 01:03:11 +02:00
|
|
|
trace(" Testing the primary buffer\n");
|
|
|
|
test_primary(lpGuid);
|
|
|
|
|
|
|
|
trace(" Testing 3D primary buffer\n");
|
|
|
|
test_primary_3d(lpGuid);
|
|
|
|
|
|
|
|
trace(" Testing 3D primary buffer with listener\n");
|
|
|
|
test_primary_3d_with_listener(lpGuid);
|
|
|
|
|
|
|
|
/* Testing secondary buffers */
|
|
|
|
test_secondary(lpGuid,winetest_interactive,0,0,0,0,0,0);
|
|
|
|
test_secondary(lpGuid,winetest_interactive,0,0,0,1,0,0);
|
|
|
|
|
|
|
|
/* Testing 3D secondary buffers */
|
|
|
|
test_secondary(lpGuid,winetest_interactive,1,0,0,0,0,0);
|
|
|
|
test_secondary(lpGuid,winetest_interactive,1,1,0,0,0,0);
|
|
|
|
test_secondary(lpGuid,winetest_interactive,1,1,0,1,0,0);
|
|
|
|
test_secondary(lpGuid,winetest_interactive,1,0,1,0,0,0);
|
|
|
|
test_secondary(lpGuid,winetest_interactive,1,0,1,1,0,0);
|
|
|
|
test_secondary(lpGuid,winetest_interactive,1,1,1,0,0,0);
|
|
|
|
test_secondary(lpGuid,winetest_interactive,1,1,1,1,0,0);
|
|
|
|
test_secondary(lpGuid,winetest_interactive,1,1,1,0,1,0);
|
|
|
|
test_secondary(lpGuid,winetest_interactive,1,1,1,0,0,1);
|
|
|
|
test_secondary(lpGuid,winetest_interactive,1,1,1,0,1,1);
|
|
|
|
|
2013-11-12 22:11:12 +01:00
|
|
|
return TRUE;
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void ds3d_tests(void)
|
2004-06-18 01:03:11 +02:00
|
|
|
{
|
|
|
|
HRESULT rc;
|
2007-01-15 15:00:39 +01:00
|
|
|
rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
|
2008-07-08 17:49:20 +02:00
|
|
|
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc);
|
2012-08-13 00:16:13 +02:00
|
|
|
trace("tested %u DirectSound drivers\n", driver_count);
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(ds3d)
|
|
|
|
{
|
2007-01-15 15:00:39 +01:00
|
|
|
HMODULE hDsound;
|
|
|
|
|
2005-01-09 17:34:00 +01:00
|
|
|
CoInitialize(NULL);
|
|
|
|
|
2013-10-01 23:09:53 +02:00
|
|
|
hDsound = LoadLibraryA("dsound.dll");
|
2007-01-15 15:00:39 +01:00
|
|
|
if (hDsound)
|
|
|
|
{
|
2005-03-05 11:49:08 +01:00
|
|
|
|
2007-01-15 15:00:39 +01:00
|
|
|
pDirectSoundEnumerateA = (void*)GetProcAddress(hDsound,
|
|
|
|
"DirectSoundEnumerateA");
|
|
|
|
pDirectSoundCreate = (void*)GetProcAddress(hDsound,
|
|
|
|
"DirectSoundCreate");
|
|
|
|
|
|
|
|
ds3d_tests();
|
|
|
|
|
|
|
|
FreeLibrary(hDsound);
|
|
|
|
}
|
|
|
|
else
|
2012-08-13 00:15:33 +02:00
|
|
|
skip("dsound.dll not found - skipping all tests\n");
|
2005-01-09 17:34:00 +01:00
|
|
|
|
|
|
|
CoUninitialize();
|
2004-06-18 01:03:11 +02:00
|
|
|
}
|