1 /* IDirectMusicBandTrack Implementation
3 * Copyright (C) 2003-2004 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 "dmband_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmband);
23 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
25 /*****************************************************************************
26 * IDirectMusicBandTrack implementation
28 /* IDirectMusicBandTrack IUnknown part: */
29 HRESULT WINAPI IDirectMusicBandTrack_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
30 ICOM_THIS_MULTI(IDirectMusicBandTrack, UnknownVtbl, iface);
31 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
33 if (IsEqualIID (riid, &IID_IUnknown)) {
34 *ppobj = (LPUNKNOWN)&This->UnknownVtbl;
35 IDirectMusicBandTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
37 } else if (IsEqualIID (riid, &IID_IDirectMusicTrack)
38 || IsEqualIID (riid, &IID_IDirectMusicTrack8)) {
39 *ppobj = (LPDIRECTMUSICTRACK8)&This->TrackVtbl;
40 IDirectMusicBandTrack_IDirectMusicTrack_AddRef ((LPDIRECTMUSICTRACK8)&This->TrackVtbl);
42 } else if (IsEqualIID (riid, &IID_IPersistStream)) {
43 *ppobj = (LPPERSISTSTREAM)&This->PersistStreamVtbl;
44 IDirectMusicBandTrack_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
48 WARN("(%p, %s,%p): not found\n", This, debugstr_dmguid(riid), ppobj);
52 ULONG WINAPI IDirectMusicBandTrack_IUnknown_AddRef (LPUNKNOWN iface) {
53 ICOM_THIS_MULTI(IDirectMusicBandTrack, UnknownVtbl, iface);
54 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
58 ULONG WINAPI IDirectMusicBandTrack_IUnknown_Release (LPUNKNOWN iface) {
59 ICOM_THIS_MULTI(IDirectMusicBandTrack, UnknownVtbl, iface);
60 ULONG ref = --This->ref;
61 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
63 HeapFree(GetProcessHeap(), 0, This);
68 IUnknownVtbl DirectMusicBandTrack_Unknown_Vtbl = {
69 IDirectMusicBandTrack_IUnknown_QueryInterface,
70 IDirectMusicBandTrack_IUnknown_AddRef,
71 IDirectMusicBandTrack_IUnknown_Release
74 /* IDirectMusicBandTrack IDirectMusicTrack8 part: */
75 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_QueryInterface (LPDIRECTMUSICTRACK8 iface, REFIID riid, LPVOID *ppobj) {
76 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
77 return IDirectMusicBandTrack_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
80 ULONG WINAPI IDirectMusicBandTrack_IDirectMusicTrack_AddRef (LPDIRECTMUSICTRACK8 iface) {
81 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
82 return IDirectMusicBandTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
85 ULONG WINAPI IDirectMusicBandTrack_IDirectMusicTrack_Release (LPDIRECTMUSICTRACK8 iface) {
86 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
87 return IDirectMusicBandTrack_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
90 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_Init (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegment* pSegment) {
91 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
92 FIXME("(%p, %p): stub\n", This, pSegment);
96 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_InitPlay (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegmentState* pSegmentState, IDirectMusicPerformance* pPerformance, void** ppStateData, DWORD dwVirtualTrack8ID, DWORD dwFlags) {
97 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
98 FIXME("(%p, %p, %p, %p, %ld, %ld): stub\n", This, pSegmentState, pPerformance, ppStateData, dwVirtualTrack8ID, dwFlags);
102 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_EndPlay (LPDIRECTMUSICTRACK8 iface, void* pStateData) {
103 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
104 FIXME("(%p, %p): stub\n", This, pStateData);
108 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_Play (LPDIRECTMUSICTRACK8 iface, void* pStateData, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID) {
109 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
111 FIXME("(%p, %p, %ld, %ld, %ld, %ld, %p, %p, %ld): semi-stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
112 /* Sends following pMSG:
114 - DMUS_TRANSPOSE_PMSG
115 - DMUS_CHANNEL_PRIORITY_PMSG
122 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_GetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) {
123 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
124 FIXME("(%p, %s, %ld, %p, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pmtNext, pParam);
128 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_SetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, void* pParam) {
129 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
130 FIXME("(%p, %s, %ld, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pParam);
134 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_IsParamSupported (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType) {
135 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
137 TRACE("(%p, %s): ", This, debugstr_dmguid(rguidType));
138 if (IsEqualGUID (rguidType, &GUID_BandParam)
139 || IsEqualGUID (rguidType, &GUID_Clear_All_Bands)
140 || IsEqualGUID (rguidType, &GUID_ConnectToDLSCollection)
141 || IsEqualGUID (rguidType, &GUID_Disable_Auto_Download)
142 || IsEqualGUID (rguidType, &GUID_Download)
143 || IsEqualGUID (rguidType, &GUID_DownloadToAudioPath)
144 || IsEqualGUID (rguidType, &GUID_Enable_Auto_Download)
145 || IsEqualGUID (rguidType, &GUID_IDirectMusicBand)
146 || IsEqualGUID (rguidType, &GUID_StandardMIDIFile)
147 || IsEqualGUID (rguidType, &GUID_Unload)
148 || IsEqualGUID (rguidType, &GUID_UnloadFromAudioPath)) {
149 TRACE("param supported\n");
153 TRACE("param unsupported\n");
154 return DMUS_E_TYPE_UNSUPPORTED;
157 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_AddNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType) {
158 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
159 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
163 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_RemoveNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType) {
164 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
165 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
169 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_Clone (LPDIRECTMUSICTRACK8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, IDirectMusicTrack** ppTrack) {
170 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
171 FIXME("(%p, %ld, %ld, %p): stub\n", This, mtStart, mtEnd, ppTrack);
175 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_PlayEx (LPDIRECTMUSICTRACK8 iface, void* pStateData, REFERENCE_TIME rtStart, REFERENCE_TIME rtEnd, REFERENCE_TIME rtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID) {
176 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
177 FIXME("(%p, %p, %lli, %lli, %lli, %ld, %p, %p, %ld): stub\n", This, pStateData, rtStart, rtEnd, rtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
181 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_GetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, REFERENCE_TIME* prtNext, void* pParam, void* pStateData, DWORD dwFlags) {
182 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
183 FIXME("(%p, %s, %lli, %p, %p, %p, %ld): stub\n", This, debugstr_dmguid(rguidType), rtTime, prtNext, pParam, pStateData, dwFlags);
187 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_SetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, void* pParam, void* pStateData, DWORD dwFlags) {
188 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
189 FIXME("(%p, %s, %lli, %p, %p, %ld): stub\n", This, debugstr_dmguid(rguidType), rtTime, pParam, pStateData, dwFlags);
193 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_Compose (LPDIRECTMUSICTRACK8 iface, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack) {
194 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
195 FIXME("(%p, %p, %ld, %p): stub\n", This, pContext, dwTrackGroup, ppResultTrack);
199 HRESULT WINAPI IDirectMusicBandTrack_IDirectMusicTrack_Join (LPDIRECTMUSICTRACK8 iface, IDirectMusicTrack* pNewTrack, MUSIC_TIME mtJoin, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack) {
200 ICOM_THIS_MULTI(IDirectMusicBandTrack, TrackVtbl, iface);
201 FIXME("(%p, %p, %ld, %p, %ld, %p): stub\n", This, pNewTrack, mtJoin, pContext, dwTrackGroup, ppResultTrack);
205 IDirectMusicTrack8Vtbl DirectMusicBandTrack_DirectMusicTrack_Vtbl = {
206 IDirectMusicBandTrack_IDirectMusicTrack_QueryInterface,
207 IDirectMusicBandTrack_IDirectMusicTrack_AddRef,
208 IDirectMusicBandTrack_IDirectMusicTrack_Release,
209 IDirectMusicBandTrack_IDirectMusicTrack_Init,
210 IDirectMusicBandTrack_IDirectMusicTrack_InitPlay,
211 IDirectMusicBandTrack_IDirectMusicTrack_EndPlay,
212 IDirectMusicBandTrack_IDirectMusicTrack_Play,
213 IDirectMusicBandTrack_IDirectMusicTrack_GetParam,
214 IDirectMusicBandTrack_IDirectMusicTrack_SetParam,
215 IDirectMusicBandTrack_IDirectMusicTrack_IsParamSupported,
216 IDirectMusicBandTrack_IDirectMusicTrack_AddNotificationType,
217 IDirectMusicBandTrack_IDirectMusicTrack_RemoveNotificationType,
218 IDirectMusicBandTrack_IDirectMusicTrack_Clone,
219 IDirectMusicBandTrack_IDirectMusicTrack_PlayEx,
220 IDirectMusicBandTrack_IDirectMusicTrack_GetParamEx,
221 IDirectMusicBandTrack_IDirectMusicTrack_SetParamEx,
222 IDirectMusicBandTrack_IDirectMusicTrack_Compose,
223 IDirectMusicBandTrack_IDirectMusicTrack_Join
226 /* IDirectMusicBandTrack IPersistStream part: */
227 HRESULT WINAPI IDirectMusicBandTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
228 ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
229 return IDirectMusicBandTrack_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
232 ULONG WINAPI IDirectMusicBandTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
233 ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
234 return IDirectMusicBandTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
237 ULONG WINAPI IDirectMusicBandTrack_IPersistStream_Release (LPPERSISTSTREAM iface) {
238 ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
239 return IDirectMusicBandTrack_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
242 HRESULT WINAPI IDirectMusicBandTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
243 ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
244 TRACE("(%p, %p)\n", This, pClassID);
245 memcpy(pClassID, &CLSID_DirectMusicBandTrack, sizeof(CLSID));
249 HRESULT WINAPI IDirectMusicBandTrack_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
250 ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
251 FIXME("(%p): stub, always S_FALSE\n", This);
255 static HRESULT IDirectMusicBandTrack_IPersistStream_LoadBand (LPPERSISTSTREAM iface, IStream* pClonedStream, IDirectMusicBand** ppBand,
256 DMUS_PRIVATE_BAND_ITEM_HEADER* pHeader) {
258 ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
260 IPersistStream* pPersistStream = NULL;
262 hr = CoCreateInstance (&CLSID_DirectMusicBand, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicBand, (LPVOID*) ppBand);
264 ERR(": could not create object\n");
267 /* acquire PersistStream interface */
268 hr = IDirectMusicBand_QueryInterface (*ppBand, &IID_IPersistStream, (LPVOID*) &pPersistStream);
270 ERR(": could not acquire IPersistStream\n");
274 hr = IPersistStream_Load (pPersistStream, pClonedStream);
276 ERR(": failed to load object\n");
280 /* release all loading-related stuff */
281 IPersistStream_Release (pPersistStream);
284 * @TODO insert pBand into This
287 LPDMUS_PRIVATE_BAND pNewBand = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_BAND));
288 if (NULL == pNewBand) {
289 ERR(": no more memory\n");
290 return E_OUTOFMEMORY;
292 memcpy(&pNewBand->pBandHeader, pHeader, sizeof(DMUS_PRIVATE_BAND_ITEM_HEADER));
293 pNewBand->ppBand = (IDirectMusicBandImpl*)((char*)(*ppBand) - offsetof(IDirectMusicBandImpl,BandVtbl));
294 IDirectMusicBandImpl_IDirectMusicBand_AddRef(*ppBand);
295 list_add_tail (&This->Bands, &pNewBand->entry);
301 static HRESULT IDirectMusicBandTrack_IPersistStream_ParseBandsList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
303 /*ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);*/
305 DMUS_PRIVATE_CHUNK Chunk;
306 DWORD StreamSize, ListSize[3], ListCount[3];
307 LARGE_INTEGER liMove; /* used when skipping chunks */
309 IDirectMusicBand* pBand = NULL;
310 DMUS_PRIVATE_BAND_ITEM_HEADER header;
312 if (pChunk->fccID != DMUS_FOURCC_BANDS_LIST) {
313 ERR_(dmfile)(": %s chunk should be a BANDS list\n", debugstr_fourcc (pChunk->fccID));
317 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
321 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
322 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
323 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
324 switch (Chunk.fccID) {
326 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
327 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
328 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
331 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
332 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
333 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
334 switch (Chunk.fccID) {
335 case DMUS_FOURCC_BANDITEM_CHUNK: {
336 DMUS_IO_BAND_ITEM_HEADER tmp_header;
337 TRACE_(dmfile)(": Band Item chunk v1\n");
339 IStream_Read (pStm, &tmp_header, sizeof(DMUS_IO_BAND_ITEM_HEADER), NULL);
340 TRACE_(dmfile)(" - lBandTime: %lu\n", tmp_header.lBandTime);
342 header.dwVersion = 1;
343 header.lBandTime = tmp_header.lBandTime;
346 case DMUS_FOURCC_BANDITEM_CHUNK2: {
347 DMUS_IO_BAND_ITEM_HEADER2 tmp_header2;
348 TRACE_(dmfile)(": Band Item chunk v2\n");
350 IStream_Read (pStm, &tmp_header2, sizeof(DMUS_IO_BAND_ITEM_HEADER2), NULL);
351 TRACE_(dmfile)(" - lBandTimeLogical: %lu\n", tmp_header2.lBandTimeLogical);
352 TRACE_(dmfile)(" - lBandTimePhysical: %lu\n", tmp_header2.lBandTimePhysical);
354 header.dwVersion = 2;
355 header.lBandTimeLogical = tmp_header2.lBandTimeLogical;
356 header.lBandTimePhysical = tmp_header2.lBandTimePhysical;
360 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
361 TRACE_(dmfile)(": RIFF chunk of type %s\n", debugstr_fourcc(Chunk.fccID));
362 StreamSize = Chunk.dwSize - sizeof(FOURCC);
363 switch (Chunk.fccID) {
364 case DMUS_FOURCC_BAND_FORM: {
365 LPSTREAM pClonedStream = NULL;
366 TRACE_(dmfile)(": BAND RIFF\n");
368 IStream_Clone (pStm, &pClonedStream);
371 liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD));
372 IStream_Seek (pClonedStream, liMove, STREAM_SEEK_CUR, NULL);
374 hr = IDirectMusicBandTrack_IPersistStream_LoadBand (iface, pClonedStream, &pBand, &header);
376 ERR(": could not load track\n");
379 IStream_Release (pClonedStream);
381 IDirectMusicTrack_Release(pBand); pBand = NULL; /* now we can release at as it inserted */
383 /** now safe move the cursor */
384 liMove.QuadPart = StreamSize;
385 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
389 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
390 liMove.QuadPart = StreamSize;
391 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
398 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
399 liMove.QuadPart = Chunk.dwSize;
400 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
404 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
405 } while (ListCount[1] < ListSize[1]);
409 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
410 liMove.QuadPart = Chunk.dwSize;
411 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
415 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
416 } while (ListCount[0] < ListSize[0]);
421 static HRESULT IDirectMusicBandTrack_IPersistStream_ParseBandTrackForm (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
423 ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
425 DMUS_PRIVATE_CHUNK Chunk;
426 DWORD StreamSize, StreamCount, ListSize[3], ListCount[3];
427 LARGE_INTEGER liMove; /* used when skipping chunks */
429 if (pChunk->fccID != DMUS_FOURCC_BANDTRACK_FORM) {
430 ERR_(dmfile)(": %s chunk should be a BANDTRACK form\n", debugstr_fourcc (pChunk->fccID));
434 StreamSize = pChunk->dwSize - sizeof(FOURCC);
438 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
439 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
440 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
442 hr = IDirectMusicUtils_IPersistStream_ParseDescGeneric(&Chunk, pStm, This->pDesc);
443 if (FAILED(hr)) return hr;
446 switch (Chunk.fccID) {
447 case DMUS_FOURCC_BANDTRACK_CHUNK: {
448 TRACE_(dmfile)(": BandTrack chunk\n");
449 IStream_Read (pStm, &This->header, sizeof(DMUS_IO_BAND_TRACK_HEADER), NULL);
450 TRACE_(dmfile)(" - bAutoDownload: %u\n", This->header.bAutoDownload);
454 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
455 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
456 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
458 switch (Chunk.fccID) {
459 case DMUS_FOURCC_UNFO_LIST: {
460 TRACE_(dmfile)(": UNFO list\n");
462 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
463 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
464 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
466 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, This->pDesc);
467 if (FAILED(hr)) return hr;
470 switch (Chunk.fccID) {
472 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
473 liMove.QuadPart = Chunk.dwSize;
474 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
479 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
480 } while (ListCount[0] < ListSize[0]);
483 case DMUS_FOURCC_BANDS_LIST: {
484 TRACE_(dmfile)(": TRACK list\n");
485 hr = IDirectMusicBandTrack_IPersistStream_ParseBandsList (iface, &Chunk, pStm);
486 if (FAILED(hr)) return hr;
490 TRACE_(dmfile)(": unknown (skipping)\n");
491 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
492 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
499 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
500 liMove.QuadPart = Chunk.dwSize;
501 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
506 TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount, StreamSize);
507 } while (StreamCount < StreamSize);
513 HRESULT WINAPI IDirectMusicBandTrack_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
514 ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
516 DMUS_PRIVATE_CHUNK Chunk;
517 LARGE_INTEGER liMove;
520 TRACE("(%p, %p): Loading\n", This, pStm);
522 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
523 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
524 switch (Chunk.fccID) {
526 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
527 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
528 switch (Chunk.fccID) {
529 case DMUS_FOURCC_BANDTRACK_FORM: {
530 TRACE_(dmfile)(": Band track form\n");
531 hr = IDirectMusicBandTrack_IPersistStream_ParseBandTrackForm (iface, &Chunk, pStm);
532 if (FAILED(hr)) return hr;
536 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
537 liMove.QuadPart = Chunk.dwSize;
538 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
542 TRACE_(dmfile)(": reading finished\n");
546 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
547 liMove.QuadPart = Chunk.dwSize;
548 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
556 HRESULT WINAPI IDirectMusicBandTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
557 ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
558 FIXME("(%p): Saving not implemented yet\n", This);
562 HRESULT WINAPI IDirectMusicBandTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
563 ICOM_THIS_MULTI(IDirectMusicBandTrack, PersistStreamVtbl, iface);
564 FIXME("(%p, %p): stub\n", This, pcbSize);
568 IPersistStreamVtbl DirectMusicBandTrack_PerststStream_Vtbl = {
569 IDirectMusicBandTrack_IPersistStream_QueryInterface,
570 IDirectMusicBandTrack_IPersistStream_AddRef,
571 IDirectMusicBandTrack_IPersistStream_Release,
572 IDirectMusicBandTrack_IPersistStream_GetClassID,
573 IDirectMusicBandTrack_IPersistStream_IsDirty,
574 IDirectMusicBandTrack_IPersistStream_Load,
575 IDirectMusicBandTrack_IPersistStream_Save,
576 IDirectMusicBandTrack_IPersistStream_GetSizeMax
579 /* for ClassFactory */
580 HRESULT WINAPI DMUSIC_CreateDirectMusicBandTrack (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
581 IDirectMusicBandTrack* track;
583 track = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBandTrack));
586 return E_OUTOFMEMORY;
588 track->UnknownVtbl = &DirectMusicBandTrack_Unknown_Vtbl;
589 track->TrackVtbl = &DirectMusicBandTrack_DirectMusicTrack_Vtbl;
590 track->PersistStreamVtbl = &DirectMusicBandTrack_PerststStream_Vtbl;
591 track->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
592 DM_STRUCT_INIT(track->pDesc);
593 track->pDesc->dwValidData |= DMUS_OBJ_CLASS;
594 memcpy (&track->pDesc->guidClass, &CLSID_DirectMusicBandTrack, sizeof (CLSID));
595 track->ref = 0; /* will be inited by QueryInterface */
596 list_init (&track->Bands);
598 return IDirectMusicBandTrack_IUnknown_QueryInterface ((LPUNKNOWN)&track->UnknownVtbl, lpcGUID, ppobj);