Split the dmusic interfaces.
[wine/wine64.git] / dlls / dmime / graph.c
blob7cdbe9812587fddc6d9877153a15c7371fb04ea8
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 "windef.h"
21 #include "winbase.h"
22 #include "winuser.h"
23 #include "wingdi.h"
24 #include "wine/debug.h"
26 #include "dmime_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
30 /* IDirectMusicGraph IUnknown parts follow: */
31 HRESULT WINAPI IDirectMusicGraphImpl_QueryInterface (LPDIRECTMUSICGRAPH iface, REFIID riid, LPVOID *ppobj)
33 ICOM_THIS(IDirectMusicGraphImpl,iface);
35 if (IsEqualGUID(riid, &IID_IUnknown) ||
36 IsEqualGUID(riid, &IID_IDirectMusicGraph))
38 IDirectMusicGraphImpl_AddRef(iface);
39 *ppobj = This;
40 return S_OK;
42 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
43 return E_NOINTERFACE;
46 ULONG WINAPI IDirectMusicGraphImpl_AddRef (LPDIRECTMUSICGRAPH iface)
48 ICOM_THIS(IDirectMusicGraphImpl,iface);
49 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
50 return ++(This->ref);
53 ULONG WINAPI IDirectMusicGraphImpl_Release (LPDIRECTMUSICGRAPH iface)
55 ICOM_THIS(IDirectMusicGraphImpl,iface);
56 ULONG ref = --This->ref;
57 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
58 if (ref == 0)
60 HeapFree(GetProcessHeap(), 0, This);
62 return ref;
65 /* IDirectMusicGraph Interface follow: */
66 HRESULT WINAPI IDirectMusicGraphImpl_StampPMsg (LPDIRECTMUSICGRAPH iface, DMUS_PMSG* pPMSG)
68 ICOM_THIS(IDirectMusicGraphImpl,iface);
70 FIXME("(%p, %p): stub\n", This, pPMSG);
72 return S_OK;
75 HRESULT WINAPI IDirectMusicGraphImpl_InsertTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool, DWORD* pdwPChannels, DWORD cPChannels, LONG lIndex)
77 int i;
78 IDirectMusicTool8Impl* p;
79 IDirectMusicTool8Impl* toAdd = (IDirectMusicTool8Impl*) pTool;
80 ICOM_THIS(IDirectMusicGraphImpl,iface);
82 FIXME("(%p, %p, %p, %ld, %li): use of pdwPChannels\n", This, pTool, pdwPChannels, cPChannels, lIndex);
84 if (0 == This->num_tools) {
85 This->pFirst = This->pLast = toAdd;
86 toAdd->pPrev = toAdd->pNext = NULL;
87 } else if (lIndex == 0 || lIndex <= -This->num_tools) {
88 This->pFirst->pPrev = toAdd;
89 toAdd->pNext = This->pFirst;
90 toAdd->pPrev = NULL;
91 This->pFirst = toAdd;
92 } else if (lIndex < 0) {
93 p = This->pLast;
94 for (i = 0; i < -lIndex; ++i) {
95 p = p->pPrev;
97 toAdd->pNext = p->pNext;
98 if (p->pNext) p->pNext->pPrev = toAdd;
99 p->pNext = toAdd;
100 toAdd->pPrev = p;
101 } else if (lIndex >= This->num_tools) {
102 This->pLast->pNext = toAdd;
103 toAdd->pPrev = This->pLast;
104 toAdd->pNext = NULL;
105 This->pLast = toAdd;
106 } else if (lIndex > 0) {
107 p = This->pFirst;
108 for (i = 0; i < lIndex; ++i) {
109 p = p->pNext;
111 toAdd->pPrev = p->pPrev;
112 if (p->pPrev) p->pPrev->pNext = toAdd;
113 p->pPrev = toAdd;
114 toAdd->pNext = p;
116 ++This->num_tools;
117 return DS_OK;
120 HRESULT WINAPI IDirectMusicGraphImpl_GetTool (LPDIRECTMUSICGRAPH iface, DWORD dwIndex, IDirectMusicTool** ppTool)
122 int i;
123 IDirectMusicTool8Impl* p = NULL;
124 ICOM_THIS(IDirectMusicGraphImpl,iface);
126 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, ppTool);
128 p = This->pFirst;
129 for (i = 0; i < dwIndex && i < This->num_tools; ++i) {
130 p = p->pNext;
132 *ppTool = (IDirectMusicTool*) p;
133 if (NULL != *ppTool) {
134 IDirectMusicTool8Impl_AddRef((LPDIRECTMUSICTOOL8) *ppTool);
136 return DS_OK;
139 HRESULT WINAPI IDirectMusicGraphImpl_RemoveTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool)
141 ICOM_THIS(IDirectMusicGraphImpl,iface);
143 FIXME("(%p, %p): stub\n", This, pTool);
145 return S_OK;
148 ICOM_VTABLE(IDirectMusicGraph) DirectMusicGraph_Vtbl =
150 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
151 IDirectMusicGraphImpl_QueryInterface,
152 IDirectMusicGraphImpl_AddRef,
153 IDirectMusicGraphImpl_Release,
154 IDirectMusicGraphImpl_StampPMsg,
155 IDirectMusicGraphImpl_InsertTool,
156 IDirectMusicGraphImpl_GetTool,
157 IDirectMusicGraphImpl_RemoveTool
160 /* for ClassFactory */
161 HRESULT WINAPI DMUSIC_CreateDirectMusicGraph (LPCGUID lpcGUID, LPDIRECTMUSICGRAPH *ppDMGrph, LPUNKNOWN pUnkOuter)
163 if (IsEqualGUID (lpcGUID, &IID_IDirectMusicGraph))
165 FIXME("Not yet\n");
166 return E_NOINTERFACE;
168 WARN("No interface found\n");
170 return E_NOINTERFACE;