user32: Add a bunch of tests for GetQueueStatus and GetMessage combinations.
[wine/multimedia.git] / dlls / quartz / main.c
blobdaefdc508acd28c62b5591139ca19ba5b6c920e5
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 LONG 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_SeekingPassThru, SeekingPassThru_create },
64 { &CLSID_FilterGraph, FilterGraph_create },
65 { &CLSID_FilterGraphNoThread, FilterGraphNoThread_create },
66 { &CLSID_FilterMapper, FilterMapper_create },
67 { &CLSID_FilterMapper2, FilterMapper2_create },
68 { &CLSID_AsyncReader, AsyncReader_create },
69 { &CLSID_MemoryAllocator, StdMemAllocator_create },
70 { &CLSID_AviSplitter, AVISplitter_create },
71 { &CLSID_MPEG1Splitter, MPEGSplitter_create },
72 { &CLSID_VideoRenderer, VideoRenderer_create },
73 { &CLSID_NullRenderer, NullRenderer_create },
74 { &CLSID_VideoRendererDefault, VideoRendererDefault_create },
75 { &CLSID_DSoundRender, DSoundRender_create },
76 { &CLSID_AudioRender, DSoundRender_create },
77 { &CLSID_AVIDec, AVIDec_create },
78 { &CLSID_SystemClock, QUARTZ_CreateSystemClock },
79 { &CLSID_ACMWrapper, ACMWrapper_create },
80 { &CLSID_WAVEParser, WAVEParser_create }
83 static HRESULT WINAPI
84 DSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
86 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
88 if (IsEqualGUID(riid, &IID_IUnknown)
89 || IsEqualGUID(riid, &IID_IClassFactory))
91 IClassFactory_AddRef(iface);
92 *ppobj = This;
93 return S_OK;
96 *ppobj = NULL;
97 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
98 return E_NOINTERFACE;
101 static ULONG WINAPI DSCF_AddRef(LPCLASSFACTORY iface)
103 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
104 return InterlockedIncrement(&This->ref);
107 static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface)
109 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
111 ULONG ref = InterlockedDecrement(&This->ref);
113 if (ref == 0)
114 CoTaskMemFree(This);
116 return ref;
120 static HRESULT WINAPI DSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
121 REFIID riid, LPVOID *ppobj)
123 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
124 HRESULT hres;
125 LPUNKNOWN punk;
127 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
129 *ppobj = NULL;
130 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
131 if (SUCCEEDED(hres)) {
132 hres = IUnknown_QueryInterface(punk, riid, ppobj);
133 IUnknown_Release(punk);
135 return hres;
138 static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
140 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
141 FIXME("(%p)->(%d),stub!\n",This,dolock);
142 return S_OK;
145 static const IClassFactoryVtbl DSCF_Vtbl =
147 DSCF_QueryInterface,
148 DSCF_AddRef,
149 DSCF_Release,
150 DSCF_CreateInstance,
151 DSCF_LockServer
154 /*******************************************************************************
155 * DllGetClassObject [QUARTZ.@]
156 * Retrieves class object from a DLL object
158 * NOTES
159 * Docs say returns STDAPI
161 * PARAMS
162 * rclsid [I] CLSID for the class object
163 * riid [I] Reference to identifier of interface for class object
164 * ppv [O] Address of variable to receive interface pointer for riid
166 * RETURNS
167 * Success: S_OK
168 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
169 * E_UNEXPECTED
171 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
173 unsigned int i;
174 IClassFactoryImpl *factory;
176 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
178 if ( !IsEqualGUID( &IID_IClassFactory, riid )
179 && ! IsEqualGUID( &IID_IUnknown, riid) )
180 return E_NOINTERFACE;
182 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
184 if (IsEqualGUID(object_creation[i].clsid, rclsid))
185 break;
188 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
190 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
191 return CLASS_E_CLASSNOTAVAILABLE;
194 factory = CoTaskMemAlloc(sizeof(*factory));
195 if (factory == NULL) return E_OUTOFMEMORY;
197 factory->ITF_IClassFactory.lpVtbl = &DSCF_Vtbl;
198 factory->ref = 1;
200 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
202 *ppv = &(factory->ITF_IClassFactory);
203 return S_OK;
206 /***********************************************************************
207 * DllCanUnloadNow (QUARTZ.@)
209 HRESULT WINAPI DllCanUnloadNow(void)
211 return dll_ref != 0 ? S_FALSE : S_OK;
215 #define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
216 { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } , #name },
218 static const struct {
219 const GUID riid;
220 const char *name;
221 } InterfaceDesc[] =
223 #include "uuids.h"
224 { { 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} }, NULL }
227 /***********************************************************************
228 * qzdebugstr_guid (internal)
230 * Gives a text version of DirectShow GUIDs
232 const char * qzdebugstr_guid( const GUID * id )
234 int i;
235 char * name = NULL;
237 for (i=0;InterfaceDesc[i].name && !name;i++) {
238 if (IsEqualGUID(&InterfaceDesc[i].riid, id)) return InterfaceDesc[i].name;
240 return debugstr_guid(id);
243 /***********************************************************************
244 * qzdebugstr_State (internal)
246 * Gives a text version of the FILTER_STATE enumeration
248 const char * qzdebugstr_State(FILTER_STATE state)
250 switch (state)
252 case State_Stopped:
253 return "State_Stopped";
254 case State_Running:
255 return "State_Running";
256 case State_Paused:
257 return "State_Paused";
258 default:
259 return "State_Unknown";
263 LONG WINAPI AmpFactorToDB(LONG ampfactor)
265 FIXME("(%d) Stub!\n", ampfactor);
266 return 0;
269 LONG WINAPI DBToAmpFactor(LONG db)
271 FIXME("(%d) Stub!\n", db);
272 /* Avoid divide by zero (probably during range computation) in Windows Media Player 6.4 */
273 if (db < -1000)
274 return 0;
275 return 100;
278 /***********************************************************************
279 * AMGetErrorTextA (QUARTZ.@)
281 DWORD WINAPI AMGetErrorTextA(HRESULT hr, LPSTR buffer, DWORD maxlen)
283 int len;
284 static const char format[] = "Error: 0x%x";
285 char error[MAX_ERROR_TEXT_LEN];
287 FIXME("(%x,%p,%d) stub\n", hr, buffer, maxlen);
289 if (!buffer) return 0;
290 wsprintfA(error, format, hr);
291 if ((len = lstrlenA(error)) >= maxlen) return 0;
292 lstrcpyA(buffer, error);
293 return len;
296 /***********************************************************************
297 * AMGetErrorTextW (QUARTZ.@)
299 DWORD WINAPI AMGetErrorTextW(HRESULT hr, LPWSTR buffer, DWORD maxlen)
301 int len;
302 static const WCHAR format[] = {'E','r','r','o','r',':',' ','0','x','%','l','x',0};
303 WCHAR error[MAX_ERROR_TEXT_LEN];
305 FIXME("(%x,%p,%d) stub\n", hr, buffer, maxlen);
307 if (!buffer) return 0;
308 wsprintfW(error, format, hr);
309 if ((len = lstrlenW(error)) >= maxlen) return 0;
310 lstrcpyW(buffer, error);
311 return len;