Commit f5080c86 authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard

Added class factories for DirectSoundCapture, DirectSoundFullDuplex

and DirectSoundPrivate. Added error checking to QueryInterface and CreateInterface. Added some more functionality to property sets.
parent d7fca891
......@@ -58,6 +58,11 @@ static HRESULT WINAPI IDirectSoundNotifyImpl_QueryInterface(
ICOM_THIS(IDirectSoundNotifyImpl,iface);
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (ppobj == NULL) {
WARN("invalid parameter\n");
return E_INVALIDARG;
}
*ppobj = NULL; /* assume error */
if ( IsEqualGUID(riid, &IID_IUnknown) ||
......@@ -905,6 +910,11 @@ static HRESULT WINAPI IDirectSoundBufferImpl_QueryInterface(
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (ppobj == NULL) {
WARN("invalid parameter\n");
return E_INVALIDARG;
}
*ppobj = NULL; /* assume failure */
if ( IsEqualGUID(riid, &IID_IUnknown) ||
......
......@@ -353,6 +353,13 @@ IDirectSoundCaptureImpl_QueryInterface(
ICOM_THIS(IDirectSoundCaptureImpl,iface);
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
if (ppobj == NULL) {
WARN("invalid parameter\n");
return E_INVALIDARG;
}
*ppobj = NULL;
if (This->driver) {
HRESULT hres;
hres = IDsCaptureDriver_QueryInterface(This->driver, riid, ppobj);
......@@ -767,6 +774,13 @@ IDirectSoundCaptureBufferImpl_QueryInterface(
ICOM_THIS(IDirectSoundCaptureBufferImpl,iface);
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
if (ppobj == NULL) {
WARN("invalid parameter\n");
return E_INVALIDARG;
}
*ppobj = NULL;
if ( IsEqualGUID( &IID_IDirectSoundNotify, riid ) ||
IsEqualGUID( &IID_IDirectSoundNotify8, riid ) ) {
if (!This->notify) {
......@@ -1422,6 +1436,79 @@ static ICOM_VTABLE(IDirectSoundCaptureBuffer8) dscbvt =
IDirectSoundCaptureBufferImpl_GetFXStatus
};
/*******************************************************************************
* DirectSoundCapture ClassFactory
*/
static HRESULT WINAPI
DSCCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
{
ICOM_THIS(IClassFactoryImpl,iface);
FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
return E_NOINTERFACE;
}
static ULONG WINAPI
DSCCF_AddRef(LPCLASSFACTORY iface)
{
ICOM_THIS(IClassFactoryImpl,iface);
TRACE("(%p) ref was %ld\n", This, This->ref);
return ++(This->ref);
}
static ULONG WINAPI
DSCCF_Release(LPCLASSFACTORY iface)
{
ICOM_THIS(IClassFactoryImpl,iface);
/* static class, won't be freed */
TRACE("(%p) ref was %ld\n", This, This->ref);
return --(This->ref);
}
static HRESULT WINAPI
DSCCF_CreateInstance(
LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj )
{
ICOM_THIS(IClassFactoryImpl,iface);
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
if (ppobj == NULL) {
WARN("invalid parameter\n");
return E_INVALIDARG;
}
*ppobj = NULL;
if ( IsEqualGUID( &IID_IDirectSoundCapture, riid ) ||
IsEqualGUID( &IID_IDirectSoundCapture8, riid ) ) {
return DirectSoundCaptureCreate8(0,(LPDIRECTSOUNDCAPTURE8*)ppobj,pOuter);
}
WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
return E_NOINTERFACE;
}
static HRESULT WINAPI
DSCCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
{
ICOM_THIS(IClassFactoryImpl,iface);
FIXME("(%p)->(%d),stub!\n",This,dolock);
return S_OK;
}
static ICOM_VTABLE(IClassFactory) DSCCF_Vtbl =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
DSCCF_QueryInterface,
DSCCF_AddRef,
DSCCF_Release,
DSCCF_CreateInstance,
DSCCF_LockServer
};
IClassFactoryImpl DSOUND_CAPTURE_CF = { &DSCCF_Vtbl, 1 };
/***************************************************************************
* DirectSoundFullDuplexCreate8 [DSOUND.10]
*
......@@ -1503,7 +1590,13 @@ IDirectSoundFullDuplexImpl_QueryInterface(
ICOM_THIS(IDirectSoundFullDuplexImpl,iface);
TRACE( "(%p,%s,%p)\n", This, debugstr_guid(riid), ppobj );
return E_FAIL;
if (ppobj == NULL) {
WARN("invalid parameter\n");
return E_INVALIDARG;
}
*ppobj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI
......@@ -1578,3 +1671,78 @@ static ICOM_VTABLE(IDirectSoundFullDuplex) dsfdvt =
/* IDirectSoundFullDuplex methods */
IDirectSoundFullDuplexImpl_Initialize
};
/*******************************************************************************
* DirectSoundFullDuplex ClassFactory
*/
static HRESULT WINAPI
DSFDCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
{
ICOM_THIS(IClassFactoryImpl,iface);
FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
return E_NOINTERFACE;
}
static ULONG WINAPI
DSFDCF_AddRef(LPCLASSFACTORY iface)
{
ICOM_THIS(IClassFactoryImpl,iface);
TRACE("(%p) ref was %ld\n", This, This->ref);
return ++(This->ref);
}
static ULONG WINAPI
DSFDCF_Release(LPCLASSFACTORY iface)
{
ICOM_THIS(IClassFactoryImpl,iface);
/* static class, won't be freed */
TRACE("(%p) ref was %ld\n", This, This->ref);
return --(This->ref);
}
static HRESULT WINAPI
DSFDCF_CreateInstance(
LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj )
{
ICOM_THIS(IClassFactoryImpl,iface);
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
if (ppobj == NULL) {
WARN("invalid parameter\n");
return E_INVALIDARG;
}
*ppobj = NULL;
if ( IsEqualGUID( &IID_IDirectSoundFullDuplex, riid ) ) {
/* FIXME: how do we do this one ? */
FIXME("not implemented\n");
return E_NOINTERFACE;
}
WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
return E_NOINTERFACE;
}
static HRESULT WINAPI
DSFDCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
{
ICOM_THIS(IClassFactoryImpl,iface);
FIXME("(%p)->(%d),stub!\n",This,dolock);
return S_OK;
}
static ICOM_VTABLE(IClassFactory) DSFDCF_Vtbl =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
DSFDCF_QueryInterface,
DSFDCF_AddRef,
DSFDCF_Release,
DSFDCF_CreateInstance,
DSFDCF_LockServer
};
IClassFactoryImpl DSOUND_FULLDUPLEX_CF = { &DSFDCF_Vtbl, 1 };
......@@ -68,6 +68,7 @@
#include "dsound.h"
#include "dsdriver.h"
#include "dsound_private.h"
#include "dsconf.h"
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
......@@ -757,6 +758,11 @@ static HRESULT WINAPI IDirectSoundImpl_QueryInterface(
ICOM_THIS(IDirectSoundImpl,iface);
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (ppobj == NULL) {
WARN("invalid parameter\n");
return E_INVALIDARG;
}
*ppobj = NULL; /* assume failure */
if ( IsEqualGUID(riid, &IID_IUnknown) ||
......@@ -1124,12 +1130,6 @@ HRESULT WINAPI DirectSoundCreate8(LPCGUID lpcGUID,LPDIRECTSOUND8 *ppDS,IUnknown
/*******************************************************************************
* DirectSound ClassFactory
*/
typedef struct
{
/* IUnknown fields */
ICOM_VFIELD(IClassFactory);
DWORD ref;
} IClassFactoryImpl;
static HRESULT WINAPI
DSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
......@@ -1157,22 +1157,22 @@ static HRESULT WINAPI DSCF_CreateInstance(
LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
) {
ICOM_THIS(IClassFactoryImpl,iface);
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
if (ppobj == NULL) {
WARN("invalid parameter\n");
return DSERR_INVALIDPARAM;
}
*ppobj = NULL;
if ( IsEqualGUID( &IID_IDirectSound, riid ) ||
IsEqualGUID( &IID_IDirectSound8, riid ) ) {
/* FIXME: reuse already created dsound if present? */
return DirectSoundCreate8(0,(LPDIRECTSOUND8*)ppobj,pOuter);
}
if ( IsEqualGUID( &IID_IDirectSoundCapture, riid ) ||
IsEqualGUID( &IID_IDirectSoundCapture8, riid ) ) {
return DirectSoundCaptureCreate8(0,(LPDIRECTSOUNDCAPTURE8*)ppobj,pOuter);
}
if ( IsEqualGUID( &IID_IKsPropertySet, riid ) ) {
return IKsPropertySetImpl_Create(0,(IKsPropertySetImpl**)ppobj);
}
FIXME("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
return E_NOINTERFACE;
}
......@@ -1190,7 +1190,75 @@ static ICOM_VTABLE(IClassFactory) DSCF_Vtbl = {
DSCF_CreateInstance,
DSCF_LockServer
};
static IClassFactoryImpl DSOUND_CF = {&DSCF_Vtbl, 1 };
static IClassFactoryImpl DSOUND_CF = { &DSCF_Vtbl, 1 };
/*******************************************************************************
* DirectSoundPrivate ClassFactory
*/
static HRESULT WINAPI
DSPCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
ICOM_THIS(IClassFactoryImpl,iface);
FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
return E_NOINTERFACE;
}
static ULONG WINAPI
DSPCF_AddRef(LPCLASSFACTORY iface) {
ICOM_THIS(IClassFactoryImpl,iface);
TRACE("(%p) ref was %ld\n", This, This->ref);
return ++(This->ref);
}
static ULONG WINAPI
DSPCF_Release(LPCLASSFACTORY iface) {
ICOM_THIS(IClassFactoryImpl,iface);
/* static class, won't be freed */
TRACE("(%p) ref was %ld\n", This, This->ref);
return --(This->ref);
}
static HRESULT WINAPI
DSPCF_CreateInstance(
LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
) {
ICOM_THIS(IClassFactoryImpl,iface);
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
if (ppobj == NULL) {
WARN("invalid parameter\n");
return DSERR_INVALIDPARAM;
}
*ppobj = NULL;
if ( IsEqualGUID( &IID_IKsPropertySet, riid ) ) {
return IKsPropertySetImpl_Create(0,(IKsPropertySetImpl**)ppobj);
}
WARN("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
return E_NOINTERFACE;
}
static HRESULT WINAPI
DSPCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
ICOM_THIS(IClassFactoryImpl,iface);
FIXME("(%p)->(%d),stub!\n",This,dolock);
return S_OK;
}
static ICOM_VTABLE(IClassFactory) DSPCF_Vtbl = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
DSPCF_QueryInterface,
DSPCF_AddRef,
DSPCF_Release,
DSPCF_CreateInstance,
DSPCF_LockServer
};
static IClassFactoryImpl DSOUND_PRIVATE_CF = { &DSPCF_Vtbl, 1 };
/*******************************************************************************
* DllGetClassObject [DSOUND.5]
......@@ -1212,13 +1280,61 @@ static IClassFactoryImpl DSOUND_CF = {&DSCF_Vtbl, 1 };
DWORD WINAPI DSOUND_DllGetClassObject(REFCLSID rclsid,REFIID riid,LPVOID *ppv)
{
TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
*ppv = (LPVOID)&DSOUND_CF;
IClassFactory_AddRef((IClassFactory*)*ppv);
return S_OK;
if (ppv == NULL) {
WARN("invalid parameter\n");
return E_INVALIDARG;
}
*ppv = NULL;
if ( IsEqualCLSID( &CLSID_DirectSound, rclsid ) ||
IsEqualCLSID( &CLSID_DirectSound8, rclsid ) ) {
if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
*ppv = (LPVOID)&DSOUND_CF;
IClassFactory_AddRef((IClassFactory*)*ppv);
return S_OK;
}
WARN("(%s,%s,%p): no interface found.\n",
debugstr_guid(rclsid), debugstr_guid(riid), ppv);
return S_FALSE;
}
if ( IsEqualCLSID( &CLSID_DirectSoundCapture, rclsid ) ||
IsEqualCLSID( &CLSID_DirectSoundCapture8, rclsid ) ) {
if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
*ppv = (LPVOID)&DSOUND_CAPTURE_CF;
IClassFactory_AddRef((IClassFactory*)*ppv);
return S_OK;
}
WARN("(%s,%s,%p): no interface found.\n",
debugstr_guid(rclsid), debugstr_guid(riid), ppv);
return S_FALSE;
}
if ( IsEqualCLSID( &CLSID_DirectSoundFullDuplex, rclsid ) ) {
if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
*ppv = (LPVOID)&DSOUND_FULLDUPLEX_CF;
IClassFactory_AddRef((IClassFactory*)*ppv);
return S_OK;
}
WARN("(%s,%s,%p): no interface found.\n",
debugstr_guid(rclsid), debugstr_guid(riid), ppv);
return S_FALSE;
}
if ( IsEqualCLSID( &CLSID_DirectSoundPrivate, rclsid ) ) {
if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
*ppv = (LPVOID)&DSOUND_PRIVATE_CF;
IClassFactory_AddRef((IClassFactory*)*ppv);
return S_OK;
}
WARN("(%s,%s,%p): no interface found.\n",
debugstr_guid(rclsid), debugstr_guid(riid), ppv);
return S_FALSE;
}
FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
WARN("(%s,%s,%p): no class found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
return CLASS_E_CLASSNOTAVAILABLE;
}
......
......@@ -54,6 +54,7 @@ typedef struct IDirectSound3DListenerImpl IDirectSound3DListenerImpl;
typedef struct IDirectSound3DBufferImpl IDirectSound3DBufferImpl;
typedef struct IKsPropertySetImpl IKsPropertySetImpl;
typedef struct PrimaryBufferImpl PrimaryBufferImpl;
typedef struct IClassFactoryImpl IClassFactoryImpl;
/*****************************************************************************
* IDirectSound implementation structure
......@@ -287,6 +288,19 @@ HRESULT WINAPI IDirectSound3DBufferImpl_Create(
IDirectSoundBufferImpl *This,
IDirectSound3DBufferImpl **pds3db);
/*******************************************************************************
* DirectSound ClassFactory implementation structure
*/
struct IClassFactoryImpl
{
/* IUnknown fields */
ICOM_VFIELD(IClassFactory);
DWORD ref;
};
extern IClassFactoryImpl DSOUND_CAPTURE_CF;
extern IClassFactoryImpl DSOUND_FULLDUPLEX_CF;
void DSOUND_RecalcVolPan(PDSVOLUMEPAN volpan);
void DSOUND_RecalcFormat(IDirectSoundBufferImpl *dsb);
......
......@@ -909,6 +909,11 @@ static HRESULT WINAPI PrimaryBufferImpl_QueryInterface(
ICOM_THIS(PrimaryBufferImpl,iface);
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (ppobj == NULL) {
WARN("invalid parameter\n");
return E_INVALIDARG;
}
*ppobj = NULL; /* assume failure */
if ( IsEqualGUID(riid, &IID_IUnknown) ||
......
......@@ -821,6 +821,13 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_QueryInterface(
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (ppobj == NULL) {
WARN("invalid parameter\n");
return E_INVALIDARG;
}
*ppobj = NULL; /* assume failure */
if ( IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IDirectSound3DListener ) ) {
IDirectSound3DListener_AddRef((LPDIRECTSOUND3DLISTENER)This);
......@@ -835,7 +842,6 @@ static HRESULT WINAPI IDirectSound3DListenerImpl_QueryInterface(
}
FIXME( "Unknown IID %s\n", debugstr_guid( riid ) );
*ppobj = NULL;
return E_NOINTERFACE;
}
......
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