quartz: Add a cleanup callback for parser filters to call on release.
[wine.git] / dlls / dmcompos / chordmap.c
blobf7a0b71993eecfda532d7d8889e3bbca67d83469
1 /* IDirectMusicChordMap 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., 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 = (LPVOID)&This->UnknownVtbl;
40 IDirectMusicChordMapImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
41 return S_OK;
42 } else if (IsEqualIID (riid, &IID_IDirectMusicChordMap)) {
43 *ppobj = (LPVOID)&This->ChordMapVtbl;
44 IDirectMusicChordMapImpl_IDirectMusicChordMap_AddRef ((LPDIRECTMUSICCHORDMAP)&This->ChordMapVtbl);
45 return S_OK;
46 } else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
47 *ppobj = (LPVOID)&This->ObjectVtbl;
48 IDirectMusicChordMapImpl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT)&This->ObjectVtbl);
49 return S_OK;
50 } else if (IsEqualIID (riid, &IID_IPersistStream)) {
51 *ppobj = (LPVOID)&This->PersistStreamVtbl;
52 IDirectMusicChordMapImpl_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
53 return S_OK;
56 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
57 return E_NOINTERFACE;
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();
68 return ref;
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);
77 if (ref == 0) {
78 HeapFree(GetProcessHeap(), 0, This);
81 DMCOMPOS_UnlockModule();
83 return ref;
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);
111 return S_OK;
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);
142 return S_OK;
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 memcpy (&This->pDesc->guidObject, &pDesc->guidObject, sizeof (pDesc->guidObject));
152 if (pDesc->dwValidData & DMUS_OBJ_CLASS)
153 memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (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 memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
162 if (pDesc->dwValidData & DMUS_OBJ_DATE)
163 memcpy (&This->pDesc->ftDate, &pDesc->ftDate, sizeof (pDesc->ftDate));
164 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
165 memcpy (&This->pDesc->llMemLength, &pDesc->llMemLength, sizeof (pDesc->llMemLength));
166 memcpy (This->pDesc->pbMemData, pDesc->pbMemData, sizeof (pDesc->pbMemData));
168 if (pDesc->dwValidData & DMUS_OBJ_STREAM) {
169 /* according to MSDN, we copy the stream */
170 IStream_Clone (pDesc->pStream, &This->pDesc->pStream);
173 /* add new flags */
174 This->pDesc->dwValidData |= pDesc->dwValidData;
176 return S_OK;
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 memcpy (&pDesc->guidClass, &CLSID_DirectMusicChordMap, sizeof(CLSID));
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) {
193 case FOURCC_RIFF: {
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);
197 StreamCount = 0;
198 if (Chunk.fccID == DMUS_FOURCC_CHORDMAP_FORM) {
199 TRACE_(dmfile)(": chord map form\n");
200 do {
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);
209 break;
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);
215 break;
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);
221 break;
223 case FOURCC_LIST: {
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);
227 ListCount[0] = 0;
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");
232 do {
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);
244 break;
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);
251 break;
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);
258 break;
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);
265 break;
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);
272 break;
274 default: {
275 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
276 liMove.QuadPart = Chunk.dwSize;
277 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
278 break;
281 TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
282 } while (ListCount[0] < ListSize[0]);
283 break;
285 default: {
286 TRACE_(dmfile)(": unknown (skipping)\n");
287 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
288 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
289 break;
292 break;
294 default: {
295 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
296 liMove.QuadPart = Chunk.dwSize;
297 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
298 break;
301 TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
302 } while (StreamCount < StreamSize);
303 } else {
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 */
307 return E_FAIL;
310 TRACE_(dmfile)(": reading finished\n");
311 break;
313 default: {
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));
323 return S_OK;
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) {
353 return E_NOTIMPL;
356 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
357 return E_NOTIMPL;
360 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
361 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, PersistStreamVtbl, iface);
363 FOURCC chunkID;
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);
371 switch (chunkID) {
372 case FOURCC_RIFF: {
373 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
374 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunkID));
375 StreamSize = chunkSize - sizeof(FOURCC);
376 StreamCount = 0;
377 switch (chunkID) {
378 case DMUS_FOURCC_CHORDMAP_FORM: {
379 TRACE_(dmfile)(": chordmap form\n");
380 do {
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);
385 switch (chunkID) {
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);
390 break;
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);
396 break;
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);
402 break;
404 case FOURCC_LIST: {
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);
408 ListCount[0] = 0;
409 switch (chunkID) {
410 case DMUS_FOURCC_UNFO_LIST: {
411 TRACE_(dmfile)(": UNFO list\n");
412 do {
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);
417 switch (chunkID) {
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);
425 break;
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);
432 break;
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);
439 break;
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);
446 break;
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);
453 break;
455 default: {
456 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
457 liMove.QuadPart = chunkSize;
458 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
459 break;
462 TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
463 } while (ListCount[0] < ListSize[0]);
464 break;
466 default: {
467 TRACE_(dmfile)(": unknown (skipping)\n");
468 liMove.QuadPart = chunkSize - sizeof(FOURCC);
469 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
470 break;
473 break;
475 default: {
476 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
477 liMove.QuadPart = chunkSize;
478 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
479 break;
482 TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
483 } while (StreamCount < StreamSize);
484 break;
486 default: {
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 */
490 return E_FAIL;
493 TRACE_(dmfile)(": reading finished\n");
494 break;
496 default: {
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 */
500 return E_FAIL;
504 return S_OK;
507 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
508 return E_NOTIMPL;
511 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
512 return E_NOTIMPL;
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));
531 if (NULL == obj) {
532 *ppobj = NULL;
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 memcpy (&obj->pDesc->guidClass, &CLSID_DirectMusicChordMap, sizeof (CLSID));
543 obj->ref = 0; /* will be inited by QueryInterface */
545 return IDirectMusicChordMapImpl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);