1 /* IDirectMusicBand Implementation
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.
26 #include "wine/debug.h"
28 #include "dmband_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(dmband);
31 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
33 /*****************************************************************************
34 * IDirectMusicBandImpl implementation
36 /* IDirectMusicBand IUnknown part: */
37 HRESULT WINAPI IDirectMusicBandImpl_QueryInterface (LPDIRECTMUSICBAND iface, REFIID riid, LPVOID *ppobj)
39 ICOM_THIS(IDirectMusicBandImpl,iface);
41 if (IsEqualGUID(riid, &IID_IUnknown) ||
42 IsEqualGUID(riid, &IID_IDirectMusicBand)) {
43 IDirectMusicBandImpl_AddRef(iface);
47 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
51 ULONG WINAPI IDirectMusicBandImpl_AddRef (LPDIRECTMUSICBAND iface)
53 ICOM_THIS(IDirectMusicBandImpl,iface);
54 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
58 ULONG WINAPI IDirectMusicBandImpl_Release (LPDIRECTMUSICBAND iface)
60 ICOM_THIS(IDirectMusicBandImpl,iface);
61 ULONG ref = --This->ref;
62 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
64 HeapFree(GetProcessHeap(), 0, This);
69 /* IDirectMusicBand IDirectMusicBand part: */
70 HRESULT WINAPI IDirectMusicBandImpl_CreateSegment (LPDIRECTMUSICBAND iface, IDirectMusicSegment** ppSegment)
72 ICOM_THIS(IDirectMusicBandImpl,iface);
74 FIXME("(%p, %p): stub\n", This, ppSegment);
79 HRESULT WINAPI IDirectMusicBandImpl_Download (LPDIRECTMUSICBAND iface, IDirectMusicPerformance* pPerformance)
81 ICOM_THIS(IDirectMusicBandImpl,iface);
83 FIXME("(%p, %p): stub\n", This, pPerformance);
88 HRESULT WINAPI IDirectMusicBandImpl_Unload (LPDIRECTMUSICBAND iface, IDirectMusicPerformance* pPerformance)
90 ICOM_THIS(IDirectMusicBandImpl,iface);
92 FIXME("(%p, %p): stub\n", This, pPerformance);
97 ICOM_VTABLE(IDirectMusicBand) DirectMusicBand_Vtbl =
99 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
100 IDirectMusicBandImpl_QueryInterface,
101 IDirectMusicBandImpl_AddRef,
102 IDirectMusicBandImpl_Release,
103 IDirectMusicBandImpl_CreateSegment,
104 IDirectMusicBandImpl_Download,
105 IDirectMusicBandImpl_Unload
108 /* for ClassFactory */
109 HRESULT WINAPI DMUSIC_CreateDirectMusicBand (LPCGUID lpcGUID, LPDIRECTMUSICBAND* ppDMBand, LPUNKNOWN pUnkOuter)
111 IDirectMusicBandImpl* dmband;
113 if (IsEqualGUID (lpcGUID, &IID_IDirectMusicBand)) {
114 dmband = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBandImpl));
115 if (NULL == dmband) {
116 *ppDMBand = (LPDIRECTMUSICBAND) NULL;
117 return E_OUTOFMEMORY;
119 dmband->lpVtbl = &DirectMusicBand_Vtbl;
121 list_init (&dmband->Instruments);
122 *ppDMBand = (LPDIRECTMUSICBAND) dmband;
125 WARN("No interface found\n");
127 return E_NOINTERFACE;
130 /*****************************************************************************
131 * IDirectMusicBandObject implementation
133 /* IDirectMusicBandObject IUnknown part: */
134 HRESULT WINAPI IDirectMusicBandObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj)
136 ICOM_THIS(IDirectMusicBandObject,iface);
138 if (IsEqualGUID (riid, &IID_IUnknown)
139 || IsEqualGUID(riid, &IID_IDirectMusicObject)) {
140 IDirectMusicBandObject_AddRef(iface);
143 } else if (IsEqualGUID (riid, &IID_IPersistStream)) {
144 IPersistStream_AddRef ((LPPERSISTSTREAM)This->pStream);
145 *ppobj = (LPPERSISTSTREAM)This->pStream;
147 } else if (IsEqualGUID (riid, &IID_IDirectMusicBand)) {
148 IDirectMusicBand_AddRef ((LPDIRECTMUSICBAND)This->pBand);
149 *ppobj = (LPDIRECTMUSICBAND)This->pBand;
152 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
153 return E_NOINTERFACE;
156 ULONG WINAPI IDirectMusicBandObject_AddRef (LPDIRECTMUSICOBJECT iface)
158 ICOM_THIS(IDirectMusicBandObject,iface);
159 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
160 return ++(This->ref);
163 ULONG WINAPI IDirectMusicBandObject_Release (LPDIRECTMUSICOBJECT iface)
165 ICOM_THIS(IDirectMusicBandObject,iface);
166 ULONG ref = --This->ref;
167 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
170 HeapFree(GetProcessHeap(), 0, This);
175 /* IDirectMusicBandObject IDirectMusicObject part: */
176 HRESULT WINAPI IDirectMusicBandObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
178 ICOM_THIS(IDirectMusicBandObject,iface);
180 TRACE("(%p, %p)\n", This, pDesc);
186 HRESULT WINAPI IDirectMusicBandObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
188 ICOM_THIS(IDirectMusicBandObject,iface);
190 TRACE("(%p, %p)\n", This, pDesc);
196 HRESULT WINAPI IDirectMusicBandObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc)
198 ICOM_THIS(IDirectMusicBandObject,iface);
200 FIXME("(%p, %p, %p): stub\n", This, pStream, pDesc);
205 ICOM_VTABLE(IDirectMusicObject) DirectMusicBandObject_Vtbl =
207 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
208 IDirectMusicBandObject_QueryInterface,
209 IDirectMusicBandObject_AddRef,
210 IDirectMusicBandObject_Release,
211 IDirectMusicBandObject_GetDescriptor,
212 IDirectMusicBandObject_SetDescriptor,
213 IDirectMusicBandObject_ParseDescriptor
216 /* for ClassFactory */
217 HRESULT WINAPI DMUSIC_CreateDirectMusicBandObject (LPCGUID lpcGUID, LPDIRECTMUSICOBJECT* ppObject, LPUNKNOWN pUnkOuter)
219 IDirectMusicBandObject *obj;
221 TRACE("(%p,%p,%p)\n", lpcGUID, ppObject, pUnkOuter);
222 if (IsEqualGUID (lpcGUID, &IID_IDirectMusicObject)) {
223 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBandObject));
225 *ppObject = (LPDIRECTMUSICOBJECT) NULL;
226 return E_OUTOFMEMORY;
228 obj->lpVtbl = &DirectMusicBandObject_Vtbl;
230 /* prepare IPersistStream */
231 obj->pStream = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBandObjectStream));
232 obj->pStream->lpVtbl = &DirectMusicBandObjectStream_Vtbl;
233 obj->pStream->ref = 1;
234 obj->pStream->pParentObject = obj;
235 /* prepare IDirectMusicBand */
236 DMUSIC_CreateDirectMusicBand (&IID_IDirectMusicBand, (LPDIRECTMUSICBAND*)&obj->pBand, NULL);
237 obj->pBand->pObject = obj;
238 *ppObject = (LPDIRECTMUSICOBJECT) obj;
241 WARN("No interface found\n");
243 return E_NOINTERFACE;
246 /*****************************************************************************
247 * IDirectMusicBandObjectStream implementation
249 /* IDirectMusicBandObjectStream IUnknown part: */
250 HRESULT WINAPI IDirectMusicBandObjectStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj)
252 ICOM_THIS(IDirectMusicBandObjectStream,iface);
254 if (IsEqualGUID(riid, &IID_IUnknown)
255 || IsEqualGUID(riid, &IID_IPersistStream)) {
256 IDirectMusicBandObjectStream_AddRef(iface);
260 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
261 return E_NOINTERFACE;
264 ULONG WINAPI IDirectMusicBandObjectStream_AddRef (LPPERSISTSTREAM iface)
266 ICOM_THIS(IDirectMusicBandObjectStream,iface);
267 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
268 return ++(This->ref);
271 ULONG WINAPI IDirectMusicBandObjectStream_Release (LPPERSISTSTREAM iface)
273 ICOM_THIS(IDirectMusicBandObjectStream,iface);
274 ULONG ref = --This->ref;
275 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
277 HeapFree(GetProcessHeap(), 0, This);
282 /* IDirectMusicBandObjectStream IPersist part: */
283 HRESULT WINAPI IDirectMusicBandObjectStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID)
288 /* IDirectMusicBandObjectStream IPersistStream part: */
289 HRESULT WINAPI IDirectMusicBandObjectStream_IsDirty (LPPERSISTSTREAM iface)
294 HRESULT WINAPI IDirectMusicBandObjectStream_Load (LPPERSISTSTREAM iface, IStream* pStm)
296 ICOM_THIS(IDirectMusicBandObjectStream,iface);
298 DWORD chunkSize, StreamSize, StreamCount, ListSize[3], ListCount[3];
299 LARGE_INTEGER liMove; /* used when skipping chunks */
300 DMUS_IO_REFERENCE tempReferenceHeader;
301 DMUS_OBJECTDESC ObjDesc;
302 IDirectMusicBandImpl* pBand = This->pParentObject->pBand; /* that's where we load data to */
303 LPDIRECTMUSICLOADER pLoader;
304 LPDIRECTMUSICGETLOADER pGetLoader;
306 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
307 IStream_Read (pStm, &chunkSize, sizeof(DWORD), NULL);
308 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
311 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
312 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunkID));
313 StreamSize = chunkSize - sizeof(FOURCC);
316 case DMUS_FOURCC_BAND_FORM: {
317 TRACE_(dmfile)(": band form\n");
319 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
320 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
321 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
322 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
324 case DMUS_FOURCC_GUID_CHUNK: {
325 TRACE_(dmfile)(": GUID chunk\n");
326 IStream_Read (pStm, pBand->guidID, chunkSize, NULL);
329 case DMUS_FOURCC_VERSION_CHUNK: {
330 TRACE_(dmfile)(": version chunk\n");
331 IStream_Read (pStm, pBand->vVersion, chunkSize, NULL);
335 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
336 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
337 ListSize[0] = chunkSize - sizeof(FOURCC);
340 case DMUS_FOURCC_UNFO_LIST: {
341 TRACE_(dmfile)(": UNFO list\n");
343 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
344 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
345 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
346 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
348 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
349 (though strings seem to be valid unicode) */
350 case mmioFOURCC('I','N','A','M'):
351 case DMUS_FOURCC_UNAM_CHUNK: {
352 TRACE_(dmfile)(": name chunk\n");
353 pBand->wzName = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
354 IStream_Read (pStm, pBand->wzName, chunkSize, NULL);
357 case mmioFOURCC('I','A','R','T'):
358 case DMUS_FOURCC_UART_CHUNK: {
359 TRACE_(dmfile)(": artist chunk\n");
360 pBand->wzArtist = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
361 IStream_Read (pStm, pBand->wzArtist, chunkSize, NULL);
364 case mmioFOURCC('I','C','O','P'):
365 case DMUS_FOURCC_UCOP_CHUNK: {
366 TRACE_(dmfile)(": copyright chunk\n");
367 pBand->wzCopyright = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
368 IStream_Read (pStm, pBand->wzCopyright, chunkSize, NULL);
371 case mmioFOURCC('I','S','B','J'):
372 case DMUS_FOURCC_USBJ_CHUNK: {
373 TRACE_(dmfile)(": subject chunk\n");
374 pBand->wzSubject = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
375 IStream_Read (pStm, pBand->wzSubject, chunkSize, NULL);
378 case mmioFOURCC('I','C','M','T'):
379 case DMUS_FOURCC_UCMT_CHUNK: {
380 TRACE_(dmfile)(": comment chunk\n");
381 pBand->wzComment = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
382 IStream_Read (pStm, pBand->wzComment, chunkSize, NULL);
386 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
387 liMove.QuadPart = chunkSize;
388 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
392 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
393 } while (ListCount[0] < ListSize[0]);
396 case DMUS_FOURCC_INSTRUMENTS_LIST: {
397 TRACE_(dmfile)(": instruments list\n");
399 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
400 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
401 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
402 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
405 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
406 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
407 ListSize[1] = chunkSize - sizeof(FOURCC);
410 case DMUS_FOURCC_INSTRUMENT_LIST: {
411 /* init new instrument list entry */
412 LPDMUS_PRIVATE_INSTRUMENT pNewInstrument = (LPDMUS_PRIVATE_INSTRUMENT) HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_INSTRUMENT));
413 TRACE_(dmfile)(": instrument list\n");
415 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
416 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
417 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
418 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
420 case DMUS_FOURCC_INSTRUMENT_CHUNK: {
421 TRACE_(dmfile)(": band instrument header\n");
422 IStream_Read (pStm, &pNewInstrument->pInstrument, chunkSize, NULL);
426 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
427 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
428 ListSize[2] = chunkSize - sizeof(FOURCC);
431 case DMUS_FOURCC_REF_LIST: {
432 TRACE_(dmfile)(": reference list\n");
433 ZeroMemory ((LPVOID)&ObjDesc, sizeof(DMUS_OBJECTDESC));
435 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
436 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
437 ListCount[2] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
438 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
440 case DMUS_FOURCC_REF_CHUNK: {
441 TRACE_(dmfile)(": reference header chunk\n");
442 IStream_Read (pStm, &tempReferenceHeader, chunkSize, NULL);
443 /* copy retrieved data to DMUS_OBJECTDESC */
444 ObjDesc.dwSize = sizeof(DMUS_OBJECTDESC);
445 ObjDesc.guidClass = tempReferenceHeader.guidClassID;
446 ObjDesc.dwValidData = tempReferenceHeader.dwValidData;
449 case DMUS_FOURCC_GUID_CHUNK: {
450 TRACE_(dmfile)(": guid chunk\n");
451 IStream_Read (pStm, &ObjDesc.guidObject, chunkSize, NULL);
454 case DMUS_FOURCC_DATE_CHUNK: {
455 TRACE_(dmfile)(": file date chunk\n");
456 IStream_Read (pStm, &ObjDesc.ftDate, chunkSize, NULL);
459 case DMUS_FOURCC_NAME_CHUNK: {
460 TRACE_(dmfile)(": name chunk\n");
461 IStream_Read (pStm, &ObjDesc.wszName, chunkSize, NULL);
464 case DMUS_FOURCC_FILE_CHUNK: {
465 TRACE_(dmfile)(": file name chunk\n");
466 IStream_Read (pStm, &ObjDesc.wszFileName, chunkSize, NULL);
469 case DMUS_FOURCC_CATEGORY_CHUNK: {
470 TRACE_(dmfile)(": category chunk\n");
471 IStream_Read (pStm, &ObjDesc.wszCategory, chunkSize, NULL);
474 case DMUS_FOURCC_VERSION_CHUNK: {
475 TRACE_(dmfile)(": version chunk\n");
476 IStream_Read (pStm, &ObjDesc.vVersion, chunkSize, NULL);
480 TRACE_(dmfile)(": unknown chunk (skipping)\n");
481 liMove.QuadPart = chunkSize;
482 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip this chunk */
486 TRACE_(dmfile)(": ListCount[2] = %ld < ListSize[2] = %ld\n", ListCount[2], ListSize[2]);
487 } while (ListCount[2] < ListSize[2]);
488 /* let's see what we have */
489 TRACE_(dmfile)(": (READ): reference: dwSize = %ld; dwValidData = %ld; guidObject = %s; guidClass = %s; \
490 vVersion = %08lx,%08lx; wszName = %s; wszCategory = %s; wszFileName = %s\n", ObjDesc.dwSize, ObjDesc.dwValidData, debugstr_guid(&ObjDesc.guidObject), debugstr_guid(&ObjDesc.guidClass),
491 ObjDesc.vVersion.dwVersionMS, ObjDesc.vVersion.dwVersionLS, debugstr_w(ObjDesc.wszName), debugstr_w(ObjDesc.wszCategory), debugstr_w(ObjDesc.wszFileName));
492 /* now, let's convience loader to load reference */
493 if (IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*)&pGetLoader) == S_OK) {
494 if (IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader) == S_OK) {
495 /* load referenced object */
496 IDirectMusicObject* pObject;
497 if(FAILED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc, &IID_IDirectMusicObject, (LPVOID*)&pObject)))
498 /* acquire collection from loaded referenced object */
499 if(FAILED(IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicCollection, (LPVOID*)&pNewInstrument->ppReferenceCollection)))
500 IDirectMusicLoader_Release (pLoader);
502 IDirectMusicGetLoader_Release (pGetLoader);
504 ERR("Could not get IDirectMusicGetLoader... reference will not be loaded :(\n");
510 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
517 TRACE_(dmfile)(": unknown chunk (skipping)\n");
518 liMove.QuadPart = chunkSize;
519 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip this chunk */
523 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
524 } while (ListCount[1] < ListSize[1]);
525 /* hmm... in dxdiag segment's band there aren't any references, but loader still desperatly
526 loads default collection... does that mean that if there is no reference, use default?
528 if (!pNewInstrument->ppReferenceCollection) {
529 TRACE_(dmfile)(": (READ): loading default collection (as no specific reference was made)\n");
530 ZeroMemory ((LPVOID)&ObjDesc, sizeof(DMUS_OBJECTDESC));
531 ObjDesc.dwSize = sizeof(DMUS_OBJECTDESC);
532 ObjDesc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_OBJECT;
533 ObjDesc.guidObject = GUID_DefaultGMCollection;
534 ObjDesc.guidClass = CLSID_DirectMusicCollection;
535 if (SUCCEEDED(IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*)&pGetLoader))) {
536 if (SUCCEEDED(IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader))) {
537 IDirectMusicObject* pObject;
538 if (SUCCEEDED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc, &IID_IDirectMusicObject, (LPVOID*)&pObject))) {
539 IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicCollection, (LPVOID*)&pNewInstrument->ppReferenceCollection);
540 IDirectMusicLoader_Release (pLoader);
543 IDirectMusicGetLoader_Release (pGetLoader);
545 ERR("Could not get IDirectMusicGetLoader... reference will not be loaded :(\n");
549 list_add_tail (&This->pParentObject->pBand->Instruments, &pNewInstrument->entry);
553 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
560 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
561 liMove.QuadPart = chunkSize;
562 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
566 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
567 } while (ListCount[0] < ListSize[0]);
571 TRACE_(dmfile)(": unknown (skipping)\n");
572 liMove.QuadPart = chunkSize - sizeof(FOURCC);
573 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
580 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
581 liMove.QuadPart = chunkSize;
582 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
586 TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount, StreamSize);
587 } while (StreamCount < StreamSize);
591 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
592 liMove.QuadPart = StreamSize;
593 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
597 TRACE_(dmfile)(": reading finished\n");
601 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
602 liMove.QuadPart = chunkSize;
603 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
608 /* DEBUG: dumps whole band object tree: */
609 if (TRACE_ON(dmband)) {
611 DMUS_PRIVATE_INSTRUMENT *tmpEntry;
612 struct list *listEntry;
614 TRACE("*** IDirectMusicBand (%p) ***\n", pBand);
616 TRACE(" - GUID = %s\n", debugstr_guid(pBand->guidID));
618 TRACE(" - Version = %i,%i,%i,%i\n", (pBand->vVersion->dwVersionMS >> 8) && 0x0000FFFF, pBand->vVersion->dwVersionMS && 0x0000FFFF, \
619 (pBand->vVersion->dwVersionLS >> 8) && 0x0000FFFF, pBand->vVersion->dwVersionLS && 0x0000FFFF);
621 TRACE(" - Name = %s\n", debugstr_w(pBand->wzName));
623 TRACE(" - Artist = %s\n", debugstr_w(pBand->wzArtist));
624 if (pBand->wzCopyright)
625 TRACE(" - Copyright = %s\n", debugstr_w(pBand->wzCopyright));
626 if (pBand->wzSubject)
627 TRACE(" - Subject = %s\n", debugstr_w(pBand->wzSubject));
628 if (pBand->wzComment)
629 TRACE(" - Comment = %s\n", debugstr_w(pBand->wzComment));
631 TRACE(" - Instruments:\n");
633 LIST_FOR_EACH (listEntry, &This->pParentObject->pBand->Instruments) {
634 tmpEntry = LIST_ENTRY( listEntry, DMUS_PRIVATE_INSTRUMENT, entry );
635 TRACE(" - Instrument[%i]:\n", r);
636 TRACE(" - Instrument header:\n");
637 TRACE(" - dwPatch = %ld\n", tmpEntry->pInstrument.dwPatch);
638 TRACE(" - dwAssignPatch = %ld\n", tmpEntry->pInstrument.dwAssignPatch);
639 TRACE(" - dwNoteRanges[4] = %ln\n", tmpEntry->pInstrument.dwNoteRanges);
640 TRACE(" - dwPChannel = %ld\n", tmpEntry->pInstrument.dwPChannel);
641 TRACE(" - dwFlags = %ld\n", tmpEntry->pInstrument.dwFlags);
642 TRACE(" - bPan = %i\n", tmpEntry->pInstrument.bPan);
643 TRACE(" - bVolume = %i\n", tmpEntry->pInstrument.bVolume);
644 TRACE(" - nTranspose = %i\n", tmpEntry->pInstrument.nTranspose);
645 TRACE(" - dwChannelPriority = %ld\n", tmpEntry->pInstrument.dwChannelPriority);
646 TRACE(" - nPitchBendRange = %i\n", tmpEntry->pInstrument.nPitchBendRange);
647 TRACE(" - Reference collection: %p\n", tmpEntry->ppReferenceCollection);
655 HRESULT WINAPI IDirectMusicBandObjectStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty)
660 HRESULT WINAPI IDirectMusicBandObjectStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize)
665 ICOM_VTABLE(IPersistStream) DirectMusicBandObjectStream_Vtbl =
667 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
668 IDirectMusicBandObjectStream_QueryInterface,
669 IDirectMusicBandObjectStream_AddRef,
670 IDirectMusicBandObjectStream_Release,
671 IDirectMusicBandObjectStream_GetClassID,
672 IDirectMusicBandObjectStream_IsDirty,
673 IDirectMusicBandObjectStream_Load,
674 IDirectMusicBandObjectStream_Save,
675 IDirectMusicBandObjectStream_GetSizeMax