jscript: Support also VT_UI4 in debugstr_variant.
[wine/multimedia.git] / dlls / dmloader / classfactory.c
blob266e713454807a4b47a96deb2e65facaea861f0f
1 /* IDirectMusicLoaderCF
2 * IDirectMusicContainerCF
4 * Copyright (C) 2004 Rok Mandeljc
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "dmloader_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmloader);
25 /*****************************************************************************
26 * IDirectMusicLoaderCF implementation
28 static ULONG WINAPI IDirectMusicLoaderCF_AddRef (LPCLASSFACTORY iface);
30 static HRESULT WINAPI IDirectMusicLoaderCF_QueryInterface (LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj) {
31 IDirectMusicLoaderCF *This = (IDirectMusicLoaderCF *)iface;
33 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
34 if (IsEqualIID (riid, &IID_IUnknown) ||
35 IsEqualIID (riid, &IID_IClassFactory)) {
36 IDirectMusicLoaderCF_AddRef (iface);
37 *ppobj = This;
38 return S_OK;
41 WARN(": not found\n");
42 return E_NOINTERFACE;
45 static ULONG WINAPI IDirectMusicLoaderCF_AddRef (LPCLASSFACTORY iface) {
46 IDirectMusicLoaderCF *This = (IDirectMusicLoaderCF *)iface;
47 TRACE("(%p): AddRef from %d\n", This, This->dwRef);
48 return InterlockedIncrement (&This->dwRef);
51 static ULONG WINAPI IDirectMusicLoaderCF_Release (LPCLASSFACTORY iface) {
52 IDirectMusicLoaderCF *This = (IDirectMusicLoaderCF *)iface;
54 DWORD dwRef = InterlockedDecrement (&This->dwRef);
55 TRACE("(%p): ReleaseRef to %d\n", This, dwRef);
56 if (dwRef == 0) {
57 HeapFree(GetProcessHeap (), 0, This);
58 /* decrease number of instances */
59 InterlockedDecrement(&dwDirectMusicLoader);
62 return dwRef;
65 static HRESULT WINAPI IDirectMusicLoaderCF_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
66 IDirectMusicLoaderCF *This = (IDirectMusicLoaderCF *)iface;
68 TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
69 if (pOuter) {
70 ERR(": pOuter should be NULL\n");
71 return CLASS_E_NOAGGREGATION;
74 return DMUSIC_CreateDirectMusicLoaderImpl (riid, ppobj, pOuter);
77 static HRESULT WINAPI IDirectMusicLoaderCF_LockServer (LPCLASSFACTORY iface, BOOL dolock) {
78 IDirectMusicLoaderCF *This = (IDirectMusicLoaderCF *)iface;
79 TRACE("(%p, %d)\n", This, dolock);
80 if (dolock)
81 InterlockedIncrement (&dwDirectMusicLoader);
82 else
83 InterlockedDecrement (&dwDirectMusicLoader);
84 return S_OK;
87 static const IClassFactoryVtbl DirectMusicLoaderCF_Vtbl = {
88 IDirectMusicLoaderCF_QueryInterface,
89 IDirectMusicLoaderCF_AddRef,
90 IDirectMusicLoaderCF_Release,
91 IDirectMusicLoaderCF_CreateInstance,
92 IDirectMusicLoaderCF_LockServer
95 HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderCF (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
96 IDirectMusicLoaderCF *obj;
98 TRACE("(%s, %p, %p)\n", debugstr_dmguid(lpcGUID), ppobj, pUnkOuter);
99 obj = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoaderCF));
100 if (NULL == obj) {
101 *ppobj = NULL;
102 return E_OUTOFMEMORY;
104 obj->lpVtbl = &DirectMusicLoaderCF_Vtbl;
105 obj->dwRef = 0; /* will be inited with QueryInterface */
107 /* increase number of instances */
108 InterlockedIncrement (&dwDirectMusicLoader);
110 return IDirectMusicLoaderCF_QueryInterface ((LPCLASSFACTORY)obj, lpcGUID, ppobj);
114 /*****************************************************************************
115 * IDirectMusicContainerCF implementation
117 static ULONG WINAPI IDirectMusicContainerCF_AddRef (LPCLASSFACTORY iface);
119 static HRESULT WINAPI IDirectMusicContainerCF_QueryInterface (LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj) {
120 IDirectMusicContainerCF *This = (IDirectMusicContainerCF *)iface;
122 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
123 if (IsEqualIID (riid, &IID_IUnknown) ||
124 IsEqualIID (riid, &IID_IClassFactory)) {
125 IDirectMusicContainerCF_AddRef (iface);
126 *ppobj = This;
127 return S_OK;
130 WARN(": not found\n");
131 return E_NOINTERFACE;
134 static ULONG WINAPI IDirectMusicContainerCF_AddRef (LPCLASSFACTORY iface) {
135 IDirectMusicContainerCF *This = (IDirectMusicContainerCF *)iface;
136 TRACE("(%p): AddRef from %d\n", This, This->dwRef);
137 return InterlockedIncrement (&This->dwRef);
140 static ULONG WINAPI IDirectMusicContainerCF_Release (LPCLASSFACTORY iface) {
141 IDirectMusicContainerCF *This = (IDirectMusicContainerCF *)iface;
143 DWORD dwRef = InterlockedDecrement (&This->dwRef);
144 TRACE("(%p): ReleaseRef to %d\n", This, dwRef);
145 if (dwRef == 0) {
146 HeapFree(GetProcessHeap (), 0, This);
147 /* decrease number of instances */
148 InterlockedDecrement(&dwDirectMusicContainer);
151 return dwRef;
154 static HRESULT WINAPI IDirectMusicContainerCF_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
155 IDirectMusicContainerCF *This = (IDirectMusicContainerCF *)iface;
157 TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
158 if (pOuter) {
159 ERR(": pOuter should be NULL\n");
160 return CLASS_E_NOAGGREGATION;
163 return DMUSIC_CreateDirectMusicContainerImpl (riid, ppobj, pOuter);
166 static HRESULT WINAPI IDirectMusicContainerCF_LockServer (LPCLASSFACTORY iface, BOOL dolock) {
167 IDirectMusicContainerCF *This = (IDirectMusicContainerCF *)iface;
168 TRACE("(%p, %d)\n", This, dolock);
169 if (dolock)
170 InterlockedIncrement (&dwDirectMusicContainer);
171 else
172 InterlockedDecrement (&dwDirectMusicContainer);
173 return S_OK;
176 static const IClassFactoryVtbl DirectMusicContainerCF_Vtbl = {
177 IDirectMusicContainerCF_QueryInterface,
178 IDirectMusicContainerCF_AddRef,
179 IDirectMusicContainerCF_Release,
180 IDirectMusicContainerCF_CreateInstance,
181 IDirectMusicContainerCF_LockServer
184 HRESULT WINAPI DMUSIC_CreateDirectMusicContainerCF (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
185 IDirectMusicContainerCF *obj;
187 TRACE("(%s, %p, %p)\n", debugstr_dmguid(lpcGUID), ppobj, pUnkOuter);
188 obj = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerCF));
189 if (NULL == obj) {
190 *ppobj = NULL;
191 return E_OUTOFMEMORY;
193 obj->lpVtbl = &DirectMusicContainerCF_Vtbl;
194 obj->dwRef = 0; /* will be inited with QueryInterface */
196 /* increase number of instances */
197 InterlockedIncrement (&dwDirectMusicContainer);
199 return IDirectMusicContainerCF_QueryInterface ((LPCLASSFACTORY)obj, lpcGUID, ppobj);