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 IDirectMusicLoaderCF
*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
);
39 WARN(": not found\n");
43 ULONG WINAPI
IDirectMusicLoaderCF_AddRef (LPCLASSFACTORY iface
) {
44 IDirectMusicLoaderCF
*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 IDirectMusicLoaderCF
*This
= (IDirectMusicLoaderCF
*)iface
;
52 DWORD dwRef
= InterlockedDecrement (&This
->dwRef
);
53 TRACE("(%p): ReleaseRef to %ld\n", This
, dwRef
);
55 HeapFree(GetProcessHeap (), 0, This
);
56 /* decrease number of instances */
57 InterlockedDecrement(&dwDirectMusicLoader
);
63 HRESULT WINAPI
IDirectMusicLoaderCF_CreateInstance (LPCLASSFACTORY iface
, LPUNKNOWN pOuter
, REFIID riid
, LPVOID
*ppobj
) {
64 IDirectMusicLoaderCF
*This
= (IDirectMusicLoaderCF
*)iface
;
66 TRACE ("(%p, %p, %s, %p)\n", This
, pOuter
, debugstr_dmguid(riid
), ppobj
);
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 IDirectMusicLoaderCF
*This
= (IDirectMusicLoaderCF
*)iface
;
77 TRACE("(%p, %d)\n", This
, dolock
);
79 InterlockedIncrement (&dwDirectMusicLoader
);
81 InterlockedDecrement (&dwDirectMusicLoader
);
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
));
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 IDirectMusicContainerCF
*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
);
126 WARN(": not found\n");
127 return E_NOINTERFACE
;
130 ULONG WINAPI
IDirectMusicContainerCF_AddRef (LPCLASSFACTORY iface
) {
131 IDirectMusicContainerCF
*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 IDirectMusicContainerCF
*This
= (IDirectMusicContainerCF
*)iface
;
139 DWORD dwRef
= InterlockedDecrement (&This
->dwRef
);
140 TRACE("(%p): ReleaseRef to %ld\n", This
, dwRef
);
142 HeapFree(GetProcessHeap (), 0, This
);
143 /* decrease number of instances */
144 InterlockedDecrement(&dwDirectMusicContainer
);
150 HRESULT WINAPI
IDirectMusicContainerCF_CreateInstance (LPCLASSFACTORY iface
, LPUNKNOWN pOuter
, REFIID riid
, LPVOID
*ppobj
) {
151 IDirectMusicContainerCF
*This
= (IDirectMusicContainerCF
*)iface
;
153 TRACE ("(%p, %p, %s, %p)\n", This
, pOuter
, debugstr_dmguid(riid
), ppobj
);
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 IDirectMusicContainerCF
*This
= (IDirectMusicContainerCF
*)iface
;
164 TRACE("(%p, %d)\n", This
, dolock
);
166 InterlockedIncrement (&dwDirectMusicContainer
);
168 InterlockedDecrement (&dwDirectMusicContainer
);
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
));
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
);