mf/session: Forward more events to the application.
[wine/zf.git] / dlls / dswave / dswave_main.c
blob12df6da86189e9db408ed5e36b286869a3e3accc
1 /* DirectMusic Wave 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
21 #include <stdio.h>
22 #include <stdarg.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winnt.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "winreg.h"
32 #include "objbase.h"
33 #include "rpcproxy.h"
34 #include "initguid.h"
35 #include "dmusici.h"
37 #include "dswave_private.h"
38 #include "dmobject.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(dswave);
42 static HINSTANCE instance;
43 LONG DSWAVE_refCount = 0;
45 typedef struct {
46 IClassFactory IClassFactory_iface;
47 } IClassFactoryImpl;
49 /******************************************************************
50 * DirectMusicWave ClassFactory
52 static HRESULT WINAPI WaveCF_QueryInterface(IClassFactory * iface, REFIID riid, void **ppv)
54 if (ppv == NULL)
55 return E_POINTER;
57 if (IsEqualGUID(&IID_IUnknown, riid))
58 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
59 else if (IsEqualGUID(&IID_IClassFactory, riid))
60 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
61 else {
62 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
63 *ppv = NULL;
64 return E_NOINTERFACE;
67 *ppv = iface;
68 IUnknown_AddRef((IUnknown*)*ppv);
69 return S_OK;
72 static ULONG WINAPI WaveCF_AddRef(IClassFactory * iface)
74 DSWAVE_LockModule();
76 return 2; /* non-heap based object */
79 static ULONG WINAPI WaveCF_Release(IClassFactory * iface)
81 DSWAVE_UnlockModule();
83 return 1; /* non-heap based object */
86 static HRESULT WINAPI WaveCF_CreateInstance(IClassFactory * iface, IUnknown *outer_unk, REFIID riid,
87 void **ret_iface)
89 TRACE ("(%p, %s, %p)\n", outer_unk, debugstr_dmguid(riid), ret_iface);
91 if (outer_unk) {
92 *ret_iface = NULL;
93 return CLASS_E_NOAGGREGATION;
96 return create_dswave(riid, ret_iface);
99 static HRESULT WINAPI WaveCF_LockServer(IClassFactory * iface, BOOL dolock)
101 TRACE("(%d)\n", dolock);
103 if (dolock)
104 DSWAVE_LockModule();
105 else
106 DSWAVE_UnlockModule();
108 return S_OK;
111 static const IClassFactoryVtbl WaveCF_Vtbl = {
112 WaveCF_QueryInterface,
113 WaveCF_AddRef,
114 WaveCF_Release,
115 WaveCF_CreateInstance,
116 WaveCF_LockServer
119 static IClassFactoryImpl Wave_CF = {{&WaveCF_Vtbl}};
121 /******************************************************************
122 * DllMain
126 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
127 if (fdwReason == DLL_PROCESS_ATTACH) {
128 instance = hinstDLL;
129 DisableThreadLibraryCalls(hinstDLL);
132 return TRUE;
136 /******************************************************************
137 * DllCanUnloadNow (DSWAVE.@)
141 HRESULT WINAPI DllCanUnloadNow(void)
143 return DSWAVE_refCount != 0 ? S_FALSE : S_OK;
147 /******************************************************************
148 * DllGetClassObject (DSWAVE.@)
152 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
154 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
155 if (IsEqualCLSID (rclsid, &CLSID_DirectSoundWave) && IsEqualIID (riid, &IID_IClassFactory)) {
156 *ppv = &Wave_CF;
157 IClassFactory_AddRef((IClassFactory*)*ppv);
158 return S_OK;
161 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
162 return CLASS_E_CLASSNOTAVAILABLE;
165 /***********************************************************************
166 * DllRegisterServer (DSWAVE.@)
168 HRESULT WINAPI DllRegisterServer(void)
170 return __wine_register_resources( instance );
173 /***********************************************************************
174 * DllUnregisterServer (DSWAVE.@)
176 HRESULT WINAPI DllUnregisterServer(void)
178 return __wine_unregister_resources( instance );