xaudio2_8: Add 3D audio function stubs.
[wine.git] / dlls / xaudio2_8 / xaudio_dll.c
blob0a0ef4a9b38304af16b7c4ca23077e18342369d1
1 /*
2 * Copyright (c) 2015 Andrew Eikum for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "wine/debug.h"
28 #include "initguid.h"
29 #include "xaudio2.h"
30 #include "xaudio2fx.h"
31 #include "xapo.h"
32 #include "xapofx.h"
33 #include "x3daudio.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(xaudio2);
37 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
39 switch (fdwReason)
41 case DLL_WINE_PREATTACH:
42 return FALSE; /* prefer native version */
43 case DLL_PROCESS_ATTACH:
44 DisableThreadLibraryCalls( hinstDLL );
45 break;
47 return TRUE;
50 HRESULT WINAPI XAudio2Create(IXAudio2 **ppxa2, UINT32 flags, XAUDIO2_PROCESSOR proc)
52 HRESULT hr;
53 IXAudio2 *xa2;
54 IXAudio27 *xa27;
56 /* create XAudio2 2.8 instance */
57 hr = CoCreateInstance(&CLSID_XAudio2, NULL, CLSCTX_INPROC_SERVER,
58 &IID_IXAudio2, (void**)&xa2);
59 if(FAILED(hr))
60 return hr;
62 hr = IXAudio2_QueryInterface(xa2, &IID_IXAudio27, (void**)&xa27);
63 if(FAILED(hr)){
64 IXAudio2_Release(xa2);
65 return hr;
68 hr = IXAudio27_Initialize(xa27, flags, proc);
69 if(FAILED(hr)){
70 IXAudio27_Release(xa27);
71 IXAudio2_Release(xa2);
72 return hr;
75 IXAudio27_Release(xa27);
77 *ppxa2 = xa2;
79 return S_OK;
82 HRESULT WINAPI CreateAudioVolumeMeter(IUnknown **out)
84 return CoCreateInstance(&CLSID_AudioVolumeMeter, NULL, CLSCTX_INPROC_SERVER,
85 &IID_IUnknown, (void**)out);
88 HRESULT WINAPI CreateAudioReverb(IUnknown **out)
90 return CoCreateInstance(&CLSID_AudioReverb, NULL, CLSCTX_INPROC_SERVER,
91 &IID_IUnknown, (void**)out);
94 HRESULT CDECL CreateFX(REFCLSID clsid, IUnknown **out, void *initdata, UINT32 initdata_bytes)
96 HRESULT hr;
97 IUnknown *obj;
98 const GUID *class;
100 *out = NULL;
101 class = clsid;
103 if(IsEqualGUID(clsid, &CLSID_FXReverb27) ||
104 IsEqualGUID(clsid, &CLSID_FXReverb))
105 class = &CLSID_WINE_FXReverb28;
107 hr = CoCreateInstance(class, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&obj);
108 if(FAILED(hr)){
109 WARN("CoCreateInstance failed: %08x\n", hr);
110 return hr;
113 if(initdata && initdata_bytes > 0){
114 IXAPO *xapo;
116 hr = IUnknown_QueryInterface(obj, &IID_IXAPO, (void**)&xapo);
117 if(SUCCEEDED(hr)){
118 hr = IXAPO_Initialize(xapo, initdata, initdata_bytes);
120 IXAPO_Release(xapo);
122 if(FAILED(hr)){
123 WARN("Initialize failed: %08x\n", hr);
124 IUnknown_Release(obj);
125 return hr;
130 *out = obj;
132 return S_OK;
135 HRESULT CDECL X3DAudioInitialize(UINT32 chanmask, float speedofsound,
136 X3DAUDIO_HANDLE handle)
138 FIXME("0x%x, %f, %p: Stub!\n", chanmask, speedofsound, handle);
139 return S_OK;
142 void CDECL X3DAudioCalculate(const X3DAUDIO_HANDLE handle,
143 const X3DAUDIO_LISTENER *listener, const X3DAUDIO_EMITTER *emitter,
144 UINT32 flags, X3DAUDIO_DSP_SETTINGS *out)
146 static int once = 0;
147 if(!once){
148 FIXME("%p %p %p 0x%x %p: Stub!\n", handle, listener, emitter, flags, out);
149 ++once;
152 out->LPFDirectCoefficient = 0;
153 out->LPFReverbCoefficient = 0;
154 out->ReverbLevel = 0;
155 out->DopplerFactor = 1;
156 out->EmitterToListenerAngle = 0;
157 out->EmitterToListenerDistance = 0;
158 out->EmitterVelocityComponent = 0;
159 out->ListenerVelocityComponent = 0;