3 * Copyright (C) 2003 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Library General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #include "wine/debug.h"
28 #include "dmime_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(dmime
);
32 /* IDirectMusicGraph IUnknown part: */
33 HRESULT WINAPI
IDirectMusicGraphImpl_QueryInterface (LPDIRECTMUSICGRAPH iface
, REFIID riid
, LPVOID
*ppobj
)
35 ICOM_THIS(IDirectMusicGraphImpl
,iface
);
37 if (IsEqualIID (riid
, &IID_IUnknown
) ||
38 IsEqualIID (riid
, &IID_IDirectMusicGraph
)) {
39 IDirectMusicGraphImpl_AddRef(iface
);
44 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
48 ULONG WINAPI
IDirectMusicGraphImpl_AddRef (LPDIRECTMUSICGRAPH iface
)
50 ICOM_THIS(IDirectMusicGraphImpl
,iface
);
51 TRACE("(%p) : AddRef from %ld\n", This
, This
->ref
);
55 ULONG WINAPI
IDirectMusicGraphImpl_Release (LPDIRECTMUSICGRAPH iface
)
57 ICOM_THIS(IDirectMusicGraphImpl
,iface
);
58 ULONG ref
= --This
->ref
;
59 TRACE("(%p) : ReleaseRef to %ld\n", This
, This
->ref
);
61 HeapFree(GetProcessHeap(), 0, This
);
66 /* IDirectMusicGraph IDirectMusicGraph part: */
67 HRESULT WINAPI
IDirectMusicGraphImpl_StampPMsg (LPDIRECTMUSICGRAPH iface
, DMUS_PMSG
* pPMSG
)
69 ICOM_THIS(IDirectMusicGraphImpl
,iface
);
71 FIXME("(%p, %p): stub\n", This
, pPMSG
);
76 HRESULT WINAPI
IDirectMusicGraphImpl_InsertTool (LPDIRECTMUSICGRAPH iface
, IDirectMusicTool
* pTool
, DWORD
* pdwPChannels
, DWORD cPChannels
, LONG lIndex
)
79 IDirectMusicTool8Impl
* p
;
80 IDirectMusicTool8Impl
* toAdd
= (IDirectMusicTool8Impl
*) pTool
;
81 ICOM_THIS(IDirectMusicGraphImpl
,iface
);
83 FIXME("(%p, %p, %p, %ld, %li): use of pdwPChannels\n", This
, pTool
, pdwPChannels
, cPChannels
, lIndex
);
85 if (0 == This
->num_tools
) {
86 This
->pFirst
= This
->pLast
= toAdd
;
87 toAdd
->pPrev
= toAdd
->pNext
= NULL
;
88 } else if (lIndex
== 0 || lIndex
<= -This
->num_tools
) {
89 This
->pFirst
->pPrev
= toAdd
;
90 toAdd
->pNext
= This
->pFirst
;
93 } else if (lIndex
< 0) {
95 for (i
= 0; i
< -lIndex
; ++i
) {
98 toAdd
->pNext
= p
->pNext
;
99 if (p
->pNext
) p
->pNext
->pPrev
= toAdd
;
102 } else if (lIndex
>= This
->num_tools
) {
103 This
->pLast
->pNext
= toAdd
;
104 toAdd
->pPrev
= This
->pLast
;
107 } else if (lIndex
> 0) {
109 for (i
= 0; i
< lIndex
; ++i
) {
112 toAdd
->pPrev
= p
->pPrev
;
113 if (p
->pPrev
) p
->pPrev
->pNext
= toAdd
;
121 HRESULT WINAPI
IDirectMusicGraphImpl_GetTool (LPDIRECTMUSICGRAPH iface
, DWORD dwIndex
, IDirectMusicTool
** ppTool
)
124 IDirectMusicTool8Impl
* p
= NULL
;
125 ICOM_THIS(IDirectMusicGraphImpl
,iface
);
127 FIXME("(%p, %ld, %p): stub\n", This
, dwIndex
, ppTool
);
130 for (i
= 0; i
< dwIndex
&& i
< This
->num_tools
; ++i
) {
133 *ppTool
= (IDirectMusicTool
*) p
;
134 if (NULL
!= *ppTool
) {
135 IDirectMusicTool8Impl_AddRef((LPDIRECTMUSICTOOL8
) *ppTool
);
140 HRESULT WINAPI
IDirectMusicGraphImpl_RemoveTool (LPDIRECTMUSICGRAPH iface
, IDirectMusicTool
* pTool
)
142 ICOM_THIS(IDirectMusicGraphImpl
,iface
);
144 FIXME("(%p, %p): stub\n", This
, pTool
);
149 ICOM_VTABLE(IDirectMusicGraph
) DirectMusicGraph_Vtbl
=
151 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
152 IDirectMusicGraphImpl_QueryInterface
,
153 IDirectMusicGraphImpl_AddRef
,
154 IDirectMusicGraphImpl_Release
,
155 IDirectMusicGraphImpl_StampPMsg
,
156 IDirectMusicGraphImpl_InsertTool
,
157 IDirectMusicGraphImpl_GetTool
,
158 IDirectMusicGraphImpl_RemoveTool
161 /* for ClassFactory */
162 HRESULT WINAPI
DMUSIC_CreateDirectMusicGraph (LPCGUID lpcGUID
, LPDIRECTMUSICGRAPH
*ppDMGrph
, LPUNKNOWN pUnkOuter
)
164 IDirectMusicGraphImpl
* dmgraph
;
166 if (IsEqualIID (lpcGUID
, &IID_IDirectMusicGraph
)) {
167 dmgraph
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicGraphImpl
));
168 if (NULL
== dmgraph
) {
169 *ppDMGrph
= (LPDIRECTMUSICGRAPH
) NULL
;
170 return E_OUTOFMEMORY
;
172 dmgraph
->lpVtbl
= &DirectMusicGraph_Vtbl
;
174 *ppDMGrph
= (LPDIRECTMUSICGRAPH
) dmgraph
;
177 WARN("No interface found\n");
179 return E_NOINTERFACE
;
182 /*****************************************************************************
183 * IDirectMusicGraphObject implementation
185 /* IDirectMusicGraphObject IUnknown part: */
186 HRESULT WINAPI
IDirectMusicGraphObject_QueryInterface (LPDIRECTMUSICOBJECT iface
, REFIID riid
, LPVOID
*ppobj
)
188 ICOM_THIS(IDirectMusicGraphObject
,iface
);
190 if (IsEqualIID (riid
, &IID_IUnknown
)
191 || IsEqualIID (riid
, &IID_IDirectMusicObject
)) {
192 IDirectMusicGraphObject_AddRef(iface
);
195 } else if (IsEqualIID (riid
, &IID_IPersistStream
)) {
196 IPersistStream_AddRef ((LPPERSISTSTREAM
)This
->pStream
);
197 *ppobj
= (LPPERSISTSTREAM
)This
->pStream
;
199 } else if (IsEqualIID (riid
, &IID_IDirectMusicGraph
)) {
200 IDirectMusicGraph_AddRef ((LPDIRECTMUSICGRAPH
)This
->pGraph
);
201 *ppobj
= (LPDIRECTMUSICGRAPH
)This
->pGraph
;
205 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
206 return E_NOINTERFACE
;
209 ULONG WINAPI
IDirectMusicGraphObject_AddRef (LPDIRECTMUSICOBJECT iface
)
211 ICOM_THIS(IDirectMusicGraphObject
,iface
);
212 TRACE("(%p) : AddRef from %ld\n", This
, This
->ref
);
213 return ++(This
->ref
);
216 ULONG WINAPI
IDirectMusicGraphObject_Release (LPDIRECTMUSICOBJECT iface
)
218 ICOM_THIS(IDirectMusicGraphObject
,iface
);
219 ULONG ref
= --This
->ref
;
220 TRACE("(%p) : ReleaseRef to %ld\n", This
, This
->ref
);
222 HeapFree(GetProcessHeap(), 0, This
);
227 /* IDirectMusicGraphObject IDirectMusicObject part: */
228 HRESULT WINAPI
IDirectMusicGraphObject_GetDescriptor (LPDIRECTMUSICOBJECT iface
, LPDMUS_OBJECTDESC pDesc
)
230 ICOM_THIS(IDirectMusicGraphObject
,iface
);
232 TRACE("(%p, %p)\n", This
, pDesc
);
238 HRESULT WINAPI
IDirectMusicGraphObject_SetDescriptor (LPDIRECTMUSICOBJECT iface
, LPDMUS_OBJECTDESC pDesc
)
240 ICOM_THIS(IDirectMusicGraphObject
,iface
);
242 TRACE("(%p, %p)\n", This
, pDesc
);
248 HRESULT WINAPI
IDirectMusicGraphObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface
, LPSTREAM pStream
, LPDMUS_OBJECTDESC pDesc
)
250 ICOM_THIS(IDirectMusicGraphObject
,iface
);
252 FIXME("(%p, %p, %p): stub\n", This
, pStream
, pDesc
);
257 ICOM_VTABLE(IDirectMusicObject
) DirectMusicGraphObject_Vtbl
=
259 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
260 IDirectMusicGraphObject_QueryInterface
,
261 IDirectMusicGraphObject_AddRef
,
262 IDirectMusicGraphObject_Release
,
263 IDirectMusicGraphObject_GetDescriptor
,
264 IDirectMusicGraphObject_SetDescriptor
,
265 IDirectMusicGraphObject_ParseDescriptor
268 /* for ClassFactory */
269 HRESULT WINAPI
DMUSIC_CreateDirectMusicGraphObject (LPCGUID lpcGUID
, LPDIRECTMUSICOBJECT
* ppObject
, LPUNKNOWN pUnkOuter
)
271 IDirectMusicGraphObject
*obj
;
273 TRACE("(%p,%p,%p)\n", lpcGUID
, ppObject
, pUnkOuter
);
274 if (IsEqualIID (lpcGUID
, &IID_IDirectMusicObject
)) {
275 obj
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicGraphObject
));
277 *ppObject
= (LPDIRECTMUSICOBJECT
) NULL
;
278 return E_OUTOFMEMORY
;
280 obj
->lpVtbl
= &DirectMusicGraphObject_Vtbl
;
282 /* prepare IPersistStream */
283 obj
->pStream
= HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicGraphObjectStream
));
284 obj
->pStream
->lpVtbl
= &DirectMusicGraphObjectStream_Vtbl
;
285 obj
->pStream
->ref
= 1;
286 obj
->pStream
->pParentObject
= obj
;
287 /* prepare IDirectMusicGraph */
288 DMUSIC_CreateDirectMusicGraph (&IID_IDirectMusicGraph
, (LPDIRECTMUSICGRAPH
*)&obj
->pGraph
, NULL
);
289 obj
->pGraph
->pObject
= obj
;
290 *ppObject
= (LPDIRECTMUSICOBJECT
) obj
;
293 WARN("No interface found\n");
295 return E_NOINTERFACE
;
298 /*****************************************************************************
299 * IDirectMusicGraphObjectStream implementation
301 /* IDirectMusicGraphObjectStream IUnknown part: */
302 HRESULT WINAPI
IDirectMusicGraphObjectStream_QueryInterface (LPPERSISTSTREAM iface
, REFIID riid
, LPVOID
*ppobj
)
304 ICOM_THIS(IDirectMusicGraphObjectStream
,iface
);
306 if (IsEqualIID (riid
, &IID_IUnknown
)
307 || IsEqualIID (riid
, &IID_IPersistStream
)) {
308 IDirectMusicGraphObjectStream_AddRef(iface
);
313 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
314 return E_NOINTERFACE
;
317 ULONG WINAPI
IDirectMusicGraphObjectStream_AddRef (LPPERSISTSTREAM iface
)
319 ICOM_THIS(IDirectMusicGraphObjectStream
,iface
);
320 TRACE("(%p) : AddRef from %ld\n", This
, This
->ref
);
321 return ++(This
->ref
);
324 ULONG WINAPI
IDirectMusicGraphObjectStream_Release (LPPERSISTSTREAM iface
)
326 ICOM_THIS(IDirectMusicGraphObjectStream
,iface
);
327 ULONG ref
= --This
->ref
;
328 TRACE("(%p) : ReleaseRef to %ld\n", This
, This
->ref
);
330 HeapFree(GetProcessHeap(), 0, This
);
335 /* IDirectMusicGraphObjectStream IPersist part: */
336 HRESULT WINAPI
IDirectMusicGraphObjectStream_GetClassID (LPPERSISTSTREAM iface
, CLSID
* pClassID
)
341 /* IDirectMusicGraphObjectStream IPersistStream part: */
342 HRESULT WINAPI
IDirectMusicGraphObjectStream_IsDirty (LPPERSISTSTREAM iface
)
347 HRESULT WINAPI
IDirectMusicGraphObjectStream_Load (LPPERSISTSTREAM iface
, IStream
* pStm
)
349 FIXME(": Loading not implemented yet\n");
353 HRESULT WINAPI
IDirectMusicGraphObjectStream_Save (LPPERSISTSTREAM iface
, IStream
* pStm
, BOOL fClearDirty
)
358 HRESULT WINAPI
IDirectMusicGraphObjectStream_GetSizeMax (LPPERSISTSTREAM iface
, ULARGE_INTEGER
* pcbSize
)
363 ICOM_VTABLE(IPersistStream
) DirectMusicGraphObjectStream_Vtbl
=
365 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
366 IDirectMusicGraphObjectStream_QueryInterface
,
367 IDirectMusicGraphObjectStream_AddRef
,
368 IDirectMusicGraphObjectStream_Release
,
369 IDirectMusicGraphObjectStream_GetClassID
,
370 IDirectMusicGraphObjectStream_IsDirty
,
371 IDirectMusicGraphObjectStream_Load
,
372 IDirectMusicGraphObjectStream_Save
,
373 IDirectMusicGraphObjectStream_GetSizeMax