Fixed header dependencies to be fully compatible with the Windows
[wine/multimedia.git] / dlls / dmime / graph.c
blob4842999aa60713f5c95b8594e8ebb3a4f823b37e
1 /* IDirectMusicGraph
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.
20 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winuser.h"
25 #include "wingdi.h"
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);
40 *ppobj = This;
41 return S_OK;
44 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
45 return E_NOINTERFACE;
48 ULONG WINAPI IDirectMusicGraphImpl_AddRef (LPDIRECTMUSICGRAPH iface)
50 ICOM_THIS(IDirectMusicGraphImpl,iface);
51 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
52 return ++(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);
60 if (ref == 0) {
61 HeapFree(GetProcessHeap(), 0, This);
63 return ref;
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);
73 return S_OK;
76 HRESULT WINAPI IDirectMusicGraphImpl_InsertTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool, DWORD* pdwPChannels, DWORD cPChannels, LONG lIndex)
78 int i;
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;
91 toAdd->pPrev = NULL;
92 This->pFirst = toAdd;
93 } else if (lIndex < 0) {
94 p = This->pLast;
95 for (i = 0; i < -lIndex; ++i) {
96 p = p->pPrev;
98 toAdd->pNext = p->pNext;
99 if (p->pNext) p->pNext->pPrev = toAdd;
100 p->pNext = toAdd;
101 toAdd->pPrev = p;
102 } else if (lIndex >= This->num_tools) {
103 This->pLast->pNext = toAdd;
104 toAdd->pPrev = This->pLast;
105 toAdd->pNext = NULL;
106 This->pLast = toAdd;
107 } else if (lIndex > 0) {
108 p = This->pFirst;
109 for (i = 0; i < lIndex; ++i) {
110 p = p->pNext;
112 toAdd->pPrev = p->pPrev;
113 if (p->pPrev) p->pPrev->pNext = toAdd;
114 p->pPrev = toAdd;
115 toAdd->pNext = p;
117 ++This->num_tools;
118 return DS_OK;
121 HRESULT WINAPI IDirectMusicGraphImpl_GetTool (LPDIRECTMUSICGRAPH iface, DWORD dwIndex, IDirectMusicTool** ppTool)
123 int i;
124 IDirectMusicTool8Impl* p = NULL;
125 ICOM_THIS(IDirectMusicGraphImpl,iface);
127 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, ppTool);
129 p = This->pFirst;
130 for (i = 0; i < dwIndex && i < This->num_tools; ++i) {
131 p = p->pNext;
133 *ppTool = (IDirectMusicTool*) p;
134 if (NULL != *ppTool) {
135 IDirectMusicTool8Impl_AddRef((LPDIRECTMUSICTOOL8) *ppTool);
137 return DS_OK;
140 HRESULT WINAPI IDirectMusicGraphImpl_RemoveTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool)
142 ICOM_THIS(IDirectMusicGraphImpl,iface);
144 FIXME("(%p, %p): stub\n", This, pTool);
146 return S_OK;
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;
173 dmgraph->ref = 1;
174 *ppDMGrph = (LPDIRECTMUSICGRAPH) dmgraph;
175 return S_OK;
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);
193 *ppobj = This;
194 return S_OK;
195 } else if (IsEqualIID (riid, &IID_IPersistStream)) {
196 IPersistStream_AddRef ((LPPERSISTSTREAM)This->pStream);
197 *ppobj = (LPPERSISTSTREAM)This->pStream;
198 return S_OK;
199 } else if (IsEqualIID (riid, &IID_IDirectMusicGraph)) {
200 IDirectMusicGraph_AddRef ((LPDIRECTMUSICGRAPH)This->pGraph);
201 *ppobj = (LPDIRECTMUSICGRAPH)This->pGraph;
202 return S_OK;
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);
221 if (ref == 0) {
222 HeapFree(GetProcessHeap(), 0, This);
224 return ref;
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);
233 pDesc = This->pDesc;
235 return S_OK;
238 HRESULT WINAPI IDirectMusicGraphObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
240 ICOM_THIS(IDirectMusicGraphObject,iface);
242 TRACE("(%p, %p)\n", This, pDesc);
243 This->pDesc = pDesc;
245 return S_OK;
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);
254 return S_OK;
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));
276 if (NULL == obj) {
277 *ppObject = (LPDIRECTMUSICOBJECT) NULL;
278 return E_OUTOFMEMORY;
280 obj->lpVtbl = &DirectMusicGraphObject_Vtbl;
281 obj->ref = 1;
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;
291 return S_OK;
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);
309 *ppobj = This;
310 return S_OK;
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);
329 if (ref == 0) {
330 HeapFree(GetProcessHeap(), 0, This);
332 return ref;
335 /* IDirectMusicGraphObjectStream IPersist part: */
336 HRESULT WINAPI IDirectMusicGraphObjectStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID)
338 return E_NOTIMPL;
341 /* IDirectMusicGraphObjectStream IPersistStream part: */
342 HRESULT WINAPI IDirectMusicGraphObjectStream_IsDirty (LPPERSISTSTREAM iface)
344 return E_NOTIMPL;
347 HRESULT WINAPI IDirectMusicGraphObjectStream_Load (LPPERSISTSTREAM iface, IStream* pStm)
349 FIXME(": Loading not implemented yet\n");
350 return S_OK;
353 HRESULT WINAPI IDirectMusicGraphObjectStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty)
355 return E_NOTIMPL;
358 HRESULT WINAPI IDirectMusicGraphObjectStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize)
360 return E_NOTIMPL;
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