Commit 11cb83cf authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

xaudio2_3: Add compatibility implementation and forward to xaudio2_7.

parent 3ecdbd25
......@@ -1374,6 +1374,7 @@ enable_xapofx1_1
enable_xapofx1_3
enable_xapofx1_4
enable_xapofx1_5
enable_xaudio2_3
enable_xaudio2_7
enable_xaudio2_8
enable_xinput1_1
......@@ -17911,6 +17912,7 @@ wine_fn_config_dll xapofx1_1 enable_xapofx1_1
wine_fn_config_dll xapofx1_3 enable_xapofx1_3
wine_fn_config_dll xapofx1_4 enable_xapofx1_4
wine_fn_config_dll xapofx1_5 enable_xapofx1_5
wine_fn_config_dll xaudio2_3 enable_xaudio2_3 clean
wine_fn_config_dll xaudio2_7 enable_xaudio2_7 clean
wine_fn_config_test dlls/xaudio2_7/tests xaudio2_7_test
wine_fn_config_dll xaudio2_8 enable_xaudio2_8
......
......@@ -3460,6 +3460,7 @@ WINE_CONFIG_DLL(xapofx1_1)
WINE_CONFIG_DLL(xapofx1_3)
WINE_CONFIG_DLL(xapofx1_4)
WINE_CONFIG_DLL(xapofx1_5)
WINE_CONFIG_DLL(xaudio2_3,,[clean])
WINE_CONFIG_DLL(xaudio2_7,,[clean])
WINE_CONFIG_TEST(dlls/xaudio2_7/tests)
WINE_CONFIG_DLL(xaudio2_8)
......
MODULE = xaudio2_3.dll
IMPORTS = ole32
C_SRCS = \
xaudio_dll.c
IDL_SRCS = xaudio_classes.idl
@ stdcall -private DllCanUnloadNow()
@ stdcall -private DllGetClassObject(ptr ptr ptr) xaudio2_7.DllGetClassObject
@ stdcall -private DllRegisterServer()
@ stdcall -private DllUnregisterServer()
/*
* COM Classes for xaudio
*
* Copyright 2015 Andrew Eikum for CodeWeavers
*
* 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.3 Class"),
threading(both),
uuid(4c5e637a-16c7-4de3-9c46-5ed22181962d)
]
coclass XAudio23 { interface IXAudio27; }
/*
* Copyright (c) 2015 Andrew Eikum for CodeWeavers
*
* 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 <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "rpcproxy.h"
static HINSTANCE instance;
BOOL WINAPI DllMain(HINSTANCE hinstance, DWORD reason, LPVOID reserved)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
instance = hinstance;
DisableThreadLibraryCalls(hinstance);
break;
}
return TRUE;
}
HRESULT WINAPI DllCanUnloadNow(void)
{
return S_FALSE;
}
HRESULT WINAPI DllRegisterServer(void)
{
return __wine_register_resources(instance);
}
HRESULT WINAPI DllUnregisterServer(void)
{
return __wine_unregister_resources(instance);
}
......@@ -1348,6 +1348,7 @@ static HRESULT WINAPI IXAudio2Impl_CreateSourceVoice(IXAudio2 *iface,
list_add_head(&This->source_voices, &src->entry);
src->IXAudio23SourceVoice_iface.lpVtbl = &XAudio23SourceVoice_Vtbl;
src->IXAudio27SourceVoice_iface.lpVtbl = &XAudio27SourceVoice_Vtbl;
src->IXAudio2SourceVoice_iface.lpVtbl = &XAudio2SourceVoice_Vtbl;
......@@ -1386,7 +1387,9 @@ static HRESULT WINAPI IXAudio2Impl_CreateSourceVoice(IXAudio2 *iface,
alSourcePlay(src->al_src);
if(This->version == 27)
if(This->version <= 23)
*ppSourceVoice = (IXAudio2SourceVoice*)&src->IXAudio23SourceVoice_iface;
else if(This->version <= 27)
*ppSourceVoice = (IXAudio2SourceVoice*)&src->IXAudio27SourceVoice_iface;
else
*ppSourceVoice = &src->IXAudio2SourceVoice_iface;
......@@ -1425,6 +1428,7 @@ static HRESULT WINAPI IXAudio2Impl_CreateSubmixVoice(IXAudio2 *iface,
list_add_head(&This->submix_voices, &sub->entry);
sub->IXAudio23SubmixVoice_iface.lpVtbl = &XAudio23SubmixVoice_Vtbl;
sub->IXAudio2SubmixVoice_iface.lpVtbl = &XAudio2SubmixVoice_Vtbl;
InitializeCriticalSection(&sub->lock);
......@@ -1435,7 +1439,10 @@ static HRESULT WINAPI IXAudio2Impl_CreateSubmixVoice(IXAudio2 *iface,
LeaveCriticalSection(&This->lock);
*ppSubmixVoice = &sub->IXAudio2SubmixVoice_iface;
if(This->version <= 23)
*ppSubmixVoice = (IXAudio2SubmixVoice*)&sub->IXAudio23SubmixVoice_iface;
else
*ppSubmixVoice = &sub->IXAudio2SubmixVoice_iface;
TRACE("Created submix voice: %p\n", sub);
......@@ -1658,7 +1665,10 @@ static HRESULT WINAPI IXAudio2Impl_CreateMasteringVoice(IXAudio2 *iface,
IAudioClient_Start(This->aclient);
*ppMasteringVoice = &This->IXAudio2MasteringVoice_iface;
if(This->version <= 23)
*ppMasteringVoice = (IXAudio2MasteringVoice*)&This->IXAudio23MasteringVoice_iface;
else
*ppMasteringVoice = &This->IXAudio2MasteringVoice_iface;
exit:
if(FAILED(hr)){
......@@ -2159,6 +2169,17 @@ static const IXAPOParametersVtbl RVBXAPOParameters_Vtbl = {
RVBXAPOParams_GetParameters
};
struct xaudio2_cf {
IClassFactory IClassFactory_iface;
LONG ref;
DWORD version;
};
struct xaudio2_cf *impl_from_IClassFactory(IClassFactory *iface)
{
return CONTAINING_RECORD(iface, struct xaudio2_cf, IClassFactory_iface);
}
static HRESULT WINAPI XAudio2CF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
{
if(IsEqualGUID(riid, &IID_IUnknown)
......@@ -2176,12 +2197,20 @@ static HRESULT WINAPI XAudio2CF_QueryInterface(IClassFactory *iface, REFIID riid
static ULONG WINAPI XAudio2CF_AddRef(IClassFactory *iface)
{
return 2;
struct xaudio2_cf *This = impl_from_IClassFactory(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->(): Refcount now %u\n", This, ref);
return ref;
}
static ULONG WINAPI XAudio2CF_Release(IClassFactory *iface)
{
return 1;
struct xaudio2_cf *This = impl_from_IClassFactory(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->(): Refcount now %u\n", This, ref);
if (!ref)
HeapFree(GetProcessHeap(), 0, This);
return ref;
}
static HRESULT initialize_mmdevices(IXAudio2Impl *This)
......@@ -2260,10 +2289,11 @@ static HRESULT initialize_mmdevices(IXAudio2Impl *This)
static HRESULT WINAPI XAudio2CF_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
REFIID riid, void **ppobj)
{
struct xaudio2_cf *This = impl_from_IClassFactory(iface);
HRESULT hr;
IXAudio2Impl *object;
TRACE("(static)->(%p,%s,%p)\n", pOuter, debugstr_guid(riid), ppobj);
TRACE("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
*ppobj = NULL;
......@@ -2276,11 +2306,12 @@ static HRESULT WINAPI XAudio2CF_CreateInstance(IClassFactory *iface, IUnknown *p
object->IXAudio27_iface.lpVtbl = &XAudio27_Vtbl;
object->IXAudio2_iface.lpVtbl = &XAudio2_Vtbl;
object->IXAudio23MasteringVoice_iface.lpVtbl = &XAudio23MasteringVoice_Vtbl;
object->IXAudio2MasteringVoice_iface.lpVtbl = &XAudio2MasteringVoice_Vtbl;
if(IsEqualGUID(riid, &IID_IXAudio27))
object->version = 27;
else
object->version = This->version;
else /* only xaudio 2.8 has a different IID */
object->version = 28;
list_init(&object->source_voices);
......@@ -2310,6 +2341,16 @@ static HRESULT WINAPI XAudio2CF_CreateInstance(IClassFactory *iface, IUnknown *p
return hr;
}
static ULONG WINAPI static_AddRef(IClassFactory *iface)
{
return 2;
}
static ULONG WINAPI static_Release(IClassFactory *iface)
{
return 1;
}
static HRESULT WINAPI VUMeterCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
REFIID riid, void **ppobj)
{
......@@ -2386,8 +2427,8 @@ static const IClassFactoryVtbl XAudio2CF_Vtbl =
static const IClassFactoryVtbl VUMeterCF_Vtbl =
{
XAudio2CF_QueryInterface,
XAudio2CF_AddRef,
XAudio2CF_Release,
static_AddRef,
static_Release,
VUMeterCF_CreateInstance,
XAudio2CF_LockServer
};
......@@ -2395,24 +2436,34 @@ static const IClassFactoryVtbl VUMeterCF_Vtbl =
static const IClassFactoryVtbl ReverbCF_Vtbl =
{
XAudio2CF_QueryInterface,
XAudio2CF_AddRef,
XAudio2CF_Release,
static_AddRef,
static_Release,
ReverbCF_CreateInstance,
XAudio2CF_LockServer
};
static IClassFactory xaudio2_cf = { &XAudio2CF_Vtbl };
static IClassFactory vumeter_cf = { &VUMeterCF_Vtbl };
static IClassFactory reverb_cf = { &ReverbCF_Vtbl };
static IClassFactory *make_xaudio2_factory(DWORD version)
{
struct xaudio2_cf *ret = HeapAlloc(GetProcessHeap(), 0, sizeof(struct xaudio2_cf));
ret->IClassFactory_iface.lpVtbl = &XAudio2CF_Vtbl;
ret->version = version;
ret->ref = 0;
return &ret->IClassFactory_iface;
}
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
{
IClassFactory *factory = NULL;
TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
if(IsEqualGUID(rclsid, &CLSID_XAudio2)) {
factory = &xaudio2_cf;
if IsEqualGUID(rclsid, &CLSID_XAudio23){
factory = make_xaudio2_factory(23);
}else if(IsEqualGUID(rclsid, &CLSID_XAudio2)){
factory = make_xaudio2_factory(27);
}else if(IsEqualGUID(rclsid, &CLSID_AudioVolumeMeter)) {
factory = &vumeter_cf;
}else if(IsEqualGUID(rclsid, &CLSID_AudioReverb)) {
......
......@@ -42,6 +42,7 @@ typedef struct _XA2Buffer {
typedef struct _IXAudio2Impl IXAudio2Impl;
typedef struct _XA2SourceImpl {
IXAudio23SourceVoice IXAudio23SourceVoice_iface;
IXAudio27SourceVoice IXAudio27SourceVoice_iface;
IXAudio2SourceVoice IXAudio2SourceVoice_iface;
......@@ -80,6 +81,7 @@ typedef struct _XA2SourceImpl {
} XA2SourceImpl;
typedef struct _XA2SubmixImpl {
IXAudio23SubmixVoice IXAudio23SubmixVoice_iface;
IXAudio2SubmixVoice IXAudio2SubmixVoice_iface;
BOOL in_use;
......@@ -92,6 +94,7 @@ typedef struct _XA2SubmixImpl {
struct _IXAudio2Impl {
IXAudio27 IXAudio27_iface;
IXAudio2 IXAudio2_iface;
IXAudio23MasteringVoice IXAudio23MasteringVoice_iface;
IXAudio2MasteringVoice IXAudio2MasteringVoice_iface;
LONG ref;
......@@ -129,3 +132,7 @@ struct _IXAudio2Impl {
extern const IXAudio27SourceVoiceVtbl XAudio27SourceVoice_Vtbl DECLSPEC_HIDDEN;
extern const IXAudio27Vtbl XAudio27_Vtbl DECLSPEC_HIDDEN;
extern const IXAudio23SourceVoiceVtbl XAudio23SourceVoice_Vtbl DECLSPEC_HIDDEN;
extern const IXAudio23SubmixVoiceVtbl XAudio23SubmixVoice_Vtbl DECLSPEC_HIDDEN;
extern const IXAudio23MasteringVoiceVtbl XAudio23MasteringVoice_Vtbl DECLSPEC_HIDDEN;
......@@ -31,6 +31,13 @@ coclass XAudio2 {
}
[
uuid(4c5e637a-16c7-4de3-9c46-5ed22181962d)
]
coclass XAudio23 {
interface IUnknown;
}
[
uuid(db05ea35-0329-4d4b-a53a-6dead03d3852)
]
coclass XAudio2Debug {
......@@ -153,6 +160,13 @@ typedef struct XAUDIO2_SEND_DESCRIPTOR
IXAudio2Voice* pOutputVoice;
} XAUDIO2_SEND_DESCRIPTOR;
/* XAudio2 2.3's XAUDIO2_VOICE_SENDS struct */
typedef struct XAUDIO23_VOICE_SENDS
{
UINT32 OutputCount;
IXAudio2Voice **pOutputVoices;
} XAUDIO23_VOICE_SENDS;
typedef struct XAUDIO2_VOICE_SENDS
{
UINT32 SendCount;
......@@ -222,6 +236,80 @@ typedef struct XAUDIO2_FILTER_PARAMETERS
float OneOverQ;
} XAUDIO2_FILTER_PARAMETERS;
/* XAudio 2.3's IXAudio2Voice */
/* XAudio2 2.3's IXAudio2Voice interface. Actually called
* IXAudio2Voice in the Nov 2008 DX SDK */
[
object,
local
]
interface IXAudio23Voice
{
void GetVoiceDetails([out] XAUDIO2_VOICE_DETAILS* pVoiceDetails);
HRESULT SetOutputVoices([in] const XAUDIO23_VOICE_SENDS* pSendList);
HRESULT SetEffectChain([in] const XAUDIO2_EFFECT_CHAIN* pEffectChain);
HRESULT EnableEffect(
[in] UINT32 EffectIndex,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
HRESULT DisableEffect(
[in] UINT32 EffectIndex,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
void GetEffectState(
[in] UINT32 EffectIndex,
[out] BOOL* pEnabled);
HRESULT SetEffectParameters(
[in] UINT32 EffectIndex,
[in] const void* pParameters,
[in] UINT32 ParametersByteSize,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
HRESULT GetEffectParameters(
[in] UINT32 EffectIndex,
[out] void* pParameters,
[in] UINT32 ParametersByteSize);
HRESULT SetFilterParameters(
[in] const XAUDIO2_FILTER_PARAMETERS* pParameters,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
void GetFilterParameters([out] XAUDIO2_FILTER_PARAMETERS* pParameters);
HRESULT SetVolume(
[in] float Volume,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
void GetVolume([out] float* pVolume);
HRESULT SetChannelVolumes(
[in] UINT32 Channels,
[in, size_is(Channels)] const float* pVolumes,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
void GetChannelVolumes(
[in] UINT32 Channels,
[out, size_is(Channels)] float* pVolumes);
HRESULT SetOutputMatrix(
[in] IXAudio2Voice* pDestinationVoice,
[in] UINT32 SourceChannels,
[in] UINT32 DestinationChannels,
[in, size_is(SourceChannels * DestinationChannels)] const float* pLevelMatrix,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
void GetOutputMatrix(
[in] IXAudio2Voice* pDestinationVoice,
[in] UINT32 SourceChannels,
[in] UINT32 DestinationChannels,
[out, size_is(SourceChannels * DestinationChannels)] float* pLevelMatrix);
void DestroyVoice();
}
[
object,
local
......@@ -332,6 +420,40 @@ typedef struct XAUDIO2_VOICE_STATE
[
local
]
/* XAudio2 2.3's IXAudio2SourceVoice interface. Actually called
* IXAudio2SourceVoice in the Nov 2008 DX SDK */
interface IXAudio23SourceVoice : IXAudio23Voice
{
HRESULT Start(
[in, defaultvalue(0)] UINT32 Flags,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
HRESULT Stop(
[in, defaultvalue(0)] UINT32 Flags,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
HRESULT SubmitSourceBuffer(
[in] const XAUDIO2_BUFFER* pBuffer,
[in, defaultvalue(NULL)] const XAUDIO2_BUFFER_WMA* pBufferWMA);
HRESULT FlushSourceBuffers();
HRESULT Discontinuity();
HRESULT ExitLoop([in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
void GetState([out] XAUDIO2_VOICE_STATE* pVoiceState);
HRESULT SetFrequencyRatio(
[in] float Ratio,
[in, defaultvalue(XAUDIO2_COMMIT_NOW)] UINT32 OperationSet);
void GetFrequencyRatio([out] float* pRatio);
}
[
local
]
/* XAudio2 2.7's IXAudio2SourceVoice interface. Actually called
* IXAudio2SourceVoice in the Jun 2010 DX SDK */
interface IXAudio27SourceVoice : IXAudio2Voice
......@@ -403,6 +525,15 @@ interface IXAudio2SourceVoice : IXAudio2Voice
[
local
]
/* XAudio2 2.3's IXAudio2SubmixVoice interface. Actually called
* IXAudio2SubmixVoice in the Nov 2008 DX SDK */
interface IXAudio23SubmixVoice : IXAudio23Voice
{
}
[
local
]
interface IXAudio2SubmixVoice : IXAudio2Voice
{
}
......@@ -410,6 +541,15 @@ interface IXAudio2SubmixVoice : IXAudio2Voice
[
local
]
/* XAudio2 2.3's IXAudio2MasteringVoice interface. Actually called
* IXAudio2MasteringVoice in the Nov 2008 DX SDK */
interface IXAudio23MasteringVoice : IXAudio23Voice
{
}
[
local
]
interface IXAudio2MasteringVoice : IXAudio2Voice
{
/* not present in XAudio2 2.7 */
......
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