From: Guillaume Charifi Subject: xaudio2_{7, 8}: Implement IXaudio interface as stub (try 2) Message-Id: <1424373593.11975.2.camel@guillaume-MS-7751> Date: Thu, 19 Feb 2015 20:19:53 +0100 Supersedes http://source.winehq.org/patches/data/109234 Correct a typo Fixes https://bugs.winehq.org/show_bug.cgi?id=26808 --- configure | 2 + configure.ac | 1 + dlls/xaudio2_7/Makefile.in | 3 + dlls/xaudio2_7/xaudio2.c | 236 ++++++++++++++++++++++++++++++++++++++ dlls/xaudio2_7/xaudio_classes.idl | 28 +++++ dlls/xaudio2_7/xaudio_dll.c | 94 +++++++++++++-- dlls/xaudio2_7/xaudio_private.h | 32 ++++++ dlls/xaudio2_8/Makefile.in | 10 ++ dlls/xaudio2_8/xaudio2_8.spec | 4 + 9 files changed, 399 insertions(+), 11 deletions(-) diff --git a/configure b/configure index fd639fc..668be10 100755 --- a/configure +++ b/configure @@ -1328,6 +1328,7 @@ enable_xapofx1_1 enable_xapofx1_4 enable_xapofx1_5 enable_xaudio2_7 +enable_xaudio2_8 enable_xinput1_1 enable_xinput1_2 enable_xinput1_3 @@ -17680,6 +17681,7 @@ wine_fn_config_dll xapofx1_1 enable_xapofx1_1 wine_fn_config_dll xapofx1_4 enable_xapofx1_4 wine_fn_config_dll xapofx1_5 enable_xapofx1_5 wine_fn_config_dll xaudio2_7 enable_xaudio2_7 +wine_fn_config_dll xaudio2_8 enable_xaudio2_8 wine_fn_config_dll xinput1_1 enable_xinput1_1 wine_fn_config_dll xinput1_2 enable_xinput1_2 wine_fn_config_dll xinput1_3 enable_xinput1_3 implib xinput diff --git a/configure.ac b/configure.ac index 97ae4e2..c12b3f3 100644 --- a/configure.ac +++ b/configure.ac @@ -3389,6 +3389,7 @@ WINE_CONFIG_DLL(xapofx1_1) WINE_CONFIG_DLL(xapofx1_4) WINE_CONFIG_DLL(xapofx1_5) WINE_CONFIG_DLL(xaudio2_7) +WINE_CONFIG_DLL(xaudio2_8) WINE_CONFIG_DLL(xinput1_1) WINE_CONFIG_DLL(xinput1_2) WINE_CONFIG_DLL(xinput1_3,,[implib],[xinput]) diff --git a/dlls/xaudio2_7/Makefile.in b/dlls/xaudio2_7/Makefile.in index 853d1d6..e60272d 100644 --- a/dlls/xaudio2_7/Makefile.in +++ b/dlls/xaudio2_7/Makefile.in @@ -2,4 +2,7 @@ MODULE = xaudio2_7.dll IMPORTS = advapi32 kernel32 ole32 user32 uuid C_SRCS = \ + xaudio2.c \ xaudio_dll.c + +IDL_SRCS = xaudio_classes.idl diff --git a/dlls/xaudio2_7/xaudio2.c b/dlls/xaudio2_7/xaudio2.c index e69de29..93b752f 100644 --- /dev/null +++ b/dlls/xaudio2_7/xaudio2.c @@ -0,0 +1,236 @@ +/* + * Implementation of IXAudio2 Interface + * + * Copyright 2015 Guillaume Charifi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * 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 "wine/debug.h" + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" + +#include "xaudio_private.h" +#include "xaudio2.h" + +WINE_DEFAULT_DEBUG_CHANNEL(xaudio2); + +typedef struct { + IXAudio2 IXAudio2Impl_iface; + LONG ref; +} IXAudio2Impl; + +static inline IXAudio2Impl *impl_from_IXAudio2(IXAudio2 *iface) +{ + return CONTAINING_RECORD(iface, IXAudio2Impl, IXAudio2Impl_iface); +} + +static const struct IXAudio2Vtbl XAudio2_Vtbl; + +HRESULT XAudio2_create(IUnknown *pUnkOuter, LPVOID *ppObj) +{ + IXAudio2Impl* object; + + TRACE("(%p, %p)\n", pUnkOuter, ppObj); + + if(pUnkOuter) + return CLASS_E_NOAGGREGATION; + + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IXAudio2Impl)); + if(!object) + return E_OUTOFMEMORY; + + object->IXAudio2Impl_iface.lpVtbl = &XAudio2_Vtbl; + object->ref = 1; + + *ppObj = object; + + return S_OK; +} + +/*** IUnknown methods ***/ +static HRESULT WINAPI IXAudio2Impl_QueryInterface(IXAudio2 *iface, REFIID riid, void **ppvObject) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppvObject); + + if(IsEqualGUID(riid, &IID_IUnknown) || + IsEqualGUID(riid, &IID_IXAudio2)) + { + IXAudio2_AddRef(iface); + *ppvObject = iface; + return S_OK; + } + + ERR("(%p)->(%s,%p), not found\n", This,debugstr_guid(riid), ppvObject); + + return E_NOINTERFACE; +} + +static ULONG WINAPI IXAudio2Impl_AddRef(IXAudio2 *iface) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + TRACE("(%p)->()\n", This); + + return InterlockedIncrement(&This->ref); +} + +static ULONG WINAPI IXAudio2Impl_Release(IXAudio2 *iface) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p)->()\n", This); + + if (!ref) + HeapFree(GetProcessHeap(), 0, This); + + return ref; +} + +/*** IXAudio2 methods ***/ +static HRESULT WINAPI IXAudio2Impl_GetDeviceCount(IXAudio2 *iface, UINT32 *pCount) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + FIXME("(%p)->(%p): stub!\n", This, pCount); + + return E_NOTIMPL; +} + +static HRESULT WINAPI IXAudio2Impl_GetDeviceDetails(IXAudio2 *iface, UINT32 index, XAUDIO2_DEVICE_DETAILS *pDeviceDetails) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + FIXME("(%p)->(%u, %p): stub!\n", This, index, pDeviceDetails); + + return E_NOTIMPL; +} + +static HRESULT WINAPI IXAudio2Impl_Initialize(IXAudio2 *iface, UINT32 flags, XAUDIO2_PROCESSOR processor) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + FIXME("(%p)->(%u, %u): stub!\n", This, flags, processor); + + return S_OK; +} + +static HRESULT WINAPI IXAudio2Impl_RegisterForCallbacks(IXAudio2 *iface, IXAudio2EngineCallback *pCallback) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + FIXME("(%p)->(%p): stub!\n", This, pCallback); + + return E_NOTIMPL; +} + +static void WINAPI IXAudio2Impl_UnregisterForCallbacks(IXAudio2 *iface, IXAudio2EngineCallback *pCallback) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + FIXME("(%p)->(%p): stub!\n", This, pCallback); +} + +static HRESULT WINAPI IXAudio2Impl_CreateSourceVoice(IXAudio2 *iface, IXAudio2SourceVoice **ppSourceVoice, const WAVEFORMATEX *pSourceFormat, UINT32 flags, float maxFrequencyRatio, IXAudio2VoiceCallback *pCallback, const XAUDIO2_VOICE_SENDS *pSendList, const XAUDIO2_EFFECT_CHAIN *pEffectChain) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + FIXME("(%p)->(%p, %p, %u, %f, %p, %p, %p): stub!\n", This, ppSourceVoice, pSourceFormat, flags, maxFrequencyRatio, pCallback, pSendList, pEffectChain); + + return E_NOTIMPL; +} + +static HRESULT WINAPI IXAudio2Impl_CreateSubmixVoice(IXAudio2 *iface, IXAudio2SubmixVoice **ppSubmixVoice, UINT32 inputChannels, UINT32 inputSampleRate, UINT32 flags, UINT32 processingStage, const XAUDIO2_VOICE_SENDS *pSendList, const XAUDIO2_EFFECT_CHAIN *pEffectChain) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + FIXME("(%p)->(%p, %u, %u, %u, %u, %p, %p): stub!\n", This, ppSubmixVoice, inputChannels, inputSampleRate, flags, processingStage, pSendList, pEffectChain); + + return E_NOTIMPL; +} + +static HRESULT WINAPI IXAudio2Impl_CreateMasteringVoice(IXAudio2 *iface, IXAudio2MasteringVoice **ppMasteringVoice, UINT32 inputChannels, UINT32 inputSampleRate, UINT32 flags, UINT32 deviceIndex, const XAUDIO2_EFFECT_CHAIN *pEffectChain) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + FIXME("(%p)->(%p, %u, %u, %u, %u, %p): stub!\n", This, ppMasteringVoice, inputChannels, inputSampleRate, flags, deviceIndex, pEffectChain); + + return S_OK; +} + +static HRESULT WINAPI IXAudio2Impl_StartEngine(IXAudio2 *iface) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + FIXME("(%p)->(): stub!\n", This); + + return E_NOTIMPL; +} + +static void WINAPI IXAudio2Impl_StopEngine(IXAudio2 *iface) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + FIXME("(%p)->(): stub!\n", This); +} + +static HRESULT WINAPI IXAudio2Impl_CommitChanges(IXAudio2 *iface, UINT32 operationSet) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + FIXME("(%p)->(%u): stub!\n", This, operationSet); + + return E_NOTIMPL; +} + +static void WINAPI IXAudio2Impl_GetPerformanceData(IXAudio2 *iface, XAUDIO2_PERFORMANCE_DATA *pPerfData) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + FIXME("(%p)->(%p): stub!\n", This, pPerfData); +} + +static void WINAPI IXAudio2Impl_SetDebugConfiguration(IXAudio2 *iface, const XAUDIO2_DEBUG_CONFIGURATION *pDebugConfiguration, void *pReserved) +{ + IXAudio2Impl *This = impl_from_IXAudio2(iface); + + FIXME("(%p)->(%p, %p): stub!\n", This, pDebugConfiguration, pReserved); +} + +static const IXAudio2Vtbl XAudio2_Vtbl = +{ + IXAudio2Impl_QueryInterface, + IXAudio2Impl_AddRef, + IXAudio2Impl_Release, + IXAudio2Impl_GetDeviceCount, + IXAudio2Impl_GetDeviceDetails, + IXAudio2Impl_Initialize, + IXAudio2Impl_RegisterForCallbacks, + IXAudio2Impl_UnregisterForCallbacks, + IXAudio2Impl_CreateSourceVoice, + IXAudio2Impl_CreateSubmixVoice, + IXAudio2Impl_CreateMasteringVoice, + IXAudio2Impl_StartEngine, + IXAudio2Impl_StopEngine, + IXAudio2Impl_CommitChanges, + IXAudio2Impl_GetPerformanceData, + IXAudio2Impl_SetDebugConfiguration +}; diff --git a/dlls/xaudio2_7/xaudio_classes.idl b/dlls/xaudio2_7/xaudio_classes.idl index e69de29..79bc7a4 100644 --- /dev/null +++ b/dlls/xaudio2_7/xaudio_classes.idl @@ -0,0 +1,28 @@ +/* + * COM Classes for xaudio + * + * Copyright 2015 Guillaume Charifi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#pragma makedep register + +[ + helpstring("XAudio2 Class"), + threading(both), + uuid(5a508685-a254-4fba-9b82-9a24b00306af) +] +coclass XAudio2 { interface IXAudio2; } diff --git a/dlls/xaudio2_7/xaudio_dll.c b/dlls/xaudio2_7/xaudio_dll.c index c8b7904..57e5a29 100644 --- a/dlls/xaudio2_7/xaudio_dll.c +++ b/dlls/xaudio2_7/xaudio_dll.c @@ -30,6 +30,8 @@ #include "wine/debug.h" #include #include "initguid.h" + +#include "xaudio_private.h" #include "xaudio2.h" WINE_DEFAULT_DEBUG_CHANNEL(xaudio2); @@ -52,35 +54,105 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) return TRUE; } -HRESULT WINAPI DllCanUnloadNow(void) +typedef struct { + IClassFactory IClassFactory_iface; + HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj); +} IClassFactoryImpl; + +static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface) { - return S_FALSE; + return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface); } +static HRESULT WINAPI XAudio2CF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj) +{ + if(IsEqualGUID(riid, &IID_IUnknown) + || IsEqualGUID(riid, &IID_IClassFactory)) + { + IClassFactory_AddRef(iface); + *ppobj = iface; + return S_OK; + } + + *ppobj = NULL; + WARN("(%p)->(%s, %p): interface not found\n", iface, debugstr_guid(riid), ppobj); + return E_NOINTERFACE; +} + +static ULONG WINAPI XAudio2CF_AddRef(IClassFactory *iface) +{ + return 2; +} + +static ULONG WINAPI XAudio2CF_Release(IClassFactory *iface) +{ + return 1; +} + +static HRESULT WINAPI XAudio2CF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, + REFIID riid, void **ppobj) +{ + IClassFactoryImpl *This = impl_from_IClassFactory(iface); + HRESULT hr; + LPUNKNOWN punk; + + TRACE("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj); + + *ppobj = NULL; + hr = This->pfnCreateInstance(pOuter, (LPVOID *) &punk); + if (FAILED(hr)) + return hr; + + hr = IUnknown_QueryInterface(punk, riid, ppobj); + IUnknown_Release(punk); + return hr; +} + +static HRESULT WINAPI XAudio2CF_LockServer(IClassFactory *iface, BOOL dolock) +{ + IClassFactoryImpl *This = impl_from_IClassFactory(iface); + FIXME("(%p)->(%d): stub!\n", This, dolock); + return S_OK; +} + +static const IClassFactoryVtbl XAudio2CF_Vtbl = +{ + XAudio2CF_QueryInterface, + XAudio2CF_AddRef, + XAudio2CF_Release, + XAudio2CF_CreateInstance, + XAudio2CF_LockServer +}; + +static IClassFactoryImpl xaudio2_cf = { { &XAudio2CF_Vtbl }, XAudio2_create }; + HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) { + IClassFactory *factory = NULL; + TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); - if (ppv == NULL) { - WARN("invalid parameter\n"); - return E_INVALIDARG; + if(IsEqualGUID(rclsid, &CLSID_XAudio2)) { + factory = &xaudio2_cf.IClassFactory_iface; } + if(!factory) return CLASS_E_CLASSNOTAVAILABLE; - *ppv = NULL; + return IClassFactory_QueryInterface(factory, riid, ppv); +} - WARN("(%s, %s, %p): no class found.\n", debugstr_guid(rclsid), - debugstr_guid(riid), ppv); - return CLASS_E_CLASSNOTAVAILABLE; +HRESULT WINAPI DllCanUnloadNow(void) +{ + return S_FALSE; } HRESULT WINAPI DllRegisterServer(void) { TRACE("\n"); - return __wine_register_resources( instance ); + return __wine_register_resources(instance); } HRESULT WINAPI DllUnregisterServer(void) { TRACE("\n"); - return __wine_unregister_resources( instance ); + return __wine_unregister_resources(instance); } diff --git a/dlls/xaudio2_7/xaudio_private.h b/dlls/xaudio2_7/xaudio_private.h index e69de29..d830018 100644 --- /dev/null +++ b/dlls/xaudio2_7/xaudio_private.h @@ -0,0 +1,32 @@ +/* + * XAudio2 private interfaces + * + * Copyright 2015 Guillaume Charifi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __XAUDIO_PRIVATE_INCLUDED__ +#define __XAUDIO_PRIVATE_INCLUDED__ + +#include + +#include "windef.h" +#include "winbase.h" +#include "wtypes.h" + +HRESULT XAudio2_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN; + +#endif /* __XAUDIO_PRIVATE_INCLUDED__ */ diff --git a/dlls/xaudio2_8/Makefile.in b/dlls/xaudio2_8/Makefile.in index e69de29..56c547f 100644 --- /dev/null +++ b/dlls/xaudio2_8/Makefile.in @@ -0,0 +1,10 @@ +PARENTSRC = ../xaudio2_7 + +MODULE = xaudio2_8.dll +IMPORTS = advapi32 kernel32 ole32 user32 uuid + +C_SRCS = \ + xaudio2.c \ + xaudio_dll.c + +IDL_SRCS = xaudio_classes.idl diff --git a/dlls/xaudio2_8/xaudio2_8.spec b/dlls/xaudio2_8/xaudio2_8.spec index e69de29..b16365d 100644 --- /dev/null +++ b/dlls/xaudio2_8/xaudio2_8.spec @@ -0,0 +1,4 @@ +@ stdcall -private DllCanUnloadNow() +@ stdcall -private DllGetClassObject(ptr ptr ptr) +@ stdcall -private DllRegisterServer() +@ stdcall -private DllUnregisterServer()