From b49b78db49d79bdd1358f2244a87d74db6350b73 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Wed, 27 Feb 2019 11:36:56 -0500 Subject: [PATCH] xaudio2: IXAudio23 needs its own interface, for XAUDIO23_VOICE_SENDS parameters. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46727 Signed-off-by: Ethan Lee Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- dlls/xaudio2_7/compat.c | 222 +++++++++++++++++++++++++++++++- dlls/xaudio2_7/xaudio_dll.c | 4 + dlls/xaudio2_7/xaudio_private.h | 4 + include/xaudio2.idl | 61 +++++++++ 4 files changed, 286 insertions(+), 5 deletions(-) diff --git a/dlls/xaudio2_7/compat.c b/dlls/xaudio2_7/compat.c index bc33cb92ed7..c4538ae3677 100644 --- a/dlls/xaudio2_7/compat.c +++ b/dlls/xaudio2_7/compat.c @@ -2488,6 +2488,222 @@ const IXAudio22Vtbl XAudio22_Vtbl = { XA22_SetDebugConfiguration }; +#elif XAUDIO2_VER <= 3 + +static inline IXAudio2Impl *impl_from_IXAudio23(IXAudio23 *iface) +{ + return CONTAINING_RECORD(iface, IXAudio2Impl, IXAudio23_iface); +} + +static HRESULT WINAPI XA23_QueryInterface(IXAudio23 *iface, REFIID riid, + void **ppvObject) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + return IXAudio2_QueryInterface(&This->IXAudio2_iface, riid, ppvObject); +} + +static ULONG WINAPI XA23_AddRef(IXAudio23 *iface) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + return IXAudio2_AddRef(&This->IXAudio2_iface); +} + +static ULONG WINAPI XA23_Release(IXAudio23 *iface) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + return IXAudio2_Release(&This->IXAudio2_iface); +} + +static HRESULT WINAPI XA23_GetDeviceCount(IXAudio23 *iface, UINT32 *pCount) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + TRACE("%p, %p\n", This, pCount); + return FAudio_GetDeviceCount(This->faudio, pCount); +} + +static HRESULT WINAPI XA23_GetDeviceDetails(IXAudio23 *iface, UINT32 index, + XAUDIO2_DEVICE_DETAILS *pDeviceDetails) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + TRACE("%p, %u, %p\n", This, index, pDeviceDetails); + return FAudio_GetDeviceDetails(This->faudio, index, (FAudioDeviceDetails *)pDeviceDetails); +} + +static HRESULT WINAPI XA23_Initialize(IXAudio23 *iface, UINT32 flags, + XAUDIO2_PROCESSOR processor) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + TRACE("(%p)->(0x%x, 0x%x)\n", This, flags, processor); + return xaudio2_initialize(This, flags, processor); +} + +static HRESULT WINAPI XA23_RegisterForCallbacks(IXAudio23 *iface, + IXAudio2EngineCallback *pCallback) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + return IXAudio2_RegisterForCallbacks(&This->IXAudio2_iface, pCallback); +} + +static void WINAPI XA23_UnregisterForCallbacks(IXAudio23 *iface, + IXAudio2EngineCallback *pCallback) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + IXAudio2_UnregisterForCallbacks(&This->IXAudio2_iface, pCallback); +} + +static HRESULT WINAPI XA23_CreateSourceVoice(IXAudio23 *iface, + IXAudio2SourceVoice **ppSourceVoice, const WAVEFORMATEX *pSourceFormat, + UINT32 flags, float maxFrequencyRatio, + IXAudio2VoiceCallback *pCallback, const XAUDIO23_VOICE_SENDS *pSendList, + const XAUDIO2_EFFECT_CHAIN *pEffectChain) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + XAUDIO2_VOICE_SENDS sends, *psends = NULL; + HRESULT hr; + + if(pSendList){ + sends.SendCount = pSendList->OutputCount; + sends.pSends = convert_send_descriptors23(pSendList); + psends = &sends; + } + + hr = IXAudio2_CreateSourceVoice(&This->IXAudio2_iface, ppSourceVoice, + pSourceFormat, flags, maxFrequencyRatio, pCallback, psends, + pEffectChain); + + if(pSendList) + HeapFree(GetProcessHeap(), 0, sends.pSends); + + return hr; +} + +static HRESULT WINAPI XA23_CreateSubmixVoice(IXAudio23 *iface, + IXAudio2SubmixVoice **ppSubmixVoice, UINT32 inputChannels, + UINT32 inputSampleRate, UINT32 flags, UINT32 processingStage, + const XAUDIO23_VOICE_SENDS *pSendList, + const XAUDIO2_EFFECT_CHAIN *pEffectChain) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + XAUDIO2_VOICE_SENDS sends, *psends = NULL; + HRESULT hr; + + if(pSendList){ + sends.SendCount = pSendList->OutputCount; + sends.pSends = convert_send_descriptors23(pSendList); + psends = &sends; + } + + hr = IXAudio2_CreateSubmixVoice(&This->IXAudio2_iface, ppSubmixVoice, + inputChannels, inputSampleRate, flags, processingStage, psends, + pEffectChain); + + if(pSendList) + HeapFree(GetProcessHeap(), 0, sends.pSends); + + return hr; +} + +static HRESULT WINAPI XA23_CreateMasteringVoice(IXAudio23 *iface, + IXAudio2MasteringVoice **ppMasteringVoice, UINT32 inputChannels, + UINT32 inputSampleRate, UINT32 flags, UINT32 deviceIndex, + const XAUDIO2_EFFECT_CHAIN *pEffectChain) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + + TRACE("(%p)->(%p, %u, %u, 0x%x, %u, %p)\n", This, ppMasteringVoice, + inputChannels, inputSampleRate, flags, deviceIndex, + pEffectChain); + + EnterCriticalSection(&This->lock); + + /* XAUDIO2_VER == 3 */ + *ppMasteringVoice = (IXAudio2MasteringVoice*)&This->mst.IXAudio23MasteringVoice_iface; + + EnterCriticalSection(&This->mst.lock); + + if(This->mst.in_use){ + LeaveCriticalSection(&This->mst.lock); + LeaveCriticalSection(&This->lock); + return COMPAT_E_INVALID_CALL; + } + + LeaveCriticalSection(&This->lock); + + This->mst.effect_chain = wrap_effect_chain(pEffectChain); + + pthread_mutex_lock(&This->mst.engine_lock); + + This->mst.engine_thread = CreateThread(NULL, 0, &engine_thread, &This->mst, 0, NULL); + + pthread_cond_wait(&This->mst.engine_done, &This->mst.engine_lock); + + pthread_mutex_unlock(&This->mst.engine_lock); + + FAudio_SetEngineProcedureEXT(This->faudio, &engine_cb, &This->mst); + + FAudio_CreateMasteringVoice(This->faudio, &This->mst.faudio_voice, inputChannels, + inputSampleRate, flags, deviceIndex, This->mst.effect_chain); + + This->mst.in_use = TRUE; + + LeaveCriticalSection(&This->mst.lock); + + return S_OK; +} + +static HRESULT WINAPI XA23_StartEngine(IXAudio23 *iface) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + return IXAudio2_StartEngine(&This->IXAudio2_iface); +} + +static void WINAPI XA23_StopEngine(IXAudio23 *iface) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + return IXAudio2_StopEngine(&This->IXAudio2_iface); +} + +static HRESULT WINAPI XA23_CommitChanges(IXAudio23 *iface, UINT32 operationSet) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + return IXAudio2_CommitChanges(&This->IXAudio2_iface, operationSet); +} + +static void WINAPI XA23_GetPerformanceData(IXAudio23 *iface, + XAUDIO2_PERFORMANCE_DATA *pPerfData) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + return IXAudio2_GetPerformanceData(&This->IXAudio2_iface, pPerfData); +} + +static void WINAPI XA23_SetDebugConfiguration(IXAudio23 *iface, + const XAUDIO2_DEBUG_CONFIGURATION *pDebugConfiguration, + void *pReserved) +{ + IXAudio2Impl *This = impl_from_IXAudio23(iface); + return IXAudio2_SetDebugConfiguration(&This->IXAudio2_iface, + pDebugConfiguration, pReserved); +} + +const IXAudio23Vtbl XAudio23_Vtbl = { + XA23_QueryInterface, + XA23_AddRef, + XA23_Release, + XA23_GetDeviceCount, + XA23_GetDeviceDetails, + XA23_Initialize, + XA23_RegisterForCallbacks, + XA23_UnregisterForCallbacks, + XA23_CreateSourceVoice, + XA23_CreateSubmixVoice, + XA23_CreateMasteringVoice, + XA23_StartEngine, + XA23_StopEngine, + XA23_CommitChanges, + XA23_GetPerformanceData, + XA23_SetDebugConfiguration +}; + #elif XAUDIO2_VER <= 7 static inline IXAudio2Impl *impl_from_IXAudio27(IXAudio27 *iface) @@ -2588,12 +2804,8 @@ static HRESULT WINAPI XA27_CreateMasteringVoice(IXAudio27 *iface, EnterCriticalSection(&This->lock); - /* 3 <= XAUDIO2_VER <= 7 */ -#if XAUDIO2_VER == 3 - *ppMasteringVoice = (IXAudio2MasteringVoice*)&This->mst.IXAudio23MasteringVoice_iface; -#else + /* 4 <= XAUDIO2_VER <= 7 */ *ppMasteringVoice = (IXAudio2MasteringVoice*)&This->mst.IXAudio27MasteringVoice_iface; -#endif EnterCriticalSection(&This->mst.lock); diff --git a/dlls/xaudio2_7/xaudio_dll.c b/dlls/xaudio2_7/xaudio_dll.c index f338b56dc91..18306a16035 100644 --- a/dlls/xaudio2_7/xaudio_dll.c +++ b/dlls/xaudio2_7/xaudio_dll.c @@ -1400,6 +1400,8 @@ static HRESULT WINAPI IXAudio2Impl_QueryInterface(IXAudio2 *iface, REFIID riid, *ppvObject = &This->IXAudio20_iface; #elif XAUDIO2_VER <= 2 *ppvObject = &This->IXAudio22_iface; +#elif XAUDIO2_VER <= 3 + *ppvObject = &This->IXAudio23_iface; #elif XAUDIO2_VER <= 7 *ppvObject = &This->IXAudio27_iface; #else @@ -1902,6 +1904,8 @@ static HRESULT WINAPI XAudio2CF_CreateInstance(IClassFactory *iface, IUnknown *p object->IXAudio20_iface.lpVtbl = &XAudio20_Vtbl; #elif XAUDIO2_VER <= 2 object->IXAudio22_iface.lpVtbl = &XAudio22_Vtbl; +#elif XAUDIO2_VER <= 3 + object->IXAudio23_iface.lpVtbl = &XAudio23_Vtbl; #elif XAUDIO2_VER <= 7 object->IXAudio27_iface.lpVtbl = &XAudio27_Vtbl; #endif diff --git a/dlls/xaudio2_7/xaudio_private.h b/dlls/xaudio2_7/xaudio_private.h index 84bab8257d0..46d842bf4c1 100644 --- a/dlls/xaudio2_7/xaudio_private.h +++ b/dlls/xaudio2_7/xaudio_private.h @@ -111,6 +111,8 @@ typedef struct _IXAudio2Impl { IXAudio20 IXAudio20_iface; #elif XAUDIO2_VER <= 2 IXAudio22 IXAudio22_iface; +#elif XAUDIO2_VER <= 3 + IXAudio23 IXAudio23_iface; #elif XAUDIO2_VER <= 7 IXAudio27 IXAudio27_iface; #endif @@ -158,6 +160,8 @@ extern XA2VoiceImpl *impl_from_IXAudio27MasteringVoice(IXAudio27MasteringVoice * extern const IXAudio20Vtbl XAudio20_Vtbl DECLSPEC_HIDDEN; #elif XAUDIO2_VER <= 2 extern const IXAudio22Vtbl XAudio22_Vtbl DECLSPEC_HIDDEN; +#elif XAUDIO2_VER <= 3 +extern const IXAudio23Vtbl XAudio23_Vtbl DECLSPEC_HIDDEN; #elif XAUDIO2_VER <= 7 extern const IXAudio27Vtbl XAudio27_Vtbl DECLSPEC_HIDDEN; #endif diff --git a/include/xaudio2.idl b/include/xaudio2.idl index e97cf9948ba..074454d4906 100644 --- a/include/xaudio2.idl +++ b/include/xaudio2.idl @@ -1050,6 +1050,67 @@ interface IXAudio22 : IUnknown [in, defaultvalue(NULL)] void* pReserved); } +[ + object, + uuid(8bcf1f58-9fe7-4583-8ac6-e2adc465c8bb), /* all versions before 28 share IID_IXAudio */ +] +/* XAudio2 2.3's IXAudio2 interface. Actually called IXAudio2 in the Nov 2008 + * DX SDK */ +interface IXAudio23 : IUnknown +{ + HRESULT GetDeviceCount([out] UINT32* pCount); + + HRESULT GetDeviceDetails( + [in] UINT32 Index, + [out] XAUDIO2_DEVICE_DETAILS* pDeviceDetails); + + HRESULT Initialize( + [in, defaultvalue(0)] UINT32 Flags, + [in, defaultvalue(XAUDIO2_DEFAULT_PROCESSOR)] XAUDIO2_PROCESSOR XAudio2Processor); + + HRESULT RegisterForCallbacks([in] IXAudio2EngineCallback* pCallback); + + void UnregisterForCallbacks([in] IXAudio2EngineCallback* pCallback); + + HRESULT CreateSourceVoice( + [out] IXAudio2SourceVoice** ppSourceVoice, + [in] const WAVEFORMATEX* pSourceFormat, + [in, defaultvalue(0)] UINT32 Flags, + [in, defaultvalue(XAUDIO2_DEFAULT_FREQ_RATIO)] float MaxFrequencyRatio, + [in, defaultvalue(NULL)] IXAudio2VoiceCallback* pCallback, + [in, defaultvalue(NULL)] const XAUDIO23_VOICE_SENDS* pSendList, + [in, defaultvalue(NULL)] const XAUDIO2_EFFECT_CHAIN* pEffectChain); + + HRESULT CreateSubmixVoice( + [out] IXAudio2SubmixVoice** ppSubmixVoice, + [in] UINT32 InputChannels, + [in] UINT32 InputSampleRate, + [in, defaultvalue(0)] UINT32 Flags, + [in, defaultvalue(0)] UINT32 ProcessingStage, + [in, defaultvalue(NULL)] const XAUDIO23_VOICE_SENDS* pSendList, + [in, defaultvalue(NULL)] const XAUDIO2_EFFECT_CHAIN* pEffectChain); + + HRESULT CreateMasteringVoice( + [out] IXAudio2MasteringVoice** ppMasteringVoice, + [in, defaultvalue(XAUDIO2_DEFAULT_CHANNELS)] UINT32 InputChannels, + [in, defaultvalue(XAUDIO2_DEFAULT_SAMPLERATE)] UINT32 InputSampleRate, + [in, defaultvalue(0)] UINT32 Flags, + [in, defaultvalue(0)] UINT32 DeviceIndex, + [in, defaultvalue(NULL)] const XAUDIO2_EFFECT_CHAIN* pEffectChain); + + HRESULT StartEngine(); + + void StopEngine(); + + HRESULT CommitChanges([in] UINT32 OperationSet); + + void GetPerformanceData([out] XAUDIO2_PERFORMANCE_DATA* pPerfData); + + [local] void SetDebugConfiguration( + [in] const XAUDIO2_DEBUG_CONFIGURATION* pDebugConfiguration, + [in, defaultvalue(NULL)] void* pReserved); +} + [ object, uuid(8bcf1f58-9fe7-4583-8ac6-e2adc465c8bb),