Author: akhaldi
Date: Mon Sep 30 11:39:02 2013
New Revision: 60475
URL:
http://svn.reactos.org/svn/reactos?rev=60475&view=rev
Log:
[DSOUND_WINETEST]
* Sync with Wine 1.7.1.
CORE-7469
Modified:
trunk/rostests/winetests/dsound/CMakeLists.txt
trunk/rostests/winetests/dsound/capture.c
trunk/rostests/winetests/dsound/ds3d.c
trunk/rostests/winetests/dsound/ds3d8.c
trunk/rostests/winetests/dsound/dsound.c
trunk/rostests/winetests/dsound/dsound8.c
trunk/rostests/winetests/dsound/dsound_test.h
trunk/rostests/winetests/dsound/duplex.c
trunk/rostests/winetests/dsound/propset.c
trunk/rostests/winetests/dsound/testlist.c
Modified: trunk/rostests/winetests/dsound/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/CMakeLis…
==============================================================================
--- trunk/rostests/winetests/dsound/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/winetests/dsound/CMakeLists.txt [iso-8859-1] Mon Sep 30 11:39:02 2013
@@ -1,7 +1,3 @@
-
-add_definitions(
- -D__ROS_LONG64__
- -D_DLL -D__USE_CRTIMP)
list(APPEND SOURCE
capture.c
@@ -14,7 +10,7 @@
testlist.c)
add_executable(dsound_winetest ${SOURCE})
-target_link_libraries(dsound_winetest wine uuid dxguid)
+target_link_libraries(dsound_winetest uuid dxguid)
set_module_type(dsound_winetest win32cui)
-add_importlibs(dsound_winetest dsound ole32 user32 msvcrt kernel32 ntdll)
+add_importlibs(dsound_winetest ole32 user32 msvcrt kernel32)
add_cd_file(TARGET dsound_winetest DESTINATION reactos/bin FOR all)
Modified: trunk/rostests/winetests/dsound/capture.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/capture.…
==============================================================================
--- trunk/rostests/winetests/dsound/capture.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/dsound/capture.c [iso-8859-1] Mon Sep 30 11:39:02 2013
@@ -19,13 +19,21 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+#define COBJMACROS
+
+#include <wine/test.h>
+
#include <stdio.h>
-#include "initguid.h"
-#include "windows.h"
-#include "wine/test.h"
-#include "dsound.h"
-#include "mmreg.h"
-#include "dsconf.h"
+//#include "initguid.h"
+//#include "windows.h"
+#include <wingdi.h>
+#include <mmsystem.h>
+#include <dsound.h>
+#include <mmreg.h>
+#include <dsconf.h>
#include "dsound_test.h"
@@ -177,7 +185,7 @@
"should have 0\n", ref);
}
-static void IDirectSoundCapture_tests(void)
+static void test_capture(void)
{
HRESULT rc;
LPDIRECTSOUNDCAPTURE dsco=NULL;
@@ -379,8 +387,6 @@
(void **)&(state.notify));
ok((rc==DS_OK)&&(state.notify!=NULL),
"IDirectSoundCaptureBuffer_QueryInterface() failed: %08x\n", rc);
- if (rc!=DS_OK)
- return;
for (i = 0; i < NOTIFICATIONS; i++) {
state.posnotify[i].dwOffset = (i * state.size) + state.size - 1;
@@ -390,28 +396,23 @@
rc=IDirectSoundNotify_SetNotificationPositions(state.notify,NOTIFICATIONS,
state.posnotify);
ok(rc==DS_OK,"IDirectSoundNotify_SetNotificationPositions() failed:
%08x\n", rc);
- if (rc!=DS_OK)
- return;
ref=IDirectSoundNotify_Release(state.notify);
ok(ref==0,"IDirectSoundNotify_Release(): has %d references, should have "
"0\n",ref);
- if (ref!=0)
- return;
+
+ rc=IDirectSoundCaptureBuffer_Start(dscbo,DSCBSTART_LOOPING);
+ ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %08x\n", rc);
+
+ rc=IDirectSoundCaptureBuffer_Start(dscbo,0);
+ ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %08x\n", rc);
+
+ rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status);
+ ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %08x\n", rc);
+ ok(status==(DSCBSTATUS_CAPTURING|DSCBSTATUS_LOOPING) ||
broken(status==DSCBSTATUS_CAPTURING),
+ "GetStatus: bad status: %x\n",status);
if (record) {
- rc=IDirectSoundCaptureBuffer_Start(dscbo,DSCBSTART_LOOPING);
- ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Start() failed: %08x\n", rc);
- if (rc!=DS_OK)
- return;
-
- rc=IDirectSoundCaptureBuffer_GetStatus(dscbo,&status);
- ok(rc==DS_OK,"IDirectSoundCaptureBuffer_GetStatus() failed: %08x\n", rc);
- ok(status==(DSCBSTATUS_CAPTURING|DSCBSTATUS_LOOPING),
- "GetStatus: bad status: %x\n",status);
- if (rc!=DS_OK)
- return;
-
/* wait for the notifications */
for (i = 0; i < (NOTIFICATIONS * 2); i++) {
rc=WaitForMultipleObjects(NOTIFICATIONS,state.event,FALSE,3000);
@@ -426,11 +427,12 @@
break;
}
- rc=IDirectSoundCaptureBuffer_Stop(dscbo);
- ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc);
- if (rc!=DS_OK)
- return;
- }
+ }
+ rc=IDirectSoundCaptureBuffer_Stop(dscbo);
+ ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc);
+
+ rc=IDirectSoundCaptureBuffer_Stop(dscbo);
+ ok(rc==DS_OK,"IDirectSoundCaptureBuffer_Stop() failed: %08x\n", rc);
}
static BOOL WINAPI dscenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
@@ -671,13 +673,93 @@
return TRUE;
}
-static void capture_tests(void)
+static void test_enumerate(void)
{
HRESULT rc;
rc=pDirectSoundCaptureEnumerateA(&dscenum_callback,NULL);
ok(rc==DS_OK,"DirectSoundCaptureEnumerateA() failed: %08x\n", rc);
}
+static void test_COM(void)
+{
+ IDirectSoundCapture *dsc = (IDirectSoundCapture*)0xdeadbeef;
+ IDirectSoundCaptureBuffer *buffer = (IDirectSoundCaptureBuffer*)0xdeadbeef;
+ IDirectSoundNotify *notify;
+ IUnknown *unk;
+ DSCBUFFERDESC bufdesc;
+ WAVEFORMATEX wfx;
+ HRESULT hr;
+ ULONG refcount;
+
+ hr = pDirectSoundCaptureCreate(NULL, &dsc, (IUnknown*)0xdeadbeef);
+ ok(hr == DSERR_NOAGGREGATION,
+ "DirectSoundCaptureCreate failed: %08x, expected DSERR_NOAGGREGATION\n",
hr);
+ ok(dsc == (IDirectSoundCapture*)0xdeadbeef, "dsc = %p\n", dsc);
+
+ hr = pDirectSoundCaptureCreate(NULL, &dsc, NULL);
+ if (hr == DSERR_NODRIVER) {
+ skip("No driver\n");
+ return;
+ }
+ ok(hr == DS_OK, "DirectSoundCaptureCreate failed: %08x, expected DS_OK\n",
hr);
+
+ /* Different refcount for IDirectSoundCapture and for IUnknown */
+ refcount = IDirectSoundCapture_AddRef(dsc);
+ ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
+ hr = IDirectSoundCapture_QueryInterface(dsc, &IID_IUnknown, (void**)&unk);
+ ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
+ refcount = IUnknown_AddRef(unk);
+ ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
+ IUnknown_Release(unk);
+ IUnknown_Release(unk);
+ IDirectSoundCapture_Release(dsc);
+
+ init_format(&wfx, WAVE_FORMAT_PCM, 44100, 16, 1);
+ ZeroMemory(&bufdesc, sizeof(bufdesc));
+ bufdesc.dwSize = sizeof(bufdesc);
+ bufdesc.dwBufferBytes = wfx.nAvgBytesPerSec;
+ bufdesc.lpwfxFormat = &wfx;
+
+ hr = IDirectSoundCapture_CreateCaptureBuffer(dsc, &bufdesc, &buffer,
(IUnknown*)0xdeadbeef);
+ if (hr == E_INVALIDARG) {
+ /* Old DirectX has only the 1st version of the DSCBUFFERDESC struct */
+ bufdesc.dwSize = sizeof(DSCBUFFERDESC1);
+ hr = IDirectSoundCapture_CreateCaptureBuffer(dsc, &bufdesc, &buffer,
(IUnknown*)0xdeadbeef);
+ }
+ ok(hr == DSERR_NOAGGREGATION,
+ "IDirectSoundCapture_CreateCaptureBuffer failed: %08x, expected
DSERR_NOAGGREGATION\n", hr);
+ ok(buffer == (IDirectSoundCaptureBuffer*)0xdeadbeef || !buffer /* Win2k without
DirectX9 */,
+ "buffer = %p\n", buffer);
+
+ hr = IDirectSoundCapture_CreateCaptureBuffer(dsc, &bufdesc, &buffer, NULL);
+ ok(hr == DS_OK, "IDirectSoundCapture_CreateCaptureBuffer failed: %08x, expected
DS_OK\n", hr);
+
+ /* IDirectSoundCaptureBuffer and IDirectSoundNotify have separate refcounts */
+ IDirectSoundCaptureBuffer_AddRef(buffer);
+ refcount = IDirectSoundCaptureBuffer_AddRef(buffer);
+ ok(refcount == 3, "IDirectSoundCaptureBuffer refcount is %u, expected 3\n",
refcount);
+ hr = IDirectSoundCaptureBuffer_QueryInterface(buffer, &IID_IDirectSoundNotify,
(void**)¬ify);
+ ok(hr == DS_OK, "IDirectSoundCapture_QueryInterface failed: %08x, expected
DS_OK\n", hr);
+ refcount = IDirectSoundNotify_AddRef(notify);
+ ok(refcount == 2, "IDirectSoundNotify refcount is %u, expected 2\n",
refcount);
+ IDirectSoundCaptureBuffer_AddRef(buffer);
+ refcount = IDirectSoundCaptureBuffer_Release(buffer);
+ ok(refcount == 3, "IDirectSoundCaptureBuffer refcount is %u, expected 3\n",
refcount);
+
+ /* Release IDirectSoundCaptureBuffer while keeping IDirectSoundNotify alive */
+ while (IDirectSoundCaptureBuffer_Release(buffer) > 0);
+ refcount = IDirectSoundNotify_AddRef(notify);
+ ok(refcount == 3, "IDirectSoundNotify refcount is %u, expected 3\n",
refcount);
+ refcount = IDirectSoundCaptureBuffer_AddRef(buffer);
+ ok(refcount == 1, "IDirectSoundCaptureBuffer refcount is %u, expected 1\n",
refcount);
+
+ while (IDirectSoundNotify_Release(notify) > 0);
+ refcount = IDirectSoundCaptureBuffer_Release(buffer);
+ ok(refcount == 0, "IDirectSoundCaptureBuffer refcount is %u, expected 0\n",
refcount);
+ refcount = IDirectSoundCapture_Release(dsc);
+ ok(refcount == 0, "IDirectSoundCapture refcount is %u, expected 0\n",
refcount);
+}
+
START_TEST(capture)
{
HMODULE hDsound;
@@ -685,25 +767,22 @@
CoInitialize(NULL);
hDsound = LoadLibrary("dsound.dll");
- if (hDsound)
- {
-
- pDirectSoundCaptureCreate=(void*)GetProcAddress(hDsound,
- "DirectSoundCaptureCreate");
- pDirectSoundCaptureEnumerateA=(void*)GetProcAddress(hDsound,
- "DirectSoundCaptureEnumerateA");
- if (pDirectSoundCaptureCreate && pDirectSoundCaptureEnumerateA)
- {
- IDirectSoundCapture_tests();
- capture_tests();
- }
- else
- skip("capture test skipped\n");
-
- FreeLibrary(hDsound);
- }
- else
- skip("dsound.dll not found!\n");
-
+ if (!hDsound) {
+ skip("dsound.dll not found - skipping all tests\n");
+ return;
+ }
+
+ pDirectSoundCaptureCreate = (void*)GetProcAddress(hDsound,
"DirectSoundCaptureCreate");
+ pDirectSoundCaptureEnumerateA = (void*)GetProcAddress(hDsound,
"DirectSoundCaptureEnumerateA");
+ if (!pDirectSoundCaptureCreate || !pDirectSoundCaptureEnumerateA) {
+ skip("DirectSoundCapture{Create,Enumerate} missing - skipping all
tests\n");
+ return;
+ }
+
+ test_COM();
+ test_capture();
+ test_enumerate();
+
+ FreeLibrary(hDsound);
CoUninitialize();
}
Modified: trunk/rostests/winetests/dsound/ds3d.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/ds3d.c?r…
==============================================================================
--- trunk/rostests/winetests/dsound/ds3d.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/dsound/ds3d.c [iso-8859-1] Mon Sep 30 11:39:02 2013
@@ -23,13 +23,21 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include <windows.h>
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
+#include <wine/test.h>
+
+//#include <windows.h>
#include <math.h>
-
-#include "wine/test.h"
-#include "dsound.h"
-#include "mmreg.h"
+#include <wingdi.h>
+#include <mmsystem.h>
+#include <dsound.h>
+#include <mmreg.h>
+#include "ks.h"
+#include "ksmedia.h"
#include "dsound_test.h"
#define PI 3.14159265358979323846
@@ -39,7 +47,7 @@
static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID,LPDIRECTSOUND*,
LPUNKNOWN)=NULL;
-char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size)
+char* wave_generate_la(WAVEFORMATEX* wfx, double duration, DWORD* size, BOOL ieee)
{
int i;
int nb_samples;
@@ -52,12 +60,12 @@
for (i=0;i<nb_samples;i++) {
double y=sin(440.0*2*PI*i/wfx->nSamplesPerSec);
if (wfx->wBitsPerSample==8) {
- unsigned char sample=(unsigned char)((double)127.5*(y+1.0));
+ unsigned char sample=127.5*(y+1.0);
*b++=sample;
if (wfx->nChannels==2)
*b++=sample;
} else if (wfx->wBitsPerSample == 16) {
- signed short sample=(signed short)((double)32767.5*y-0.5);
+ signed short sample=32767.5*y-0.5;
b[0]=sample & 0xff;
b[1]=sample >> 8;
b+=2;
@@ -67,7 +75,7 @@
b+=2;
}
} else if (wfx->wBitsPerSample == 24) {
- signed int sample=(signed int)((double)8388607.5*y-0.5);
+ signed int sample=8388607.5*y-0.5;
b[0]=sample & 0xff;
b[1]=(sample >> 8)&0xff;
b[2]=sample >> 16;
@@ -79,18 +87,31 @@
b+=3;
}
} else if (wfx->wBitsPerSample == 32) {
- signed int sample=(signed int)((double)2147483647.5*y-0.5);
- b[0]=sample & 0xff;
- b[1]=(sample >> 8)&0xff;
- b[2]=(sample >> 16)&0xff;
- b[3]=sample >> 24;
- b+=4;
- if (wfx->nChannels==2) {
+ if (ieee) {
+ float *ptr = (float *) b;
+ *ptr = y;
+
+ ptr++;
+ b+=4;
+
+ if (wfx->nChannels==2) {
+ *ptr = y;
+ b+=4;
+ }
+ } else {
+ signed int sample=2147483647.5*y-0.5;
b[0]=sample & 0xff;
b[1]=(sample >> 8)&0xff;
b[2]=(sample >> 16)&0xff;
b[3]=sample >> 24;
b+=4;
+ if (wfx->nChannels==2) {
+ b[0]=sample & 0xff;
+ b[1]=(sample >> 8)&0xff;
+ b[2]=(sample >> 16)&0xff;
+ b[3]=sample >> 24;
+ b+=4;
+ }
}
}
}
@@ -317,6 +338,7 @@
DSBCAPS dsbcaps;
WAVEFORMATEX wfx,wfx2;
DWORD size,status,freq;
+ BOOL ieee = FALSE;
int ref;
if (set_frequency) {
@@ -358,12 +380,16 @@
if (size == sizeof(WAVEFORMATEX)) {
rc=IDirectSoundBuffer_GetFormat(*dsbo,&wfx,size,NULL);
+ ieee = (wfx.wFormatTag == WAVE_FORMAT_IEEE_FLOAT);
}
else if (size == sizeof(WAVEFORMATEXTENSIBLE)) {
WAVEFORMATEXTENSIBLE wfxe;
rc=IDirectSoundBuffer_GetFormat(*dsbo,(WAVEFORMATEX*)&wfxe,size,NULL);
wfx = wfxe.Format;
- }
+ ieee = IsEqualGUID(&wfxe.SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT);
+ } else
+ return;
+
ok(rc==DS_OK,
"IDirectSoundBuffer_GetFormat() failed: %08x\n", rc);
if (rc==DS_OK && winetest_debug > 1) {
@@ -600,9 +626,9 @@
"returned DSERR_INVALIDPARAM, returned %08x\n", rc);
if (set_frequency)
-
state.wave=wave_generate_la(&wfx,(duration*frequency)/wfx.nSamplesPerSec,&state.wave_len);
+
state.wave=wave_generate_la(&wfx,(duration*frequency)/wfx.nSamplesPerSec,&state.wave_len,ieee);
else
- state.wave=wave_generate_la(&wfx,duration,&state.wave_len);
+ state.wave=wave_generate_la(&wfx,duration,&state.wave_len,ieee);
state.dsbo=*dsbo;
state.wfx=&wfx;
@@ -783,7 +809,7 @@
ZeroMemory(&bufdesc, sizeof(bufdesc));
bufdesc.dwSize=sizeof(bufdesc);
bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
- if (has_3d)
+ if (has_3dbuffer)
bufdesc.dwFlags|=DSBCAPS_CTRL3D;
else
bufdesc.dwFlags|=
@@ -805,8 +831,8 @@
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 %s%ssecondary buffer %s%s%s%sat %dx%dx%d (%s):
%08x\n",
+ 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",
has_3dbuffer?"3D ":"", has_duplicate?"duplicated
":"",
listener!=NULL||move_sound?"with ":"",
move_listener?"moving ":"",
listener!=NULL?"listener ":"",
@@ -815,6 +841,14 @@
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
getDSBCAPS(bufdesc.dwFlags),rc);
if (rc==DS_OK && secondary!=NULL) {
+ 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);
+
if (!has_3d) {
LONG refvol,vol,refpan,pan;
@@ -1195,15 +1229,13 @@
!(dscaps.dwFlags & DSCAPS_EMULDRIVER),1.0,0,
listener,0,0,FALSE,0);
- todo_wine {
- temp_buffer = NULL;
- rc=IDirectSound3DListener_QueryInterface(listener,
- &IID_IKsPropertySet,(LPVOID *)&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);
- }
+ 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);
}
/* Testing the reference counting */
@@ -1212,15 +1244,12 @@
"references, should have 0\n",ref);
}
- todo_wine {
- temp_buffer = NULL;
- rc=IDirectSoundBuffer_QueryInterface(primary,
- &IID_IKsPropertySet,(LPVOID *)&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);
- }
+ 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);
/* Testing the reference counting */
ref=IDirectSoundBuffer_Release(primary);
@@ -1237,11 +1266,14 @@
return rc;
}
+static unsigned driver_count = 0;
+
static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
LPCSTR lpcstrModule, LPVOID lpContext)
{
HRESULT rc;
trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
+ driver_count++;
rc = test_for_driver(lpGuid);
if (rc == DSERR_NODRIVER) {
@@ -1288,6 +1320,7 @@
HRESULT rc;
rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc);
+ trace("tested %u DirectSound drivers\n", driver_count);
}
START_TEST(ds3d)
@@ -1310,7 +1343,7 @@
FreeLibrary(hDsound);
}
else
- skip("dsound.dll not found!\n");
+ skip("dsound.dll not found - skipping all tests\n");
CoUninitialize();
}
Modified: trunk/rostests/winetests/dsound/ds3d8.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/ds3d8.c?…
==============================================================================
--- trunk/rostests/winetests/dsound/ds3d8.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/dsound/ds3d8.c [iso-8859-1] Mon Sep 30 11:39:02 2013
@@ -23,13 +23,20 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include <windows.h>
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
+//#include <windows.h>
#include <math.h>
-#include "wine/test.h"
-#include "dsound.h"
-#include "mmreg.h"
+#include <wine/test.h>
+#include <wingdi.h>
+#include <mmreg.h>
+#include <dsound.h>
+//#include "ks.h"
+#include <ksmedia.h>
#include "dsound_test.h"
static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA,LPVOID)=NULL;
@@ -181,6 +188,7 @@
DSBCAPS dsbcaps;
WAVEFORMATEX wfx,wfx2;
DWORD size,status,freq;
+ BOOL ieee = FALSE;
int ref;
/* DSOUND: Error: Invalid caps pointer */
@@ -214,11 +222,15 @@
if (size == sizeof(WAVEFORMATEX)) {
rc=IDirectSoundBuffer_GetFormat(*dsbo,&wfx,size,NULL);
+ ieee = (wfx.wFormatTag == WAVE_FORMAT_IEEE_FLOAT);
} else if (size == sizeof(WAVEFORMATEXTENSIBLE)) {
WAVEFORMATEXTENSIBLE wfxe;
rc=IDirectSoundBuffer_GetFormat(*dsbo,(WAVEFORMATEX*)&wfxe,size,NULL);
wfx = wfxe.Format;
- }
+ ieee = IsEqualGUID(&wfxe.SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT);
+ } else
+ return;
+
ok(rc==DS_OK,"IDirectSoundBuffer_GetFormat() failed: %08x\n", rc);
if (rc==DS_OK && winetest_debug > 1) {
trace(" Format: %s tag=0x%04x %dx%dx%d avg.B/s=%d align=%d\n",
@@ -447,7 +459,7 @@
ok(rc==DSERR_INVALIDPARAM, "IDirectSoundBuffer_Lock() should have "
"returned DSERR_INVALIDPARAM, returned %08x\n", rc);
- state.wave=wave_generate_la(&wfx,duration,&state.wave_len);
+ state.wave=wave_generate_la(&wfx,duration,&state.wave_len,ieee);
state.dsbo=*dsbo;
state.wfx=&wfx;
@@ -643,7 +655,10 @@
"IDirectSound8_CreateSoundBuffer(secondary) should have "
"returned DSERR_INVALIDPARAM, returned %08x\n", rc);
if (secondary)
+ {
ref=IDirectSoundBuffer_Release(secondary);
+ ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references,
should have 0\n",ref);
+ }
init_format(&wfx,WAVE_FORMAT_PCM,22050,16,1);
}
@@ -699,7 +714,7 @@
rc=IDirectSoundBuffer_SetPan(secondary,-1000);
ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed:
%08x\n",rc);
rc=IDirectSoundBuffer_GetPan(secondary,&pan);
- ok(rc==DS_OK,"IDirectSoundBuffer_SetPan(secondary) failed:
%08x\n",rc);
+ ok(rc==DS_OK,"IDirectSoundBuffer_GetPan(secondary) failed:
%08x\n",rc);
ok(pan==-1000,"secondary: wrong pan %d instead of -1000\n",
pan);
@@ -1073,11 +1088,14 @@
return rc;
}
+static unsigned driver_count = 0;
+
static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
LPCSTR lpcstrModule, LPVOID lpContext)
{
HRESULT rc;
trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
+ driver_count++;
rc = test_for_driver8(lpGuid);
if (rc == DSERR_NODRIVER) {
@@ -1124,6 +1142,7 @@
HRESULT rc;
rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc);
+ trace("tested %u DirectSound drivers\n", driver_count);
}
START_TEST(ds3d8)
@@ -1143,12 +1162,12 @@
if (pDirectSoundCreate8)
ds3d8_tests();
else
- skip("ds3d8 test skipped\n");
+ skip("DirectSoundCreate8 missing - skipping all tests\n");
FreeLibrary(hDsound);
}
else
- skip("dsound.dll not found!\n");
+ skip("dsound.dll not found - skipping all tests\n");
CoUninitialize();
}
Modified: trunk/rostests/winetests/dsound/dsound.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/dsound.c…
==============================================================================
--- trunk/rostests/winetests/dsound/dsound.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/dsound/dsound.c [iso-8859-1] Mon Sep 30 11:39:02 2013
@@ -26,15 +26,20 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include <windows.h>
-
-#include "wine/test.h"
-#include "dsound.h"
-#include "dsconf.h"
-#include "mmreg.h"
-#include "initguid.h"
-#include "ks.h"
-#include "ksmedia.h"
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
+//#include <windows.h>
+
+#include <wine/test.h>
+#include <wingdi.h>
+#include <mmreg.h>
+#include <dsound.h>
+#include <dsconf.h>
+//#include "initguid.h"
+//#include "ks.h"
+#include <ksmedia.h>
#include "dsound_test.h"
@@ -173,7 +178,7 @@
static void IDirectSound_tests(void)
{
HRESULT rc;
- LPDIRECTSOUND dso=NULL;
+ IDirectSound *dso=(IDirectSound*)0xdeadbeef;
LPCLASSFACTORY cf=NULL;
trace("Testing IDirectSound\n");
@@ -187,6 +192,12 @@
&IID_IUnknown, (void**)&cf);
ok(rc==S_OK,"CoGetClassObject(CLSID_DirectSound, IID_IUnknown) "
"failed: %08x\n", rc);
+
+ /* COM aggregation */
+ rc=CoCreateInstance(&CLSID_DirectSound, (IUnknown*)&dso,
CLSCTX_INPROC_SERVER,
+ &IID_IDirectSound, (void**)&dso);
+ ok(rc==CLASS_E_NOAGGREGATION || broken(rc==DSERR_INVALIDPARAM),
+ "DirectMusicPerformance create failed: %08x, expected
CLASS_E_NOAGGREGATION\n", rc);
/* try the COM class factory method of creation with no device specified */
rc=CoCreateInstance(&CLSID_DirectSound, NULL, CLSCTX_INPROC_SERVER,
@@ -326,7 +337,7 @@
wfx.nBlockAlign);
bufdesc.lpwfxFormat=&wfx;
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
- ok(rc==DS_OK && secondary!=NULL,
+ ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL),
/* vmware drivers on w2k */
"IDirectSound_CreateSoundBuffer() failed to create a secondary "
"buffer %08x\n",rc);
if (rc==DS_OK && secondary!=NULL) {
@@ -493,6 +504,15 @@
!(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\n",ref);
+
+ ref=IDirectSoundBuffer_AddRef(primary);
+ ok(ref==1,"IDirectSoundBuffer_AddRef() primary has %d
references\n",ref);
+
+ ref=IDirectSoundBuffer_Release(primary);
+ ok(ref==0,"IDirectSoundBuffer_Release() primary has %d
references\n",ref);
+
+ ref=IDirectSoundBuffer_Release(primary);
ok(ref==0,"IDirectSoundBuffer_Release() primary has %d references, "
"should have 0\n",ref);
}
@@ -523,7 +543,7 @@
DSBUFFERDESC bufdesc;
DSCAPS dscaps;
WAVEFORMATEX wfx, wfx2;
- int f,ref;
+ int f,ref,tag;
/* Create the DirectSound object */
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
@@ -556,6 +576,11 @@
if (rc==DS_OK && primary!=NULL) {
for (f=0;f<NB_FORMATS;f++) {
+ for (tag=0;tag<NB_TAGS;tag++) {
+ /* if float, we only want to test 32-bit */
+ if ((format_tags[tag] == WAVE_FORMAT_IEEE_FLOAT) && (formats[f][1] !=
32))
+ continue;
+
/* We must call SetCooperativeLevel to be allowed to call
* SetFormat */
/* DSOUND: Setting DirectSound cooperative level to
@@ -565,7 +590,7 @@
if (rc!=DS_OK)
goto EXIT;
- init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
+ init_format(&wfx,format_tags[tag],formats[f][0],formats[f][1],
formats[f][2]);
wfx2=wfx;
rc=IDirectSoundBuffer_SetFormat(primary,&wfx);
@@ -612,13 +637,13 @@
wfx.nBlockAlign);
bufdesc.lpwfxFormat=&wfx2;
if (winetest_interactive) {
- trace(" Testing a primary buffer at %dx%dx%d with a "
+ trace(" Testing a primary buffer at %dx%dx%d (fmt=%d) with a
"
"secondary buffer at %dx%dx%d\n",
- wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
+
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,format_tags[tag],
wfx2.nSamplesPerSec,wfx2.wBitsPerSample,wfx2.nChannels);
}
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
- ok(rc==DS_OK && secondary!=NULL,
+ ok((rc==DS_OK && secondary!=NULL) || broken(rc ==
DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */
"IDirectSound_CreateSoundBuffer() failed to create a secondary buffer
%08x\n",rc);
if (rc==DS_OK && secondary!=NULL) {
@@ -629,6 +654,7 @@
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
"should have 0\n",ref);
}
+ }
}
ref=IDirectSoundBuffer_Release(primary);
@@ -658,7 +684,7 @@
DSBUFFERDESC bufdesc;
DSCAPS dscaps;
WAVEFORMATEX wfx, wfx1;
- DWORD f;
+ DWORD f, tag;
int ref;
/* Create the DirectSound object */
@@ -697,8 +723,14 @@
goto EXIT1;
for (f=0;f<NB_FORMATS;f++) {
+ for (tag=0;tag<NB_TAGS;tag++) {
WAVEFORMATEXTENSIBLE wfxe;
- init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
+
+ /* if float, we only want to test 32-bit */
+ if ((format_tags[tag] == WAVE_FORMAT_IEEE_FLOAT) && (formats[f][1] !=
32))
+ continue;
+
+ init_format(&wfx,format_tags[tag],formats[f][0],formats[f][1],
formats[f][2]);
secondary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
@@ -720,16 +752,16 @@
wfx.nBlockAlign);
bufdesc.lpwfxFormat=&wfx;
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
- if (gotdx8 || wfx.wBitsPerSample <= 16)
+ if (gotdx8 || wfx.wBitsPerSample <= 16 || wfx.wFormatTag ==
WAVE_FORMAT_IEEE_FLOAT)
{
if (wfx.wBitsPerSample > 16)
- ok(((rc == DSERR_CONTROLUNAVAIL || rc == DSERR_INVALIDCALL || rc ==
DSERR_INVALIDPARAM /* 2003 */) && !secondary)
+ ok(broken((rc == DSERR_CONTROLUNAVAIL || rc == DSERR_INVALIDCALL ||
rc == DSERR_INVALIDPARAM /* 2003 */) && !secondary)
|| rc == DS_OK, /* driver dependent? */
"IDirectSound_CreateSoundBuffer() "
"should have returned (DSERR_CONTROLUNAVAIL or
DSERR_INVALIDCALL) "
"and NULL, returned: %08x %p\n", rc, secondary);
else
- ok(rc==DS_OK && secondary!=NULL,
+ ok((rc==DS_OK && secondary!=NULL) || broken(rc ==
DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */
"IDirectSound_CreateSoundBuffer() failed to create a
secondary buffer %08x\n",rc);
}
else
@@ -738,7 +770,7 @@
if (!gotdx8)
{
- skip("Not doing the WAVE_FORMAT_EXTENSIBLE tests\n");
+ win_skip("Not doing the WAVE_FORMAT_EXTENSIBLE tests\n");
/* Apparently they succeed with bogus values,
* which means that older dsound doesn't look at them
*/
@@ -752,7 +784,7 @@
bufdesc.lpwfxFormat=(WAVEFORMATEX*)&wfxe;
wfxe.Format = wfx;
wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+ wfxe.SubFormat = (format_tags[tag] == WAVE_FORMAT_PCM ?
KSDATAFORMAT_SUBTYPE_PCM : KSDATAFORMAT_SUBTYPE_IEEE_FLOAT);
wfxe.Format.cbSize = 1;
wfxe.Samples.wValidBitsPerSample = wfx.wBitsPerSample;
wfxe.dwChannelMask = (wfx.nChannels == 1 ? KSAUDIO_SPEAKER_MONO :
KSAUDIO_SPEAKER_STEREO);
@@ -792,7 +824,7 @@
IDirectSoundBuffer_Release(secondary);
secondary=NULL;
}
- wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+ wfxe.SubFormat = (format_tags[tag] == WAVE_FORMAT_PCM ?
KSDATAFORMAT_SUBTYPE_PCM : KSDATAFORMAT_SUBTYPE_IEEE_FLOAT);
++wfxe.Samples.wValidBitsPerSample;
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
@@ -825,9 +857,9 @@
no_wfe:
if (rc==DS_OK && secondary!=NULL) {
if (winetest_interactive) {
- trace(" Testing a secondary buffer at %dx%dx%d "
+ trace(" Testing a secondary buffer at %dx%dx%d (fmt=%d) "
"with a primary buffer at %dx%dx%d\n",
- wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
+
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,format_tags[tag],
wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
}
test_buffer(dso,&secondary,0,FALSE,0,FALSE,0,
@@ -837,6 +869,7 @@
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
"should have 0\n",ref);
}
+ }
}
EXIT1:
ref=IDirectSoundBuffer_Release(primary);
@@ -883,8 +916,8 @@
bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec + 1;
bufdesc.lpwfxFormat=&wfx;
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
- ok(rc==DS_OK,"IDirectSound_CreateSoundBuffer() "
- "should have returned DS_OK, returned: %08x\n", rc);
+ ok(rc == DS_OK || broken(rc == DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */
+ "IDirectSound_CreateSoundBuffer() should have returned DS_OK, returned:
%08x\n", rc);
if (rc==DS_OK && secondary!=NULL) {
ZeroMemory(&dsbcaps, sizeof(dsbcaps));
@@ -993,7 +1026,7 @@
wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
}
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
- ok(rc==DS_OK && secondary!=NULL,
+ ok((rc==DS_OK && secondary!=NULL) || broken(rc ==
DSERR_CONTROLUNAVAIL), /* vmware drivers on w2k */
"IDirectSound_CreateSoundBuffer() failed to create a secondary buffer
%08x\n",rc);
if (rc==DS_OK && secondary!=NULL) {
@@ -1024,6 +1057,438 @@
return DSERR_GENERIC;
return rc;
+}
+
+static HRESULT test_notify(LPDIRECTSOUNDBUFFER dsb,
+ DWORD count, LPHANDLE event,
+ DWORD expected)
+{
+ HRESULT rc;
+ DWORD ret;
+
+ rc=IDirectSoundBuffer_SetCurrentPosition(dsb,0);
+ ok(rc==DS_OK,
+ "IDirectSoundBuffer_SetCurrentPosition failed %08x\n",rc);
+ if(rc!=DS_OK)
+ return rc;
+
+ rc=IDirectSoundBuffer_Play(dsb,0,0,0);
+ ok(rc==DS_OK,"IDirectSoundBuffer_Play failed %08x\n",rc);
+ if(rc!=DS_OK)
+ return rc;
+
+ rc=IDirectSoundBuffer_Stop(dsb);
+ ok(rc==DS_OK,"IDirectSoundBuffer_Stop failed %08x\n",rc);
+ if(rc!=DS_OK)
+ return rc;
+
+ ret=WaitForMultipleObjects(count,event,FALSE,0);
+ ok(ret==expected,"expected %d. got %d\n",expected,ret);
+ return rc;
+}
+
+static HRESULT test_duplicate(LPGUID lpGuid)
+{
+ HRESULT rc;
+ LPDIRECTSOUND dso=NULL;
+ LPDIRECTSOUNDBUFFER primary=NULL;
+ DSBUFFERDESC bufdesc;
+ int ref;
+
+ /* Create the DirectSound object */
+ rc=pDirectSoundCreate(lpGuid,&dso,NULL);
+ ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
+ "DirectSoundCreate() failed: %08x\n",rc);
+ if (rc!=DS_OK)
+ return rc;
+
+ /* We must call SetCooperativeLevel before creating primary buffer */
+ /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
+ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
+ ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
+ if (rc!=DS_OK)
+ goto EXIT;
+
+ ZeroMemory(&bufdesc, sizeof(bufdesc));
+ bufdesc.dwSize=sizeof(bufdesc);
+ bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
+ rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
+ ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() failed
"
+ "to create a primary buffer %08x\n",rc);
+
+ if (rc==DS_OK && primary!=NULL) {
+ LPDIRECTSOUNDBUFFER original=NULL;
+ WAVEFORMATEX wfx;
+
+ init_format(&wfx,WAVE_FORMAT_PCM,22050,16,1);
+ ZeroMemory(&bufdesc, sizeof(bufdesc));
+ bufdesc.dwSize=sizeof(bufdesc);
+ bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_CTRLPOSITIONNOTIFY;
+ bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec/100; /* very short buffer */
+ bufdesc.lpwfxFormat=&wfx;
+ rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&original,NULL);
+ ok(rc==DS_OK && original!=NULL,
+ "IDirectSound_CreateSoundBuffer() failed to create a original "
+ "buffer %08x\n",rc);
+ if (rc==DS_OK && original!=NULL) {
+ LPDIRECTSOUNDBUFFER duplicated=NULL;
+ LPDIRECTSOUNDNOTIFY notify=NULL;
+ HANDLE event[2];
+ LPVOID buf=NULL;
+ DWORD bufsize;
+ int i;
+
+ /* Prepare notify events */
+ for (i=0;i<sizeof(event)/sizeof(event[0]);i++) {
+ event[i] = CreateEvent(NULL,FALSE,FALSE,NULL);
+ }
+
+ /* Make silent buffer */
+ rc=IDirectSoundBuffer_Lock(original,0,0,&buf,&bufsize,
+ NULL,NULL,DSBLOCK_ENTIREBUFFER);
+ ok(rc==DS_OK && buf!=NULL,
+ "IDirectSoundBuffer_Lock failed to lock the buffer %08x\n",rc);
+ if (rc==DS_OK && buf!=NULL) {
+ ZeroMemory(buf,bufsize);
+ rc=IDirectSoundBuffer_Unlock(original,buf,bufsize,
+ NULL,0);
+ ok(rc==DS_OK,"IDirectSoundBuffer_Unlock failed to unlock "
+ "%08x\n",rc);
+ }
+
+ rc=IDirectSoundBuffer_QueryInterface(original,
+ &IID_IDirectSoundNotify,
+ (void**)¬ify);
+ ok(rc==DS_OK && notify!=NULL,
+ "IDirectSoundBuffer_QueryInterface() failed to create a "
+ "notification %08x\n",rc);
+ if (rc==DS_OK && notify!=NULL) {
+ DSBPOSITIONNOTIFY dsbpn;
+ LPDIRECTSOUNDNOTIFY dup_notify=NULL;
+
+ dsbpn.dwOffset=DSBPN_OFFSETSTOP;
+ dsbpn.hEventNotify=event[0];
+ rc=IDirectSoundNotify_SetNotificationPositions(notify,
+ 1,&dsbpn);
+ ok(rc==DS_OK,"IDirectSoundNotify_SetNotificationPositions "
+ "failed %08x\n",rc);
+
+ rc=IDirectSound_DuplicateSoundBuffer(dso,original,&duplicated);
+ ok(rc==DS_OK && duplicated!=NULL,
+ "IDirectSound_DuplicateSoundBuffer failed %08x\n",rc);
+
+ trace("testing duplicated buffer without notifications.\n");
+ test_notify(duplicated,sizeof(event)/sizeof(event[0]),
+ event,WAIT_TIMEOUT);
+
+ rc=IDirectSoundBuffer_QueryInterface(duplicated,
+ &IID_IDirectSoundNotify,
+ (void**)&dup_notify);
+ ok(rc==DS_OK&&dup_notify!=NULL,
+ "IDirectSoundBuffer_QueryInterface() failed to create a "
+ "notification %08x\n",rc);
+ if(rc==DS_OK&&dup_notify!=NULL) {
+ dsbpn.dwOffset=DSBPN_OFFSETSTOP;
+ dsbpn.hEventNotify=event[1];
+ rc=IDirectSoundNotify_SetNotificationPositions(dup_notify,
+ 1,&dsbpn);
+ ok(rc==DS_OK,"IDirectSoundNotify_SetNotificationPositions
"
+ "failed %08x\n",rc);
+
+ trace("testing duplicated buffer with a notification.\n");
+ test_notify(duplicated,sizeof(event)/sizeof(event[0]),
+ event,WAIT_OBJECT_0+1);
+
+ ref=IDirectSoundNotify_Release(dup_notify);
+ ok(ref==0,"IDirectSoundNotify_Release() has %d references,
"
+ "should have 0\n",ref);
+ }
+ ref=IDirectSoundNotify_Release(notify);
+ ok(ref==0,"IDirectSoundNotify_Release() has %d references, "
+ "should have 0\n",ref);
+
+ trace("testing original buffer with a notification.\n");
+ test_notify(original,sizeof(event)/sizeof(event[0]),
+ event,WAIT_OBJECT_0);
+
+ ref=IDirectSoundBuffer_Release(duplicated);
+ ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
+ "should have 0\n",ref);
+ }
+ ref=IDirectSoundBuffer_Release(original);
+ ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
+ "should have 0\n",ref);
+ }
+ ref=IDirectSoundBuffer_Release(primary);
+ ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
+ "should have 0\n",ref);
+ }
+
+ /* Set the CooperativeLevel back to normal */
+ /* DSOUND: Setting DirectSound cooperative level to DSSCL_NORMAL */
+ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_NORMAL);
+ ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
+
+EXIT:
+ ref=IDirectSound_Release(dso);
+ ok(ref==0,"IDirectSound_Release() has %d references, should have
0\n",ref);
+ if (ref!=0)
+ return DSERR_GENERIC;
+
+ return rc;
+}
+
+static HRESULT test_invalid_fmts(LPGUID lpGuid)
+{
+ HRESULT rc;
+ LPDIRECTSOUND dso=NULL;
+ LPDIRECTSOUNDBUFFER primary=NULL;
+ DSBUFFERDESC bufdesc;
+
+ /* Create the DirectSound object */
+ rc=pDirectSoundCreate(lpGuid,&dso,NULL);
+ ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
+ "DirectSoundCreate() failed: %08x\n",rc);
+ if (rc!=DS_OK)
+ return rc;
+
+ /* We must call SetCooperativeLevel before creating primary buffer */
+ /* DSOUND: Setting DirectSound cooperative level to DSSCL_PRIORITY */
+ rc=IDirectSound_SetCooperativeLevel(dso,get_hwnd(),DSSCL_PRIORITY);
+ ok(rc==DS_OK,"IDirectSound_SetCooperativeLevel() failed: %08x\n", rc);
+ if (rc!=DS_OK){
+ IDirectSound_Release(dso);
+ return rc;
+ }
+
+ ZeroMemory(&bufdesc, sizeof(bufdesc));
+ bufdesc.dwSize=sizeof(bufdesc);
+ bufdesc.dwFlags=DSBCAPS_PRIMARYBUFFER;
+ rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&primary,NULL);
+ ok(rc==DS_OK && primary!=NULL,"IDirectSound_CreateSoundBuffer() failed
"
+ "to create a primary buffer %08x\n",rc);
+
+ if (rc==DS_OK && primary!=NULL) {
+ WAVEFORMATEX wfx;
+ WAVEFORMATEXTENSIBLE fmtex;
+
+ wfx.wFormatTag = WAVE_FORMAT_PCM;
+ wfx.nChannels = 0;
+ wfx.nSamplesPerSec = 44100;
+ wfx.wBitsPerSample = 16;
+ wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
+ wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
+ rc = IDirectSoundBuffer_SetFormat(primary, &wfx);
+ ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc);
+
+ wfx.nChannels = 2;
+ wfx.nSamplesPerSec = 44100;
+ wfx.wBitsPerSample = 0;
+ wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
+ wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
+ rc = IDirectSoundBuffer_SetFormat(primary, &wfx);
+ ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc);
+
+ wfx.nChannels = 2;
+ wfx.nSamplesPerSec = 44100;
+ wfx.wBitsPerSample = 2;
+ wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
+ wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
+ rc = IDirectSoundBuffer_SetFormat(primary, &wfx);
+ ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc);
+
+ wfx.nChannels = 2;
+ wfx.nSamplesPerSec = 44100;
+ wfx.wBitsPerSample = 12;
+ wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
+ wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
+ rc = IDirectSoundBuffer_SetFormat(primary, &wfx);
+ ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc);
+
+ wfx.nChannels = 2;
+ wfx.nSamplesPerSec = 0;
+ wfx.wBitsPerSample = 16;
+ wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
+ wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
+ rc = IDirectSoundBuffer_SetFormat(primary, &wfx);
+ ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc);
+
+ wfx.nChannels = 2;
+ wfx.nSamplesPerSec = 44100;
+ wfx.wBitsPerSample = 16;
+ wfx.nBlockAlign = 0;
+ wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
+ rc = IDirectSoundBuffer_SetFormat(primary, &wfx);
+ ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc);
+
+ wfx.nChannels = 2;
+ wfx.nSamplesPerSec = 44100;
+ wfx.wBitsPerSample = 16;
+ wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
+ wfx.nAvgBytesPerSec = 0;
+ rc = IDirectSoundBuffer_SetFormat(primary, &wfx);
+ ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc);
+
+ wfx.nChannels = 2;
+ wfx.nSamplesPerSec = 44100;
+ wfx.wBitsPerSample = 16;
+ wfx.nBlockAlign = (wfx.nChannels * wfx.wBitsPerSample / 8) - 1;
+ wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
+ rc = IDirectSoundBuffer_SetFormat(primary, &wfx);
+ ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc);
+
+ wfx.nChannels = 2;
+ wfx.nSamplesPerSec = 44100;
+ wfx.wBitsPerSample = 16;
+ wfx.nBlockAlign = (wfx.nChannels * wfx.wBitsPerSample / 8) + 1;
+ wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
+ rc = IDirectSoundBuffer_SetFormat(primary, &wfx);
+ ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc);
+
+ wfx.nChannels = 2;
+ wfx.nSamplesPerSec = 44100;
+ wfx.wBitsPerSample = 16;
+ wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
+ wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign + 1;
+ rc = IDirectSoundBuffer_SetFormat(primary, &wfx);
+ ok(rc == S_OK, "SetFormat: %08x\n", rc);
+
+ rc = IDirectSoundBuffer_GetFormat(primary, &wfx, sizeof(wfx), NULL);
+ ok(rc == S_OK, "GetFormat: %08x\n", rc);
+ ok(wfx.wFormatTag == WAVE_FORMAT_PCM, "format: 0x%x\n",
wfx.wFormatTag);
+ ok(wfx.nChannels == 2, "channels: %u\n", wfx.nChannels);
+ ok(wfx.nSamplesPerSec == 44100, "rate: %u\n", wfx.nSamplesPerSec);
+ ok(wfx.wBitsPerSample == 16, "bps: %u\n", wfx.wBitsPerSample);
+ ok(wfx.nBlockAlign == 4, "blockalign: %u\n", wfx.nBlockAlign);
+ ok(wfx.nAvgBytesPerSec == 44100 * 4 + 1, "avgbytes: %u\n",
wfx.nAvgBytesPerSec);
+
+ wfx.nChannels = 2;
+ wfx.nSamplesPerSec = 44100;
+ wfx.wBitsPerSample = 16;
+ wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
+ wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign - 1;
+ rc = IDirectSoundBuffer_SetFormat(primary, &wfx);
+ ok(rc == S_OK, "SetFormat: %08x\n", rc);
+
+ rc = IDirectSoundBuffer_GetFormat(primary, &wfx, sizeof(wfx), NULL);
+ ok(rc == S_OK, "GetFormat: %08x\n", rc);
+ ok(wfx.wFormatTag == WAVE_FORMAT_PCM, "format: 0x%x\n",
wfx.wFormatTag);
+ ok(wfx.nChannels == 2, "channels: %u\n", wfx.nChannels);
+ ok(wfx.nSamplesPerSec == 44100, "rate: %u\n", wfx.nSamplesPerSec);
+ ok(wfx.wBitsPerSample == 16, "bps: %u\n", wfx.wBitsPerSample);
+ ok(wfx.nBlockAlign == 4, "blockalign: %u\n", wfx.nBlockAlign);
+ ok(wfx.nAvgBytesPerSec == 44100 * 4 - 1, "avgbytes: %u\n",
wfx.nAvgBytesPerSec);
+
+ wfx.nChannels = 2;
+ wfx.nSamplesPerSec = 44100;
+ wfx.wBitsPerSample = 16;
+ wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
+ wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign + 1;
+ rc = IDirectSoundBuffer_SetFormat(primary, &wfx);
+ ok(rc == S_OK, "SetFormat: %08x\n", rc);
+
+ rc = IDirectSoundBuffer_GetFormat(primary, &wfx, sizeof(wfx), NULL);
+ ok(rc == S_OK, "GetFormat: %08x\n", rc);
+ ok(wfx.wFormatTag == WAVE_FORMAT_PCM, "format: 0x%x\n",
wfx.wFormatTag);
+ ok(wfx.nChannels == 2, "channels: %u\n", wfx.nChannels);
+ ok(wfx.nSamplesPerSec == 44100, "rate: %u\n", wfx.nSamplesPerSec);
+ ok(wfx.wBitsPerSample == 16, "bps: %u\n", wfx.wBitsPerSample);
+ ok(wfx.nBlockAlign == 4, "blockalign: %u\n", wfx.nBlockAlign);
+ ok(wfx.nAvgBytesPerSec == 44100 * 4 + 1, "avgbytes: %u\n",
wfx.nAvgBytesPerSec);
+
+ wfx.wFormatTag = WAVE_FORMAT_ALAW;
+ wfx.nChannels = 2;
+ wfx.nSamplesPerSec = 44100;
+ wfx.wBitsPerSample = 16;
+ wfx.nBlockAlign = wfx.nChannels * wfx.wBitsPerSample / 8;
+ wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
+ rc = IDirectSoundBuffer_SetFormat(primary, &wfx);
+ ok(rc == S_OK, "SetFormat: %08x\n", rc);
+
+ rc = IDirectSoundBuffer_GetFormat(primary, &wfx, sizeof(wfx), NULL);
+ ok(rc == S_OK, "GetFormat: %08x\n", rc);
+ ok(wfx.wFormatTag == WAVE_FORMAT_ALAW, "format: 0x%x\n",
wfx.wFormatTag);
+ ok(wfx.nChannels == 2, "channels: %u\n", wfx.nChannels);
+ ok(wfx.nSamplesPerSec == 44100, "rate: %u\n", wfx.nSamplesPerSec);
+ ok(wfx.wBitsPerSample == 16, "bps: %u\n", wfx.wBitsPerSample);
+ ok(wfx.nBlockAlign == 4, "blockalign: %u\n", wfx.nBlockAlign);
+ ok(wfx.nAvgBytesPerSec == 44100 * 4, "avgbytes: %u\n",
wfx.nAvgBytesPerSec);
+
+ if(!gotdx8){
+ win_skip("Not doing the WAVE_FORMAT_EXTENSIBLE tests\n");
+ goto done;
+ }
+
+ fmtex.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
+ fmtex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+ fmtex.Format.nChannels = 2;
+ fmtex.Format.nSamplesPerSec = 44100;
+ fmtex.Format.wBitsPerSample = 16;
+ fmtex.Format.nBlockAlign = fmtex.Format.nChannels * fmtex.Format.wBitsPerSample /
8;
+ fmtex.Format.nAvgBytesPerSec = fmtex.Format.nSamplesPerSec *
fmtex.Format.nBlockAlign;
+ fmtex.Samples.wValidBitsPerSample = 0;
+ fmtex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
+ fmtex.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+ rc = IDirectSoundBuffer_SetFormat(primary, (WAVEFORMATEX*)&fmtex);
+ ok(rc == S_OK, "SetFormat: %08x\n", rc);
+
+ rc = IDirectSoundBuffer_GetFormat(primary, (WAVEFORMATEX*)&fmtex,
sizeof(fmtex), NULL);
+ ok(rc == S_OK, "GetFormat: %08x\n", rc);
+ ok(fmtex.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE, "format: 0x%x\n",
fmtex.Format.wFormatTag);
+ ok(fmtex.Format.nChannels == 2, "channels: %u\n",
fmtex.Format.nChannels);
+ ok(fmtex.Format.nSamplesPerSec == 44100, "rate: %u\n",
fmtex.Format.nSamplesPerSec);
+ ok(fmtex.Format.wBitsPerSample == 16, "bps: %u\n",
fmtex.Format.wBitsPerSample);
+ ok(fmtex.Format.nBlockAlign == 4, "blockalign: %u\n",
fmtex.Format.nBlockAlign);
+ ok(fmtex.Format.nAvgBytesPerSec == 44100 * 4, "avgbytes: %u\n",
fmtex.Format.nAvgBytesPerSec);
+ ok(fmtex.Samples.wValidBitsPerSample == 0 || /* <= XP */
+ fmtex.Samples.wValidBitsPerSample == 16, /* >= Vista */
+ "validbits: %u\n", fmtex.Samples.wValidBitsPerSample);
+ ok(IsEqualGUID(&fmtex.SubFormat, &KSDATAFORMAT_SUBTYPE_PCM),
"subtype incorrect\n");
+
+ fmtex.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
+ fmtex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+ fmtex.Format.nChannels = 2;
+ fmtex.Format.nSamplesPerSec = 44100;
+ fmtex.Format.wBitsPerSample = 24;
+ fmtex.Format.nBlockAlign = fmtex.Format.nChannels * fmtex.Format.wBitsPerSample /
8;
+ fmtex.Format.nAvgBytesPerSec = fmtex.Format.nSamplesPerSec *
fmtex.Format.nBlockAlign;
+ fmtex.Samples.wValidBitsPerSample = 20;
+ fmtex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
+ fmtex.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+ rc = IDirectSoundBuffer_SetFormat(primary, (WAVEFORMATEX*)&fmtex);
+ ok(rc == S_OK, "SetFormat: %08x\n", rc);
+
+ rc = IDirectSoundBuffer_GetFormat(primary, (WAVEFORMATEX*)&fmtex,
sizeof(fmtex), NULL);
+ ok(rc == S_OK, "GetFormat: %08x\n", rc);
+ ok(fmtex.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE, "format: 0x%x\n",
fmtex.Format.wFormatTag);
+ ok(fmtex.Format.nChannels == 2, "channels: %u\n",
fmtex.Format.nChannels);
+ ok(fmtex.Format.nSamplesPerSec == 44100, "rate: %u\n",
fmtex.Format.nSamplesPerSec);
+ ok(fmtex.Format.wBitsPerSample == 24, "bps: %u\n",
fmtex.Format.wBitsPerSample);
+ ok(fmtex.Format.nBlockAlign == 6, "blockalign: %u\n",
fmtex.Format.nBlockAlign);
+ ok(fmtex.Format.nAvgBytesPerSec == 44100 * 6, "avgbytes: %u\n",
fmtex.Format.nAvgBytesPerSec);
+ ok(fmtex.Samples.wValidBitsPerSample == 20, "validbits: %u\n",
fmtex.Samples.wValidBitsPerSample);
+ ok(IsEqualGUID(&fmtex.SubFormat, &KSDATAFORMAT_SUBTYPE_PCM),
"subtype incorrect\n");
+
+ fmtex.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
+ fmtex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+ fmtex.Format.nChannels = 2;
+ fmtex.Format.nSamplesPerSec = 44100;
+ fmtex.Format.wBitsPerSample = 24;
+ fmtex.Format.nBlockAlign = fmtex.Format.nChannels * fmtex.Format.wBitsPerSample /
8;
+ fmtex.Format.nAvgBytesPerSec = fmtex.Format.nSamplesPerSec *
fmtex.Format.nBlockAlign;
+ fmtex.Samples.wValidBitsPerSample = 32;
+ fmtex.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
+ fmtex.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+ rc = IDirectSoundBuffer_SetFormat(primary, (WAVEFORMATEX*)&fmtex);
+ ok(rc == E_INVALIDARG, "SetFormat: %08x\n", rc);
+
+ IDirectSoundBuffer_Release(primary);
+ }
+
+done:
+ IDirectSound_Release(dso);
+
+ return S_OK;
}
static unsigned int number;
@@ -1054,6 +1519,8 @@
test_primary_secondary(lpGuid);
test_secondary(lpGuid);
test_frequency(lpGuid);
+ test_duplicate(lpGuid);
+ test_invalid_fmts(lpGuid);
}
return 1;
@@ -1066,6 +1533,118 @@
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc);
}
+static void test_hw_buffers(void)
+{
+ IDirectSound *ds;
+ IDirectSoundBuffer *primary, *primary2, **secondaries, *secondary;
+ IDirectSoundBuffer8 *buf8;
+ DSCAPS caps;
+ DSBCAPS bufcaps;
+ DSBUFFERDESC bufdesc;
+ WAVEFORMATEX fmt;
+ UINT i;
+ HRESULT hr;
+
+ hr = pDirectSoundCreate(NULL, &ds, NULL);
+ ok(hr == S_OK || hr == DSERR_NODRIVER || hr == DSERR_ALLOCATED || hr == E_FAIL,
+ "DirectSoundCreate failed: %08x\n", hr);
+ if(hr != S_OK)
+ return;
+
+ caps.dwSize = sizeof(caps);
+
+ hr = IDirectSound_GetCaps(ds, &caps);
+ ok(hr == S_OK, "GetCaps failed: %08x\n", hr);
+
+ ok(caps.dwPrimaryBuffers == 1, "Got wrong number of primary buffers:
%u\n",
+ caps.dwPrimaryBuffers);
+
+ /* DSBCAPS_LOC* is ignored for primary buffers */
+ bufdesc.dwSize = sizeof(bufdesc);
+ bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCHARDWARE |
+ DSBCAPS_PRIMARYBUFFER;
+ bufdesc.dwBufferBytes = 0;
+ bufdesc.dwReserved = 0;
+ bufdesc.lpwfxFormat = NULL;
+ bufdesc.guid3DAlgorithm = GUID_NULL;
+
+ hr = IDirectSound_CreateSoundBuffer(ds, &bufdesc, &primary, NULL);
+ ok(hr == S_OK, "CreateSoundBuffer failed: %08x\n", hr);
+ if(hr != S_OK){
+ IDirectSound_Release(ds);
+ return;
+ }
+
+ bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCSOFTWARE |
+ DSBCAPS_PRIMARYBUFFER;
+
+ hr = IDirectSound_CreateSoundBuffer(ds, &bufdesc, &primary2, NULL);
+ ok(hr == S_OK, "CreateSoundBuffer failed: %08x\n", hr);
+ ok(primary == primary2, "Got different primary buffers: %p, %p\n", primary,
primary2);
+ if(hr == S_OK)
+ IDirectSoundBuffer_Release(primary2);
+
+ buf8 = (IDirectSoundBuffer8 *)0xDEADBEEF;
+ hr = IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSoundBuffer8,
+ (void**)&buf8);
+ ok(hr == E_NOINTERFACE, "QueryInterface gave wrong failure: %08x\n", hr);
+ ok(buf8 == NULL, "Pointer didn't get set to NULL\n");
+
+ fmt.wFormatTag = WAVE_FORMAT_PCM;
+ fmt.nChannels = 2;
+ fmt.nSamplesPerSec = 48000;
+ fmt.wBitsPerSample = 16;
+ fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8;
+ fmt.nAvgBytesPerSec = fmt.nBlockAlign * fmt.nSamplesPerSec;
+ fmt.cbSize = 0;
+
+ bufdesc.lpwfxFormat = &fmt;
+ bufdesc.dwBufferBytes = fmt.nSamplesPerSec * fmt.nBlockAlign / 10;
+ bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCHARDWARE |
+ DSBCAPS_CTRLVOLUME;
+
+ secondaries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+ sizeof(IDirectSoundBuffer *) * caps.dwMaxHwMixingAllBuffers);
+
+ /* try to fill all of the hw buffers */
+ trace("dwMaxHwMixingAllBuffers: %u\n", caps.dwMaxHwMixingAllBuffers);
+ trace("dwMaxHwMixingStaticBuffers: %u\n",
caps.dwMaxHwMixingStaticBuffers);
+ trace("dwMaxHwMixingStreamingBuffers: %u\n",
caps.dwMaxHwMixingStreamingBuffers);
+ for(i = 0; i < caps.dwMaxHwMixingAllBuffers; ++i){
+ hr = IDirectSound_CreateSoundBuffer(ds, &bufdesc, &secondaries[i],
NULL);
+ ok(hr == S_OK || hr == E_NOTIMPL || broken(hr == DSERR_CONTROLUNAVAIL) ||
broken(hr == E_FAIL),
+ "CreateSoundBuffer(%u) failed: %08x\n", i, hr);
+ if(hr != S_OK)
+ break;
+
+ bufcaps.dwSize = sizeof(bufcaps);
+ hr = IDirectSoundBuffer_GetCaps(secondaries[i], &bufcaps);
+ ok(hr == S_OK, "GetCaps failed: %08x\n", hr);
+ ok((bufcaps.dwFlags & DSBCAPS_LOCHARDWARE) != 0,
+ "Buffer wasn't allocated in hardware, dwFlags: %x\n",
bufcaps.dwFlags);
+ }
+
+ /* see if we can create one more */
+ hr = IDirectSound_CreateSoundBuffer(ds, &bufdesc, &secondary, NULL);
+ ok((i == caps.dwMaxHwMixingAllBuffers && hr == DSERR_ALLOCATED) || /* out of
hw buffers */
+ (caps.dwMaxHwMixingAllBuffers == 0 && hr == DSERR_INVALIDCALL) || /*
no hw buffers at all */
+ hr == E_NOTIMPL || /* don't support hw buffers */
+ broken(hr == DSERR_CONTROLUNAVAIL) || /* vmware winxp, others? */
+ broken(hr == E_FAIL) || /* broken AC97 driver */
+ broken(hr == S_OK) /* broken driver allows more hw bufs than dscaps claims
*/,
+ "CreateSoundBuffer(%u) gave wrong error: %08x\n", i, hr);
+ if(hr == S_OK)
+ IDirectSoundBuffer_Release(secondary);
+
+ for(i = 0; i < caps.dwMaxHwMixingAllBuffers; ++i)
+ if(secondaries[i])
+ IDirectSoundBuffer_Release(secondaries[i]);
+ HeapFree(GetProcessHeap(), 0, secondaries);
+
+ IDirectSoundBuffer_Release(primary);
+ IDirectSound_Release(ds);
+}
+
START_TEST(dsound)
{
HMODULE hDsound;
@@ -1077,14 +1656,8 @@
{
BOOL ret;
- ok( FreeLibrary(hDsound), "FreeLibrary(1) returned %d\n",
GetLastError());
- SetLastError(0xdeadbeef);
ret = FreeLibrary(hDsound);
- ok( ret ||
- broken(!ret && GetLastError() == ERROR_MOD_NOT_FOUND) || /* NT4 */
- broken(!ret && GetLastError() == ERROR_INVALID_HANDLE), /* Win9x */
- "FreeLibrary(2) returned %d\n", GetLastError());
- ok(!FreeLibrary(hDsound), "DirectSound DLL still loaded\n");
+ ok( ret, "FreeLibrary(1) returned %d\n", GetLastError());
}
hDsound = LoadLibrary("dsound.dll");
@@ -1100,11 +1673,12 @@
IDirectSound_tests();
dsound_tests();
+ test_hw_buffers();
FreeLibrary(hDsound);
}
else
- skip("dsound.dll not found!\n");
+ win_skip("dsound.dll not found - skipping all tests\n");
CoUninitialize();
}
Modified: trunk/rostests/winetests/dsound/dsound8.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/dsound8.…
==============================================================================
--- trunk/rostests/winetests/dsound/dsound8.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/dsound/dsound8.c [iso-8859-1] Mon Sep 30 11:39:02 2013
@@ -25,15 +25,27 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include <windows.h>
-#include <stdio.h>
-
-#include "wine/test.h"
-#include "dsound.h"
-#include "dsconf.h"
-#include "mmreg.h"
-#include "ks.h"
-#include "ksmedia.h"
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
+#define COBJMACROS
+#define NONAMELESSUNION
+//#include <windows.h>
+//#include <stdio.h>
+
+#include <wine/test.h>
+#include <wingdi.h>
+#include <mmreg.h>
+#include <dsound.h>
+#include <dsconf.h>
+//#include "ks.h"
+#include <ksmedia.h>
+#include <initguid.h>
+#include <mmdeviceapi.h>
+//#include "audioclient.h"
+//#include "propkey.h"
+//#include "devpkey.h"
#include "dsound_test.h"
@@ -356,6 +368,8 @@
&IID_IDirectSoundBuffer8,
(void **)&buffer8);
if (rc==DS_OK && buffer8!=NULL) {
+ ok(buffer8==(IDirectSoundBuffer8*)secondary,
+ "IDirectSoundBuffer8 iface different from
IDirectSoundBuffer.\n");
ref=IDirectSoundBuffer8_AddRef(buffer8);
ok(ref==3,"IDirectSoundBuffer8_AddRef() has %d references, "
"should have 3\n",ref);
@@ -534,7 +548,7 @@
DSCAPS dscaps;
WAVEFORMATEX wfx, wfx2;
int ref;
- unsigned int f;
+ unsigned int f, tag;
/* Create the DirectSound object */
rc=pDirectSoundCreate8(lpGuid,&dso,NULL);
@@ -568,6 +582,11 @@
if (rc==DS_OK && primary!=NULL) {
for (f=0;f<NB_FORMATS;f++) {
+ for (tag=0;tag<NB_TAGS;tag++) {
+ /* if float, we only want to test 32-bit */
+ if ((format_tags[tag] == WAVE_FORMAT_IEEE_FLOAT) && (formats[f][1] !=
32))
+ continue;
+
/* We must call SetCooperativeLevel to be allowed to call
* SetFormat */
/* DSOUND: Setting DirectSound cooperative level to
@@ -577,7 +596,7 @@
if (rc!=DS_OK)
goto EXIT;
- init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
+ init_format(&wfx,format_tags[tag],formats[f][0],formats[f][1],
formats[f][2]);
wfx2=wfx;
rc=IDirectSoundBuffer_SetFormat(primary,&wfx);
@@ -621,9 +640,9 @@
wfx.nBlockAlign);
bufdesc.lpwfxFormat=&wfx2;
if (winetest_interactive) {
- trace(" Testing a primary buffer at %dx%dx%d with a "
+ trace(" Testing a primary buffer at %dx%dx%d (fmt=%d) with a
"
"secondary buffer at %dx%dx%d\n",
- wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
+
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,format_tags[tag],
wfx2.nSamplesPerSec,wfx2.wBitsPerSample,wfx2.nChannels);
}
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
@@ -639,6 +658,7 @@
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
"should have 0\n",ref);
}
+ }
}
ref=IDirectSoundBuffer_Release(primary);
@@ -668,7 +688,7 @@
DSBUFFERDESC bufdesc;
DSCAPS dscaps;
WAVEFORMATEX wfx, wfx1;
- DWORD f;
+ DWORD f, tag;
int ref;
/* Create the DirectSound object */
@@ -708,8 +728,14 @@
goto EXIT1;
for (f=0;f<NB_FORMATS;f++) {
+ for (tag=0;tag<NB_TAGS;tag++) {
WAVEFORMATEXTENSIBLE wfxe;
- init_format(&wfx,WAVE_FORMAT_PCM,formats[f][0],formats[f][1],
+
+ /* if float, we only want to test 32-bit */
+ if ((format_tags[tag] == WAVE_FORMAT_IEEE_FLOAT) && (formats[f][1] !=
32))
+ continue;
+
+ init_format(&wfx,format_tags[tag],formats[f][0],formats[f][1],
formats[f][2]);
secondary=NULL;
ZeroMemory(&bufdesc, sizeof(bufdesc));
@@ -748,7 +774,7 @@
bufdesc.lpwfxFormat=(WAVEFORMATEX*)&wfxe;
wfxe.Format = wfx;
wfxe.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+ wfxe.SubFormat = (format_tags[tag] == WAVE_FORMAT_PCM ?
KSDATAFORMAT_SUBTYPE_PCM : KSDATAFORMAT_SUBTYPE_IEEE_FLOAT);
wfxe.Format.cbSize = 1;
wfxe.Samples.wValidBitsPerSample = wfx.wBitsPerSample;
wfxe.dwChannelMask = (wfx.nChannels == 1 ? KSAUDIO_SPEAKER_MONO :
KSAUDIO_SPEAKER_STEREO);
@@ -799,7 +825,7 @@
secondary=NULL;
}
- wfxe.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+ wfxe.SubFormat = (format_tags[tag] == WAVE_FORMAT_PCM ?
KSDATAFORMAT_SUBTYPE_PCM : KSDATAFORMAT_SUBTYPE_IEEE_FLOAT);
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
ok(rc==DS_OK && secondary,
"IDirectSound_CreateSoundBuffer() returned: %08x %p\n",
@@ -854,9 +880,9 @@
if (rc==DS_OK && secondary!=NULL) {
if (winetest_interactive) {
- trace(" Testing a secondary buffer at %dx%dx%d "
+ trace(" Testing a secondary buffer at %dx%dx%d (fmt=%d) "
"with a primary buffer at %dx%dx%d\n",
- wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,
+
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels,format_tags[tag],
wfx1.nSamplesPerSec,wfx1.wBitsPerSample,wfx1.nChannels);
}
test_buffer8(dso,&secondary,0,FALSE,0,FALSE,0,
@@ -866,6 +892,7 @@
ok(ref==0,"IDirectSoundBuffer_Release() has %d references, "
"should have 0\n",ref);
}
+ }
}
EXIT1:
ref=IDirectSoundBuffer_Release(primary);
@@ -915,6 +942,236 @@
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc);
}
+static void test_hw_buffers(void)
+{
+ IDirectSound8 *ds;
+ IDirectSoundBuffer *primary, *primary2, **secondaries, *secondary;
+ IDirectSoundBuffer8 *buf8;
+ DSCAPS caps;
+ DSBCAPS bufcaps;
+ DSBUFFERDESC bufdesc;
+ WAVEFORMATEX fmt;
+ UINT i;
+ HRESULT hr;
+
+ hr = pDirectSoundCreate8(NULL, &ds, NULL);
+ ok(hr == S_OK || hr == DSERR_NODRIVER || hr == DSERR_ALLOCATED || hr == E_FAIL,
+ "DirectSoundCreate8 failed: %08x\n", hr);
+ if(hr != S_OK)
+ return;
+
+ caps.dwSize = sizeof(caps);
+
+ hr = IDirectSound8_GetCaps(ds, &caps);
+ ok(hr == S_OK, "GetCaps failed: %08x\n", hr);
+
+ ok(caps.dwPrimaryBuffers == 1, "Got wrong number of primary buffers:
%u\n",
+ caps.dwPrimaryBuffers);
+
+ /* DSBCAPS_LOC* is ignored for primary buffers */
+ bufdesc.dwSize = sizeof(bufdesc);
+ bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCHARDWARE |
+ DSBCAPS_PRIMARYBUFFER;
+ bufdesc.dwBufferBytes = 0;
+ bufdesc.dwReserved = 0;
+ bufdesc.lpwfxFormat = NULL;
+ bufdesc.guid3DAlgorithm = GUID_NULL;
+
+ hr = IDirectSound8_CreateSoundBuffer(ds, &bufdesc, &primary, NULL);
+ ok(hr == S_OK, "CreateSoundBuffer failed: %08x\n", hr);
+ if(hr != S_OK){
+ IDirectSound8_Release(ds);
+ return;
+ }
+
+ bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCSOFTWARE |
+ DSBCAPS_PRIMARYBUFFER;
+
+ hr = IDirectSound8_CreateSoundBuffer(ds, &bufdesc, &primary2, NULL);
+ ok(hr == S_OK, "CreateSoundBuffer failed: %08x\n", hr);
+ ok(primary == primary2, "Got different primary buffers: %p, %p\n", primary,
primary2);
+ if(hr == S_OK)
+ IDirectSoundBuffer_Release(primary2);
+
+ buf8 = (IDirectSoundBuffer8 *)0xDEADBEEF;
+ hr = IDirectSoundBuffer_QueryInterface(primary, &IID_IDirectSoundBuffer8,
+ (void**)&buf8);
+ ok(hr == E_NOINTERFACE, "QueryInterface gave wrong failure: %08x\n", hr);
+ ok(buf8 == NULL, "Pointer didn't get set to NULL\n");
+
+ fmt.wFormatTag = WAVE_FORMAT_PCM;
+ fmt.nChannels = 2;
+ fmt.nSamplesPerSec = 48000;
+ fmt.wBitsPerSample = 16;
+ fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8;
+ fmt.nAvgBytesPerSec = fmt.nBlockAlign * fmt.nSamplesPerSec;
+ fmt.cbSize = 0;
+
+ bufdesc.lpwfxFormat = &fmt;
+ bufdesc.dwBufferBytes = fmt.nSamplesPerSec * fmt.nBlockAlign / 10;
+ bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_LOCHARDWARE |
+ DSBCAPS_CTRLVOLUME;
+
+ secondaries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+ sizeof(IDirectSoundBuffer *) * caps.dwMaxHwMixingAllBuffers);
+
+ /* try to fill all of the hw buffers */
+ trace("dwMaxHwMixingAllBuffers: %u\n", caps.dwMaxHwMixingAllBuffers);
+ trace("dwMaxHwMixingStaticBuffers: %u\n",
caps.dwMaxHwMixingStaticBuffers);
+ trace("dwMaxHwMixingStreamingBuffers: %u\n",
caps.dwMaxHwMixingStreamingBuffers);
+ for(i = 0; i < caps.dwMaxHwMixingAllBuffers; ++i){
+ hr = IDirectSound8_CreateSoundBuffer(ds, &bufdesc, &secondaries[i],
NULL);
+ ok(hr == S_OK || hr == E_NOTIMPL || broken(hr == DSERR_CONTROLUNAVAIL) ||
broken(hr == E_FAIL),
+ "CreateSoundBuffer(%u) failed: %08x\n", i, hr);
+ if(hr != S_OK)
+ break;
+
+ bufcaps.dwSize = sizeof(bufcaps);
+ hr = IDirectSoundBuffer_GetCaps(secondaries[i], &bufcaps);
+ ok(hr == S_OK, "GetCaps failed: %08x\n", hr);
+ ok((bufcaps.dwFlags & DSBCAPS_LOCHARDWARE) != 0,
+ "Buffer wasn't allocated in hardware, dwFlags: %x\n",
bufcaps.dwFlags);
+ }
+
+ /* see if we can create one more */
+ hr = IDirectSound8_CreateSoundBuffer(ds, &bufdesc, &secondary, NULL);
+ ok((i == caps.dwMaxHwMixingAllBuffers && hr == DSERR_ALLOCATED) || /* out of
hw buffers */
+ (caps.dwMaxHwMixingAllBuffers == 0 && hr == DSERR_INVALIDCALL) || /*
no hw buffers at all */
+ hr == E_NOTIMPL || /* don't support hw buffers */
+ broken(hr == DSERR_CONTROLUNAVAIL) || /* vmware winxp, others? */
+ broken(hr == E_FAIL) || /* broken AC97 driver */
+ broken(hr == S_OK) /* broken driver allows more hw bufs than dscaps claims
*/,
+ "CreateSoundBuffer(%u) gave wrong error: %08x\n", i, hr);
+ if(hr == S_OK)
+ IDirectSoundBuffer_Release(secondary);
+
+ for(i = 0; i < caps.dwMaxHwMixingAllBuffers; ++i)
+ if(secondaries[i])
+ IDirectSoundBuffer_Release(secondaries[i]);
+
+ HeapFree(GetProcessHeap(), 0, secondaries);
+
+ IDirectSoundBuffer_Release(primary);
+ IDirectSound8_Release(ds);
+}
+
+static struct {
+ UINT dev_count;
+ GUID guid;
+} default_info = { 0 };
+
+static BOOL WINAPI default_device_cb(GUID *guid, const char *desc,
+ const char *module, void *user)
+{
+ trace("guid: %p, desc: %s\n", guid, desc);
+ if(!guid)
+ ok(default_info.dev_count == 0, "Got NULL GUID not in first
position\n");
+ else{
+ if(default_info.dev_count == 0){
+ ok(IsEqualGUID(guid, &default_info.guid), "Expected default device
GUID\n");
+ }else{
+ ok(!IsEqualGUID(guid, &default_info.guid), "Got default GUID at
unexpected location: %u\n",
+ default_info.dev_count);
+ }
+
+ /* only count real devices */
+ ++default_info.dev_count;
+ }
+
+ return TRUE;
+}
+
+static void test_first_device(void)
+{
+ IMMDeviceEnumerator *devenum;
+ IMMDevice *defdev;
+ IPropertyStore *ps;
+ PROPVARIANT pv;
+ HRESULT hr;
+
+ hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL,
+ CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, (void**)&devenum);
+ if(FAILED(hr)){
+ win_skip("MMDevAPI is not available, skipping default device test\n");
+ return;
+ }
+
+ hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum, eRender,
+ eMultimedia, &defdev);
+ if (hr == E_NOTFOUND) {
+ win_skip("No default device found\n");
+ return;
+ }
+ ok(hr == S_OK, "GetDefaultAudioEndpoint failed: %08x\n", hr);
+
+ hr = IMMDevice_OpenPropertyStore(defdev, STGM_READ, &ps);
+ ok(hr == S_OK, "OpenPropertyStore failed: %08x\n", hr);
+
+ PropVariantInit(&pv);
+
+ hr = IPropertyStore_GetValue(ps, &PKEY_AudioEndpoint_GUID, &pv);
+ ok(hr == S_OK, "GetValue failed: %08x\n", hr);
+
+ CLSIDFromString(pv.u.pwszVal, &default_info.guid);
+
+ PropVariantClear(&pv);
+ IPropertyStore_Release(ps);
+ IMMDevice_Release(defdev);
+ IMMDeviceEnumerator_Release(devenum);
+
+ hr = pDirectSoundEnumerateA(&default_device_cb, NULL);
+ ok(hr == S_OK, "DirectSoundEnumerateA failed: %08x\n", hr);
+}
+
+static void test_COM(void)
+{
+ IDirectSound *ds;
+ IDirectSound8 *ds8 = (IDirectSound8*)0xdeadbeef;
+ IUnknown *unk, *unk8;
+ ULONG refcount;
+ HRESULT hr;
+
+ /* COM aggregation */
+ hr = CoCreateInstance(&CLSID_DirectSound8, (IUnknown*)&ds,
CLSCTX_INPROC_SERVER,
+ &IID_IUnknown, (void**)&ds8);
+ ok(hr == CLASS_E_NOAGGREGATION,
+ "DirectSound create failed: %08x, expected
CLASS_E_NOAGGREGATION\n", hr);
+ ok(!ds8, "ds8 = %p\n", ds8);
+
+ /* Invalid RIID */
+ hr = CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IDirectSound3DBuffer, (void**)&ds8);
+ ok(hr == E_NOINTERFACE,
+ "DirectSound create failed: %08x, expected E_NOINTERFACE\n", hr);
+
+ /* Same refcount for IDirectSound and IDirectSound8 */
+ hr = CoCreateInstance(&CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectSound8,
+ (void**)&ds8);
+ ok(hr == S_OK, "DirectSound create failed: %08x, expected S_OK\n", hr);
+ refcount = IDirectSound8_AddRef(ds8);
+ ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
+ hr = IDirectSound8_QueryInterface(ds8, &IID_IDirectSound, (void**)&ds);
+ ok(hr == S_OK, "QueryInterface for IID_IDirectSound failed: %08x\n", hr);
+ refcount = IDirectSound8_AddRef(ds8);
+ ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
+ refcount = IDirectSound_AddRef(ds);
+ ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
+
+ /* Separate refcount for IUnknown */
+ hr = IDirectSound_QueryInterface(ds, &IID_IUnknown, (void**)&unk);
+ ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
+ refcount = IUnknown_AddRef(unk);
+ ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
+ hr = IDirectSound_QueryInterface(ds8, &IID_IUnknown, (void**)&unk8);
+ ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
+ refcount = IUnknown_AddRef(unk8);
+ ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
+ refcount = IDirectSound_AddRef(ds);
+ ok(refcount == 6, "refcount == %u, expected 6\n", refcount);
+
+ while (IDirectSound_Release(ds));
+ while (IUnknown_Release(unk));
+}
START_TEST(dsound8)
{
@@ -932,16 +1189,19 @@
"DirectSoundCreate8");
if (pDirectSoundCreate8)
{
+ test_COM();
IDirectSound8_tests();
dsound8_tests();
+ test_hw_buffers();
+ test_first_device();
}
else
- skip("dsound8 test skipped\n");
+ skip("DirectSoundCreate8 missing - skipping all tests\n");
FreeLibrary(hDsound);
}
else
- skip("dsound.dll not found!\n");
+ skip("dsound.dll not found - skipping all tests\n");
CoUninitialize();
}
Modified: trunk/rostests/winetests/dsound/dsound_test.h
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/dsound_t…
==============================================================================
--- trunk/rostests/winetests/dsound/dsound_test.h [iso-8859-1] (original)
+++ trunk/rostests/winetests/dsound/dsound_test.h [iso-8859-1] Mon Sep 30 11:39:02 2013
@@ -17,6 +17,10 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+
+#include <wingdi.h>
+#include <mmreg.h>
+#include <mmsystem.h>
static const unsigned int formats[][4]={
{ 8000, 8, 1, 0 },
@@ -70,11 +74,14 @@
};
#define NB_FORMATS (sizeof(formats)/sizeof(*formats))
+static const unsigned int format_tags[] = {WAVE_FORMAT_PCM, WAVE_FORMAT_IEEE_FLOAT};
+#define NB_TAGS (sizeof(format_tags)/sizeof(*format_tags))
+
/* The time slice determines how often we will service the buffer */
#define TIME_SLICE 31
#define BUFFER_LEN 400
-extern char* wave_generate_la(WAVEFORMATEX*,double,DWORD*);
+extern char* wave_generate_la(WAVEFORMATEX*,double,DWORD*,BOOL);
extern HWND get_hwnd(void);
extern void init_format(WAVEFORMATEX*,int,int,int,int);
extern void test_buffer(LPDIRECTSOUND,LPDIRECTSOUNDBUFFER*,
Modified: trunk/rostests/winetests/dsound/duplex.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/duplex.c…
==============================================================================
--- trunk/rostests/winetests/dsound/duplex.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/dsound/duplex.c [iso-8859-1] Mon Sep 30 11:39:02 2013
@@ -18,14 +18,19 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include <windows.h>
-
-#include <stdio.h>
-
-#include "wine/test.h"
-#include "dsound.h"
-#include "mmreg.h"
-#include "dsconf.h"
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
+#define COBJMACROS
+//#include <windows.h>
+//#include <stdio.h>
+
+#include <wine/test.h>
+#include <wingdi.h>
+#include <mmreg.h>
+#include <dsound.h>
+#include <dsconf.h>
#include "dsound_test.h"
@@ -93,8 +98,9 @@
ok(rc==DS_OK,"IDirectSoundFullDuplex_QueryInterface(IID_IDirectSoundFullDuplex)
"
"failed: %08x\n",rc);
if (rc==DS_OK) {
- ok (dsfdo==dsfd, "different interfaces\n");
+ ok(dsfdo==dsfd, "different interfaces\n");
ref=IDirectSound8_Release(dsfd);
+ ok(ref==1, "IDirectSoundFullDuplex_Release() has %d references, should have
1\n", ref);
}
ref=IDirectSoundFullDuplex_Release(dsfdo);
@@ -222,6 +228,117 @@
IDirectSoundFullDuplex_Release(dsfdo);
}
+static void test_COM(void)
+{
+ IDirectSoundFullDuplex *dsfd = (IDirectSoundFullDuplex*)0xdeadbeef;
+ IDirectSound *ds;
+ IDirectSound8 *ds8;
+ IDirectSoundCapture *dsc;
+ IUnknown *unk, *unk8;
+ IDirectSoundBuffer8 *dsb8;
+ IDirectSoundCaptureBuffer8 *dscb8;
+ DSBUFFERDESC bufdesc;
+ DSCBUFFERDESC cbufdesc;
+ WAVEFORMATEX wfx;
+ ULONG refcount;
+ HRESULT hr;
+
+ /* COM aggregation */
+ hr = CoCreateInstance(&CLSID_DirectSoundFullDuplex, (IUnknown*)&dsfd,
CLSCTX_INPROC_SERVER,
+ &IID_IUnknown, (void**)&dsfd);
+ ok(hr == CLASS_E_NOAGGREGATION,
+ "DirectSoundFullDuplex create failed: %08x, expected
CLASS_E_NOAGGREGATION\n", hr);
+ ok(!dsfd, "dsfd = %p\n", dsfd);
+
+ /* Invalid RIID */
+ hr = CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IDirectSound3DBuffer, (void**)&dsfd);
+ ok(hr == E_NOINTERFACE,
+ "DirectSoundFullDuplex create failed: %08x, expected
E_NOINTERFACE\n", hr);
+
+ /* Different refcount for IDirectSoundFullDuplex and for IUnknown */
+ hr = CoCreateInstance(&CLSID_DirectSoundFullDuplex, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IDirectSoundFullDuplex, (void**)&dsfd);
+ ok(hr == S_OK, "DirectSoundFullDuplex create failed: %08x, expected
S_OK\n", hr);
+ refcount = IDirectSoundFullDuplex_AddRef(dsfd);
+ ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
+ hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IUnknown,
(void**)&unk);
+ ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
+ refcount = IUnknown_AddRef(unk);
+ ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
+
+ /* Not initialized */
+ hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSound8,
(void**)&ds8);
+ ok(hr == E_NOINTERFACE,
+ "QueryInterface for IID_IDirectSound8 failed: %08x, expected
E_NOINTERFACE\n", hr);
+ hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSoundCapture,
(void**)&dsc);
+ ok(hr == E_NOINTERFACE,
+ "QueryInterface for IID_IDirectSoundCapture failed: %08x, expected
E_NOINTERFACE\n", hr);
+
+ init_format(&wfx, WAVE_FORMAT_PCM, 44100, 16, 1);
+ ZeroMemory(&bufdesc, sizeof(bufdesc));
+ bufdesc.dwSize = sizeof(bufdesc);
+ bufdesc.dwBufferBytes = wfx.nAvgBytesPerSec;
+ bufdesc.lpwfxFormat = &wfx;
+ ZeroMemory(&cbufdesc, sizeof(cbufdesc));
+ cbufdesc.dwSize = sizeof(cbufdesc);
+ cbufdesc.dwBufferBytes = wfx.nAvgBytesPerSec;
+ cbufdesc.lpwfxFormat = &wfx;
+ hr = IDirectSoundFullDuplex_Initialize(dsfd, NULL, NULL, &cbufdesc, &bufdesc,
get_hwnd(),
+ DSSCL_EXCLUSIVE, NULL, NULL);
+ ok(hr == E_INVALIDARG,
+ "IDirectSoundFullDuplex_Initialize failed: %08x, expected
E_INVALIDARG\n", hr);
+ hr = IDirectSoundFullDuplex_Initialize(dsfd, NULL, NULL, &cbufdesc, &bufdesc,
get_hwnd(),
+ DSSCL_EXCLUSIVE, &dscb8, &dsb8);
+ if (hr == DSERR_NODRIVER || hr == DSERR_INVALIDCALL) {
+ skip("No driver\n");
+ return;
+ }
+ ok(hr == S_OK, "IDirectSoundFullDuplex_Initialize failed: %08x\n", hr);
+
+ /* IDirectSound and IDirectSound8 */
+ hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSound8,
(void**)&ds8);
+ ok(hr == S_OK, "QueryInterface for IID_IDirectSound8 failed: %08x\n", hr);
+ refcount = IDirectSound8_AddRef(ds8);
+ ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
+ hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSound,
(void**)&ds);
+ ok(hr == S_OK, "QueryInterface for IID_IDirectSound failed: %08x\n", hr);
+ refcount = IDirectSound8_AddRef(ds8);
+ ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
+ refcount = IDirectSound_AddRef(ds);
+ ok(refcount == 5, "refcount == %u, expected 5\n", refcount);
+ hr = IDirectSound8_QueryInterface(ds8, &IID_IUnknown, (void**)&unk8);
+ ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
+ ok(unk == unk8, "Got different IUnknown when QI'ing IDirectSoundFullDuplex
and IDirectSound\n");
+ refcount = IUnknown_AddRef(unk8);
+ ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
+ refcount = IDirectSound_AddRef(ds);
+ ok(refcount == 6, "refcount == %u, expected 6\n", refcount);
+ refcount = IDirectSoundFullDuplex_AddRef(dsfd);
+ ok(refcount == 3, "refcount == %u, expected 3\n", refcount);
+
+ /* IDirectSoundCapture */
+ hr = IDirectSoundFullDuplex_QueryInterface(dsfd, &IID_IDirectSoundCapture,
(void**)&dsc);
+ ok(hr == S_OK, "QueryInterface for IID_IDirectSoundCapture failed: %08x\n",
hr);
+ refcount = IDirectSoundCapture_AddRef(dsc);
+ ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
+ refcount = IDirectSoundFullDuplex_AddRef(dsfd);
+ ok(refcount == 4, "refcount == %u, expected 4\n", refcount);
+ hr = IDirectSoundCapture_QueryInterface(ds8, &IID_IUnknown, (void**)&unk8);
+ ok(hr == S_OK, "QueryInterface for IID_IUnknown failed: %08x\n", hr);
+ ok(unk == unk8,
+ "Got different IUnknown when QI'ing IDirectSoundFullDuplex and
IDirectSoundCapture\n");
+ refcount = IUnknown_AddRef(unk8);
+ ok(refcount == 6, "refcount == %u, expected 6\n", refcount);
+
+ IDirectSoundBuffer8_Release(dsb8);
+ IDirectSoundCaptureBuffer8_Release(dscb8);
+ while (IDirectSound8_Release(ds8));
+ while (IDirectSoundCapture_Release(dsc));
+ while (IDirectSoundFullDuplex_Release(dsfd));
+ while (IUnknown_Release(unk));
+}
+
START_TEST(duplex)
{
HMODULE hDsound;
@@ -234,15 +351,16 @@
pDirectSoundFullDuplexCreate=(void*)GetProcAddress(hDsound,
"DirectSoundFullDuplexCreate");
- if (pDirectSoundFullDuplexCreate)
+ if (pDirectSoundFullDuplexCreate) {
+ test_COM();
IDirectSoundFullDuplex_tests();
- else
- skip("duplex test skipped\n");
+ } else
+ skip("DirectSoundFullDuplexCreate missing - skipping all
tests\n");
FreeLibrary(hDsound);
}
else
- skip("dsound.dll not found!\n");
+ skip("dsound.dll not found - skipping all tests\n");
CoUninitialize();
}
Modified: trunk/rostests/winetests/dsound/propset.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/propset.…
==============================================================================
--- trunk/rostests/winetests/dsound/propset.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/dsound/propset.c [iso-8859-1] Mon Sep 30 11:39:02 2013
@@ -19,12 +19,19 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
#define COBJMACROS
-#include <windows.h>
-
-#include "wine/test.h"
-#include "dsound.h"
-#include "dsconf.h"
+//#include <windows.h>
+
+#include <wine/test.h>
+#include <wingdi.h>
+#include <winnls.h>
+#include <mmreg.h>
+#include <dsound.h>
+#include <dsconf.h>
#include "dsound_test.h"
@@ -553,6 +560,8 @@
IKsPropertySet_Release(pps);
}
+static unsigned driver_count = 0;
+
static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
LPCSTR lpcstrModule, LPVOID lpContext)
{
@@ -564,6 +573,7 @@
int ref;
trace("*** Testing %s - %s ***\n",lpcstrDescription,lpcstrModule);
+ driver_count++;
rc=pDirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED||rc==E_FAIL,
@@ -616,8 +626,8 @@
trace(" Testing a secondary buffer at %dx%dx%d\n",
wfx.nSamplesPerSec,wfx.wBitsPerSample,wfx.nChannels);
rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
- ok(rc==DS_OK&&secondary!=NULL,"IDirectSound_CreateSoundBuffer()
"
- "failed to create a secondary buffer: %08x\n",rc);
+ ok((rc==DS_OK && secondary!=NULL) || broken(rc == DSERR_CONTROLUNAVAIL),
/* vmware drivers on w2k */
+ "IDirectSound_CreateSoundBuffer() failed to create a secondary buffer:
%08x\n",rc);
if (rc==DS_OK&&secondary!=NULL) {
IKsPropertySet * pPropertySet=NULL;
rc=IDirectSoundBuffer_QueryInterface(secondary,
@@ -710,6 +720,7 @@
HRESULT rc;
rc=pDirectSoundEnumerateA(&dsenum_callback,NULL);
ok(rc==DS_OK,"DirectSoundEnumerateA() failed: %08x\n",rc);
+ trace("tested %u DirectSound drivers\n", driver_count);
}
START_TEST(propset)
@@ -743,7 +754,7 @@
FreeLibrary(hDsound);
}
else
- skip("dsound.dll not found!\n");
+ skip("dsound.dll not found - skipping all tests\n");
CoUninitialize();
}
Modified: trunk/rostests/winetests/dsound/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/dsound/testlist…
==============================================================================
--- trunk/rostests/winetests/dsound/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/dsound/testlist.c [iso-8859-1] Mon Sep 30 11:39:02 2013
@@ -1,10 +1,7 @@
/* Automatically generated file; DO NOT EDIT!! */
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
#define STANDALONE
-#include "wine/test.h"
+#include <wine/test.h>
extern void func_capture(void);
extern void func_ds3d8(void);