Commit 31f817b6 authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard

Separated DirectSoundCreate8 into two functions and added a

IDirectSound implementation. Added proper COM behavior for QueryInterface for IDirectSound and IDirectSound8. Fixed a bug in the dsound.h header file for IDirectSound8 CreateSoundBuffer and DuplicateSoundBuffer. Added new tests for proper COM behavior and enables some commented out code for tests that work on windows. Added new tests for IDirectSound8.
parent 87bacf46
...@@ -9,6 +9,7 @@ EXTRALIBS = -ldxguid -luuid ...@@ -9,6 +9,7 @@ EXTRALIBS = -ldxguid -luuid
C_SRCS = \ C_SRCS = \
buffer.c \ buffer.c \
capture.c \ capture.c \
dsound.c \
dsound_main.c \ dsound_main.c \
mixer.c \ mixer.c \
primary.c \ primary.c \
......
1 stdcall DirectSoundCreate(ptr ptr ptr) DirectSoundCreate8 1 stdcall DirectSoundCreate(ptr ptr ptr)
2 stdcall DirectSoundEnumerateA(ptr ptr) 2 stdcall DirectSoundEnumerateA(ptr ptr)
3 stdcall DirectSoundEnumerateW(ptr ptr) 3 stdcall DirectSoundEnumerateW(ptr ptr)
4 stdcall -private DllCanUnloadNow() DSOUND_DllCanUnloadNow 4 stdcall -private DllCanUnloadNow() DSOUND_DllCanUnloadNow
......
...@@ -45,6 +45,11 @@ extern int ds_default_capture; ...@@ -45,6 +45,11 @@ extern int ds_default_capture;
* Predeclare the interface implementation structures * Predeclare the interface implementation structures
*/ */
typedef struct IDirectSoundImpl IDirectSoundImpl; typedef struct IDirectSoundImpl IDirectSoundImpl;
typedef struct IDirectSound_IUnknown IDirectSound_IUnknown;
typedef struct IDirectSound_IDirectSound IDirectSound_IDirectSound;
typedef struct IDirectSound8_IUnknown IDirectSound8_IUnknown;
typedef struct IDirectSound8_IDirectSound IDirectSound8_IDirectSound;
typedef struct IDirectSound8_IDirectSound8 IDirectSound8_IDirectSound8;
typedef struct IDirectSoundBufferImpl IDirectSoundBufferImpl; typedef struct IDirectSoundBufferImpl IDirectSoundBufferImpl;
typedef struct IDirectSoundCaptureImpl IDirectSoundCaptureImpl; typedef struct IDirectSoundCaptureImpl IDirectSoundCaptureImpl;
typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl; typedef struct IDirectSoundCaptureBufferImpl IDirectSoundCaptureBufferImpl;
...@@ -95,6 +100,10 @@ struct IDirectSoundImpl ...@@ -95,6 +100,10 @@ struct IDirectSoundImpl
IDirectSound3DListenerImpl* listener; IDirectSound3DListenerImpl* listener;
DS3DLISTENER ds3dl; DS3DLISTENER ds3dl;
BOOL ds3dl_need_recalc; BOOL ds3dl_need_recalc;
LPUNKNOWN pUnknown;
LPDIRECTSOUND pDS;
LPDIRECTSOUND8 pDS8;
}; };
/* reference counted buffer memory for duplicated buffer memory */ /* reference counted buffer memory for duplicated buffer memory */
...@@ -104,6 +113,66 @@ typedef struct BufferMemory ...@@ -104,6 +113,66 @@ typedef struct BufferMemory
LPBYTE memory; LPBYTE memory;
} BufferMemory; } BufferMemory;
HRESULT WINAPI IDirectSoundImpl_Create(
LPCGUID lpcGUID,
LPDIRECTSOUND8 * ppds);
/*****************************************************************************
* IDirectSound COM components
*/
struct IDirectSound_IUnknown {
ICOM_VFIELD(IUnknown);
DWORD ref;
LPDIRECTSOUND8 pds;
};
HRESULT WINAPI IDirectSound_IUnknown_Create(
LPDIRECTSOUND8 pds,
LPUNKNOWN * ppunk);
struct IDirectSound_IDirectSound {
ICOM_VFIELD(IDirectSound);
DWORD ref;
LPDIRECTSOUND8 pds;
};
HRESULT WINAPI IDirectSound_IDirectSound_Create(
LPDIRECTSOUND8 pds,
LPDIRECTSOUND * ppds);
/*****************************************************************************
* IDirectSound8 COM components
*/
struct IDirectSound8_IUnknown {
ICOM_VFIELD(IUnknown);
DWORD ref;
LPDIRECTSOUND8 pds;
};
HRESULT WINAPI IDirectSound8_IUnknown_Create(
LPDIRECTSOUND8 pds,
LPUNKNOWN * ppunk);
struct IDirectSound8_IDirectSound {
ICOM_VFIELD(IDirectSound);
DWORD ref;
LPDIRECTSOUND8 pds;
};
HRESULT WINAPI IDirectSound8_IDirectSound_Create(
LPDIRECTSOUND8 pds,
LPDIRECTSOUND * ppds);
struct IDirectSound8_IDirectSound8 {
ICOM_VFIELD(IDirectSound8);
DWORD ref;
LPDIRECTSOUND8 pds;
};
HRESULT WINAPI IDirectSound8_IDirectSound8_Create(
LPDIRECTSOUND8 pds,
LPDIRECTSOUND8 * ppds);
/***************************************************************************** /*****************************************************************************
* IDirectSoundBuffer implementation structure * IDirectSoundBuffer implementation structure
*/ */
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "windef.h" #include "windef.h"
#include "wingdi.h" #include "wingdi.h"
#include "dsound.h" #include "dsound.h"
#include "dxerr9.h"
#include "dsound_test.h" #include "dsound_test.h"
...@@ -46,32 +47,51 @@ static HRESULT test_dsound(LPGUID lpGuid) ...@@ -46,32 +47,51 @@ static HRESULT test_dsound(LPGUID lpGuid)
LPDIRECTSOUND dso=NULL; LPDIRECTSOUND dso=NULL;
DSCAPS dscaps; DSCAPS dscaps;
int ref; int ref;
IUnknown * unknown;
IDirectSound * ds;
IDirectSound8 * ds8;
/* DSOUND: Error: Invalid interface buffer */ /* DSOUND: Error: Invalid interface buffer */
rc=DirectSoundCreate(lpGuid,0,NULL); rc=DirectSoundCreate(lpGuid,0,NULL);
ok(rc==DSERR_INVALIDPARAM,"DirectSoundCreate should have failed: 0x%lx\n",rc); ok(rc==DSERR_INVALIDPARAM,"DirectSoundCreate should have failed: %s\n",DXGetErrorString9(rc));
/* Create the DirectSound object */ /* Create the DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL); rc=DirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK,"DirectSoundCreate failed: 0x%lx\n",rc); ok(rc==DS_OK,"DirectSoundCreate failed: %s\n",DXGetErrorString9(rc));
if (rc!=DS_OK) if (rc!=DS_OK)
return rc; return rc;
/* Try to Query for objects */
rc=IDirectSound_QueryInterface(dso,&IID_IUnknown,(LPVOID*)&unknown);
ok(rc==DS_OK,"IDirectSound_QueryInterface(IID_IUnknown) failed: %s\n",DXGetErrorString9(rc));
if (rc==DS_OK)
IDirectSound_Release(unknown);
rc=IDirectSound_QueryInterface(dso,&IID_IDirectSound,(LPVOID*)&ds);
ok(rc==DS_OK,"IDirectSound_QueryInterface(IID_IDirectSound) failed: %s\n",DXGetErrorString9(rc));
if (rc==DS_OK)
IDirectSound_Release(ds);
rc=IDirectSound_QueryInterface(dso,&IID_IDirectSound8,(LPVOID*)&ds8);
ok(rc==E_NOINTERFACE,"IDirectSound_QueryInterface(IID_IDirectSound8) should have failed: %s\n",DXGetErrorString9(rc));
if (rc==DS_OK)
IDirectSound8_Release(ds8);
/* DSOUND: Error: Invalid caps buffer */ /* DSOUND: Error: Invalid caps buffer */
rc=IDirectSound_GetCaps(dso,0); rc=IDirectSound_GetCaps(dso,0);
ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: 0x%lx\n",rc); ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: %s\n",DXGetErrorString9(rc));
ZeroMemory(&dscaps, sizeof(dscaps)); ZeroMemory(&dscaps, sizeof(dscaps));
/* DSOUND: Error: Invalid caps buffer */ /* DSOUND: Error: Invalid caps buffer */
rc=IDirectSound_GetCaps(dso,&dscaps); rc=IDirectSound_GetCaps(dso,&dscaps);
ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: 0x%lx\n",rc); ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: %s\n",DXGetErrorString9(rc));
dscaps.dwSize=sizeof(dscaps); dscaps.dwSize=sizeof(dscaps);
/* DSOUND: Running on a certified driver */ /* DSOUND: Running on a certified driver */
rc=IDirectSound_GetCaps(dso,&dscaps); rc=IDirectSound_GetCaps(dso,&dscaps);
ok(rc==DS_OK,"GetCaps failed: 0x%lx\n",rc); ok(rc==DS_OK,"GetCaps failed: %s\n",DXGetErrorString9(rc));
if (rc==DS_OK) { if (rc==DS_OK) {
trace(" DirectSound Caps: flags=0x%08lx secondary min=%ld max=%ld\n", trace(" DirectSound Caps: flags=0x%08lx secondary min=%ld max=%ld\n",
dscaps.dwFlags,dscaps.dwMinSecondarySampleRate, dscaps.dwFlags,dscaps.dwMinSecondarySampleRate,
...@@ -84,17 +104,15 @@ static HRESULT test_dsound(LPGUID lpGuid) ...@@ -84,17 +104,15 @@ static HRESULT test_dsound(LPGUID lpGuid)
if (ref!=0) if (ref!=0)
return DSERR_GENERIC; return DSERR_GENERIC;
#if 0
/* FIXME: this works on windows */
/* Create a DirectSound object */ /* Create a DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso,NULL); rc=DirectSoundCreate(lpGuid,&dso,NULL);
ok(rc==DS_OK,"DirectSoundCreate failed: 0x%lx\n",rc); ok(rc==DS_OK,"DirectSoundCreate failed: %s\n",DXGetErrorString9(rc));
if (rc==DS_OK) { if (rc==DS_OK) {
LPDIRECTSOUND dso1=NULL; LPDIRECTSOUND dso1=NULL;
/* Create a second DirectSound object */ /* Create a second DirectSound object */
rc=DirectSoundCreate(lpGuid,&dso1,NULL); rc=DirectSoundCreate(lpGuid,&dso1,NULL);
ok(rc==DS_OK,"DirectSoundCreate failed: 0x%lx\n",rc); ok(rc==DS_OK,"DirectSoundCreate failed: %s\n",DXGetErrorString9(rc));
if (rc==DS_OK) { if (rc==DS_OK) {
/* Release the second DirectSound object */ /* Release the second DirectSound object */
ref=IDirectSound_Release(dso1); ref=IDirectSound_Release(dso1);
...@@ -109,7 +127,96 @@ static HRESULT test_dsound(LPGUID lpGuid) ...@@ -109,7 +127,96 @@ static HRESULT test_dsound(LPGUID lpGuid)
return DSERR_GENERIC; return DSERR_GENERIC;
} else } else
return rc; return rc;
#endif
return DS_OK;
}
static HRESULT test_dsound8(LPGUID lpGuid)
{
HRESULT rc;
LPDIRECTSOUND8 dso=NULL;
DSCAPS dscaps;
int ref;
IUnknown * unknown;
IDirectSound * ds;
IDirectSound8 * ds8;
/* DSOUND: Error: Invalid interface buffer */
rc=DirectSoundCreate8(lpGuid,0,NULL);
ok(rc==DSERR_INVALIDPARAM,"DirectSoundCreate8 should have failed: %s\n",DXGetErrorString9(rc));
/* Create the DirectSound8 object */
rc=DirectSoundCreate8(lpGuid,&dso,NULL);
ok(rc==DS_OK,"DirectSoundCreate8 failed: %s\n",DXGetErrorString9(rc));
if (rc!=DS_OK)
return rc;
/* Try to Query for objects */
rc=IDirectSound8_QueryInterface(dso,&IID_IUnknown,(LPVOID*)&unknown);
ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IUnknown) failed: %s\n",DXGetErrorString9(rc));
if (rc==DS_OK)
IDirectSound8_Release(unknown);
rc=IDirectSound8_QueryInterface(dso,&IID_IDirectSound,(LPVOID*)&ds);
ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IDirectSound) failed: %s\n",DXGetErrorString9(rc));
if (rc==DS_OK)
IDirectSound_Release(ds);
rc=IDirectSound8_QueryInterface(dso,&IID_IDirectSound8,(LPVOID*)&ds8);
ok(rc==DS_OK,"IDirectSound8_QueryInterface(IID_IDirectSound8) failed: %s\n",DXGetErrorString9(rc));
if (rc==DS_OK)
IDirectSound8_Release(ds8);
/* DSOUND: Error: Invalid caps buffer */
rc=IDirectSound8_GetCaps(dso,0);
ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: %s\n",DXGetErrorString9(rc));
ZeroMemory(&dscaps, sizeof(dscaps));
/* DSOUND: Error: Invalid caps buffer */
rc=IDirectSound8_GetCaps(dso,&dscaps);
ok(rc==DSERR_INVALIDPARAM,"GetCaps should have failed: %s\n",DXGetErrorString9(rc));
dscaps.dwSize=sizeof(dscaps);
/* DSOUND: Running on a certified driver */
rc=IDirectSound8_GetCaps(dso,&dscaps);
ok(rc==DS_OK,"GetCaps failed: %s\n",DXGetErrorString9(rc));
if (rc==DS_OK) {
trace(" DirectSound Caps: flags=0x%08lx secondary min=%ld max=%ld\n",
dscaps.dwFlags,dscaps.dwMinSecondarySampleRate,
dscaps.dwMaxSecondarySampleRate);
}
/* Release the DirectSound8 object */
ref=IDirectSound8_Release(dso);
ok(ref==0,"IDirectSound_Release has %d references, should have 0\n",ref);
if (ref!=0)
return DSERR_GENERIC;
/* Create a DirectSound8 object */
rc=DirectSoundCreate8(lpGuid,&dso,NULL);
ok(rc==DS_OK,"DirectSoundCreate failed: %s\n",DXGetErrorString9(rc));
if (rc==DS_OK) {
LPDIRECTSOUND8 dso1=NULL;
/* Create a second DirectSound8 object */
rc=DirectSoundCreate8(lpGuid,&dso1,NULL);
ok(rc==DS_OK,"DirectSoundCreate8 failed: %s\n",DXGetErrorString9(rc));
if (rc==DS_OK) {
/* Release the second DirectSound8 object */
ref=IDirectSound8_Release(dso1);
ok(ref==0,"IDirectSound8_Release has %d references, should have 0\n",ref);
ok(dso!=dso1,"DirectSound8 objects should be unique: dso=0x%08lx,dso1=0x%08lx\n",(DWORD)dso,(DWORD)dso1);
}
/* Release the first DirectSound8 object */
ref=IDirectSound8_Release(dso);
ok(ref==0,"IDirectSound8_Release has %d references, should have 0\n",ref);
if (ref!=0)
return DSERR_GENERIC;
} else
return rc;
return DS_OK; return DS_OK;
} }
...@@ -294,6 +401,7 @@ static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, ...@@ -294,6 +401,7 @@ static BOOL WINAPI dsenum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription,
{ {
trace("*** Testing %s - %s\n",lpcstrDescription,lpcstrModule); trace("*** Testing %s - %s\n",lpcstrDescription,lpcstrModule);
test_dsound(lpGuid); test_dsound(lpGuid);
test_dsound8(lpGuid);
test_primary(lpGuid); test_primary(lpGuid);
test_secondary(lpGuid); test_secondary(lpGuid);
......
...@@ -456,9 +456,9 @@ ICOM_DEFINE(IDirectSound,IUnknown) ...@@ -456,9 +456,9 @@ ICOM_DEFINE(IDirectSound,IUnknown)
#define INTERFACE IDirectSound8 #define INTERFACE IDirectSound8
#define IDirectSound8_METHODS \ #define IDirectSound8_METHODS \
IUnknown_METHODS \ IUnknown_METHODS \
STDMETHOD(CreateSoundBuffer)(THIS_ LPCDSBUFFERDESC lpcDSBufferDesc, LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer, IUnknown *pUnkOuter) PURE; \ STDMETHOD(CreateSoundBuffer)(THIS_ LPCDSBUFFERDESC lpcDSBufferDesc, LPLPDIRECTSOUNDBUFFER lplpDirectSoundBuffer, IUnknown *pUnkOuter) PURE; \
STDMETHOD(GetCaps)(THIS_ LPDSCAPS lpDSCaps) PURE; \ STDMETHOD(GetCaps)(THIS_ LPDSCAPS lpDSCaps) PURE; \
STDMETHOD(DuplicateSoundBuffer)(THIS_ LPDIRECTSOUNDBUFFER8 lpDsbOriginal, LPLPDIRECTSOUNDBUFFER8 lplpDsbDuplicate) PURE; \ STDMETHOD(DuplicateSoundBuffer)(THIS_ LPDIRECTSOUNDBUFFER lpDsbOriginal, LPLPDIRECTSOUNDBUFFER lplpDsbDuplicate) PURE; \
STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwLevel) PURE; \ STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwLevel) PURE; \
STDMETHOD(Compact)(THIS) PURE; \ STDMETHOD(Compact)(THIS) PURE; \
STDMETHOD(GetSpeakerConfig)(THIS_ LPDWORD lpdwSpeakerConfig) PURE; \ STDMETHOD(GetSpeakerConfig)(THIS_ LPDWORD lpdwSpeakerConfig) PURE; \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment