Fixed header dependencies to be fully compatible with the Windows
[wine/multimedia.git] / dlls / dmband / band.c
blob6dd620e8c5615a41ca494bc1f1ec43188a0baaee
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.
20 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winuser.h"
25 #include "wingdi.h"
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))
44 IDirectMusicBandImpl_AddRef(iface);
45 *ppobj = This;
46 return S_OK;
48 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
49 return E_NOINTERFACE;
52 ULONG WINAPI IDirectMusicBandImpl_AddRef (LPDIRECTMUSICBAND iface)
54 ICOM_THIS(IDirectMusicBandImpl,iface);
55 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
56 return ++(This->ref);
59 ULONG WINAPI IDirectMusicBandImpl_Release (LPDIRECTMUSICBAND iface)
61 ICOM_THIS(IDirectMusicBandImpl,iface);
62 ULONG ref = --This->ref;
63 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
64 if (ref == 0)
66 HeapFree(GetProcessHeap(), 0, This);
68 return ref;
71 /* IDirectMusicBand IDirectMusicBand part: */
72 HRESULT WINAPI IDirectMusicBandImpl_CreateSegment (LPDIRECTMUSICBAND iface, IDirectMusicSegment** ppSegment)
74 ICOM_THIS(IDirectMusicBandImpl,iface);
76 FIXME("(%p, %p): stub\n", This, ppSegment);
78 return S_OK;
81 HRESULT WINAPI IDirectMusicBandImpl_Download (LPDIRECTMUSICBAND iface, IDirectMusicPerformance* pPerformance)
83 ICOM_THIS(IDirectMusicBandImpl,iface);
85 FIXME("(%p, %p): stub\n", This, pPerformance);
87 return S_OK;
90 HRESULT WINAPI IDirectMusicBandImpl_Unload (LPDIRECTMUSICBAND iface, IDirectMusicPerformance* pPerformance)
92 ICOM_THIS(IDirectMusicBandImpl,iface);
94 FIXME("(%p, %p): stub\n", This, pPerformance);
96 return S_OK;
99 ICOM_VTABLE(IDirectMusicBand) DirectMusicBand_Vtbl =
101 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
102 IDirectMusicBandImpl_QueryInterface,
103 IDirectMusicBandImpl_AddRef,
104 IDirectMusicBandImpl_Release,
105 IDirectMusicBandImpl_CreateSegment,
106 IDirectMusicBandImpl_Download,
107 IDirectMusicBandImpl_Unload
110 /* for ClassFactory */
111 HRESULT WINAPI DMUSIC_CreateDirectMusicBand (LPCGUID lpcGUID, LPDIRECTMUSICBAND* ppDMBand, LPUNKNOWN pUnkOuter)
113 IDirectMusicBandImpl* dmband;
115 if (IsEqualGUID (lpcGUID, &IID_IDirectMusicBand))
117 dmband = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBandImpl));
118 if (NULL == dmband) {
119 *ppDMBand = (LPDIRECTMUSICBAND) NULL;
120 return E_OUTOFMEMORY;
122 dmband->lpVtbl = &DirectMusicBand_Vtbl;
123 dmband->ref = 1;
124 *ppDMBand = (LPDIRECTMUSICBAND) dmband;
125 return S_OK;
127 WARN("No interface found\n");
129 return E_NOINTERFACE;
132 /*****************************************************************************
133 * IDirectMusicBandObject implementation
135 /* IDirectMusicBandObject IUnknown part: */
136 HRESULT WINAPI IDirectMusicBandObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj)
138 ICOM_THIS(IDirectMusicBandObject,iface);
140 if (IsEqualGUID (riid, &IID_IUnknown)
141 || IsEqualGUID(riid, &IID_IDirectMusicObject)) {
142 IDirectMusicBandObject_AddRef(iface);
143 *ppobj = This;
144 return S_OK;
145 } else if (IsEqualGUID (riid, &IID_IPersistStream)) {
146 IPersistStream_AddRef ((LPPERSISTSTREAM)This->pStream);
147 *ppobj = (LPPERSISTSTREAM)This->pStream;
148 return S_OK;
149 } else if (IsEqualGUID (riid, &IID_IDirectMusicBand)) {
150 IDirectMusicBand_AddRef ((LPDIRECTMUSICBAND)This->pBand);
151 *ppobj = (LPDIRECTMUSICBAND)This->pBand;
152 return S_OK;
154 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
155 return E_NOINTERFACE;
158 ULONG WINAPI IDirectMusicBandObject_AddRef (LPDIRECTMUSICOBJECT iface)
160 ICOM_THIS(IDirectMusicBandObject,iface);
161 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
162 return ++(This->ref);
165 ULONG WINAPI IDirectMusicBandObject_Release (LPDIRECTMUSICOBJECT iface)
167 ICOM_THIS(IDirectMusicBandObject,iface);
168 ULONG ref = --This->ref;
169 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
170 if (ref == 0)
172 HeapFree(GetProcessHeap(), 0, This);
174 return ref;
177 /* IDirectMusicBandObject IDirectMusicObject part: */
178 HRESULT WINAPI IDirectMusicBandObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
180 ICOM_THIS(IDirectMusicBandObject,iface);
182 TRACE("(%p, %p)\n", This, pDesc);
183 pDesc = This->pDesc;
185 return S_OK;
188 HRESULT WINAPI IDirectMusicBandObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
190 ICOM_THIS(IDirectMusicBandObject,iface);
192 TRACE("(%p, %p)\n", This, pDesc);
193 This->pDesc = pDesc;
195 return S_OK;
198 HRESULT WINAPI IDirectMusicBandObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc)
200 ICOM_THIS(IDirectMusicBandObject,iface);
202 FIXME("(%p, %p, %p): stub\n", This, pStream, pDesc);
204 return S_OK;
207 ICOM_VTABLE(IDirectMusicObject) DirectMusicBandObject_Vtbl =
209 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
210 IDirectMusicBandObject_QueryInterface,
211 IDirectMusicBandObject_AddRef,
212 IDirectMusicBandObject_Release,
213 IDirectMusicBandObject_GetDescriptor,
214 IDirectMusicBandObject_SetDescriptor,
215 IDirectMusicBandObject_ParseDescriptor
218 /* for ClassFactory */
219 HRESULT WINAPI DMUSIC_CreateDirectMusicBandObject (LPCGUID lpcGUID, LPDIRECTMUSICOBJECT* ppObject, LPUNKNOWN pUnkOuter)
221 IDirectMusicBandObject *obj;
223 TRACE("(%p,%p,%p)\n", lpcGUID, ppObject, pUnkOuter);
224 if (IsEqualGUID (lpcGUID, &IID_IDirectMusicObject)) {
225 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBandObject));
226 if (NULL == obj) {
227 *ppObject = (LPDIRECTMUSICOBJECT) NULL;
228 return E_OUTOFMEMORY;
230 obj->lpVtbl = &DirectMusicBandObject_Vtbl;
231 obj->ref = 1;
232 /* prepare IPersistStream */
233 obj->pStream = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBandObjectStream));
234 obj->pStream->lpVtbl = &DirectMusicBandObjectStream_Vtbl;
235 obj->pStream->ref = 1;
236 obj->pStream->pParentObject = obj;
237 /* prepare IDirectMusicBand */
238 DMUSIC_CreateDirectMusicBand (&IID_IDirectMusicBand, (LPDIRECTMUSICBAND*)&obj->pBand, NULL);
239 obj->pBand->pObject = obj;
240 *ppObject = (LPDIRECTMUSICOBJECT) obj;
241 return S_OK;
243 WARN("No interface found\n");
245 return E_NOINTERFACE;
248 /*****************************************************************************
249 * IDirectMusicBandObjectStream implementation
251 /* IDirectMusicBandObjectStream IUnknown part: */
252 HRESULT WINAPI IDirectMusicBandObjectStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj)
254 ICOM_THIS(IDirectMusicBandObjectStream,iface);
256 if (IsEqualGUID(riid, &IID_IUnknown)
257 || IsEqualGUID(riid, &IID_IPersistStream)) {
258 IDirectMusicBandObjectStream_AddRef(iface);
259 *ppobj = This;
260 return S_OK;
262 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
263 return E_NOINTERFACE;
266 ULONG WINAPI IDirectMusicBandObjectStream_AddRef (LPPERSISTSTREAM iface)
268 ICOM_THIS(IDirectMusicBandObjectStream,iface);
269 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
270 return ++(This->ref);
273 ULONG WINAPI IDirectMusicBandObjectStream_Release (LPPERSISTSTREAM iface)
275 ICOM_THIS(IDirectMusicBandObjectStream,iface);
276 ULONG ref = --This->ref;
277 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
278 if (ref == 0) {
279 HeapFree(GetProcessHeap(), 0, This);
281 return ref;
284 /* IDirectMusicBandObjectStream IPersist part: */
285 HRESULT WINAPI IDirectMusicBandObjectStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID)
287 return E_NOTIMPL;
290 /* IDirectMusicBandObjectStream IPersistStream part: */
291 HRESULT WINAPI IDirectMusicBandObjectStream_IsDirty (LPPERSISTSTREAM iface)
293 return E_NOTIMPL;
296 HRESULT WINAPI IDirectMusicBandObjectStream_Load (LPPERSISTSTREAM iface, IStream* pStm)
298 ICOM_THIS(IDirectMusicBandObjectStream,iface);
299 FOURCC chunkID;
300 DWORD chunkSize, StreamSize, StreamCount, ListSize[3], ListCount[3];
301 LARGE_INTEGER liMove; /* used when skipping chunks */
302 DMUS_IO_REFERENCE tempReferenceHeader;
303 DMUS_OBJECTDESC ObjDesc;
304 IDirectMusicBandImpl* pBand = This->pParentObject->pBand; /* that's where we load data to */
305 LPDIRECTMUSICLOADER pLoader;
306 LPDIRECTMUSICGETLOADER pGetLoader;
308 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
309 IStream_Read (pStm, &chunkSize, sizeof(DWORD), NULL);
310 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
311 switch (chunkID) {
312 case FOURCC_RIFF: {
313 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
314 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunkID));
315 StreamSize = chunkSize - sizeof(FOURCC);
316 StreamCount = 0;
317 switch (chunkID) {
318 case DMUS_FOURCC_BAND_FORM: {
319 TRACE_(dmfile)(": band form\n");
320 do {
321 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
322 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
323 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
324 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
325 switch (chunkID) {
326 case DMUS_FOURCC_GUID_CHUNK: {
327 TRACE_(dmfile)(": GUID chunk\n");
328 IStream_Read (pStm, &pBand->vVersion, chunkSize, NULL);
329 break;
331 case DMUS_FOURCC_VERSION_CHUNK: {
332 TRACE_(dmfile)(": version chunk\n");
333 IStream_Read (pStm, &pBand->guidID, chunkSize, NULL);
334 break;
336 case FOURCC_LIST: {
337 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
338 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
339 ListSize[0] = chunkSize - sizeof(FOURCC);
340 ListCount[0] = 0;
341 switch (chunkID) {
342 case DMUS_FOURCC_UNFO_LIST: {
343 TRACE_(dmfile)(": UNFO list\n");
344 do {
345 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
346 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
347 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
348 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
349 switch (chunkID) {
350 case DMUS_FOURCC_UNAM_CHUNK: {
351 TRACE_(dmfile)(": name chunk\n");
352 pBand->wszName = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
353 IStream_Read (pStm, pBand->wszName, chunkSize, NULL);
354 break;
356 case DMUS_FOURCC_UART_CHUNK: {
357 TRACE_(dmfile)(": artist chunk\n");
358 pBand->wszArtist = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
359 IStream_Read (pStm, pBand->wszArtist, chunkSize, NULL);
360 break;
362 case DMUS_FOURCC_UCOP_CHUNK: {
363 TRACE_(dmfile)(": copyright chunk\n");
364 pBand->wszCopyright = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
365 IStream_Read (pStm, pBand->wszCopyright, chunkSize, NULL);
366 break;
368 case DMUS_FOURCC_USBJ_CHUNK: {
369 TRACE_(dmfile)(": subject chunk\n");
370 pBand->wszSubject = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
371 IStream_Read (pStm, pBand->wszSubject, chunkSize, NULL);
372 break;
374 case DMUS_FOURCC_UCMT_CHUNK: {
375 TRACE_(dmfile)(": comment chunk\n");
376 pBand->wszComment = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
377 IStream_Read (pStm, pBand->wszComment, chunkSize, NULL);
378 break;
380 default: {
381 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
382 liMove.QuadPart = chunkSize;
383 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
384 break;
387 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
388 } while (ListCount[0] < ListSize[0]);
389 break;
391 case DMUS_FOURCC_INSTRUMENTS_LIST: {
392 TRACE_(dmfile)(": instruments list\n");
393 do {
394 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
395 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
396 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
397 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
398 switch (chunkID) {
399 case FOURCC_LIST: {
400 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
401 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
402 ListSize[1] = chunkSize - sizeof(FOURCC);
403 ListCount[1] = 0;
404 switch (chunkID) {
405 case DMUS_FOURCC_INSTRUMENT_LIST: {
406 TRACE_(dmfile)(": instrument list\n");
407 do {
408 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
409 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
410 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
411 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
412 switch (chunkID) {
413 case DMUS_FOURCC_INSTRUMENT_CHUNK: {
414 TRACE_(dmfile)(": band instrument header\n");
415 IStream_Read (pStm, &pBand->pInstruments[pBand->dwInstruments], chunkSize, NULL);
416 break;
418 case FOURCC_LIST: {
419 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
420 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
421 ListSize[2] = chunkSize - sizeof(FOURCC);
422 ListCount[2] = 0;
423 switch (chunkID) {
424 case DMUS_FOURCC_REF_LIST: {
425 TRACE_(dmfile)(": reference list\n");
426 ZeroMemory ((LPVOID)&ObjDesc, sizeof(DMUS_OBJECTDESC));
427 do {
428 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
429 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
430 ListCount[2] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
431 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
432 switch (chunkID) {
433 case DMUS_FOURCC_REF_CHUNK: {
434 TRACE_(dmfile)(": reference header chunk\n");
435 IStream_Read (pStm, &tempReferenceHeader, chunkSize, NULL);
436 /* copy retrieved data to DMUS_OBJECTDESC */
437 ObjDesc.dwSize = sizeof(DMUS_OBJECTDESC);
438 ObjDesc.guidClass = tempReferenceHeader.guidClassID;
439 ObjDesc.dwValidData = tempReferenceHeader.dwValidData;
440 break;
442 case DMUS_FOURCC_GUID_CHUNK: {
443 TRACE_(dmfile)(": guid chunk\n");
444 IStream_Read (pStm, &ObjDesc.guidObject, chunkSize, NULL);
445 break;
447 case DMUS_FOURCC_DATE_CHUNK: {
448 TRACE_(dmfile)(": file date chunk\n");
449 IStream_Read (pStm, &ObjDesc.ftDate, chunkSize, NULL);
450 break;
452 case DMUS_FOURCC_NAME_CHUNK: {
453 TRACE_(dmfile)(": name chunk\n");
454 IStream_Read (pStm, &ObjDesc.wszName, chunkSize, NULL);
455 break;
457 case DMUS_FOURCC_FILE_CHUNK: {
458 TRACE_(dmfile)(": file name chunk\n");
459 IStream_Read (pStm, &ObjDesc.wszFileName, chunkSize, NULL);
460 break;
462 case DMUS_FOURCC_CATEGORY_CHUNK: {
463 TRACE_(dmfile)(": category chunk\n");
464 IStream_Read (pStm, &ObjDesc.wszCategory, chunkSize, NULL);
465 break;
467 case DMUS_FOURCC_VERSION_CHUNK: {
468 TRACE_(dmfile)(": version chunk\n");
469 IStream_Read (pStm, &ObjDesc.vVersion, chunkSize, NULL);
470 break;
472 default: {
473 TRACE_(dmfile)(": unknown chunk (skipping)\n");
474 liMove.QuadPart = chunkSize;
475 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip this chunk */
476 break;
479 TRACE_(dmfile)(": ListCount[2] = %ld < ListSize[2] = %ld\n", ListCount[2], ListSize[2]);
480 } while (ListCount[2] < ListSize[2]);
481 /* let's see what we have */
482 TRACE_(dmfile)(": (READ): reference: dwSize = %ld; dwValidData = %ld; guidObject = %s; guidClass = %s; \
483 vVersion = %08lx,%08lx; wszName = %s; wszCategory = %s; wszFileName = %s\n", ObjDesc.dwSize, ObjDesc.dwValidData, debugstr_guid(&ObjDesc.guidObject), debugstr_guid(&ObjDesc.guidClass),
484 ObjDesc.vVersion.dwVersionMS, ObjDesc.vVersion.dwVersionLS, debugstr_w(ObjDesc.wszName), debugstr_w(ObjDesc.wszCategory), debugstr_w(ObjDesc.wszFileName));
485 /* now, let's convience loader to load reference */
486 if (IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*)&pGetLoader) == S_OK) {
487 if (IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader) == S_OK) {
488 /* load referenced object */
489 IDirectMusicObject* pObject;
490 if(FAILED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc, &IID_IDirectMusicObject, (LPVOID*)&pObject)))
491 /* acquire collection from loaded referenced object */
492 if(FAILED(IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicCollection, (LPVOID*)&pBand->ppReferenceCollection[pBand->dwInstruments])))
493 IDirectMusicLoader_Release (pLoader);
495 IDirectMusicGetLoader_Release (pGetLoader);
496 } else {
497 ERR("Could not get IDirectMusicGetLoader... reference will not be loaded :(\n");
498 /* E_FAIL */
500 break;
502 default: {
503 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
504 return E_FAIL;
507 break;
509 default: {
510 TRACE_(dmfile)(": unknown chunk (skipping)\n");
511 liMove.QuadPart = chunkSize;
512 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip this chunk */
513 break;
516 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
517 } while (ListCount[1] < ListSize[1]);
518 /* causes crash :( */
519 #if 0
520 /* hmm... in dxdiag segment's band there aren't any references, but loader still desperatly
521 loads default collection... does that mean that if there is no reference, use default?
523 if (!pBand->ppReferenceCollection[pBand->dwInstruments]) {
524 TRACE(": (READ): loading default collection (as no specific reference was made)\n");
525 ZeroMemory ((LPVOID)&ObjDesc, sizeof(DMUS_OBJECTDESC));
526 ObjDesc.dwSize = sizeof(DMUS_OBJECTDESC);
527 ObjDesc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_OBJECT;
528 ObjDesc.guidObject = GUID_DefaultGMCollection;
529 ObjDesc.guidClass = CLSID_DirectMusicCollection;
530 if (SUCCEEDED(IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*)&pGetLoader))) {
531 if (SUCCEEDED(IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader))) {
532 IDirectMusicObject* pObject;
533 if (SUCCEEDED(IDirectMusicLoader_GetObject (pLoader, &ObjDesc, &IID_IDirectMusicObject, (LPVOID*)&pObject))) {
534 IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicCollection, (LPVOID*)&pBand->ppReferenceCollection[pBand->dwInstruments]);
535 IDirectMusicLoader_Release (pLoader);
538 IDirectMusicGetLoader_Release (pGetLoader);
539 } else {
540 ERR("Could not get IDirectMusicGetLoader... reference will not be loaded :(\n");
541 /* E_FAIL */
544 #endif
545 pBand->dwInstruments++; /* add count */
546 break;
548 default: {
549 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
550 return E_FAIL;
553 break;
555 default: {
556 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
557 liMove.QuadPart = chunkSize;
558 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
559 break;
562 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
563 } while (ListCount[0] < ListSize[0]);
564 break;
566 default: {
567 TRACE_(dmfile)(": unknown (skipping)\n");
568 liMove.QuadPart = chunkSize - sizeof(FOURCC);
569 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
570 break;
573 break;
575 default: {
576 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
577 liMove.QuadPart = chunkSize;
578 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
579 break;
582 TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount, StreamSize);
583 } while (StreamCount < StreamSize);
584 break;
586 default: {
587 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
588 liMove.QuadPart = StreamSize;
589 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
590 return E_FAIL;
593 TRACE_(dmfile)(": reading finished\n");
594 break;
596 default: {
597 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
598 liMove.QuadPart = chunkSize;
599 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
600 return E_FAIL;
604 return S_OK;
607 HRESULT WINAPI IDirectMusicBandObjectStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty)
609 return E_NOTIMPL;
612 HRESULT WINAPI IDirectMusicBandObjectStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize)
614 return E_NOTIMPL;
617 ICOM_VTABLE(IPersistStream) DirectMusicBandObjectStream_Vtbl =
619 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
620 IDirectMusicBandObjectStream_QueryInterface,
621 IDirectMusicBandObjectStream_AddRef,
622 IDirectMusicBandObjectStream_Release,
623 IDirectMusicBandObjectStream_GetClassID,
624 IDirectMusicBandObjectStream_IsDirty,
625 IDirectMusicBandObjectStream_Load,
626 IDirectMusicBandObjectStream_Save,
627 IDirectMusicBandObjectStream_GetSizeMax