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
37 #include "dswave_private.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(dswave
);
42 static HINSTANCE instance
;
43 LONG DSWAVE_refCount
= 0;
46 IClassFactory IClassFactory_iface
;
49 /******************************************************************
50 * DirectMusicWave ClassFactory
52 static HRESULT WINAPI
WaveCF_QueryInterface(IClassFactory
* iface
, REFIID riid
, void **ppv
)
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
);
62 FIXME("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
68 IUnknown_AddRef((IUnknown
*)*ppv
);
72 static ULONG WINAPI
WaveCF_AddRef(IClassFactory
* iface
)
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
,
89 TRACE ("(%p, %s, %p)\n", outer_unk
, debugstr_dmguid(riid
), ret_iface
);
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
);
106 DSWAVE_UnlockModule();
111 static const IClassFactoryVtbl WaveCF_Vtbl
= {
112 WaveCF_QueryInterface
,
115 WaveCF_CreateInstance
,
119 static IClassFactoryImpl Wave_CF
= {{&WaveCF_Vtbl
}};
121 /******************************************************************
126 BOOL WINAPI
DllMain (HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
) {
127 if (fdwReason
== DLL_PROCESS_ATTACH
) {
129 DisableThreadLibraryCalls(hinstDLL
);
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
)) {
157 IClassFactory_AddRef((IClassFactory
*)*ppv
);
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
);