Dump HeapWalk entries.
[wine/multimedia.git] / dlls / quartz / main.c
blobb3c40989b63321d80ce13d62aee9df1798d8aed1
1 /* DirectShow Base Functions (QUARTZ.DLL)
3 * Copyright 2002 Lionel Ulmer
5 * This file contains the (internal) driver registration functions,
6 * driver enumeration APIs and DirectDraw creation functions.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "config.h"
24 #include "wine/debug.h"
26 #include "quartz_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
30 static DWORD dll_ref = 0;
32 /* For the moment, do nothing here. */
33 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
35 switch(fdwReason) {
36 case DLL_PROCESS_ATTACH:
37 DisableThreadLibraryCalls(hInstDLL);
38 break;
39 case DLL_PROCESS_DETACH:
40 break;
42 return TRUE;
45 /******************************************************************************
46 * DirectShow ClassFactory
48 typedef struct {
49 IClassFactory ITF_IClassFactory;
51 DWORD ref;
52 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
53 } IClassFactoryImpl;
55 struct object_creation_info
57 const CLSID *clsid;
58 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
61 static const struct object_creation_info object_creation[] =
63 { &CLSID_FilterGraph, FILTERGRAPH_create },
64 { &CLSID_FilterMapper, FilterMapper2_create },
65 { &CLSID_FilterMapper2, FilterMapper2_create },
66 { &CLSID_AsyncReader, AsyncReader_create },
67 { &CLSID_MemoryAllocator, StdMemAllocator_create },
68 { &CLSID_AviSplitter, AVISplitter_create },
69 { &CLSID_VideoRenderer, VideoRenderer_create },
70 { &CLSID_DSoundRender, DSoundRender_create },
71 { &CLSID_AVIDec, AVIDec_create },
72 { &CLSID_SystemClock, &QUARTZ_CreateSystemClock },
73 { &CLSID_ACMWrapper, &ACMWrapper_create },
74 { &CLSID_WAVEParser, &WAVEParser_create }
77 static HRESULT WINAPI
78 DSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
80 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
82 if (IsEqualGUID(riid, &IID_IUnknown)
83 || IsEqualGUID(riid, &IID_IClassFactory))
85 IClassFactory_AddRef(iface);
86 *ppobj = This;
87 return S_OK;
90 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
91 return E_NOINTERFACE;
94 static ULONG WINAPI DSCF_AddRef(LPCLASSFACTORY iface)
96 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
97 return InterlockedIncrement(&This->ref);
100 static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface)
102 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
104 ULONG ref = InterlockedDecrement(&This->ref);
106 if (ref == 0)
107 HeapFree(GetProcessHeap(), 0, This);
109 return ref;
113 static HRESULT WINAPI DSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
114 REFIID riid, LPVOID *ppobj)
116 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
117 HRESULT hres;
118 LPUNKNOWN punk;
120 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
122 *ppobj = NULL;
123 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
124 if (SUCCEEDED(hres)) {
125 hres = IUnknown_QueryInterface(punk, riid, ppobj);
126 IUnknown_Release(punk);
128 return hres;
131 static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
133 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
134 FIXME("(%p)->(%d),stub!\n",This,dolock);
135 return S_OK;
138 static IClassFactoryVtbl DSCF_Vtbl =
140 DSCF_QueryInterface,
141 DSCF_AddRef,
142 DSCF_Release,
143 DSCF_CreateInstance,
144 DSCF_LockServer
147 /*******************************************************************************
148 * DllGetClassObject [QUARTZ.@]
149 * Retrieves class object from a DLL object
151 * NOTES
152 * Docs say returns STDAPI
154 * PARAMS
155 * rclsid [I] CLSID for the class object
156 * riid [I] Reference to identifier of interface for class object
157 * ppv [O] Address of variable to receive interface pointer for riid
159 * RETURNS
160 * Success: S_OK
161 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
162 * E_UNEXPECTED
164 DWORD WINAPI QUARTZ_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
166 unsigned int i;
167 IClassFactoryImpl *factory;
169 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
171 if ( !IsEqualGUID( &IID_IClassFactory, riid )
172 && ! IsEqualGUID( &IID_IUnknown, riid) )
173 return E_NOINTERFACE;
175 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
177 if (IsEqualGUID(object_creation[i].clsid, rclsid))
178 break;
181 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
183 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
184 return CLASS_E_CLASSNOTAVAILABLE;
187 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
188 if (factory == NULL) return E_OUTOFMEMORY;
190 factory->ITF_IClassFactory.lpVtbl = &DSCF_Vtbl;
191 factory->ref = 1;
193 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
195 *ppv = &(factory->ITF_IClassFactory);
196 return S_OK;
199 /***********************************************************************
200 * DllCanUnloadNow (QUARTZ.@)
202 HRESULT WINAPI QUARTZ_DllCanUnloadNow()
204 return dll_ref != 0 ? S_FALSE : S_OK;
208 #define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
209 { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } , #name },
211 static struct {
212 const GUID riid;
213 const char *name;
214 } InterfaceDesc[] =
216 #include "uuids.h"
217 { { 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} }, NULL }
220 /***********************************************************************
221 * qzdebugstr_guid (internal)
223 * Gives a text version of DirectShow GUIDs
225 const char * qzdebugstr_guid( const GUID * id )
227 int i;
228 char * name = NULL;
230 for (i=0;InterfaceDesc[i].name && !name;i++) {
231 if (IsEqualGUID(&InterfaceDesc[i].riid, id)) return InterfaceDesc[i].name;
233 return debugstr_guid(id);
236 /***********************************************************************
237 * qzdebugstr_State (internal)
239 * Gives a text version of the FILTER_STATE enumeration
241 const char * qzdebugstr_State(FILTER_STATE state)
243 switch (state)
245 case State_Stopped:
246 return "State_Stopped";
247 case State_Running:
248 return "State_Running";
249 case State_Paused:
250 return "State_Paused";
251 default:
252 return "State_Unknown";
256 LONG WINAPI AmpFactorToDB(LONG ampfactor)
258 FIXME("(%ld) Stub!\n", ampfactor);
259 return 0;
262 LONG WINAPI DBToAmpFactor(LONG db)
264 FIXME("(%ld) Stub!\n", db);
265 /* Avoid divide by zero (probably during range computation) in Windows Media Player 6.4 */
266 if (db < -1000)
267 return 0;
268 return 100;