Add secondary buffer SetFrequency test.
This commit is contained in:
parent
2a052044fe
commit
3b78212f1d
|
@ -280,7 +280,8 @@ void test_buffer(LPDIRECTSOUND dso, LPDIRECTSOUNDBUFFER dsbo,
|
|||
BOOL is_primary, BOOL set_volume, LONG volume,
|
||||
BOOL set_pan, LONG pan, BOOL play, double duration,
|
||||
BOOL buffer3d, LPDIRECTSOUND3DLISTENER listener,
|
||||
BOOL move_listener, BOOL move_sound)
|
||||
BOOL move_listener, BOOL move_sound,
|
||||
BOOL set_frequency, DWORD frequency)
|
||||
{
|
||||
HRESULT rc;
|
||||
DSBCAPS dsbcaps;
|
||||
|
@ -288,6 +289,15 @@ void test_buffer(LPDIRECTSOUND dso, LPDIRECTSOUNDBUFFER dsbo,
|
|||
DWORD size,status,freq;
|
||||
int ref;
|
||||
|
||||
if (set_frequency) {
|
||||
rc=IDirectSoundBuffer_SetFrequency(dsbo,frequency);
|
||||
ok(rc==DS_OK||rc==DSERR_CONTROLUNAVAIL,
|
||||
"IDirectSoundBuffer_SetFrequency() failed to set frequency "
|
||||
"%s\n",DXGetErrorString8(rc));
|
||||
if (rc!=DS_OK)
|
||||
return;
|
||||
}
|
||||
|
||||
/* DSOUND: Error: Invalid caps pointer */
|
||||
rc=IDirectSoundBuffer_GetCaps(dsbo,0);
|
||||
ok(rc==DSERR_INVALIDPARAM,"IDirectSoundBuffer_GetCaps() should have "
|
||||
|
@ -336,8 +346,9 @@ void test_buffer(LPDIRECTSOUND dso, LPDIRECTSOUNDBUFFER dsbo,
|
|||
(rc==DSERR_CONTROLUNAVAIL&&!(dsbcaps.dwFlags&DSBCAPS_CTRLFREQUENCY)),
|
||||
"IDirectSoundBuffer_GetFrequency() failed: %s\n",DXGetErrorString8(rc));
|
||||
if (rc==DS_OK) {
|
||||
ok(freq==wfx.nSamplesPerSec,"The frequency returned by GetFrequency "
|
||||
"%ld does not match the format %ld\n",freq,wfx.nSamplesPerSec);
|
||||
DWORD f = set_frequency?frequency:wfx.nSamplesPerSec;
|
||||
ok(freq==f,"The frequency returned by GetFrequency "
|
||||
"%ld does not match the format %ld\n",freq,f);
|
||||
}
|
||||
|
||||
/* DSOUND: Error: Invalid status pointer */
|
||||
|
@ -404,8 +415,14 @@ void test_buffer(LPDIRECTSOUND dso, LPDIRECTSOUNDBUFFER dsbo,
|
|||
DWORD start_time,now;
|
||||
|
||||
if (winetest_interactive) {
|
||||
trace(" Playing %g second 440Hz tone at %ldx%dx%d\n", duration,
|
||||
wfx.nSamplesPerSec, wfx.wBitsPerSample,wfx.nChannels);
|
||||
if (set_frequency)
|
||||
trace(" Playing %g second 440Hz tone at %ldx%dx%d with a "
|
||||
"frequency of %ld (%ldHz)\n", duration,
|
||||
wfx.nSamplesPerSec, wfx.wBitsPerSample, wfx.nChannels,
|
||||
frequency, (440 * frequency) / wfx.nSamplesPerSec);
|
||||
else
|
||||
trace(" Playing %g second 440Hz tone at %ldx%dx%d\n", duration,
|
||||
wfx.nSamplesPerSec, wfx.wBitsPerSample, wfx.nChannels);
|
||||
}
|
||||
|
||||
if (is_primary) {
|
||||
|
@ -522,7 +539,10 @@ void test_buffer(LPDIRECTSOUND dso, LPDIRECTSOUNDBUFFER dsbo,
|
|||
}
|
||||
}
|
||||
|
||||
state.wave=wave_generate_la(&wfx,duration,&state.wave_len);
|
||||
if (set_frequency)
|
||||
state.wave=wave_generate_la(&wfx,(duration*frequency)/wfx.nSamplesPerSec,&state.wave_len);
|
||||
else
|
||||
state.wave=wave_generate_la(&wfx,duration,&state.wave_len);
|
||||
|
||||
state.dsbo=dsbo;
|
||||
state.wfx=&wfx;
|
||||
|
@ -840,7 +860,7 @@ static HRESULT test_secondary(LPGUID lpGuid, int play,
|
|||
duration=(move_listener || move_sound?4.0:1.0);
|
||||
test_buffer(dso,secondary,0,FALSE,0,FALSE,0,
|
||||
winetest_interactive,duration,has_3dbuffer,
|
||||
listener,move_listener,move_sound);
|
||||
listener,move_listener,move_sound,FALSE,0);
|
||||
ref=IDirectSoundBuffer_Release(secondary);
|
||||
ok(ref==0,"IDirectSoundBuffer_Release() %s has %d references, "
|
||||
"should have 0\n",has_duplicate?"duplicated":"secondary",
|
||||
|
@ -937,7 +957,8 @@ static HRESULT test_primary(LPGUID lpGuid)
|
|||
"to create a primary buffer: %s\n",DXGetErrorString8(rc));
|
||||
if (rc==DS_OK && primary!=NULL) {
|
||||
test_buffer(dso,primary,1,TRUE,0,TRUE,0,winetest_interactive &&
|
||||
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,NULL,0,0);
|
||||
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,NULL,0,0,
|
||||
FALSE,0);
|
||||
if (winetest_interactive) {
|
||||
LONG volume,pan;
|
||||
|
||||
|
@ -946,7 +967,7 @@ static HRESULT test_primary(LPGUID lpGuid)
|
|||
test_buffer(dso,primary,1,TRUE,volume,TRUE,0,
|
||||
winetest_interactive &&
|
||||
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),
|
||||
1.0,0,NULL,0,0);
|
||||
1.0,0,NULL,0,0,FALSE,0);
|
||||
volume -= ((DSBVOLUME_MAX-DSBVOLUME_MIN) / 40);
|
||||
}
|
||||
|
||||
|
@ -954,7 +975,7 @@ static HRESULT test_primary(LPGUID lpGuid)
|
|||
for (i = 0; i < 7; i++) {
|
||||
test_buffer(dso,primary,1,TRUE,0,TRUE,pan,
|
||||
winetest_interactive &&
|
||||
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0);
|
||||
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0,FALSE,0);
|
||||
pan += ((DSBPAN_RIGHT-DSBPAN_LEFT) / 6);
|
||||
}
|
||||
}
|
||||
|
@ -1030,7 +1051,8 @@ static HRESULT test_primary_3d(LPGUID lpGuid)
|
|||
"failed to create a 3D primary buffer: %s\n",DXGetErrorString8(rc));
|
||||
if (rc==DS_OK && primary!=NULL) {
|
||||
test_buffer(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive &&
|
||||
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0);
|
||||
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,0,0,0,
|
||||
FALSE,0);
|
||||
ref=IDirectSoundBuffer_Release(primary);
|
||||
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
||||
"should have 0\n",ref);
|
||||
|
@ -1129,7 +1151,7 @@ static HRESULT test_primary_3d_with_listener(LPGUID lpGuid)
|
|||
test_buffer(dso,primary,1,FALSE,0,FALSE,0,
|
||||
winetest_interactive &&
|
||||
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,
|
||||
listener,0,0);
|
||||
listener,0,0,FALSE,0);
|
||||
}
|
||||
|
||||
/* Testing the reference counting */
|
||||
|
|
|
@ -455,7 +455,7 @@ static HRESULT test_primary(LPGUID lpGuid)
|
|||
trace("Listen for stutter, changes in pitch, volume, etc.\n");
|
||||
}
|
||||
test_buffer(dso,primary,1,FALSE,0,FALSE,0,winetest_interactive &&
|
||||
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),5.0,0,0,0,0);
|
||||
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),5.0,0,0,0,0,FALSE,0);
|
||||
|
||||
ref=IDirectSoundBuffer_Release(primary);
|
||||
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
||||
|
@ -590,7 +590,7 @@ static HRESULT test_primary_secondary(LPGUID lpGuid)
|
|||
|
||||
if (rc==DS_OK && secondary!=NULL) {
|
||||
test_buffer(dso,secondary,0,FALSE,0,FALSE,0,
|
||||
winetest_interactive,1.0,0,NULL,0,0);
|
||||
winetest_interactive,1.0,0,NULL,0,0,FALSE,0);
|
||||
|
||||
ref=IDirectSoundBuffer_Release(secondary);
|
||||
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
|
||||
|
@ -703,7 +703,7 @@ static HRESULT test_secondary(LPGUID lpGuid)
|
|||
|
||||
if (rc==DS_OK && secondary!=NULL) {
|
||||
test_buffer(dso,secondary,0,FALSE,0,FALSE,0,
|
||||
winetest_interactive,1.0,0,NULL,0,0);
|
||||
winetest_interactive,1.0,0,NULL,0,0,FALSE,0);
|
||||
|
||||
ref=IDirectSoundBuffer_Release(secondary);
|
||||
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
|
||||
|
@ -783,6 +783,115 @@ static HRESULT test_block_align(LPGUID lpGuid)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static struct fmt {
|
||||
int bits;
|
||||
int channels;
|
||||
} fmts[] = { { 8, 1 }, { 8, 2 }, { 16, 1 }, {16, 2 } };
|
||||
|
||||
static HRESULT test_frequency(LPGUID lpGuid)
|
||||
{
|
||||
HRESULT rc;
|
||||
LPDIRECTSOUND dso=NULL;
|
||||
LPDIRECTSOUNDBUFFER primary=NULL,secondary=NULL;
|
||||
DSBUFFERDESC bufdesc;
|
||||
DSCAPS dscaps;
|
||||
WAVEFORMATEX wfx, wfx1;
|
||||
DWORD f, r;
|
||||
int ref;
|
||||
int rates[] = { 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100,
|
||||
48000, 96000 };
|
||||
|
||||
/* Create the DirectSound object */
|
||||
rc=DirectSoundCreate(lpGuid,&dso,NULL);
|
||||
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
|
||||
"DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
|
||||
if (rc!=DS_OK)
|
||||
return rc;
|
||||
|
||||
/* Get the device capabilities */
|
||||
ZeroMemory(&dscaps, sizeof(dscaps));
|
||||
dscaps.dwSize=sizeof(dscaps);
|
||||
rc=IDirectSound_GetCaps(dso,&dscaps);
|
||||
ok(rc==DS_OK,"IDirectSound_GetCaps() failed: %s\n",DXGetErrorString8(rc));
|
||||
if (rc!=DS_OK)
|
||||
goto EXIT;
|
||||
|
||||
/* We must call SetCooperativeLevel before creating primary buffer */
|
||||
/* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
|
||||
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
|
||||
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
if (rc!=DS_OK)
|
||||
goto EXIT;
|
||||
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
|
||||
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
|
||||
ok(rc==DS_OK && primary!=NULL,
|
||||
"IDirectSound_CreateSoundBuffer() failed to create a primary buffer "
|
||||
"%s\n",DXGetErrorString8(rc));
|
||||
|
||||
if (rc==DS_OK && primary!=NULL) {
|
||||
rc=IDirectSoundBuffer_GetFormat(primary,&wfx1,sizeof(wfx1),NULL);
|
||||
ok(rc==DS_OK,"IDirectSoundBuffer8_Getformat() failed: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
if (rc!=DS_OK)
|
||||
goto EXIT1;
|
||||
|
||||
for (f=0;f<sizeof(fmts)/sizeof(fmts[0]);f++) {
|
||||
for (r=0;r<sizeof(rates)/sizeof(rates[0]);r++) {
|
||||
init_format(&wfx,WAVE_FORMAT_PCM,11025,fmts[f].bits,
|
||||
fmts[f].channels);
|
||||
secondary=NULL;
|
||||
ZeroMemory(&bufdesc, sizeof(bufdesc));
|
||||
bufdesc.dwSize=sizeof(bufdesc);
|
||||
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_CTRLFREQUENCY;
|
||||
bufdesc.dwBufferBytes=align((wfx.nAvgBytesPerSec*rates[r]/11025)*
|
||||
BUFFER_LEN/1000,wfx.nBlockAlign);
|
||||
bufdesc.lpwfxFormat=&wfx;
|
||||
if (winetest_interactive) {
|
||||
trace(" Testing a secondary buffer at %ldx%dx%d "
|
||||
"with a primary buffer at %ldx%dx%d\n",
|
||||
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
|
||||
wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
|
||||
}
|
||||
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
|
||||
ok(rc==DS_OK && secondary!=NULL,
|
||||
"IDirectSound_CreateSoundBuffer() failed to create a secondary "
|
||||
"buffer %s\n",DXGetErrorString8(rc));
|
||||
|
||||
if (rc==DS_OK && secondary!=NULL) {
|
||||
test_buffer(dso,secondary,0,FALSE,0,FALSE,0,
|
||||
winetest_interactive,1.0,0,NULL,0,0,TRUE,rates[r]);
|
||||
|
||||
ref=IDirectSoundBuffer_Release(secondary);
|
||||
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
|
||||
"should have 0\n",ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
EXIT1:
|
||||
ref=IDirectSoundBuffer_Release(primary);
|
||||
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
|
||||
"should have 0\n",ref);
|
||||
}
|
||||
|
||||
/* Set the CooperativeLevel back to normal */
|
||||
/* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
|
||||
rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
|
||||
ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %s\n",
|
||||
DXGetErrorString8(rc));
|
||||
|
||||
EXIT:
|
||||
ref=IDirectSound_Release(dso);
|
||||
ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
|
||||
if (ref!=0)
|
||||
return DSERR_GENERIC;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
|
||||
LPCSTR lpcstrModule, LPVOID lpContext)
|
||||
{
|
||||
|
@ -800,6 +909,7 @@ static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
|
|||
test_primary(lpGuid);
|
||||
test_primary_secondary(lpGuid);
|
||||
test_secondary(lpGuid);
|
||||
test_frequency(lpGuid);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -55,7 +55,7 @@ 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);
|
||||
LPDIRECTSOUND3DLISTENER,BOOL,BOOL,BOOL,DWORD);
|
||||
extern void test_buffer8(LPDIRECTSOUND8,LPDIRECTSOUNDBUFFER,
|
||||
BOOL,BOOL,LONG,BOOL,LONG,BOOL,double,BOOL,
|
||||
LPDIRECTSOUND3DLISTENER,BOOL,BOOL);
|
||||
|
|
Loading…
Reference in New Issue