ntdll: Use cpu_info to check for AVX availability.
[wine/zf.git] / dlls / dmband / dmband_main.c
blobbaf36a3d6a916130f0339225af06c2328b4e8313
1 /* DirectMusicBand Main
3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program 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 program 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 program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "dmband_private.h"
21 #include "rpcproxy.h"
22 #include "dmobject.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(dmband);
26 static HINSTANCE instance;
27 LONG DMBAND_refCount = 0;
29 typedef struct {
30 IClassFactory IClassFactory_iface;
31 HRESULT WINAPI (*fnCreateInstance)(REFIID riid, void **ret_iface);
32 } IClassFactoryImpl;
34 /******************************************************************
35 * IClassFactory implementation
37 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
39 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
42 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
44 if (ppv == NULL)
45 return E_POINTER;
47 if (IsEqualGUID(&IID_IUnknown, riid))
48 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
49 else if (IsEqualGUID(&IID_IClassFactory, riid))
50 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
51 else {
52 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
53 *ppv = NULL;
54 return E_NOINTERFACE;
57 *ppv = iface;
58 IClassFactory_AddRef(iface);
59 return S_OK;
62 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
64 DMBAND_LockModule();
66 return 2; /* non-heap based object */
69 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
71 DMBAND_UnlockModule();
73 return 1; /* non-heap based object */
76 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
77 REFIID riid, void **ppv)
79 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
81 TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
83 if (pUnkOuter) {
84 *ppv = NULL;
85 return CLASS_E_NOAGGREGATION;
88 return This->fnCreateInstance(riid, ppv);
91 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
93 TRACE("(%d)\n", dolock);
95 if (dolock)
96 DMBAND_LockModule();
97 else
98 DMBAND_UnlockModule();
100 return S_OK;
103 static const IClassFactoryVtbl classfactory_vtbl = {
104 ClassFactory_QueryInterface,
105 ClassFactory_AddRef,
106 ClassFactory_Release,
107 ClassFactory_CreateInstance,
108 ClassFactory_LockServer
111 static IClassFactoryImpl Band_CF = {{&classfactory_vtbl}, create_dmband};
112 static IClassFactoryImpl BandTrack_CF = {{&classfactory_vtbl}, create_dmbandtrack};
114 /******************************************************************
115 * DllMain
119 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
120 if (fdwReason == DLL_PROCESS_ATTACH) {
121 instance = hinstDLL;
122 DisableThreadLibraryCalls(hinstDLL);
125 return TRUE;
129 /******************************************************************
130 * DllCanUnloadNow (DMBAND.@)
134 HRESULT WINAPI DllCanUnloadNow(void)
136 return DMBAND_refCount != 0 ? S_FALSE : S_OK;
140 /******************************************************************
141 * DllGetClassObject (DMBAND.@)
145 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
147 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
149 if (IsEqualCLSID(rclsid, &CLSID_DirectMusicBand))
150 return IClassFactory_QueryInterface(&Band_CF.IClassFactory_iface, riid, ppv);
151 else if (IsEqualCLSID(rclsid, &CLSID_DirectMusicBandTrack))
152 return IClassFactory_QueryInterface(&BandTrack_CF.IClassFactory_iface, riid, ppv);
154 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
155 return CLASS_E_CLASSNOTAVAILABLE;
158 /***********************************************************************
159 * DllRegisterServer (DMBAND.@)
161 HRESULT WINAPI DllRegisterServer(void)
163 return __wine_register_resources( instance );
166 /***********************************************************************
167 * DllUnregisterServer (DMBAND.@)
169 HRESULT WINAPI DllUnregisterServer(void)
171 return __wine_unregister_resources( instance );