widl: Strip last separator in append_namespaces if suffix is NULL.
[wine.git] / dlls / xaudio2_7 / xapofx.c
blob100ba02d3b5835bf999c35641686cb3634d03e3f
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 #ifdef XAPOFX1_VER
40 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, void *pReserved)
42 TRACE("(%p, %d, %p)\n", hinstDLL, reason, pReserved);
44 switch (reason)
46 case DLL_PROCESS_ATTACH:
47 DisableThreadLibraryCalls( hinstDLL );
48 break;
50 return TRUE;
52 #endif /* XAPOFX1_VER */
54 #if XAUDIO2_VER >= 8
55 HRESULT CDECL CreateFX(REFCLSID clsid, IUnknown **out, void *initdata, UINT32 initdata_bytes)
57 HRESULT hr;
58 IUnknown *obj;
59 const GUID *class = NULL;
60 IClassFactory *cf;
62 *out = NULL;
64 if(IsEqualGUID(clsid, &CLSID_FXReverb27) ||
65 IsEqualGUID(clsid, &CLSID_FXReverb))
66 class = &CLSID_FXReverb;
67 else if(IsEqualGUID(clsid, &CLSID_FXEQ27) ||
68 IsEqualGUID(clsid, &CLSID_FXEQ))
69 class = &CLSID_FXEQ;
70 else if(IsEqualGUID(clsid, &CLSID_FXEcho27) ||
71 IsEqualGUID(clsid, &CLSID_FXEcho))
72 class = &CLSID_FXEcho;
73 else if(IsEqualGUID(clsid, &CLSID_FXMasteringLimiter27) ||
74 IsEqualGUID(clsid, &CLSID_FXMasteringLimiter))
75 class = &CLSID_FXMasteringLimiter;
77 if(class){
78 hr = make_xapo_factory(class, &IID_IClassFactory, (void**)&cf);
79 if(FAILED(hr))
80 return hr;
82 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&obj);
83 IClassFactory_Release(cf);
84 if(FAILED(hr))
85 return hr;
86 }else{
87 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&obj);
88 if(FAILED(hr)){
89 WARN("CoCreateInstance failed: %08x\n", hr);
90 return hr;
94 if(initdata && initdata_bytes > 0){
95 IXAPO *xapo;
97 hr = IUnknown_QueryInterface(obj, &IID_IXAPO, (void**)&xapo);
98 if(SUCCEEDED(hr)){
99 hr = IXAPO_Initialize(xapo, initdata, initdata_bytes);
101 IXAPO_Release(xapo);
103 if(FAILED(hr)){
104 WARN("Initialize failed: %08x\n", hr);
105 IUnknown_Release(obj);
106 return hr;
111 *out = obj;
113 return S_OK;
115 #endif /* XAUDIO2_VER >= 8 */
117 #ifdef XAPOFX1_VER
118 HRESULT CDECL CreateFX(REFCLSID clsid, IUnknown **out)
120 HRESULT hr;
121 IUnknown *obj;
122 const GUID *class = NULL;
123 IClassFactory *cf;
125 TRACE("%s %p\n", debugstr_guid(clsid), out);
127 *out = NULL;
129 if(IsEqualGUID(clsid, &CLSID_FXReverb27) ||
130 IsEqualGUID(clsid, &CLSID_FXReverb))
131 class = &CLSID_FXReverb;
132 else if(IsEqualGUID(clsid, &CLSID_FXEQ27) ||
133 IsEqualGUID(clsid, &CLSID_FXEQ))
134 class = &CLSID_FXEQ;
135 else if(IsEqualGUID(clsid, &CLSID_FXEcho27) ||
136 IsEqualGUID(clsid, &CLSID_FXEcho))
137 class = &CLSID_FXEcho;
138 else if(IsEqualGUID(clsid, &CLSID_FXMasteringLimiter27) ||
139 IsEqualGUID(clsid, &CLSID_FXMasteringLimiter))
140 class = &CLSID_FXMasteringLimiter;
142 if(class){
143 hr = make_xapo_factory(class, &IID_IClassFactory, (void**)&cf);
144 if(FAILED(hr))
145 return hr;
147 hr = IClassFactory_CreateInstance(cf, NULL, &IID_IUnknown, (void**)&obj);
148 IClassFactory_Release(cf);
149 if(FAILED(hr))
150 return hr;
151 }else{
152 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void**)&obj);
153 if(FAILED(hr)){
154 WARN("CoCreateInstance failed: %08x\n", hr);
155 return hr;
159 *out = obj;
161 return S_OK;
163 #endif /* XAPOFX1_VER */