d3d8: Use the private store api for surfaces.
[wine/multimedia.git] / dlls / dmstyle / dmstyle_main.c
blobb76fa739ab55558d069ba72e2f68c1e3affe29d3
1 /* DirectMusicStyle 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 "dmstyle_private.h"
21 #include "rpcproxy.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
25 static HINSTANCE instance;
26 LONG DMSTYLE_refCount = 0;
28 typedef struct {
29 IClassFactory IClassFactory_iface;
30 HRESULT WINAPI (*fnCreateInstance)(REFIID riid, void **ret_iface);
31 } IClassFactoryImpl;
33 static HRESULT WINAPI create_direct_music_section(REFIID riid, void **ret_iface)
35 FIXME("(%s, %p) stub\n", debugstr_dmguid(riid), ret_iface);
37 return CLASS_E_CLASSNOTAVAILABLE;
40 /******************************************************************
41 * IClassFactory implementation
43 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
45 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
48 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
50 if (ppv == NULL)
51 return E_POINTER;
53 if (IsEqualGUID(&IID_IUnknown, riid))
54 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
55 else if (IsEqualGUID(&IID_IClassFactory, riid))
56 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
57 else {
58 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
59 *ppv = NULL;
60 return E_NOINTERFACE;
63 *ppv = iface;
64 IUnknown_AddRef((IUnknown*)*ppv);
65 return S_OK;
68 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
70 DMSTYLE_LockModule();
72 return 2; /* non-heap based object */
75 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
77 DMSTYLE_UnlockModule();
79 return 1; /* non-heap based object */
82 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
83 REFIID riid, void **ppv)
85 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
87 TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
89 if (pUnkOuter) {
90 *ppv = NULL;
91 return CLASS_E_NOAGGREGATION;
94 return This->fnCreateInstance(riid, ppv);
97 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
99 TRACE("(%d)\n", dolock);
101 if (dolock)
102 DMSTYLE_LockModule();
103 else
104 DMSTYLE_UnlockModule();
106 return S_OK;
109 static const IClassFactoryVtbl classfactory_vtbl = {
110 ClassFactory_QueryInterface,
111 ClassFactory_AddRef,
112 ClassFactory_Release,
113 ClassFactory_CreateInstance,
114 ClassFactory_LockServer
117 static IClassFactoryImpl Section_CF = {{&classfactory_vtbl}, create_direct_music_section};
118 static IClassFactoryImpl Style_CF = {{&classfactory_vtbl}, create_dmstyle};
119 static IClassFactoryImpl ChordTrack_CF = {{&classfactory_vtbl}, create_dmchordtrack};
120 static IClassFactoryImpl CommandTrack_CF = {{&classfactory_vtbl}, create_dmcommandtrack};
121 static IClassFactoryImpl StyleTrack_CF = {{&classfactory_vtbl}, create_dmstyletrack};
122 static IClassFactoryImpl MotifTrack_CF = {{&classfactory_vtbl}, create_dmmotiftrack};
123 static IClassFactoryImpl AuditionTrack_CF = {{&classfactory_vtbl}, create_dmauditiontrack};
124 static IClassFactoryImpl MuteTrack_CF = {{&classfactory_vtbl}, create_dmmutetrack};
126 /******************************************************************
127 * DllMain
131 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
132 if (fdwReason == DLL_PROCESS_ATTACH) {
133 instance = hinstDLL;
134 DisableThreadLibraryCalls(hinstDLL);
137 return TRUE;
141 /******************************************************************
142 * DllCanUnloadNow (DMSTYLE.1)
146 HRESULT WINAPI DllCanUnloadNow(void) {
147 return DMSTYLE_refCount != 0 ? S_FALSE : S_OK;
151 /******************************************************************
152 * DllGetClassObject (DMSTYLE.@)
156 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
157 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
159 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicSection) && IsEqualIID (riid, &IID_IClassFactory)) {
160 *ppv = &Section_CF;
161 IClassFactory_AddRef((IClassFactory*)*ppv);
162 return S_OK;
163 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicStyle) && IsEqualIID (riid, &IID_IClassFactory)) {
164 *ppv = &Style_CF;
165 IClassFactory_AddRef((IClassFactory*)*ppv);
166 return S_OK;
167 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicChordTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
168 *ppv = &ChordTrack_CF;
169 IClassFactory_AddRef((IClassFactory*)*ppv);
170 return S_OK;
171 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicCommandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
172 *ppv = &CommandTrack_CF;
173 IClassFactory_AddRef((IClassFactory*)*ppv);
174 return S_OK;
175 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicStyleTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
176 *ppv = &StyleTrack_CF;
177 IClassFactory_AddRef((IClassFactory*)*ppv);
178 return S_OK;
179 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMotifTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
180 *ppv = &MotifTrack_CF;
181 IClassFactory_AddRef((IClassFactory*)*ppv);
182 return S_OK;
183 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicAuditionTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
184 *ppv = &AuditionTrack_CF;
185 IClassFactory_AddRef((IClassFactory*)*ppv);
186 return S_OK;
187 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicMuteTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
188 *ppv = &MuteTrack_CF;
189 IClassFactory_AddRef((IClassFactory*)*ppv);
190 return S_OK;
193 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
194 return CLASS_E_CLASSNOTAVAILABLE;
197 /***********************************************************************
198 * DllRegisterServer (DMSTYLE.@)
200 HRESULT WINAPI DllRegisterServer(void)
202 return __wine_register_resources( instance );
205 /***********************************************************************
206 * DllUnregisterServer (DMSTYLE.@)
208 HRESULT WINAPI DllUnregisterServer(void)
210 return __wine_unregister_resources( instance );