- implemented loader, loader's stream and loading of objects (now you
[wine] / dlls / dmime / sysextrack.c
1 /* IDirectMusicSysExTrack Implementation
2  *
3  * Copyright (C) 2003 Rok Mandeljc
4  *
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.
9  *
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.
14  *
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.
18  */
19
20 #include "windef.h"
21 #include "winbase.h"
22 #include "winuser.h"
23 #include "wingdi.h"
24 #include "wine/debug.h"
25
26 #include "dmime_private.h"
27
28 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
29 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
30
31 /*****************************************************************************
32  * IDirectMusicSysExTrack implementation
33  */
34 /* IDirectMusicSysExTrack IUnknown part: */
35 HRESULT WINAPI IDirectMusicSysExTrack_QueryInterface (LPDIRECTMUSICTRACK8 iface, REFIID riid, LPVOID *ppobj)
36 {
37         ICOM_THIS(IDirectMusicSysExTrack,iface);
38
39         if (IsEqualIID (riid, &IID_IUnknown) || 
40             IsEqualIID (riid, &IID_IDirectMusicTrack) ||
41             IsEqualIID (riid, &IID_IDirectMusicTrack8)) {
42                 IDirectMusicSysExTrack_AddRef(iface);
43                 *ppobj = This;
44                 return S_OK;
45         } else if (IsEqualIID (riid, &IID_IPersistStream)) {
46                 IDirectMusicSysExTrackStream_AddRef ((LPPERSISTSTREAM)This->pStream);
47                 *ppobj = This->pStream;
48                 return S_OK;
49         }
50         WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
51         return E_NOINTERFACE;
52 }
53
54 ULONG WINAPI IDirectMusicSysExTrack_AddRef (LPDIRECTMUSICTRACK8 iface)
55 {
56         ICOM_THIS(IDirectMusicSysExTrack,iface);
57         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
58         return ++(This->ref);
59 }
60
61 ULONG WINAPI IDirectMusicSysExTrack_Release (LPDIRECTMUSICTRACK8 iface)
62 {
63         ICOM_THIS(IDirectMusicSysExTrack,iface);
64         ULONG ref = --This->ref;
65         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
66         if (ref == 0) {
67                 HeapFree(GetProcessHeap(), 0, This);
68         }
69         return ref;
70 }
71
72 /* IDirectMusicSysExTrack IDirectMusicTrack part: */
73 HRESULT WINAPI IDirectMusicSysExTrack_Init (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegment* pSegment)
74 {
75         ICOM_THIS(IDirectMusicSysExTrack,iface);
76
77         FIXME("(%p, %p): stub\n", This, pSegment);
78
79         return S_OK;
80 }
81
82 HRESULT WINAPI IDirectMusicSysExTrack_InitPlay (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegmentState* pSegmentState, IDirectMusicPerformance* pPerformance, void** ppStateData, DWORD dwVirtualTrack8ID, DWORD dwFlags)
83 {
84         ICOM_THIS(IDirectMusicSysExTrack,iface);
85
86         FIXME("(%p, %p, %p, %p, %ld, %ld): stub\n", This, pSegmentState, pPerformance, ppStateData, dwVirtualTrack8ID, dwFlags);
87
88         return S_OK;
89 }
90
91 HRESULT WINAPI IDirectMusicSysExTrack_EndPlay (LPDIRECTMUSICTRACK8 iface, void* pStateData)
92 {
93         ICOM_THIS(IDirectMusicSysExTrack,iface);
94
95         FIXME("(%p, %p): stub\n", This, pStateData);
96
97         return S_OK;
98 }
99
100 HRESULT WINAPI IDirectMusicSysExTrack_Play (LPDIRECTMUSICTRACK8 iface, void* pStateData, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID)
101 {
102         ICOM_THIS(IDirectMusicSysExTrack,iface);
103
104         FIXME("(%p, %p, %ld, %ld, %ld, %ld, %p, %p, %ld): stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
105
106         return S_OK;
107 }
108
109 HRESULT WINAPI IDirectMusicSysExTrack_GetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam)
110 {
111         ICOM_THIS(IDirectMusicSysExTrack,iface);
112
113         FIXME("(%p, %s, %ld, %p, %p): stub\n", This, debugstr_guid(rguidType), mtTime, pmtNext, pParam);
114
115         return S_OK;
116 }
117
118 HRESULT WINAPI IDirectMusicSysExTrack_SetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, void* pParam)
119 {
120         ICOM_THIS(IDirectMusicSysExTrack,iface);
121
122         FIXME("(%p, %s, %ld, %p): stub\n", This, debugstr_guid(rguidType), mtTime, pParam);
123
124         return S_OK;
125 }
126
127 HRESULT WINAPI IDirectMusicSysExTrack_IsParamSupported (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType)
128 {
129         ICOM_THIS(IDirectMusicSysExTrack,iface);
130
131         TRACE("(%p, %s): ", This, debugstr_guid(rguidType));
132         /* didn't find any params */
133
134         TRACE("param unsupported\n");
135         return DMUS_E_TYPE_UNSUPPORTED;
136 }
137
138 HRESULT WINAPI IDirectMusicSysExTrack_AddNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType)
139 {
140         ICOM_THIS(IDirectMusicSysExTrack,iface);
141
142         FIXME("(%p, %s): stub\n", This, debugstr_guid(rguidNotificationType));
143
144         return S_OK;
145 }
146
147 HRESULT WINAPI IDirectMusicSysExTrack_RemoveNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType)
148 {
149         ICOM_THIS(IDirectMusicSysExTrack,iface);
150
151         FIXME("(%p, %s): stub\n", This, debugstr_guid(rguidNotificationType));
152
153         return S_OK;
154 }
155
156 HRESULT WINAPI IDirectMusicSysExTrack_Clone (LPDIRECTMUSICTRACK8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, IDirectMusicTrack** ppTrack)
157 {
158         ICOM_THIS(IDirectMusicSysExTrack,iface);
159
160         FIXME("(%p, %ld, %ld, %p): stub\n", This, mtStart, mtEnd, ppTrack);
161
162         return S_OK;
163 }
164
165 /* IDirectMusicSysExTrack IDirectMusicTrack8 part: */
166 HRESULT WINAPI IDirectMusicSysExTrack_PlayEx (LPDIRECTMUSICTRACK8 iface, void* pStateData, REFERENCE_TIME rtStart, REFERENCE_TIME rtEnd, REFERENCE_TIME rtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID)
167 {
168         ICOM_THIS(IDirectMusicSysExTrack,iface);
169
170         FIXME("(%p, %p, %lli, %lli, %lli, %ld, %p, %p, %ld): stub\n", This, pStateData, rtStart, rtEnd, rtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
171
172         return S_OK;
173 }
174
175 HRESULT WINAPI IDirectMusicSysExTrack_GetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, REFERENCE_TIME* prtNext, void* pParam, void* pStateData, DWORD dwFlags)
176 {
177         ICOM_THIS(IDirectMusicSysExTrack,iface);
178
179         FIXME("(%p, %s, %lli, %p, %p, %p, %ld): stub\n", This, debugstr_guid(rguidType), rtTime, prtNext, pParam, pStateData, dwFlags);
180
181         return S_OK;
182 }
183
184 HRESULT WINAPI IDirectMusicSysExTrack_SetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, void* pParam, void* pStateData, DWORD dwFlags)
185 {
186         ICOM_THIS(IDirectMusicSysExTrack,iface);
187
188         FIXME("(%p, %s, %lli, %p, %p, %ld): stub\n", This, debugstr_guid(rguidType), rtTime, pParam, pStateData, dwFlags);
189
190         return S_OK;
191 }
192
193 HRESULT WINAPI IDirectMusicSysExTrack_Compose (LPDIRECTMUSICTRACK8 iface, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack)
194 {
195         ICOM_THIS(IDirectMusicSysExTrack,iface);
196
197         FIXME("(%p, %p, %ld, %p): stub\n", This, pContext, dwTrackGroup, ppResultTrack);
198
199         return S_OK;
200 }
201
202 HRESULT WINAPI IDirectMusicSysExTrack_Join (LPDIRECTMUSICTRACK8 iface, IDirectMusicTrack* pNewTrack, MUSIC_TIME mtJoin, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack)
203 {
204         ICOM_THIS(IDirectMusicSysExTrack,iface);
205
206         FIXME("(%p, %p, %ld, %p, %ld, %p): stub\n", This, pNewTrack, mtJoin, pContext, dwTrackGroup, ppResultTrack);
207
208         return S_OK;
209 }
210
211 ICOM_VTABLE(IDirectMusicTrack8) DirectMusicSysExTrack_Vtbl =
212 {
213     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
214         IDirectMusicSysExTrack_QueryInterface,
215         IDirectMusicSysExTrack_AddRef,
216         IDirectMusicSysExTrack_Release,
217         IDirectMusicSysExTrack_Init,
218         IDirectMusicSysExTrack_InitPlay,
219         IDirectMusicSysExTrack_EndPlay,
220         IDirectMusicSysExTrack_Play,
221         IDirectMusicSysExTrack_GetParam,
222         IDirectMusicSysExTrack_SetParam,
223         IDirectMusicSysExTrack_IsParamSupported,
224         IDirectMusicSysExTrack_AddNotificationType,
225         IDirectMusicSysExTrack_RemoveNotificationType,
226         IDirectMusicSysExTrack_Clone,
227         IDirectMusicSysExTrack_PlayEx,
228         IDirectMusicSysExTrack_GetParamEx,
229         IDirectMusicSysExTrack_SetParamEx,
230         IDirectMusicSysExTrack_Compose,
231         IDirectMusicSysExTrack_Join
232 };
233
234 /* for ClassFactory */
235 HRESULT WINAPI DMUSIC_CreateDirectMusicSysExTrack (LPCGUID lpcGUID, LPDIRECTMUSICTRACK8 *ppTrack, LPUNKNOWN pUnkOuter)
236 {
237         IDirectMusicSysExTrack* track;
238         
239         if (IsEqualIID (lpcGUID, &IID_IDirectMusicTrack)
240                 || IsEqualIID (lpcGUID, &IID_IDirectMusicTrack8)) {
241                 track = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSysExTrack));
242                 if (NULL == track) {
243                         *ppTrack = (LPDIRECTMUSICTRACK8) NULL;
244                         return E_OUTOFMEMORY;
245                 }
246                 track->lpVtbl = &DirectMusicSysExTrack_Vtbl;
247                 track->ref = 1;
248                 track->pStream = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSysExTrackStream));
249                 track->pStream->lpVtbl = &DirectMusicSysExTrackStream_Vtbl;
250                 track->pStream->ref = 1;        
251                 track->pStream->pParentTrack = track;
252                 *ppTrack = (LPDIRECTMUSICTRACK8) track;
253                 return S_OK;
254         }
255         WARN("No interface found\n");
256         
257         return E_NOINTERFACE;
258 }
259
260
261 /*****************************************************************************
262  * IDirectMusicSysExTrackStream implementation
263  */
264 /* IDirectMusicSysExTrackStream IUnknown part follow: */
265 HRESULT WINAPI IDirectMusicSysExTrackStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj)
266 {
267         ICOM_THIS(IDirectMusicSysExTrackStream,iface);
268
269         if (IsEqualIID (riid, &IID_IUnknown)
270                 || IsEqualIID (riid, &IID_IPersistStream)) {
271                 IDirectMusicSysExTrackStream_AddRef(iface);
272                 *ppobj = This;
273                 return S_OK;
274         }
275         
276         WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
277         return E_NOINTERFACE;
278 }
279
280 ULONG WINAPI IDirectMusicSysExTrackStream_AddRef (LPPERSISTSTREAM iface)
281 {
282         ICOM_THIS(IDirectMusicSysExTrackStream,iface);
283         TRACE("(%p) : AddRef from %ld\n", This, This->ref);
284         return ++(This->ref);
285 }
286
287 ULONG WINAPI IDirectMusicSysExTrackStream_Release (LPPERSISTSTREAM iface)
288 {
289         ICOM_THIS(IDirectMusicSysExTrackStream,iface);
290         ULONG ref = --This->ref;
291         TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
292         if (ref == 0) {
293                 HeapFree(GetProcessHeap(), 0, This);
294         }
295         return ref;
296 }
297
298 /* IDirectMusicSysExTrackStream IPersist part: */
299 HRESULT WINAPI IDirectMusicSysExTrackStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID)
300 {
301         return E_NOTIMPL;
302 }
303
304 /* IDirectMusicSysExTrackStream IPersistStream part: */
305 HRESULT WINAPI IDirectMusicSysExTrackStream_IsDirty (LPPERSISTSTREAM iface)
306 {
307         return E_NOTIMPL;
308 }
309
310 HRESULT WINAPI IDirectMusicSysExTrackStream_Load (LPPERSISTSTREAM iface, IStream* pStm)
311 {
312         FIXME(": Loading not implemented yet\n");
313         return S_OK;
314 }
315
316 HRESULT WINAPI IDirectMusicSysExTrackStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty)
317 {
318         return E_NOTIMPL;
319 }
320
321 HRESULT WINAPI IDirectMusicSysExTrackStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize)
322 {
323         return E_NOTIMPL;
324 }
325
326 ICOM_VTABLE(IPersistStream) DirectMusicSysExTrackStream_Vtbl =
327 {
328     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
329         IDirectMusicSysExTrackStream_QueryInterface,
330         IDirectMusicSysExTrackStream_AddRef,
331         IDirectMusicSysExTrackStream_Release,
332         IDirectMusicSysExTrackStream_GetClassID,
333         IDirectMusicSysExTrackStream_IsDirty,
334         IDirectMusicSysExTrackStream_Load,
335         IDirectMusicSysExTrackStream_Save,
336         IDirectMusicSysExTrackStream_GetSizeMax
337 };