1 /* IDirectMusicChordMap 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 "dmcompos_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmcompos);
23 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
25 static ULONG WINAPI IDirectMusicChordMapImpl_IUnknown_AddRef (LPUNKNOWN iface);
26 static ULONG WINAPI IDirectMusicChordMapImpl_IDirectMusicChordMap_AddRef (LPDIRECTMUSICCHORDMAP iface);
27 static ULONG WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface);
28 static ULONG WINAPI IDirectMusicChordMapImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface);
30 /*****************************************************************************
31 * IDirectMusicChordMapImpl implementation
33 /* IDirectMusicChordMapImpl IUnknown part: */
34 static HRESULT WINAPI IDirectMusicChordMapImpl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
35 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, UnknownVtbl, iface);
36 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
38 if (IsEqualIID (riid, &IID_IUnknown)) {
39 *ppobj = &This->UnknownVtbl;
40 IDirectMusicChordMapImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
42 } else if (IsEqualIID (riid, &IID_IDirectMusicChordMap)) {
43 *ppobj = &This->ChordMapVtbl;
44 IDirectMusicChordMapImpl_IDirectMusicChordMap_AddRef ((LPDIRECTMUSICCHORDMAP)&This->ChordMapVtbl);
46 } else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
47 *ppobj = &This->ObjectVtbl;
48 IDirectMusicChordMapImpl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT)&This->ObjectVtbl);
50 } else if (IsEqualIID (riid, &IID_IPersistStream)) {
51 *ppobj = &This->PersistStreamVtbl;
52 IDirectMusicChordMapImpl_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
56 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
60 static ULONG WINAPI IDirectMusicChordMapImpl_IUnknown_AddRef (LPUNKNOWN iface) {
61 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, UnknownVtbl, iface);
62 ULONG ref = InterlockedIncrement(&This->ref);
64 TRACE("(%p): AddRef from %d\n", This, ref - 1);
66 DMCOMPOS_LockModule();
71 static ULONG WINAPI IDirectMusicChordMapImpl_IUnknown_Release (LPUNKNOWN iface) {
72 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, UnknownVtbl, iface);
73 ULONG ref = InterlockedDecrement(&This->ref);
75 TRACE("(%p): ReleaseRef to %d\n", This, ref);
78 HeapFree(GetProcessHeap(), 0, This);
81 DMCOMPOS_UnlockModule();
86 static const IUnknownVtbl DirectMusicChordMap_Unknown_Vtbl = {
87 IDirectMusicChordMapImpl_IUnknown_QueryInterface,
88 IDirectMusicChordMapImpl_IUnknown_AddRef,
89 IDirectMusicChordMapImpl_IUnknown_Release
92 /* IDirectMusicChordMapImpl IDirectMusicChordMap part: */
93 static HRESULT WINAPI IDirectMusicChordMapImpl_IDirectMusicChordMap_QueryInterface (LPDIRECTMUSICCHORDMAP iface, REFIID riid, LPVOID *ppobj) {
94 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ChordMapVtbl, iface);
95 return IDirectMusicChordMapImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
98 static ULONG WINAPI IDirectMusicChordMapImpl_IDirectMusicChordMap_AddRef (LPDIRECTMUSICCHORDMAP iface) {
99 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ChordMapVtbl, iface);
100 return IDirectMusicChordMapImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
103 static ULONG WINAPI IDirectMusicChordMapImpl_IDirectMusicChordMap_Release (LPDIRECTMUSICCHORDMAP iface) {
104 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ChordMapVtbl, iface);
105 return IDirectMusicChordMapImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
108 static HRESULT WINAPI IDirectMusicChordMapImpl_IDirectMusicChordMap_GetScale (LPDIRECTMUSICCHORDMAP iface, DWORD* pdwScale) {
109 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ChordMapVtbl, iface);
110 FIXME("(%p, %p): stub\n", This, pdwScale);
114 static const IDirectMusicChordMapVtbl DirectMusicChordMap_ChordMap_Vtbl = {
115 IDirectMusicChordMapImpl_IDirectMusicChordMap_QueryInterface,
116 IDirectMusicChordMapImpl_IDirectMusicChordMap_AddRef,
117 IDirectMusicChordMapImpl_IDirectMusicChordMap_Release,
118 IDirectMusicChordMapImpl_IDirectMusicChordMap_GetScale
121 /* IDirectMusicChordMapImpl IDirectMusicObject part: */
122 static HRESULT WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
123 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ObjectVtbl, iface);
124 return IDirectMusicChordMapImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
127 static ULONG WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
128 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ObjectVtbl, iface);
129 return IDirectMusicChordMapImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
132 static ULONG WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
133 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ObjectVtbl, iface);
134 return IDirectMusicChordMapImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
137 static HRESULT WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
138 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ObjectVtbl, iface);
139 TRACE("(%p, %p)\n", This, pDesc);
140 /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
141 memcpy (pDesc, This->pDesc, This->pDesc->dwSize);
145 static HRESULT WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
146 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ObjectVtbl, iface);
147 TRACE("(%p, %p): setting descriptor:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC (pDesc));
149 /* According to MSDN, we should copy only given values, not whole struct */
150 if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
151 This->pDesc->guidObject = pDesc->guidObject;
152 if (pDesc->dwValidData & DMUS_OBJ_CLASS)
153 This->pDesc->guidClass = pDesc->guidClass;
154 if (pDesc->dwValidData & DMUS_OBJ_NAME)
155 lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
156 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
157 lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
158 if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
159 lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
160 if (pDesc->dwValidData & DMUS_OBJ_VERSION)
161 This->pDesc->vVersion = pDesc->vVersion;
162 if (pDesc->dwValidData & DMUS_OBJ_DATE)
163 This->pDesc->ftDate = pDesc->ftDate;
164 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
165 This->pDesc->llMemLength = pDesc->llMemLength;
166 memcpy (This->pDesc->pbMemData, pDesc->pbMemData, pDesc->llMemLength);
168 if (pDesc->dwValidData & DMUS_OBJ_STREAM) {
169 /* according to MSDN, we copy the stream */
170 IStream_Clone (pDesc->pStream, &This->pDesc->pStream);
174 This->pDesc->dwValidData |= pDesc->dwValidData;
179 static HRESULT WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) {
180 DMUS_PRIVATE_CHUNK Chunk;
181 DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
182 LARGE_INTEGER liMove; /* used when skipping chunks */
184 TRACE("(%p, %p)\n", pStream, pDesc);
186 /* FIXME: should this be determined from stream? */
187 pDesc->dwValidData |= DMUS_OBJ_CLASS;
188 pDesc->guidClass = CLSID_DirectMusicChordMap;
190 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
191 TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
192 switch (Chunk.fccID) {
194 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
195 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
196 StreamSize = Chunk.dwSize - sizeof(FOURCC);
198 if (Chunk.fccID == DMUS_FOURCC_CHORDMAP_FORM) {
199 TRACE_(dmfile)(": chord map form\n");
201 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
202 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
203 TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
204 switch (Chunk.fccID) {
205 case DMUS_FOURCC_GUID_CHUNK: {
206 TRACE_(dmfile)(": GUID chunk\n");
207 pDesc->dwValidData |= DMUS_OBJ_OBJECT;
208 IStream_Read (pStream, &pDesc->guidObject, Chunk.dwSize, NULL);
211 case DMUS_FOURCC_VERSION_CHUNK: {
212 TRACE_(dmfile)(": version chunk\n");
213 pDesc->dwValidData |= DMUS_OBJ_VERSION;
214 IStream_Read (pStream, &pDesc->vVersion, Chunk.dwSize, NULL);
217 case DMUS_FOURCC_CATEGORY_CHUNK: {
218 TRACE_(dmfile)(": category chunk\n");
219 pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
220 IStream_Read (pStream, pDesc->wszCategory, Chunk.dwSize, NULL);
224 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
225 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
226 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
228 switch (Chunk.fccID) {
229 /* evil M$ UNFO list, which can (!?) contain INFO elements */
230 case DMUS_FOURCC_UNFO_LIST: {
231 TRACE_(dmfile)(": UNFO list\n");
233 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
234 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
235 TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
236 switch (Chunk.fccID) {
237 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
238 (though strings seem to be valid unicode) */
239 case mmioFOURCC('I','N','A','M'):
240 case DMUS_FOURCC_UNAM_CHUNK: {
241 TRACE_(dmfile)(": name chunk\n");
242 pDesc->dwValidData |= DMUS_OBJ_NAME;
243 IStream_Read (pStream, pDesc->wszName, Chunk.dwSize, NULL);
246 case mmioFOURCC('I','A','R','T'):
247 case DMUS_FOURCC_UART_CHUNK: {
248 TRACE_(dmfile)(": artist chunk (ignored)\n");
249 liMove.QuadPart = Chunk.dwSize;
250 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
253 case mmioFOURCC('I','C','O','P'):
254 case DMUS_FOURCC_UCOP_CHUNK: {
255 TRACE_(dmfile)(": copyright chunk (ignored)\n");
256 liMove.QuadPart = Chunk.dwSize;
257 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
260 case mmioFOURCC('I','S','B','J'):
261 case DMUS_FOURCC_USBJ_CHUNK: {
262 TRACE_(dmfile)(": subject chunk (ignored)\n");
263 liMove.QuadPart = Chunk.dwSize;
264 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
267 case mmioFOURCC('I','C','M','T'):
268 case DMUS_FOURCC_UCMT_CHUNK: {
269 TRACE_(dmfile)(": comment chunk (ignored)\n");
270 liMove.QuadPart = Chunk.dwSize;
271 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
275 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
276 liMove.QuadPart = Chunk.dwSize;
277 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
281 TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
282 } while (ListCount[0] < ListSize[0]);
286 TRACE_(dmfile)(": unknown (skipping)\n");
287 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
288 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
295 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
296 liMove.QuadPart = Chunk.dwSize;
297 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
301 TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
302 } while (StreamCount < StreamSize);
304 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
305 liMove.QuadPart = StreamSize;
306 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
310 TRACE_(dmfile)(": reading finished\n");
314 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
315 liMove.QuadPart = Chunk.dwSize;
316 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
317 return DMUS_E_INVALIDFILE;
321 TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC (pDesc));
326 static const IDirectMusicObjectVtbl DirectMusicChordMap_Object_Vtbl = {
327 IDirectMusicChordMapImpl_IDirectMusicObject_QueryInterface,
328 IDirectMusicChordMapImpl_IDirectMusicObject_AddRef,
329 IDirectMusicChordMapImpl_IDirectMusicObject_Release,
330 IDirectMusicChordMapImpl_IDirectMusicObject_GetDescriptor,
331 IDirectMusicChordMapImpl_IDirectMusicObject_SetDescriptor,
332 IDirectMusicChordMapImpl_IDirectMusicObject_ParseDescriptor
336 /* IDirectMusicChordMapImpl IPersistStream part: */
337 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
338 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, PersistStreamVtbl, iface);
339 return IDirectMusicChordMapImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
342 static ULONG WINAPI IDirectMusicChordMapImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
343 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, PersistStreamVtbl, iface);
344 return IDirectMusicChordMapImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
347 static ULONG WINAPI IDirectMusicChordMapImpl_IPersistStream_Release (LPPERSISTSTREAM iface) {
348 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, PersistStreamVtbl, iface);
349 return IDirectMusicChordMapImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
352 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
356 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
360 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
361 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, PersistStreamVtbl, iface);
364 DWORD chunkSize, StreamSize, StreamCount, ListSize[3], ListCount[3];
365 LARGE_INTEGER liMove; /* used when skipping chunks */
367 FIXME("(%p, %p): Loading not implemented yet\n", This, pStm);
368 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
369 IStream_Read (pStm, &chunkSize, sizeof(DWORD), NULL);
370 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (chunkID), chunkSize);
373 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
374 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunkID));
375 StreamSize = chunkSize - sizeof(FOURCC);
378 case DMUS_FOURCC_CHORDMAP_FORM: {
379 TRACE_(dmfile)(": chordmap form\n");
381 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
382 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
383 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
384 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (chunkID), chunkSize);
386 case DMUS_FOURCC_GUID_CHUNK: {
387 TRACE_(dmfile)(": GUID chunk\n");
388 This->pDesc->dwValidData |= DMUS_OBJ_OBJECT;
389 IStream_Read (pStm, &This->pDesc->guidObject, chunkSize, NULL);
392 case DMUS_FOURCC_VERSION_CHUNK: {
393 TRACE_(dmfile)(": version chunk\n");
394 This->pDesc->dwValidData |= DMUS_OBJ_VERSION;
395 IStream_Read (pStm, &This->pDesc->vVersion, chunkSize, NULL);
398 case DMUS_FOURCC_CATEGORY_CHUNK: {
399 TRACE_(dmfile)(": category chunk\n");
400 This->pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
401 IStream_Read (pStm, This->pDesc->wszCategory, chunkSize, NULL);
405 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
406 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
407 ListSize[0] = chunkSize - sizeof(FOURCC);
410 case DMUS_FOURCC_UNFO_LIST: {
411 TRACE_(dmfile)(": UNFO list\n");
413 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
414 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
415 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
416 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (chunkID), chunkSize);
418 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
419 (though strings seem to be valid unicode) */
420 case mmioFOURCC('I','N','A','M'):
421 case DMUS_FOURCC_UNAM_CHUNK: {
422 TRACE_(dmfile)(": name chunk\n");
423 This->pDesc->dwValidData |= DMUS_OBJ_NAME;
424 IStream_Read (pStm, This->pDesc->wszName, chunkSize, NULL);
427 case mmioFOURCC('I','A','R','T'):
428 case DMUS_FOURCC_UART_CHUNK: {
429 TRACE_(dmfile)(": artist chunk (ignored)\n");
430 liMove.QuadPart = chunkSize;
431 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
434 case mmioFOURCC('I','C','O','P'):
435 case DMUS_FOURCC_UCOP_CHUNK: {
436 TRACE_(dmfile)(": copyright chunk (ignored)\n");
437 liMove.QuadPart = chunkSize;
438 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
441 case mmioFOURCC('I','S','B','J'):
442 case DMUS_FOURCC_USBJ_CHUNK: {
443 TRACE_(dmfile)(": subject chunk (ignored)\n");
444 liMove.QuadPart = chunkSize;
445 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
448 case mmioFOURCC('I','C','M','T'):
449 case DMUS_FOURCC_UCMT_CHUNK: {
450 TRACE_(dmfile)(": comment chunk (ignored)\n");
451 liMove.QuadPart = chunkSize;
452 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
456 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
457 liMove.QuadPart = chunkSize;
458 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
462 TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
463 } while (ListCount[0] < ListSize[0]);
467 TRACE_(dmfile)(": unknown (skipping)\n");
468 liMove.QuadPart = chunkSize - sizeof(FOURCC);
469 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
476 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
477 liMove.QuadPart = chunkSize;
478 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
482 TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
483 } while (StreamCount < StreamSize);
487 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
488 liMove.QuadPart = StreamSize;
489 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
493 TRACE_(dmfile)(": reading finished\n");
497 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
498 liMove.QuadPart = chunkSize;
499 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
507 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
511 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
515 static const IPersistStreamVtbl DirectMusicChordMap_PersistStream_Vtbl = {
516 IDirectMusicChordMapImpl_IPersistStream_QueryInterface,
517 IDirectMusicChordMapImpl_IPersistStream_AddRef,
518 IDirectMusicChordMapImpl_IPersistStream_Release,
519 IDirectMusicChordMapImpl_IPersistStream_GetClassID,
520 IDirectMusicChordMapImpl_IPersistStream_IsDirty,
521 IDirectMusicChordMapImpl_IPersistStream_Load,
522 IDirectMusicChordMapImpl_IPersistStream_Save,
523 IDirectMusicChordMapImpl_IPersistStream_GetSizeMax
526 /* for ClassFactory */
527 HRESULT WINAPI DMUSIC_CreateDirectMusicChordMapImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
528 IDirectMusicChordMapImpl* obj;
530 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicChordMapImpl));
533 return E_OUTOFMEMORY;
535 obj->UnknownVtbl = &DirectMusicChordMap_Unknown_Vtbl;
536 obj->ChordMapVtbl = &DirectMusicChordMap_ChordMap_Vtbl;
537 obj->ObjectVtbl = &DirectMusicChordMap_Object_Vtbl;
538 obj->PersistStreamVtbl = &DirectMusicChordMap_PersistStream_Vtbl;
539 obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
540 DM_STRUCT_INIT(obj->pDesc);
541 obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
542 obj->pDesc->guidClass = CLSID_DirectMusicChordMap;
543 obj->ref = 0; /* will be inited by QueryInterface */
545 return IDirectMusicChordMapImpl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);