1 /* IDirectMusicBandTrack Implementation
3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "dmband_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmband
);
24 WINE_DECLARE_DEBUG_CHANNEL(dmfile
);
26 /*****************************************************************************
27 * IDirectMusicBandTrack implementation
29 typedef struct IDirectMusicBandTrack
{
30 IDirectMusicTrack8 IDirectMusicTrack8_iface
;
31 struct dmobject dmobj
; /* IPersistStream only */
33 DMUS_IO_BAND_TRACK_HEADER header
;
35 } IDirectMusicBandTrack
;
37 /* IDirectMusicBandTrack IDirectMusicTrack8 part: */
38 static inline IDirectMusicBandTrack
*impl_from_IDirectMusicTrack8(IDirectMusicTrack8
*iface
)
40 return CONTAINING_RECORD(iface
, IDirectMusicBandTrack
, IDirectMusicTrack8_iface
);
43 static HRESULT WINAPI
IDirectMusicTrack8Impl_QueryInterface(IDirectMusicTrack8
*iface
, REFIID riid
,
46 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
48 TRACE("(%p, %s, %p)\n", This
, debugstr_dmguid(riid
), ret_iface
);
52 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDirectMusicTrack
) ||
53 IsEqualIID(riid
, &IID_IDirectMusicTrack8
))
55 else if (IsEqualIID(riid
, &IID_IPersistStream
))
56 *ret_iface
= &This
->dmobj
.IPersistStream_iface
;
58 WARN("(%p, %s, %p): not found\n", This
, debugstr_dmguid(riid
), ret_iface
);
62 IUnknown_AddRef((IUnknown
*)*ret_iface
);
66 static ULONG WINAPI
IDirectMusicTrack8Impl_AddRef(IDirectMusicTrack8
*iface
)
68 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
69 LONG ref
= InterlockedIncrement(&This
->ref
);
71 TRACE("(%p) ref=%d\n", This
, ref
);
76 static ULONG WINAPI
IDirectMusicTrack8Impl_Release(IDirectMusicTrack8
*iface
)
78 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
79 LONG ref
= InterlockedDecrement(&This
->ref
);
81 TRACE("(%p) ref=%d\n", This
, ref
);
84 HeapFree(GetProcessHeap(), 0, This
);
85 DMBAND_UnlockModule();
91 static HRESULT WINAPI
IDirectMusicTrack8Impl_Init(IDirectMusicTrack8
*iface
,
92 IDirectMusicSegment
*pSegment
)
94 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
95 FIXME("(%p, %p): stub\n", This
, pSegment
);
99 static HRESULT WINAPI
IDirectMusicTrack8Impl_InitPlay(IDirectMusicTrack8
*iface
,
100 IDirectMusicSegmentState
*segment_state
, IDirectMusicPerformance
*performance
,
101 void **state_data
, DWORD virtual_track8id
, DWORD flags
)
103 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
105 FIXME("(%p, %p, %p, %p, %d, %x): stub\n", This
, segment_state
, performance
, state_data
, virtual_track8id
, flags
);
110 static HRESULT WINAPI
IDirectMusicTrack8Impl_EndPlay(IDirectMusicTrack8
*iface
, void *pStateData
)
112 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
113 FIXME("(%p, %p): stub\n", This
, pStateData
);
117 static HRESULT WINAPI
IDirectMusicTrack8Impl_Play(IDirectMusicTrack8
*iface
, void *state_data
,
118 MUSIC_TIME mtStart
, MUSIC_TIME mtEnd
, MUSIC_TIME mtOffset
, DWORD flags
,
119 IDirectMusicPerformance
*performance
, IDirectMusicSegmentState
*segment_state
,
122 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
124 FIXME("(%p, %p, %d, %d, %d, %x, %p, %p, %d): semi-stub\n", This
, state_data
, mtStart
, mtEnd
, mtOffset
, flags
, performance
, segment_state
, virtual_id
);
126 /* Sends following pMSG:
128 - DMUS_TRANSPOSE_PMSG
129 - DMUS_CHANNEL_PRIORITY_PMSG
136 static HRESULT WINAPI
IDirectMusicTrack8Impl_GetParam(IDirectMusicTrack8
*iface
, REFGUID rguidType
,
137 MUSIC_TIME mtTime
, MUSIC_TIME
*pmtNext
, void *pParam
)
139 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
140 FIXME("(%p, %s, %d, %p, %p): stub\n", This
, debugstr_dmguid(rguidType
), mtTime
, pmtNext
, pParam
);
144 static HRESULT WINAPI
IDirectMusicTrack8Impl_SetParam(IDirectMusicTrack8
*iface
, REFGUID rguidType
,
145 MUSIC_TIME mtTime
, void *pParam
)
147 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
148 FIXME("(%p, %s, %d, %p): stub\n", This
, debugstr_dmguid(rguidType
), mtTime
, pParam
);
152 static HRESULT WINAPI
IDirectMusicTrack8Impl_IsParamSupported(IDirectMusicTrack8
*iface
,
155 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
157 TRACE("(%p, %s)\n", This
, debugstr_dmguid(rguidType
));
162 if (IsEqualGUID (rguidType
, &GUID_BandParam
)
163 || IsEqualGUID (rguidType
, &GUID_Clear_All_Bands
)
164 || IsEqualGUID (rguidType
, &GUID_ConnectToDLSCollection
)
165 || IsEqualGUID (rguidType
, &GUID_Disable_Auto_Download
)
166 || IsEqualGUID (rguidType
, &GUID_Download
)
167 || IsEqualGUID (rguidType
, &GUID_DownloadToAudioPath
)
168 || IsEqualGUID (rguidType
, &GUID_Enable_Auto_Download
)
169 || IsEqualGUID (rguidType
, &GUID_IDirectMusicBand
)
170 || IsEqualGUID (rguidType
, &GUID_StandardMIDIFile
)
171 || IsEqualGUID (rguidType
, &GUID_Unload
)
172 || IsEqualGUID (rguidType
, &GUID_UnloadFromAudioPath
)) {
173 TRACE("param supported\n");
177 TRACE("param unsupported\n");
178 return DMUS_E_TYPE_UNSUPPORTED
;
181 static HRESULT WINAPI
IDirectMusicTrack8Impl_AddNotificationType(IDirectMusicTrack8
*iface
,
184 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
186 TRACE("(%p, %s): method not implemented\n", This
, debugstr_dmguid(notiftype
));
190 static HRESULT WINAPI
IDirectMusicTrack8Impl_RemoveNotificationType(IDirectMusicTrack8
*iface
,
193 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
195 TRACE("(%p, %s): method not implemented\n", This
, debugstr_dmguid(notiftype
));
199 static HRESULT WINAPI
IDirectMusicTrack8Impl_Clone(IDirectMusicTrack8
*iface
, MUSIC_TIME mtStart
,
200 MUSIC_TIME mtEnd
, IDirectMusicTrack
**ppTrack
)
202 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
203 FIXME("(%p, %d, %d, %p): stub\n", This
, mtStart
, mtEnd
, ppTrack
);
207 static HRESULT WINAPI
IDirectMusicTrack8Impl_PlayEx(IDirectMusicTrack8
*iface
, void *state_data
,
208 REFERENCE_TIME rtStart
, REFERENCE_TIME rtEnd
, REFERENCE_TIME rtOffset
, DWORD flags
,
209 IDirectMusicPerformance
*performance
, IDirectMusicSegmentState
*segment_state
,
212 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
214 FIXME("(%p, %p, 0x%s, 0x%s, 0x%s, %x, %p, %p, %d): stub\n", This
, state_data
, wine_dbgstr_longlong(rtStart
),
215 wine_dbgstr_longlong(rtEnd
), wine_dbgstr_longlong(rtOffset
), flags
, performance
, segment_state
, virtual_id
);
220 static HRESULT WINAPI
IDirectMusicTrack8Impl_GetParamEx(IDirectMusicTrack8
*iface
,
221 REFGUID rguidType
, REFERENCE_TIME rtTime
, REFERENCE_TIME
*rtNext
, void *param
,
222 void *state_data
, DWORD flags
)
224 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
226 FIXME("(%p, %s, 0x%s, %p, %p, %p, %x): stub\n", This
, debugstr_dmguid(rguidType
),
227 wine_dbgstr_longlong(rtTime
), rtNext
, param
, state_data
, flags
);
232 static HRESULT WINAPI
IDirectMusicTrack8Impl_SetParamEx(IDirectMusicTrack8
*iface
,
233 REFGUID rguidType
, REFERENCE_TIME rtTime
, void *param
, void *state_data
, DWORD flags
)
235 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
237 FIXME("(%p, %s, 0x%s, %p, %p, %x): stub\n", This
, debugstr_dmguid(rguidType
),
238 wine_dbgstr_longlong(rtTime
), param
, state_data
, flags
);
243 static HRESULT WINAPI
IDirectMusicTrack8Impl_Compose(IDirectMusicTrack8
*iface
, IUnknown
*context
,
244 DWORD trackgroup
, IDirectMusicTrack
**track
)
246 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
248 TRACE("(%p, %p, %d, %p): method not implemented\n", This
, context
, trackgroup
, track
);
252 static HRESULT WINAPI
IDirectMusicTrack8Impl_Join(IDirectMusicTrack8
*iface
,
253 IDirectMusicTrack
*pNewTrack
, MUSIC_TIME mtJoin
, IUnknown
*pContext
, DWORD dwTrackGroup
,
254 IDirectMusicTrack
**ppResultTrack
)
256 IDirectMusicBandTrack
*This
= impl_from_IDirectMusicTrack8(iface
);
257 FIXME("(%p, %p, %d, %p, %d, %p): stub\n", This
, pNewTrack
, mtJoin
, pContext
, dwTrackGroup
, ppResultTrack
);
261 static const IDirectMusicTrack8Vtbl dmtrack8_vtbl
= {
262 IDirectMusicTrack8Impl_QueryInterface
,
263 IDirectMusicTrack8Impl_AddRef
,
264 IDirectMusicTrack8Impl_Release
,
265 IDirectMusicTrack8Impl_Init
,
266 IDirectMusicTrack8Impl_InitPlay
,
267 IDirectMusicTrack8Impl_EndPlay
,
268 IDirectMusicTrack8Impl_Play
,
269 IDirectMusicTrack8Impl_GetParam
,
270 IDirectMusicTrack8Impl_SetParam
,
271 IDirectMusicTrack8Impl_IsParamSupported
,
272 IDirectMusicTrack8Impl_AddNotificationType
,
273 IDirectMusicTrack8Impl_RemoveNotificationType
,
274 IDirectMusicTrack8Impl_Clone
,
275 IDirectMusicTrack8Impl_PlayEx
,
276 IDirectMusicTrack8Impl_GetParamEx
,
277 IDirectMusicTrack8Impl_SetParamEx
,
278 IDirectMusicTrack8Impl_Compose
,
279 IDirectMusicTrack8Impl_Join
282 /* IDirectMusicBandTrack IPersistStream part: */
283 static HRESULT
load_band(IDirectMusicBandTrack
*This
, IStream
*pClonedStream
,
284 IDirectMusicBand
**ppBand
, DMUS_PRIVATE_BAND_ITEM_HEADER
*pHeader
)
287 IPersistStream
* pPersistStream
= NULL
;
289 hr
= CoCreateInstance (&CLSID_DirectMusicBand
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectMusicBand
, (LPVOID
*) ppBand
);
291 ERR(": could not create object\n");
294 /* acquire PersistStream interface */
295 hr
= IDirectMusicBand_QueryInterface (*ppBand
, &IID_IPersistStream
, (LPVOID
*) &pPersistStream
);
297 ERR(": could not acquire IPersistStream\n");
301 hr
= IPersistStream_Load (pPersistStream
, pClonedStream
);
303 ERR(": failed to load object\n");
307 /* release all loading-related stuff */
308 IPersistStream_Release (pPersistStream
);
311 * @TODO insert pBand into This
314 LPDMUS_PRIVATE_BAND pNewBand
= HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
, sizeof(DMUS_PRIVATE_BAND
));
315 if (NULL
== pNewBand
) {
316 ERR(": no more memory\n");
317 return E_OUTOFMEMORY
;
319 pNewBand
->BandHeader
= *pHeader
;
320 pNewBand
->band
= *ppBand
;
321 IDirectMusicBand_AddRef(*ppBand
);
322 list_add_tail (&This
->Bands
, &pNewBand
->entry
);
328 static HRESULT
parse_bands_list(IDirectMusicBandTrack
*This
, DMUS_PRIVATE_CHUNK
*pChunk
,
332 DMUS_PRIVATE_CHUNK Chunk
;
333 DWORD StreamSize
, ListSize
[3], ListCount
[3];
334 LARGE_INTEGER liMove
; /* used when skipping chunks */
336 IDirectMusicBand
* pBand
= NULL
;
337 DMUS_PRIVATE_BAND_ITEM_HEADER header
;
339 memset(&header
, 0, sizeof header
);
341 if (pChunk
->fccID
!= DMUS_FOURCC_BANDS_LIST
) {
342 ERR_(dmfile
)(": %s chunk should be a BANDS list\n", debugstr_fourcc (pChunk
->fccID
));
346 ListSize
[0] = pChunk
->dwSize
- sizeof(FOURCC
);
350 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
351 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
352 TRACE_(dmfile
)(": %s chunk (size = %d)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
353 switch (Chunk
.fccID
) {
355 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
356 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
357 ListSize
[1] = Chunk
.dwSize
- sizeof(FOURCC
);
360 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
361 ListCount
[1] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
362 TRACE_(dmfile
)(": %s chunk (size = %d)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
363 switch (Chunk
.fccID
) {
364 case DMUS_FOURCC_BANDITEM_CHUNK
: {
365 DMUS_IO_BAND_ITEM_HEADER tmp_header
;
366 TRACE_(dmfile
)(": Band Item chunk v1\n");
368 IStream_Read (pStm
, &tmp_header
, sizeof(DMUS_IO_BAND_ITEM_HEADER
), NULL
);
369 TRACE_(dmfile
)(" - lBandTime: %u\n", tmp_header
.lBandTime
);
371 header
.dwVersion
= 1;
372 header
.lBandTime
= tmp_header
.lBandTime
;
375 case DMUS_FOURCC_BANDITEM_CHUNK2
: {
376 DMUS_IO_BAND_ITEM_HEADER2 tmp_header2
;
377 TRACE_(dmfile
)(": Band Item chunk v2\n");
379 IStream_Read (pStm
, &tmp_header2
, sizeof(DMUS_IO_BAND_ITEM_HEADER2
), NULL
);
380 TRACE_(dmfile
)(" - lBandTimeLogical: %u\n", tmp_header2
.lBandTimeLogical
);
381 TRACE_(dmfile
)(" - lBandTimePhysical: %u\n", tmp_header2
.lBandTimePhysical
);
383 header
.dwVersion
= 2;
384 header
.lBandTimeLogical
= tmp_header2
.lBandTimeLogical
;
385 header
.lBandTimePhysical
= tmp_header2
.lBandTimePhysical
;
389 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
390 TRACE_(dmfile
)(": RIFF chunk of type %s\n", debugstr_fourcc(Chunk
.fccID
));
391 StreamSize
= Chunk
.dwSize
- sizeof(FOURCC
);
392 switch (Chunk
.fccID
) {
393 case DMUS_FOURCC_BAND_FORM
: {
394 LPSTREAM pClonedStream
= NULL
;
395 TRACE_(dmfile
)(": BAND RIFF\n");
397 IStream_Clone (pStm
, &pClonedStream
);
400 liMove
.QuadPart
-= sizeof(FOURCC
) + (sizeof(FOURCC
)+sizeof(DWORD
));
401 IStream_Seek (pClonedStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
403 hr
= load_band(This
, pClonedStream
, &pBand
, &header
);
405 ERR(": could not load track\n");
408 IStream_Release (pClonedStream
);
410 IDirectMusicTrack_Release(pBand
); pBand
= NULL
; /* now we can release at as it inserted */
412 /** now safe move the cursor */
413 liMove
.QuadPart
= StreamSize
;
414 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
418 TRACE_(dmfile
)(": unknown chunk (irrelevant & skipping)\n");
419 liMove
.QuadPart
= StreamSize
;
420 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
427 TRACE_(dmfile
)(": unknown chunk (irrelevant & skipping)\n");
428 liMove
.QuadPart
= Chunk
.dwSize
;
429 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
433 TRACE_(dmfile
)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount
[1], ListSize
[1]);
434 } while (ListCount
[1] < ListSize
[1]);
438 TRACE_(dmfile
)(": unknown chunk (irrelevant & skipping)\n");
439 liMove
.QuadPart
= Chunk
.dwSize
;
440 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
444 TRACE_(dmfile
)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount
[0], ListSize
[0]);
445 } while (ListCount
[0] < ListSize
[0]);
450 static HRESULT
parse_bandtrack_form(IDirectMusicBandTrack
*This
, DMUS_PRIVATE_CHUNK
*pChunk
,
454 DMUS_PRIVATE_CHUNK Chunk
;
455 DWORD StreamSize
, StreamCount
, ListSize
[3], ListCount
[3];
456 LARGE_INTEGER liMove
; /* used when skipping chunks */
458 if (pChunk
->fccID
!= DMUS_FOURCC_BANDTRACK_FORM
) {
459 ERR_(dmfile
)(": %s chunk should be a BANDTRACK form\n", debugstr_fourcc (pChunk
->fccID
));
463 StreamSize
= pChunk
->dwSize
- sizeof(FOURCC
);
467 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
468 StreamCount
+= sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
469 TRACE_(dmfile
)(": %s chunk (size = %d)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
471 hr
= IDirectMusicUtils_IPersistStream_ParseDescGeneric(&Chunk
, pStm
, &This
->dmobj
.desc
);
472 if (FAILED(hr
)) return hr
;
475 switch (Chunk
.fccID
) {
476 case DMUS_FOURCC_BANDTRACK_CHUNK
: {
477 TRACE_(dmfile
)(": BandTrack chunk\n");
478 IStream_Read (pStm
, &This
->header
, sizeof(DMUS_IO_BAND_TRACK_HEADER
), NULL
);
479 TRACE_(dmfile
)(" - bAutoDownload: %u\n", This
->header
.bAutoDownload
);
483 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
484 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
485 ListSize
[0] = Chunk
.dwSize
- sizeof(FOURCC
);
487 switch (Chunk
.fccID
) {
488 case DMUS_FOURCC_UNFO_LIST
: {
489 TRACE_(dmfile
)(": UNFO list\n");
491 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
492 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
493 TRACE_(dmfile
)(": %s chunk (size = %d)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
495 hr
= IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk
, pStm
, &This
->dmobj
.desc
);
496 if (FAILED(hr
)) return hr
;
499 switch (Chunk
.fccID
) {
501 TRACE_(dmfile
)(": unknown chunk (irrelevant & skipping)\n");
502 liMove
.QuadPart
= Chunk
.dwSize
;
503 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
508 TRACE_(dmfile
)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount
[0], ListSize
[0]);
509 } while (ListCount
[0] < ListSize
[0]);
512 case DMUS_FOURCC_BANDS_LIST
: {
513 TRACE_(dmfile
)(": TRACK list\n");
514 hr
= parse_bands_list(This
, &Chunk
, pStm
);
515 if (FAILED(hr
)) return hr
;
519 TRACE_(dmfile
)(": unknown (skipping)\n");
520 liMove
.QuadPart
= Chunk
.dwSize
- sizeof(FOURCC
);
521 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
528 TRACE_(dmfile
)(": unknown chunk (irrelevant & skipping)\n");
529 liMove
.QuadPart
= Chunk
.dwSize
;
530 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
535 TRACE_(dmfile
)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount
, StreamSize
);
536 } while (StreamCount
< StreamSize
);
541 static inline IDirectMusicBandTrack
*impl_from_IPersistStream(IPersistStream
*iface
)
543 return CONTAINING_RECORD(iface
, IDirectMusicBandTrack
, dmobj
.IPersistStream_iface
);
546 static HRESULT WINAPI
IPersistStreamImpl_Load(IPersistStream
*iface
, IStream
*pStm
)
548 IDirectMusicBandTrack
*This
= impl_from_IPersistStream(iface
);
549 DMUS_PRIVATE_CHUNK Chunk
;
550 LARGE_INTEGER liMove
;
553 TRACE("(%p, %p): Loading\n", This
, pStm
);
555 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
556 TRACE_(dmfile
)(": %s chunk (size = %d)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
557 switch (Chunk
.fccID
) {
559 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
560 TRACE_(dmfile
)(": %s chunk (size = %d)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
561 switch (Chunk
.fccID
) {
562 case DMUS_FOURCC_BANDTRACK_FORM
: {
563 TRACE_(dmfile
)(": Band track form\n");
564 hr
= parse_bandtrack_form(This
, &Chunk
, pStm
);
565 if (FAILED(hr
)) return hr
;
569 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
570 liMove
.QuadPart
= Chunk
.dwSize
;
571 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
575 TRACE_(dmfile
)(": reading finished\n");
579 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
580 liMove
.QuadPart
= Chunk
.dwSize
;
581 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
589 static const IPersistStreamVtbl persiststream_vtbl
= {
590 dmobj_IPersistStream_QueryInterface
,
591 dmobj_IPersistStream_AddRef
,
592 dmobj_IPersistStream_Release
,
593 dmobj_IPersistStream_GetClassID
,
594 unimpl_IPersistStream_IsDirty
,
595 IPersistStreamImpl_Load
,
596 unimpl_IPersistStream_Save
,
597 unimpl_IPersistStream_GetSizeMax
600 /* for ClassFactory */
601 HRESULT WINAPI
create_dmbandtrack(REFIID lpcGUID
, void **ppobj
)
603 IDirectMusicBandTrack
*track
;
606 track
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*track
));
609 return E_OUTOFMEMORY
;
611 track
->IDirectMusicTrack8_iface
.lpVtbl
= &dmtrack8_vtbl
;
613 dmobject_init(&track
->dmobj
, &CLSID_DirectMusicBandTrack
,
614 (IUnknown
*)&track
->IDirectMusicTrack8_iface
);
615 track
->dmobj
.IPersistStream_iface
.lpVtbl
= &persiststream_vtbl
;
616 list_init (&track
->Bands
);
619 hr
= IDirectMusicTrack8_QueryInterface(&track
->IDirectMusicTrack8_iface
, lpcGUID
, ppobj
);
620 IDirectMusicTrack8_Release(&track
->IDirectMusicTrack8_iface
);