maintainers: Update the Direct3D section.
[wine.git] / dlls / xaudio2_7 / xapofx.c
blobacb175556a2b83a87ca524e15e143943160ef4a2
1 /*
2 * Copyright (c) 2015 Andrew Eikum for CodeWeavers
3 * Copyright (c) 2018 Ethan Lee for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
22 #define NONAMELESSUNION
23 #define COBJMACROS
25 #ifdef XAPOFX1_VER
26 #include "initguid.h"
27 #endif /* XAPOFX1_VER */
28 #include "xaudio_private.h"
29 #include "xapofx.h"
31 #include "wine/debug.h"
33 #if XAUDIO2_VER >= 8 || defined XAPOFX1_VER
34 WINE_DEFAULT_DEBUG_CHANNEL(xaudio2);
35 #endif
37 #if XAUDIO2_VER >= 8
38 HRESULT CDECL CreateFX(REFCLSID clsid, IUnknown **out, void *initdata, UINT32 initdata_bytes)
40 HRESULT hr;
41 IUnknown *obj;
42 const GUID *class = NULL;
43 IClassFactory *cf;
45 *out = NULL;
47 if(IsEqualGUID(clsid, &CLSID_FXReverb27) ||
48 IsEqualGUID(clsid, &CLSID_FXReverb))
49 class = &CLSID_FXReverb;
50 else if(IsEqualGUID(clsid, &CLSID_FXEQ27) ||
51 IsEqualGUID(clsid, &CLSID_FXEQ))
52 class = &CLSID_FXEQ;
53 else if(IsEqualGUID(clsid, &CLSID_FXEcho27) ||
54 IsEqualGUID(clsid, &CLSID_FXEcho))
55 class = &CLSID_FXEcho;
56 else if(IsEqualGUID(clsid, &CLSID_FXMasteringLimiter27) ||
57 IsEqualGUID(clsid, &CLSID_FXMasteringLimiter))
58 class = &CLSID_FXMasteringLimiter;
60 if(class){
61 hr = make_xapo_factory(class, &IID_IClassFactory, (void**)&cf);
62 if(FAILED(hr))
63 return hr;
65 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&obj);
66 IClassFactory_Release(cf);
67 if(FAILED(hr))
68 return hr;
69 }else{
70 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&obj);
71 if(FAILED(hr)){
72 WARN("CoCreateInstance failed: %08lx\n", hr);
73 return hr;
77 if(initdata && initdata_bytes > 0){
78 IXAPO *xapo;
80 hr = IUnknown_QueryInterface(obj, &IID_IXAPO, (void**)&xapo);
81 if(SUCCEEDED(hr)){
82 hr = IXAPO_Initialize(xapo, initdata, initdata_bytes);
84 IXAPO_Release(xapo);
86 if(FAILED(hr)){
87 WARN("Initialize failed: %08lx\n", hr);
88 IUnknown_Release(obj);
89 return hr;
94 *out = obj;
96 return S_OK;
98 #endif /* XAUDIO2_VER >= 8 */
100 #ifdef XAPOFX1_VER
101 HRESULT CDECL CreateFX(REFCLSID clsid, IUnknown **out)
103 HRESULT hr;
104 IUnknown *obj;
105 const GUID *class = NULL;
106 IClassFactory *cf;
108 TRACE("%s %p\n", debugstr_guid(clsid), out);
110 *out = NULL;
112 if(IsEqualGUID(clsid, &CLSID_FXReverb27) ||
113 IsEqualGUID(clsid, &CLSID_FXReverb))
114 class = &CLSID_FXReverb;
115 else if(IsEqualGUID(clsid, &CLSID_FXEQ27) ||
116 IsEqualGUID(clsid, &CLSID_FXEQ))
117 class = &CLSID_FXEQ;
118 else if(IsEqualGUID(clsid, &CLSID_FXEcho27) ||
119 IsEqualGUID(clsid, &CLSID_FXEcho))
120 class = &CLSID_FXEcho;
121 else if(IsEqualGUID(clsid, &CLSID_FXMasteringLimiter27) ||
122 IsEqualGUID(clsid, &CLSID_FXMasteringLimiter))
123 class = &CLSID_FXMasteringLimiter;
125 if(class){
126 hr = make_xapo_factory(class, &IID_IClassFactory, (void**)&cf);
127 if(FAILED(hr))
128 return hr;
130 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&obj);
131 IClassFactory_Release(cf);
132 if(FAILED(hr))
133 return hr;
134 }else{
135 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&obj);
136 if(FAILED(hr)){
137 WARN("CoCreateInstance failed: %08lx\n", hr);
138 return hr;
142 *out = obj;
144 return S_OK;
146 #endif /* XAPOFX1_VER */