po: Update Finnish translation.
[wine.git] / dlls / dswave / dswave_main.c
blob81dcc73de85602a51ef78f669e39e8602eb5ff57
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 LONG DSWAVE_refCount = 0;
44 typedef struct {
45 IClassFactory IClassFactory_iface;
46 } IClassFactoryImpl;
48 /******************************************************************
49 * DirectMusicWave ClassFactory
51 static HRESULT WINAPI WaveCF_QueryInterface(IClassFactory * iface, REFIID riid, void **ppv)
53 if (ppv == NULL)
54 return E_POINTER;
56 if (IsEqualGUID(&IID_IUnknown, riid))
57 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
58 else if (IsEqualGUID(&IID_IClassFactory, riid))
59 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
60 else {
61 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
62 *ppv = NULL;
63 return E_NOINTERFACE;
66 *ppv = iface;
67 IUnknown_AddRef((IUnknown*)*ppv);
68 return S_OK;
71 static ULONG WINAPI WaveCF_AddRef(IClassFactory * iface)
73 DSWAVE_LockModule();
75 return 2; /* non-heap based object */
78 static ULONG WINAPI WaveCF_Release(IClassFactory * iface)
80 DSWAVE_UnlockModule();
82 return 1; /* non-heap based object */
85 static HRESULT WINAPI WaveCF_CreateInstance(IClassFactory * iface, IUnknown *outer_unk, REFIID riid,
86 void **ret_iface)
88 TRACE ("(%p, %s, %p)\n", outer_unk, debugstr_dmguid(riid), ret_iface);
90 if (outer_unk) {
91 *ret_iface = NULL;
92 return CLASS_E_NOAGGREGATION;
95 return create_dswave(riid, ret_iface);
98 static HRESULT WINAPI WaveCF_LockServer(IClassFactory * iface, BOOL dolock)
100 TRACE("(%d)\n", dolock);
102 if (dolock)
103 DSWAVE_LockModule();
104 else
105 DSWAVE_UnlockModule();
107 return S_OK;
110 static const IClassFactoryVtbl WaveCF_Vtbl = {
111 WaveCF_QueryInterface,
112 WaveCF_AddRef,
113 WaveCF_Release,
114 WaveCF_CreateInstance,
115 WaveCF_LockServer
118 static IClassFactoryImpl Wave_CF = {{&WaveCF_Vtbl}};
120 /******************************************************************
121 * DllCanUnloadNow (DSWAVE.@)
125 HRESULT WINAPI DllCanUnloadNow(void)
127 return DSWAVE_refCount != 0 ? S_FALSE : S_OK;
131 /******************************************************************
132 * DllGetClassObject (DSWAVE.@)
136 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
138 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
139 if (IsEqualCLSID (rclsid, &CLSID_DirectSoundWave) && IsEqualIID (riid, &IID_IClassFactory)) {
140 *ppv = &Wave_CF;
141 IClassFactory_AddRef((IClassFactory*)*ppv);
142 return S_OK;
145 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
146 return CLASS_E_CLASSNOTAVAILABLE;