dsound: Merge the DirectSoundCapture create functions.
This commit is contained in:
parent
4cebe9e27e
commit
b8ffb4930f
|
@ -1000,6 +1000,7 @@ struct IDirectSoundCaptureImpl
|
||||||
IDirectSoundCapture IDirectSoundCapture_iface;
|
IDirectSoundCapture IDirectSoundCapture_iface;
|
||||||
LONG ref;
|
LONG ref;
|
||||||
DirectSoundCaptureDevice *device;
|
DirectSoundCaptureDevice *device;
|
||||||
|
BOOL has_dsc8;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct IDirectSoundCaptureImpl *impl_from_IDirectSoundCapture(IDirectSoundCapture *iface)
|
static inline struct IDirectSoundCaptureImpl *impl_from_IDirectSoundCapture(IDirectSoundCapture *iface)
|
||||||
|
@ -1161,83 +1162,41 @@ static const IDirectSoundCaptureVtbl dscvt =
|
||||||
IDirectSoundCaptureImpl_Initialize
|
IDirectSoundCaptureImpl_Initialize
|
||||||
};
|
};
|
||||||
|
|
||||||
static HRESULT IDirectSoundCaptureImpl_Create(
|
static HRESULT IDirectSoundCaptureImpl_Create(REFIID riid, void **ppv, BOOL has_dsc8)
|
||||||
LPDIRECTSOUNDCAPTURE8 * ppDSC)
|
|
||||||
{
|
{
|
||||||
IDirectSoundCaptureImpl *pDSC;
|
IDirectSoundCaptureImpl *obj;
|
||||||
TRACE("(%p)\n", ppDSC);
|
HRESULT hr;
|
||||||
|
|
||||||
/* Allocate memory */
|
TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
|
||||||
pDSC = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IDirectSoundCaptureImpl));
|
|
||||||
if (pDSC == NULL) {
|
*ppv = NULL;
|
||||||
|
obj = HeapAlloc(GetProcessHeap(), 0, sizeof(*obj));
|
||||||
|
if (obj == NULL) {
|
||||||
WARN("out of memory\n");
|
WARN("out of memory\n");
|
||||||
*ppDSC = NULL;
|
|
||||||
return DSERR_OUTOFMEMORY;
|
return DSERR_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
pDSC->IDirectSoundCapture_iface.lpVtbl = &dscvt;
|
|
||||||
pDSC->ref = 0;
|
|
||||||
pDSC->device = NULL;
|
|
||||||
|
|
||||||
*ppDSC = (LPDIRECTSOUNDCAPTURE8)pDSC;
|
|
||||||
|
|
||||||
return DS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT DSOUND_CaptureCreate(REFIID riid, IDirectSoundCapture **ppDSC)
|
|
||||||
{
|
|
||||||
IDirectSoundCapture *pDSC;
|
|
||||||
HRESULT hr;
|
|
||||||
TRACE("(%s, %p)\n", debugstr_guid(riid), ppDSC);
|
|
||||||
|
|
||||||
if (!IsEqualIID(riid, &IID_IUnknown) &&
|
|
||||||
!IsEqualIID(riid, &IID_IDirectSoundCapture)) {
|
|
||||||
*ppDSC = 0;
|
|
||||||
return E_NOINTERFACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get dsound configuration */
|
|
||||||
setup_dsound_options();
|
setup_dsound_options();
|
||||||
|
|
||||||
hr = IDirectSoundCaptureImpl_Create(&pDSC);
|
obj->IDirectSoundCapture_iface.lpVtbl = &dscvt;
|
||||||
if (hr == DS_OK) {
|
obj->ref = 1;
|
||||||
IDirectSoundCapture_AddRef(pDSC);
|
obj->device = NULL;
|
||||||
*ppDSC = pDSC;
|
obj->has_dsc8 = has_dsc8;
|
||||||
} else {
|
|
||||||
WARN("IDirectSoundCaptureImpl_Create failed\n");
|
hr = IDirectSoundCapture_QueryInterface(&obj->IDirectSoundCapture_iface, riid, ppv);
|
||||||
*ppDSC = 0;
|
IDirectSoundCapture_Release(&obj->IDirectSoundCapture_iface);
|
||||||
}
|
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT DSOUND_CaptureCreate8(
|
HRESULT DSOUND_CaptureCreate(REFIID riid, void **ppv)
|
||||||
REFIID riid,
|
|
||||||
LPDIRECTSOUNDCAPTURE8 *ppDSC8)
|
|
||||||
{
|
{
|
||||||
LPDIRECTSOUNDCAPTURE8 pDSC8;
|
return IDirectSoundCaptureImpl_Create(riid, ppv, FALSE);
|
||||||
HRESULT hr;
|
}
|
||||||
TRACE("(%s, %p)\n", debugstr_guid(riid), ppDSC8);
|
|
||||||
|
|
||||||
if (!IsEqualIID(riid, &IID_IUnknown) &&
|
HRESULT DSOUND_CaptureCreate8(REFIID riid, void **ppv)
|
||||||
!IsEqualIID(riid, &IID_IDirectSoundCapture8)) {
|
{
|
||||||
*ppDSC8 = 0;
|
return IDirectSoundCaptureImpl_Create(riid, ppv, TRUE);
|
||||||
return E_NOINTERFACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get dsound configuration */
|
|
||||||
setup_dsound_options();
|
|
||||||
|
|
||||||
hr = IDirectSoundCaptureImpl_Create(&pDSC8);
|
|
||||||
if (hr == DS_OK) {
|
|
||||||
IDirectSoundCapture_AddRef(pDSC8);
|
|
||||||
*ppDSC8 = pDSC8;
|
|
||||||
} else {
|
|
||||||
WARN("IDirectSoundCaptureImpl_Create failed\n");
|
|
||||||
*ppDSC8 = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
|
@ -1280,7 +1239,7 @@ HRESULT WINAPI DirectSoundCaptureCreate(LPCGUID lpcGUID, IDirectSoundCapture **p
|
||||||
return DSERR_NOAGGREGATION;
|
return DSERR_NOAGGREGATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = DSOUND_CaptureCreate(&IID_IDirectSoundCapture, &pDSC);
|
hr = DSOUND_CaptureCreate(&IID_IDirectSoundCapture, (void**)&pDSC);
|
||||||
if (hr == DS_OK) {
|
if (hr == DS_OK) {
|
||||||
hr = IDirectSoundCapture_Initialize(pDSC, lpcGUID);
|
hr = IDirectSoundCapture_Initialize(pDSC, lpcGUID);
|
||||||
if (hr != DS_OK) {
|
if (hr != DS_OK) {
|
||||||
|
@ -1336,7 +1295,7 @@ HRESULT WINAPI DirectSoundCaptureCreate8(
|
||||||
return DSERR_NOAGGREGATION;
|
return DSERR_NOAGGREGATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = DSOUND_CaptureCreate8(&IID_IDirectSoundCapture8, &pDSC8);
|
hr = DSOUND_CaptureCreate8(&IID_IDirectSoundCapture8, (void**)&pDSC8);
|
||||||
if (hr == DS_OK) {
|
if (hr == DS_OK) {
|
||||||
hr = IDirectSoundCapture_Initialize(pDSC8, lpcGUID);
|
hr = IDirectSoundCapture_Initialize(pDSC8, lpcGUID);
|
||||||
if (hr != DS_OK) {
|
if (hr != DS_OK) {
|
||||||
|
|
|
@ -721,8 +721,8 @@ static const IClassFactoryVtbl DSCF_Vtbl = {
|
||||||
static IClassFactoryImpl DSOUND_CF[] = {
|
static IClassFactoryImpl DSOUND_CF[] = {
|
||||||
{ { &DSCF_Vtbl }, &CLSID_DirectSound, DSOUND_Create },
|
{ { &DSCF_Vtbl }, &CLSID_DirectSound, DSOUND_Create },
|
||||||
{ { &DSCF_Vtbl }, &CLSID_DirectSound8, DSOUND_Create8 },
|
{ { &DSCF_Vtbl }, &CLSID_DirectSound8, DSOUND_Create8 },
|
||||||
{ { &DSCF_Vtbl }, &CLSID_DirectSoundCapture, (FnCreateInstance)DSOUND_CaptureCreate },
|
{ { &DSCF_Vtbl }, &CLSID_DirectSoundCapture, DSOUND_CaptureCreate },
|
||||||
{ { &DSCF_Vtbl }, &CLSID_DirectSoundCapture8, (FnCreateInstance)DSOUND_CaptureCreate8 },
|
{ { &DSCF_Vtbl }, &CLSID_DirectSoundCapture8, DSOUND_CaptureCreate8 },
|
||||||
{ { &DSCF_Vtbl }, &CLSID_DirectSoundFullDuplex, (FnCreateInstance)DSOUND_FullDuplexCreate },
|
{ { &DSCF_Vtbl }, &CLSID_DirectSoundFullDuplex, (FnCreateInstance)DSOUND_FullDuplexCreate },
|
||||||
{ { &DSCF_Vtbl }, &CLSID_DirectSoundPrivate, (FnCreateInstance)IKsPrivatePropertySetImpl_Create },
|
{ { &DSCF_Vtbl }, &CLSID_DirectSoundPrivate, (FnCreateInstance)IKsPrivatePropertySetImpl_Create },
|
||||||
{ { NULL }, NULL, NULL }
|
{ { NULL }, NULL, NULL }
|
||||||
|
|
|
@ -299,8 +299,8 @@ void DSOUND_Calc3DBuffer(IDirectSoundBufferImpl *dsb) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
/* capture.c */
|
/* capture.c */
|
||||||
|
|
||||||
HRESULT DSOUND_CaptureCreate(REFIID riid, LPDIRECTSOUNDCAPTURE *ppDSC) DECLSPEC_HIDDEN;
|
HRESULT DSOUND_CaptureCreate(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
|
||||||
HRESULT DSOUND_CaptureCreate8(REFIID riid, LPDIRECTSOUNDCAPTURE8 *ppDSC8) DECLSPEC_HIDDEN;
|
HRESULT DSOUND_CaptureCreate8(REFIID riid, void **ppv) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
#define STATE_STOPPED 0
|
#define STATE_STOPPED 0
|
||||||
#define STATE_STARTING 1
|
#define STATE_STARTING 1
|
||||||
|
|
|
@ -578,7 +578,7 @@ IDirectSoundFullDuplexImpl_Initialize(
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = DSOUND_CaptureCreate8(&IID_IDirectSoundCapture8, &This->capture_device);
|
hr = DSOUND_CaptureCreate8(&IID_IDirectSoundCapture8, (void**)&This->capture_device);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
hr = IDirectSoundCapture_Initialize(This->capture_device, pCaptureGuid);
|
hr = IDirectSoundCapture_Initialize(This->capture_device, pCaptureGuid);
|
||||||
if (hr != DS_OK) {
|
if (hr != DS_OK) {
|
||||||
|
|
Loading…
Reference in New Issue