Get rid of the no longer used ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
[wine/multimedia.git] / dlls / dmloader / classfactory.c
blobbbd80a4b1ce1980545f7b77f7c7322e63b557c09
1 /* IDirectMusicLoaderCF
2 * IDirectMusicContainerCF
4 * Copyright (C) 2004 Rok Mandeljc
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (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
14 * GNU Library General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "dmloader_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmloader);
25 /*****************************************************************************
26 * IDirectMusicLoaderCF implementation
28 HRESULT WINAPI IDirectMusicLoaderCF_QueryInterface (LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj) {
29 ICOM_THIS(IDirectMusicLoaderCF, iface);
31 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
32 if (IsEqualIID (riid, &IID_IUnknown) ||
33 IsEqualIID (riid, &IID_IClassFactory)) {
34 IDirectMusicLoaderCF_AddRef (iface);
35 *ppobj = This;
36 return S_OK;
39 WARN(": not found\n");
40 return E_NOINTERFACE;
43 ULONG WINAPI IDirectMusicLoaderCF_AddRef (LPCLASSFACTORY iface) {
44 ICOM_THIS(IDirectMusicLoaderCF, iface);
45 TRACE("(%p): AddRef from %ld\n", This, This->dwRef);
46 return InterlockedIncrement (&This->dwRef);
49 ULONG WINAPI IDirectMusicLoaderCF_Release (LPCLASSFACTORY iface) {
50 ICOM_THIS(IDirectMusicLoaderCF, iface);
52 DWORD dwRef = InterlockedDecrement (&This->dwRef);
53 TRACE("(%p): ReleaseRef to %ld\n", This, dwRef);
54 if (dwRef == 0) {
55 HeapFree(GetProcessHeap (), 0, This);
56 /* decrease number of instances */
57 InterlockedDecrement(&dwDirectMusicLoader);
60 return dwRef;
63 HRESULT WINAPI IDirectMusicLoaderCF_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
64 ICOM_THIS(IDirectMusicLoaderCF, iface);
66 TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
67 if (pOuter) {
68 ERR(": pOuter should be NULL\n");
69 return CLASS_E_NOAGGREGATION;
72 return DMUSIC_CreateDirectMusicLoaderImpl (riid, ppobj, pOuter);
75 HRESULT WINAPI IDirectMusicLoaderCF_LockServer (LPCLASSFACTORY iface, BOOL dolock) {
76 ICOM_THIS(IDirectMusicLoaderCF, iface);
77 TRACE("(%p, %d)\n", This, dolock);
78 if (dolock == TRUE)
79 InterlockedIncrement (&dwDirectMusicLoader);
80 else
81 InterlockedDecrement (&dwDirectMusicLoader);
82 return S_OK;
85 IClassFactoryVtbl DirectMusicLoaderCF_Vtbl = {
86 IDirectMusicLoaderCF_QueryInterface,
87 IDirectMusicLoaderCF_AddRef,
88 IDirectMusicLoaderCF_Release,
89 IDirectMusicLoaderCF_CreateInstance,
90 IDirectMusicLoaderCF_LockServer
93 HRESULT WINAPI DMUSIC_CreateDirectMusicLoaderCF (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
94 IDirectMusicLoaderCF *obj;
96 TRACE("(%s, %p, %p)\n", debugstr_dmguid(lpcGUID), ppobj, pUnkOuter);
97 obj = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicLoaderCF));
98 if (NULL == obj) {
99 *ppobj = (LPCLASSFACTORY)NULL;
100 return E_OUTOFMEMORY;
102 obj->lpVtbl = &DirectMusicLoaderCF_Vtbl;
103 obj->dwRef = 0; /* will be inited with QueryInterface */
105 /* increase number of instances */
106 InterlockedIncrement (&dwDirectMusicLoader);
108 return IDirectMusicLoaderCF_QueryInterface ((LPCLASSFACTORY)obj, lpcGUID, ppobj);
112 /*****************************************************************************
113 * IDirectMusicContainerCF implementation
115 HRESULT WINAPI IDirectMusicContainerCF_QueryInterface (LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj) {
116 ICOM_THIS(IDirectMusicContainerCF, iface);
118 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
119 if (IsEqualIID (riid, &IID_IUnknown) ||
120 IsEqualIID (riid, &IID_IClassFactory)) {
121 IDirectMusicContainerCF_AddRef (iface);
122 *ppobj = This;
123 return S_OK;
126 WARN(": not found\n");
127 return E_NOINTERFACE;
130 ULONG WINAPI IDirectMusicContainerCF_AddRef (LPCLASSFACTORY iface) {
131 ICOM_THIS(IDirectMusicContainerCF, iface);
132 TRACE("(%p): AddRef from %ld\n", This, This->dwRef);
133 return InterlockedIncrement (&This->dwRef);
136 ULONG WINAPI IDirectMusicContainerCF_Release (LPCLASSFACTORY iface) {
137 ICOM_THIS(IDirectMusicContainerCF, iface);
139 DWORD dwRef = InterlockedDecrement (&This->dwRef);
140 TRACE("(%p): ReleaseRef to %ld\n", This, dwRef);
141 if (dwRef == 0) {
142 HeapFree(GetProcessHeap (), 0, This);
143 /* decrease number of instances */
144 InterlockedDecrement(&dwDirectMusicContainer);
147 return dwRef;
150 HRESULT WINAPI IDirectMusicContainerCF_CreateInstance (LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
151 ICOM_THIS(IDirectMusicContainerCF, iface);
153 TRACE ("(%p, %p, %s, %p)\n", This, pOuter, debugstr_dmguid(riid), ppobj);
154 if (pOuter) {
155 ERR(": pOuter should be NULL\n");
156 return CLASS_E_NOAGGREGATION;
159 return DMUSIC_CreateDirectMusicContainerImpl (riid, ppobj, pOuter);
162 HRESULT WINAPI IDirectMusicContainerCF_LockServer (LPCLASSFACTORY iface, BOOL dolock) {
163 ICOM_THIS(IDirectMusicContainerCF, iface);
164 TRACE("(%p, %d)\n", This, dolock);
165 if (dolock == TRUE)
166 InterlockedIncrement (&dwDirectMusicContainer);
167 else
168 InterlockedDecrement (&dwDirectMusicContainer);
169 return S_OK;
172 IClassFactoryVtbl DirectMusicContainerCF_Vtbl = {
173 IDirectMusicContainerCF_QueryInterface,
174 IDirectMusicContainerCF_AddRef,
175 IDirectMusicContainerCF_Release,
176 IDirectMusicContainerCF_CreateInstance,
177 IDirectMusicContainerCF_LockServer
180 HRESULT WINAPI DMUSIC_CreateDirectMusicContainerCF (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
181 IDirectMusicContainerCF *obj;
183 TRACE("(%s, %p, %p)\n", debugstr_dmguid(lpcGUID), ppobj, pUnkOuter);
184 obj = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicContainerCF));
185 if (NULL == obj) {
186 *ppobj = (LPCLASSFACTORY)NULL;
187 return E_OUTOFMEMORY;
189 obj->lpVtbl = &DirectMusicContainerCF_Vtbl;
190 obj->dwRef = 0; /* will be inited with QueryInterface */
192 /* increase number of instances */
193 InterlockedIncrement (&dwDirectMusicContainer);
195 return IDirectMusicContainerCF_QueryInterface ((LPCLASSFACTORY)obj, lpcGUID, ppobj);