Commit bf4481d3 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

dsound: Merge the DirectSound create functions.

parent 8978a4b5
...@@ -583,9 +583,12 @@ static HRESULT IDirectSound8_IDirectSound8_Create( ...@@ -583,9 +583,12 @@ static HRESULT IDirectSound8_IDirectSound8_Create(
return DS_OK; return DS_OK;
} }
static HRESULT IDirectSoundImpl_Create(void **ppv, BOOL has_ds8) static HRESULT IDirectSoundImpl_Create(REFIID riid, void **ppv, BOOL has_ds8)
{ {
IDirectSoundImpl *obj; IDirectSoundImpl *obj;
HRESULT hr;
TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
*ppv = NULL; *ppv = NULL;
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*obj)); obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*obj));
...@@ -594,48 +597,28 @@ static HRESULT IDirectSoundImpl_Create(void **ppv, BOOL has_ds8) ...@@ -594,48 +597,28 @@ static HRESULT IDirectSoundImpl_Create(void **ppv, BOOL has_ds8)
return DSERR_OUTOFMEMORY; return DSERR_OUTOFMEMORY;
} }
setup_dsound_options();
obj->IUnknown_iface.lpVtbl = &unk_vtbl; obj->IUnknown_iface.lpVtbl = &unk_vtbl;
obj->ref = 0; obj->ref = 1;
obj->numIfaces = 0; obj->numIfaces = 1;
obj->device = NULL; obj->device = NULL;
obj->has_ds8 = has_ds8; obj->has_ds8 = has_ds8;
*ppv = obj; hr = IUnknown_QueryInterface(&obj->IUnknown_iface, riid, ppv);
return DS_OK; IUnknown_Release(&obj->IUnknown_iface);
return hr;
} }
HRESULT DSOUND_Create( HRESULT DSOUND_Create(REFIID riid, void **ppv)
REFIID riid,
LPDIRECTSOUND *ppDS)
{ {
LPDIRECTSOUND8 pDS; return IDirectSoundImpl_Create(riid, ppv, FALSE);
HRESULT hr; }
TRACE("(%s, %p)\n", debugstr_guid(riid), ppDS);
if (!IsEqualIID(riid, &IID_IUnknown) &&
!IsEqualIID(riid, &IID_IDirectSound)) {
*ppDS = 0;
return E_NOINTERFACE;
}
/* Get dsound configuration */
setup_dsound_options();
hr = IDirectSoundImpl_Create((void **)&pDS, FALSE);
if (hr == DS_OK) {
hr = IDirectSound_IDirectSound_Create(pDS, ppDS);
if (*ppDS)
IDirectSound_IDirectSound_AddRef(*ppDS);
else {
WARN("IDirectSound_IDirectSound_Create failed\n");
IDirectSound8_Release(pDS);
}
} else {
WARN("IDirectSoundImpl_Create failed\n");
*ppDS = 0;
}
return hr; HRESULT DSOUND_Create8(REFIID riid, void **ppv)
{
return IDirectSoundImpl_Create(riid, ppv, TRUE);
} }
/******************************************************************************* /*******************************************************************************
...@@ -674,7 +657,7 @@ HRESULT WINAPI DirectSoundCreate( ...@@ -674,7 +657,7 @@ HRESULT WINAPI DirectSoundCreate(
return DSERR_INVALIDPARAM; return DSERR_INVALIDPARAM;
} }
hr = DSOUND_Create(&IID_IDirectSound, &pDS); hr = DSOUND_Create(&IID_IDirectSound, (void **)&pDS);
if (hr == DS_OK) { if (hr == DS_OK) {
hr = IDirectSound_Initialize(pDS, lpcGUID); hr = IDirectSound_Initialize(pDS, lpcGUID);
if (hr != DS_OK) { if (hr != DS_OK) {
...@@ -691,41 +674,6 @@ HRESULT WINAPI DirectSoundCreate( ...@@ -691,41 +674,6 @@ HRESULT WINAPI DirectSoundCreate(
return hr; return hr;
} }
HRESULT DSOUND_Create8(
REFIID riid,
LPDIRECTSOUND8 *ppDS)
{
LPDIRECTSOUND8 pDS;
HRESULT hr;
TRACE("(%s, %p)\n", debugstr_guid(riid), ppDS);
if (!IsEqualIID(riid, &IID_IUnknown) &&
!IsEqualIID(riid, &IID_IDirectSound) &&
!IsEqualIID(riid, &IID_IDirectSound8)) {
*ppDS = 0;
return E_NOINTERFACE;
}
/* Get dsound configuration */
setup_dsound_options();
hr = IDirectSoundImpl_Create((void **)&pDS, TRUE);
if (hr == DS_OK) {
hr = IDirectSound8_IDirectSound8_Create(pDS, ppDS);
if (*ppDS)
IDirectSound8_IDirectSound8_AddRef(*ppDS);
else {
WARN("IDirectSound8_IDirectSound8_Create failed\n");
IDirectSound8_Release(pDS);
}
} else {
WARN("IDirectSoundImpl_Create failed\n");
*ppDS = 0;
}
return hr;
}
/******************************************************************************* /*******************************************************************************
* DirectSoundCreate8 (DSOUND.11) * DirectSoundCreate8 (DSOUND.11)
* *
...@@ -762,7 +710,7 @@ HRESULT WINAPI DirectSoundCreate8( ...@@ -762,7 +710,7 @@ HRESULT WINAPI DirectSoundCreate8(
return DSERR_INVALIDPARAM; return DSERR_INVALIDPARAM;
} }
hr = DSOUND_Create8(&IID_IDirectSound8, &pDS); hr = DSOUND_Create8(&IID_IDirectSound8, (void **)&pDS);
if (hr == DS_OK) { if (hr == DS_OK) {
hr = IDirectSound8_Initialize(pDS, lpcGUID); hr = IDirectSound8_Initialize(pDS, lpcGUID);
if (hr != DS_OK) { if (hr != DS_OK) {
......
...@@ -719,8 +719,8 @@ static const IClassFactoryVtbl DSCF_Vtbl = { ...@@ -719,8 +719,8 @@ static const IClassFactoryVtbl DSCF_Vtbl = {
}; };
static IClassFactoryImpl DSOUND_CF[] = { static IClassFactoryImpl DSOUND_CF[] = {
{ { &DSCF_Vtbl }, &CLSID_DirectSound, (FnCreateInstance)DSOUND_Create }, { { &DSCF_Vtbl }, &CLSID_DirectSound, DSOUND_Create },
{ { &DSCF_Vtbl }, &CLSID_DirectSound8, (FnCreateInstance)DSOUND_Create8 }, { { &DSCF_Vtbl }, &CLSID_DirectSound8, DSOUND_Create8 },
{ { &DSCF_Vtbl }, &CLSID_DirectSoundCapture, (FnCreateInstance)DSOUND_CaptureCreate }, { { &DSCF_Vtbl }, &CLSID_DirectSoundCapture, (FnCreateInstance)DSOUND_CaptureCreate },
{ { &DSCF_Vtbl }, &CLSID_DirectSoundCapture8, (FnCreateInstance)DSOUND_CaptureCreate8 }, { { &DSCF_Vtbl }, &CLSID_DirectSoundCapture8, (FnCreateInstance)DSOUND_CaptureCreate8 },
{ { &DSCF_Vtbl }, &CLSID_DirectSoundFullDuplex, (FnCreateInstance)DSOUND_FullDuplexCreate }, { { &DSCF_Vtbl }, &CLSID_DirectSoundFullDuplex, (FnCreateInstance)DSOUND_FullDuplexCreate },
......
...@@ -264,8 +264,8 @@ HRESULT IKsPrivatePropertySetImpl_Create(REFIID riid, IKsPropertySet **piks) DEC ...@@ -264,8 +264,8 @@ HRESULT IKsPrivatePropertySetImpl_Create(REFIID riid, IKsPropertySet **piks) DEC
/* dsound.c */ /* dsound.c */
HRESULT DSOUND_Create(REFIID riid, LPDIRECTSOUND *ppDS) DECLSPEC_HIDDEN; HRESULT DSOUND_Create(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
HRESULT DSOUND_Create8(REFIID riid, LPDIRECTSOUND8 *ppDS) DECLSPEC_HIDDEN; HRESULT DSOUND_Create8(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
/* primary.c */ /* primary.c */
......
...@@ -557,7 +557,7 @@ IDirectSoundFullDuplexImpl_Initialize( ...@@ -557,7 +557,7 @@ IDirectSoundFullDuplexImpl_Initialize(
return DSERR_ALREADYINITIALIZED; return DSERR_ALREADYINITIALIZED;
} }
hr = DSOUND_Create8(&IID_IDirectSound8, &This->renderer_device); hr = DSOUND_Create8(&IID_IDirectSound8, (void **)&This->renderer_device);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = IDirectSound_Initialize(This->renderer_device, pRendererGuid); hr = IDirectSound_Initialize(This->renderer_device, pRendererGuid);
if (hr != DS_OK) { if (hr != DS_OK) {
......
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