Release 6.15.
[wine.git] / dlls / xaudio2_7 / xapofx.c
blob4dcdaa2ca5fea6593423f4d31d7908b46d481afa
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 "config.h"
22 #include <stdarg.h>
24 #define NONAMELESSUNION
25 #define COBJMACROS
27 #ifdef XAPOFX1_VER
28 #include "initguid.h"
29 #endif /* XAPOFX1_VER */
30 #include "xaudio_private.h"
31 #include "xapofx.h"
33 #include "wine/debug.h"
35 #if XAUDIO2_VER >= 8 || defined XAPOFX1_VER
36 WINE_DEFAULT_DEBUG_CHANNEL(xaudio2);
37 #endif
39 #if XAUDIO2_VER >= 8
40 HRESULT CDECL CreateFX(REFCLSID clsid, IUnknown **out, void *initdata, UINT32 initdata_bytes)
42 HRESULT hr;
43 IUnknown *obj;
44 const GUID *class = NULL;
45 IClassFactory *cf;
47 *out = NULL;
49 if(IsEqualGUID(clsid, &CLSID_FXReverb27) ||
50 IsEqualGUID(clsid, &CLSID_FXReverb))
51 class = &CLSID_FXReverb;
52 else if(IsEqualGUID(clsid, &CLSID_FXEQ27) ||
53 IsEqualGUID(clsid, &CLSID_FXEQ))
54 class = &CLSID_FXEQ;
55 else if(IsEqualGUID(clsid, &CLSID_FXEcho27) ||
56 IsEqualGUID(clsid, &CLSID_FXEcho))
57 class = &CLSID_FXEcho;
58 else if(IsEqualGUID(clsid, &CLSID_FXMasteringLimiter27) ||
59 IsEqualGUID(clsid, &CLSID_FXMasteringLimiter))
60 class = &CLSID_FXMasteringLimiter;
62 if(class){
63 hr = make_xapo_factory(class, &IID_IClassFactory, (void**)&cf);
64 if(FAILED(hr))
65 return hr;
67 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&obj);
68 IClassFactory_Release(cf);
69 if(FAILED(hr))
70 return hr;
71 }else{
72 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&obj);
73 if(FAILED(hr)){
74 WARN("CoCreateInstance failed: %08x\n", hr);
75 return hr;
79 if(initdata && initdata_bytes > 0){
80 IXAPO *xapo;
82 hr = IUnknown_QueryInterface(obj, &IID_IXAPO, (void**)&xapo);
83 if(SUCCEEDED(hr)){
84 hr = IXAPO_Initialize(xapo, initdata, initdata_bytes);
86 IXAPO_Release(xapo);
88 if(FAILED(hr)){
89 WARN("Initialize failed: %08x\n", hr);
90 IUnknown_Release(obj);
91 return hr;
96 *out = obj;
98 return S_OK;
100 #endif /* XAUDIO2_VER >= 8 */
102 #ifdef XAPOFX1_VER
103 HRESULT CDECL CreateFX(REFCLSID clsid, IUnknown **out)
105 HRESULT hr;
106 IUnknown *obj;
107 const GUID *class = NULL;
108 IClassFactory *cf;
110 TRACE("%s %p\n", debugstr_guid(clsid), out);
112 *out = NULL;
114 if(IsEqualGUID(clsid, &CLSID_FXReverb27) ||
115 IsEqualGUID(clsid, &CLSID_FXReverb))
116 class = &CLSID_FXReverb;
117 else if(IsEqualGUID(clsid, &CLSID_FXEQ27) ||
118 IsEqualGUID(clsid, &CLSID_FXEQ))
119 class = &CLSID_FXEQ;
120 else if(IsEqualGUID(clsid, &CLSID_FXEcho27) ||
121 IsEqualGUID(clsid, &CLSID_FXEcho))
122 class = &CLSID_FXEcho;
123 else if(IsEqualGUID(clsid, &CLSID_FXMasteringLimiter27) ||
124 IsEqualGUID(clsid, &CLSID_FXMasteringLimiter))
125 class = &CLSID_FXMasteringLimiter;
127 if(class){
128 hr = make_xapo_factory(class, &IID_IClassFactory, (void**)&cf);
129 if(FAILED(hr))
130 return hr;
132 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&obj);
133 IClassFactory_Release(cf);
134 if(FAILED(hr))
135 return hr;
136 }else{
137 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&obj);
138 if(FAILED(hr)){
139 WARN("CoCreateInstance failed: %08x\n", hr);
140 return hr;
144 *out = obj;
146 return S_OK;
148 #endif /* XAPOFX1_VER */