make it compile again :)
[wineasio.git] / main.c
blob2c4b3f5a5e258f54fd348d56393cc2945cf7badd
1 /*
2 * Copyright (C) 2006 Robert Reif
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 #include "windef.h"
22 #include "winbase.h"
23 #include "winuser.h"
24 #include "winreg.h"
25 #include "objbase.h"
27 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(asio);
30 /* {48D0C522-BFCC-45cc-8B84-17F25F33E6E8} */
31 static GUID const CLSID_WineASIO = {
32 0x48d0c522, 0xbfcc, 0x45cc, { 0x8b, 0x84, 0x17, 0xf2, 0x5f, 0x33, 0xe6, 0xe8 } };
34 typedef struct {
35 const IClassFactoryVtbl * lpVtbl;
36 LONG ref;
37 } IClassFactoryImpl;
39 extern HRESULT WINAPI WineASIOCreateInstance(REFIID riid, LPVOID *ppobj);
41 /*******************************************************************************
42 * ClassFactory
45 static HRESULT WINAPI CF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
47 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
48 FIXME("(%p, %s, %p) stub!\n", This, debugstr_guid(riid), ppobj);
49 if (ppobj == NULL)
50 return E_POINTER;
51 return E_NOINTERFACE;
54 static ULONG WINAPI CF_AddRef(LPCLASSFACTORY iface)
56 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
57 ULONG ref = InterlockedIncrement(&(This->ref));
58 TRACE("iface: %p, ref has been set to %x\n", This, ref);
59 return ref;
62 static ULONG WINAPI CF_Release(LPCLASSFACTORY iface)
64 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
65 ULONG ref = InterlockedDecrement(&(This->ref));
66 TRACE("iface %p, ref has been set to %x\n", This, ref);
67 /* static class, won't be freed */
68 return ref;
71 static HRESULT WINAPI CF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
73 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
74 TRACE("iface: %p, pOuter: %p, riid: %s, ppobj: %p)\n", This, pOuter, debugstr_guid(riid), ppobj);
76 if (pOuter)
77 return CLASS_E_NOAGGREGATION;
79 if (ppobj == NULL) {
80 WARN("invalid parameter\n");
81 return E_INVALIDARG;
84 *ppobj = NULL;
85 TRACE("Creating the WineASIO object\n");
86 return WineASIOCreateInstance(riid, ppobj);
89 static HRESULT WINAPI CF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
91 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
92 FIXME("iface: %p, dolock: %d) stub!\n", This, dolock);
93 return S_OK;
96 static const IClassFactoryVtbl CF_Vtbl = {
97 CF_QueryInterface,
98 CF_AddRef,
99 CF_Release,
100 CF_CreateInstance,
101 CF_LockServer
104 static IClassFactoryImpl WINEASIO_CF = { &CF_Vtbl, 1 };
106 /*******************************************************************************
107 * DllGetClassObject [DSOUND.@]
108 * Retrieves class object from a DLL object
110 * NOTES
111 * Docs say returns STDAPI
113 * PARAMS
114 * rclsid [I] CLSID for the class object
115 * riid [I] Reference to identifier of interface for class object
116 * ppv [O] Address of variable to receive interface pointer for riid
118 * RETURNS
119 * Success: S_OK
120 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
121 * E_UNEXPECTED
123 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
125 TRACE("rclsid: %s, riid: %s, ppv: %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
127 if (ppv == NULL) {
128 WARN("invalid parameter\n");
129 return E_INVALIDARG;
132 *ppv = NULL;
134 if (!IsEqualIID(riid, &IID_IClassFactory) && !IsEqualIID(riid, &IID_IUnknown))
136 WARN("no interface for %s\n", debugstr_guid(riid));
137 return E_NOINTERFACE;
140 if (IsEqualGUID(rclsid, &CLSID_WineASIO))
142 CF_AddRef((IClassFactory*) &WINEASIO_CF);
143 *ppv = &WINEASIO_CF;
144 return S_OK;
147 WARN("rclsid: %s, riid: %s, ppv: %p): no class found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
148 return CLASS_E_CLASSNOTAVAILABLE;
152 /*******************************************************************************
153 * DllCanUnloadNow
154 * Determines whether the DLL is in use.
156 * RETURNS
157 * Success: S_OK
158 * Failure: S_FALSE
160 HRESULT WINAPI DllCanUnloadNow(void)
162 FIXME("(void): stub\n");
163 return S_FALSE;
166 /***********************************************************************
167 * DllMain (ASIO.init)
169 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
171 TRACE("hInstDLL: %p, fdwReason: %x lpvReserved: %p)\n", hInstDLL, fdwReason, lpvReserved);
173 switch (fdwReason) {
174 case DLL_PROCESS_ATTACH:
175 /* TRACE("DLL_PROCESS_ATTACH\n"); */
176 break;
177 case DLL_PROCESS_DETACH:
178 /* TRACE("DLL_PROCESS_DETACH\n"); */
179 break;
180 case DLL_THREAD_ATTACH:
181 /* TRACE("DLL_THREAD_ATTACH\n"); */
182 break;
183 case DLL_THREAD_DETACH:
184 /* TRACE("DLL_THREAD_DETACH\n"); */
185 break;
186 default:
187 /* TRACE("UNKNOWN REASON\n"); */
188 break;
190 return TRUE;