d3dcompiler/tests: Add a couple more checks for parent data values.
[wine/multimedia.git] / dlls / mstask / factory.c
blobf85a5f9c11c821d7b24f945178af0f04f75d0a31
1 /*
2 * Copyright (C) 2008 Google (Roy Shea)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "mstask_private.h"
20 #include "wine/debug.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(mstask);
24 struct ClassFactoryImpl
26 IClassFactory IClassFactory_iface;
27 LONG ref;
30 static inline ClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
32 return CONTAINING_RECORD(iface, ClassFactoryImpl, IClassFactory_iface);
35 static HRESULT WINAPI MSTASK_IClassFactory_QueryInterface(
36 LPCLASSFACTORY iface,
37 REFIID riid,
38 LPVOID *ppvObj)
40 ClassFactoryImpl *This = impl_from_IClassFactory(iface);
42 TRACE("IID: %s\n",debugstr_guid(riid));
43 if (ppvObj == NULL)
44 return E_POINTER;
46 if (IsEqualGUID(riid, &IID_IUnknown) ||
47 IsEqualGUID(riid, &IID_IClassFactory))
49 *ppvObj = &This->IClassFactory_iface;
50 IClassFactory_AddRef(iface);
51 return S_OK;
54 WARN("Unknown interface: %s\n", debugstr_guid(riid));
55 *ppvObj = NULL;
56 return E_NOINTERFACE;
59 static ULONG WINAPI MSTASK_IClassFactory_AddRef(IClassFactory *face)
61 TRACE("\n");
62 InterlockedIncrement(&dll_ref);
63 return 2;
66 static ULONG WINAPI MSTASK_IClassFactory_Release(IClassFactory *iface)
68 TRACE("\n");
69 InterlockedDecrement(&dll_ref);
70 return 1;
73 static HRESULT WINAPI MSTASK_IClassFactory_CreateInstance(
74 IClassFactory *iface,
75 IUnknown *pUnkOuter,
76 REFIID riid,
77 LPVOID *ppvObj)
79 HRESULT res;
80 IUnknown *punk = NULL;
81 *ppvObj = NULL;
83 TRACE("IID: %s\n",debugstr_guid(riid));
85 if (pUnkOuter)
86 return CLASS_E_NOAGGREGATION;
88 res = TaskSchedulerConstructor((LPVOID*) &punk);
89 if (FAILED(res))
90 return res;
92 res = IUnknown_QueryInterface(punk, riid, ppvObj);
93 IUnknown_Release(punk);
94 return res;
97 static HRESULT WINAPI MSTASK_IClassFactory_LockServer(
98 IClassFactory *iface,
99 BOOL fLock)
101 TRACE("\n");
103 if (fLock)
104 IClassFactory_AddRef(iface);
105 else
106 IClassFactory_Release(iface);
107 return S_OK;
110 static const IClassFactoryVtbl IClassFactory_Vtbl =
112 MSTASK_IClassFactory_QueryInterface,
113 MSTASK_IClassFactory_AddRef,
114 MSTASK_IClassFactory_Release,
115 MSTASK_IClassFactory_CreateInstance,
116 MSTASK_IClassFactory_LockServer
119 ClassFactoryImpl MSTASK_ClassFactory = { { &IClassFactory_Vtbl } };