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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "dmcompos_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmcompos
);
23 WINE_DECLARE_DEBUG_CHANNEL(dmfile
);
25 /*****************************************************************************
26 * IDirectMusicChordMapImpl implementation
28 /* IDirectMusicChordMapImpl IUnknown part: */
29 static HRESULT WINAPI
IDirectMusicChordMapImpl_IUnknown_QueryInterface (LPUNKNOWN iface
, REFIID riid
, LPVOID
*ppobj
) {
30 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, UnknownVtbl
, iface
);
31 TRACE("(%p, %s, %p)\n", This
, debugstr_dmguid(riid
), ppobj
);
33 if (IsEqualIID (riid
, &IID_IUnknown
)) {
34 *ppobj
= (LPVOID
)&This
->UnknownVtbl
;
35 IDirectMusicChordMapImpl_IUnknown_AddRef ((LPUNKNOWN
)&This
->UnknownVtbl
);
37 } else if (IsEqualIID (riid
, &IID_IDirectMusicChordMap
)) {
38 *ppobj
= (LPVOID
)&This
->ChordMapVtbl
;
39 IDirectMusicChordMapImpl_IDirectMusicChordMap_AddRef ((LPDIRECTMUSICCHORDMAP
)&This
->ChordMapVtbl
);
41 } else if (IsEqualIID (riid
, &IID_IDirectMusicObject
)) {
42 *ppobj
= (LPVOID
)&This
->ObjectVtbl
;
43 IDirectMusicChordMapImpl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT
)&This
->ObjectVtbl
);
45 } else if (IsEqualIID (riid
, &IID_IPersistStream
)) {
46 *ppobj
= (LPVOID
)&This
->PersistStreamVtbl
;
47 IDirectMusicChordMapImpl_IPersistStream_AddRef ((LPPERSISTSTREAM
)&This
->PersistStreamVtbl
);
51 WARN("(%p, %s, %p): not found\n", This
, debugstr_dmguid(riid
), ppobj
);
55 ULONG WINAPI
IDirectMusicChordMapImpl_IUnknown_AddRef (LPUNKNOWN iface
) {
56 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, UnknownVtbl
, iface
);
57 ULONG ref
= InterlockedIncrement(&This
->ref
);
59 TRACE("(%p): AddRef from %ld\n", This
, ref
- 1);
61 DMCOMPOS_LockModule();
66 static ULONG WINAPI
IDirectMusicChordMapImpl_IUnknown_Release (LPUNKNOWN iface
) {
67 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, UnknownVtbl
, iface
);
68 ULONG ref
= InterlockedDecrement(&This
->ref
);
70 TRACE("(%p): ReleaseRef to %ld\n", This
, ref
);
73 HeapFree(GetProcessHeap(), 0, This
);
76 DMCOMPOS_UnlockModule();
81 static const IUnknownVtbl DirectMusicChordMap_Unknown_Vtbl
= {
82 IDirectMusicChordMapImpl_IUnknown_QueryInterface
,
83 IDirectMusicChordMapImpl_IUnknown_AddRef
,
84 IDirectMusicChordMapImpl_IUnknown_Release
87 /* IDirectMusicChordMapImpl IDirectMusicChordMap part: */
88 static HRESULT WINAPI
IDirectMusicChordMapImpl_IDirectMusicChordMap_QueryInterface (LPDIRECTMUSICCHORDMAP iface
, REFIID riid
, LPVOID
*ppobj
) {
89 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, ChordMapVtbl
, iface
);
90 return IDirectMusicChordMapImpl_IUnknown_QueryInterface ((LPUNKNOWN
)&This
->UnknownVtbl
, riid
, ppobj
);
93 ULONG WINAPI
IDirectMusicChordMapImpl_IDirectMusicChordMap_AddRef (LPDIRECTMUSICCHORDMAP iface
) {
94 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, ChordMapVtbl
, iface
);
95 return IDirectMusicChordMapImpl_IUnknown_AddRef ((LPUNKNOWN
)&This
->UnknownVtbl
);
98 static ULONG WINAPI
IDirectMusicChordMapImpl_IDirectMusicChordMap_Release (LPDIRECTMUSICCHORDMAP iface
) {
99 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, ChordMapVtbl
, iface
);
100 return IDirectMusicChordMapImpl_IUnknown_Release ((LPUNKNOWN
)&This
->UnknownVtbl
);
103 static HRESULT WINAPI
IDirectMusicChordMapImpl_IDirectMusicChordMap_GetScale (LPDIRECTMUSICCHORDMAP iface
, DWORD
* pdwScale
) {
104 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, ChordMapVtbl
, iface
);
105 FIXME("(%p, %p): stub\n", This
, pdwScale
);
109 static const IDirectMusicChordMapVtbl DirectMusicChordMap_ChordMap_Vtbl
= {
110 IDirectMusicChordMapImpl_IDirectMusicChordMap_QueryInterface
,
111 IDirectMusicChordMapImpl_IDirectMusicChordMap_AddRef
,
112 IDirectMusicChordMapImpl_IDirectMusicChordMap_Release
,
113 IDirectMusicChordMapImpl_IDirectMusicChordMap_GetScale
116 /* IDirectMusicChordMapImpl IDirectMusicObject part: */
117 static HRESULT WINAPI
IDirectMusicChordMapImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface
, REFIID riid
, LPVOID
*ppobj
) {
118 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, ObjectVtbl
, iface
);
119 return IDirectMusicChordMapImpl_IUnknown_QueryInterface ((LPUNKNOWN
)&This
->UnknownVtbl
, riid
, ppobj
);
122 ULONG WINAPI
IDirectMusicChordMapImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface
) {
123 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, ObjectVtbl
, iface
);
124 return IDirectMusicChordMapImpl_IUnknown_AddRef ((LPUNKNOWN
)&This
->UnknownVtbl
);
127 static ULONG WINAPI
IDirectMusicChordMapImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface
) {
128 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, ObjectVtbl
, iface
);
129 return IDirectMusicChordMapImpl_IUnknown_Release ((LPUNKNOWN
)&This
->UnknownVtbl
);
132 static HRESULT WINAPI
IDirectMusicChordMapImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface
, LPDMUS_OBJECTDESC pDesc
) {
133 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, ObjectVtbl
, iface
);
134 TRACE("(%p, %p)\n", This
, pDesc
);
135 /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
136 memcpy (pDesc
, This
->pDesc
, This
->pDesc
->dwSize
);
140 static HRESULT WINAPI
IDirectMusicChordMapImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface
, LPDMUS_OBJECTDESC pDesc
) {
141 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, ObjectVtbl
, iface
);
142 TRACE("(%p, %p): setting descriptor:\n%s\n", This
, pDesc
, debugstr_DMUS_OBJECTDESC (pDesc
));
144 /* According to MSDN, we should copy only given values, not whole struct */
145 if (pDesc
->dwValidData
& DMUS_OBJ_OBJECT
)
146 memcpy (&This
->pDesc
->guidObject
, &pDesc
->guidObject
, sizeof (pDesc
->guidObject
));
147 if (pDesc
->dwValidData
& DMUS_OBJ_CLASS
)
148 memcpy (&This
->pDesc
->guidClass
, &pDesc
->guidClass
, sizeof (pDesc
->guidClass
));
149 if (pDesc
->dwValidData
& DMUS_OBJ_NAME
)
150 lstrcpynW (This
->pDesc
->wszName
, pDesc
->wszName
, DMUS_MAX_NAME
);
151 if (pDesc
->dwValidData
& DMUS_OBJ_CATEGORY
)
152 lstrcpynW (This
->pDesc
->wszCategory
, pDesc
->wszCategory
, DMUS_MAX_CATEGORY
);
153 if (pDesc
->dwValidData
& DMUS_OBJ_FILENAME
)
154 lstrcpynW (This
->pDesc
->wszFileName
, pDesc
->wszFileName
, DMUS_MAX_FILENAME
);
155 if (pDesc
->dwValidData
& DMUS_OBJ_VERSION
)
156 memcpy (&This
->pDesc
->vVersion
, &pDesc
->vVersion
, sizeof (pDesc
->vVersion
));
157 if (pDesc
->dwValidData
& DMUS_OBJ_DATE
)
158 memcpy (&This
->pDesc
->ftDate
, &pDesc
->ftDate
, sizeof (pDesc
->ftDate
));
159 if (pDesc
->dwValidData
& DMUS_OBJ_MEMORY
) {
160 memcpy (&This
->pDesc
->llMemLength
, &pDesc
->llMemLength
, sizeof (pDesc
->llMemLength
));
161 memcpy (This
->pDesc
->pbMemData
, pDesc
->pbMemData
, sizeof (pDesc
->pbMemData
));
163 if (pDesc
->dwValidData
& DMUS_OBJ_STREAM
) {
164 /* according to MSDN, we copy the stream */
165 IStream_Clone (pDesc
->pStream
, &This
->pDesc
->pStream
);
169 This
->pDesc
->dwValidData
|= pDesc
->dwValidData
;
174 static HRESULT WINAPI
IDirectMusicChordMapImpl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface
, LPSTREAM pStream
, LPDMUS_OBJECTDESC pDesc
) {
175 DMUS_PRIVATE_CHUNK Chunk
;
176 DWORD StreamSize
, StreamCount
, ListSize
[1], ListCount
[1];
177 LARGE_INTEGER liMove
; /* used when skipping chunks */
179 TRACE("(%p, %p)\n", pStream
, pDesc
);
181 /* FIXME: should this be determined from stream? */
182 pDesc
->dwValidData
|= DMUS_OBJ_CLASS
;
183 memcpy (&pDesc
->guidClass
, &CLSID_DirectMusicChordMap
, sizeof(CLSID
));
185 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
186 TRACE_(dmfile
)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
187 switch (Chunk
.fccID
) {
189 IStream_Read (pStream
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
190 TRACE_(dmfile
)(": RIFF chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
191 StreamSize
= Chunk
.dwSize
- sizeof(FOURCC
);
193 if (Chunk
.fccID
== DMUS_FOURCC_CHORDMAP_FORM
) {
194 TRACE_(dmfile
)(": chord map form\n");
196 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
197 StreamCount
+= sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
198 TRACE_(dmfile
)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
199 switch (Chunk
.fccID
) {
200 case DMUS_FOURCC_GUID_CHUNK
: {
201 TRACE_(dmfile
)(": GUID chunk\n");
202 pDesc
->dwValidData
|= DMUS_OBJ_OBJECT
;
203 IStream_Read (pStream
, &pDesc
->guidObject
, Chunk
.dwSize
, NULL
);
206 case DMUS_FOURCC_VERSION_CHUNK
: {
207 TRACE_(dmfile
)(": version chunk\n");
208 pDesc
->dwValidData
|= DMUS_OBJ_VERSION
;
209 IStream_Read (pStream
, &pDesc
->vVersion
, Chunk
.dwSize
, NULL
);
212 case DMUS_FOURCC_CATEGORY_CHUNK
: {
213 TRACE_(dmfile
)(": category chunk\n");
214 pDesc
->dwValidData
|= DMUS_OBJ_CATEGORY
;
215 IStream_Read (pStream
, pDesc
->wszCategory
, Chunk
.dwSize
, NULL
);
219 IStream_Read (pStream
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
220 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
221 ListSize
[0] = Chunk
.dwSize
- sizeof(FOURCC
);
223 switch (Chunk
.fccID
) {
224 /* evil M$ UNFO list, which can (!?) contain INFO elements */
225 case DMUS_FOURCC_UNFO_LIST
: {
226 TRACE_(dmfile
)(": UNFO list\n");
228 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
229 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
230 TRACE_(dmfile
)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
231 switch (Chunk
.fccID
) {
232 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
233 (though strings seem to be valid unicode) */
234 case mmioFOURCC('I','N','A','M'):
235 case DMUS_FOURCC_UNAM_CHUNK
: {
236 TRACE_(dmfile
)(": name chunk\n");
237 pDesc
->dwValidData
|= DMUS_OBJ_NAME
;
238 IStream_Read (pStream
, pDesc
->wszName
, Chunk
.dwSize
, NULL
);
241 case mmioFOURCC('I','A','R','T'):
242 case DMUS_FOURCC_UART_CHUNK
: {
243 TRACE_(dmfile
)(": artist chunk (ignored)\n");
244 liMove
.QuadPart
= Chunk
.dwSize
;
245 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
248 case mmioFOURCC('I','C','O','P'):
249 case DMUS_FOURCC_UCOP_CHUNK
: {
250 TRACE_(dmfile
)(": copyright chunk (ignored)\n");
251 liMove
.QuadPart
= Chunk
.dwSize
;
252 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
255 case mmioFOURCC('I','S','B','J'):
256 case DMUS_FOURCC_USBJ_CHUNK
: {
257 TRACE_(dmfile
)(": subject chunk (ignored)\n");
258 liMove
.QuadPart
= Chunk
.dwSize
;
259 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
262 case mmioFOURCC('I','C','M','T'):
263 case DMUS_FOURCC_UCMT_CHUNK
: {
264 TRACE_(dmfile
)(": comment chunk (ignored)\n");
265 liMove
.QuadPart
= Chunk
.dwSize
;
266 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
270 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
271 liMove
.QuadPart
= Chunk
.dwSize
;
272 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
276 TRACE_(dmfile
)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount
[0], ListSize
[0]);
277 } while (ListCount
[0] < ListSize
[0]);
281 TRACE_(dmfile
)(": unknown (skipping)\n");
282 liMove
.QuadPart
= Chunk
.dwSize
- sizeof(FOURCC
);
283 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
290 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
291 liMove
.QuadPart
= Chunk
.dwSize
;
292 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
296 TRACE_(dmfile
)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount
, StreamSize
);
297 } while (StreamCount
< StreamSize
);
299 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
300 liMove
.QuadPart
= StreamSize
;
301 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
305 TRACE_(dmfile
)(": reading finished\n");
309 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
310 liMove
.QuadPart
= Chunk
.dwSize
;
311 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
312 return DMUS_E_INVALIDFILE
;
316 TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC (pDesc
));
321 static const IDirectMusicObjectVtbl DirectMusicChordMap_Object_Vtbl
= {
322 IDirectMusicChordMapImpl_IDirectMusicObject_QueryInterface
,
323 IDirectMusicChordMapImpl_IDirectMusicObject_AddRef
,
324 IDirectMusicChordMapImpl_IDirectMusicObject_Release
,
325 IDirectMusicChordMapImpl_IDirectMusicObject_GetDescriptor
,
326 IDirectMusicChordMapImpl_IDirectMusicObject_SetDescriptor
,
327 IDirectMusicChordMapImpl_IDirectMusicObject_ParseDescriptor
331 /* IDirectMusicChordMapImpl IPersistStream part: */
332 static HRESULT WINAPI
IDirectMusicChordMapImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface
, REFIID riid
, LPVOID
*ppobj
) {
333 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, PersistStreamVtbl
, iface
);
334 return IDirectMusicChordMapImpl_IUnknown_QueryInterface ((LPUNKNOWN
)&This
->UnknownVtbl
, riid
, ppobj
);
337 ULONG WINAPI
IDirectMusicChordMapImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface
) {
338 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, PersistStreamVtbl
, iface
);
339 return IDirectMusicChordMapImpl_IUnknown_AddRef ((LPUNKNOWN
)&This
->UnknownVtbl
);
342 static ULONG WINAPI
IDirectMusicChordMapImpl_IPersistStream_Release (LPPERSISTSTREAM iface
) {
343 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, PersistStreamVtbl
, iface
);
344 return IDirectMusicChordMapImpl_IUnknown_Release ((LPUNKNOWN
)&This
->UnknownVtbl
);
347 static HRESULT WINAPI
IDirectMusicChordMapImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface
, CLSID
* pClassID
) {
351 static HRESULT WINAPI
IDirectMusicChordMapImpl_IPersistStream_IsDirty (LPPERSISTSTREAM iface
) {
355 static HRESULT WINAPI
IDirectMusicChordMapImpl_IPersistStream_Load (LPPERSISTSTREAM iface
, IStream
* pStm
) {
356 ICOM_THIS_MULTI(IDirectMusicChordMapImpl
, PersistStreamVtbl
, iface
);
359 DWORD chunkSize
, StreamSize
, StreamCount
, ListSize
[3], ListCount
[3];
360 LARGE_INTEGER liMove
; /* used when skipping chunks */
362 FIXME("(%p, %p): Loading not implemented yet\n", This
, pStm
);
363 IStream_Read (pStm
, &chunkID
, sizeof(FOURCC
), NULL
);
364 IStream_Read (pStm
, &chunkSize
, sizeof(DWORD
), NULL
);
365 TRACE_(dmfile
)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID
), chunkSize
);
368 IStream_Read (pStm
, &chunkID
, sizeof(FOURCC
), NULL
);
369 TRACE_(dmfile
)(": RIFF chunk of type %s", debugstr_fourcc(chunkID
));
370 StreamSize
= chunkSize
- sizeof(FOURCC
);
373 case DMUS_FOURCC_CHORDMAP_FORM
: {
374 TRACE_(dmfile
)(": chordmap form\n");
376 IStream_Read (pStm
, &chunkID
, sizeof(FOURCC
), NULL
);
377 IStream_Read (pStm
, &chunkSize
, sizeof(FOURCC
), NULL
);
378 StreamCount
+= sizeof(FOURCC
) + sizeof(DWORD
) + chunkSize
;
379 TRACE_(dmfile
)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID
), chunkSize
);
381 case DMUS_FOURCC_GUID_CHUNK
: {
382 TRACE_(dmfile
)(": GUID chunk\n");
383 This
->pDesc
->dwValidData
|= DMUS_OBJ_OBJECT
;
384 IStream_Read (pStm
, &This
->pDesc
->guidObject
, chunkSize
, NULL
);
387 case DMUS_FOURCC_VERSION_CHUNK
: {
388 TRACE_(dmfile
)(": version chunk\n");
389 This
->pDesc
->dwValidData
|= DMUS_OBJ_VERSION
;
390 IStream_Read (pStm
, &This
->pDesc
->vVersion
, chunkSize
, NULL
);
393 case DMUS_FOURCC_CATEGORY_CHUNK
: {
394 TRACE_(dmfile
)(": category chunk\n");
395 This
->pDesc
->dwValidData
|= DMUS_OBJ_CATEGORY
;
396 IStream_Read (pStm
, This
->pDesc
->wszCategory
, chunkSize
, NULL
);
400 IStream_Read (pStm
, &chunkID
, sizeof(FOURCC
), NULL
);
401 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(chunkID
));
402 ListSize
[0] = chunkSize
- sizeof(FOURCC
);
405 case DMUS_FOURCC_UNFO_LIST
: {
406 TRACE_(dmfile
)(": UNFO list\n");
408 IStream_Read (pStm
, &chunkID
, sizeof(FOURCC
), NULL
);
409 IStream_Read (pStm
, &chunkSize
, sizeof(FOURCC
), NULL
);
410 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + chunkSize
;
411 TRACE_(dmfile
)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID
), chunkSize
);
413 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
414 (though strings seem to be valid unicode) */
415 case mmioFOURCC('I','N','A','M'):
416 case DMUS_FOURCC_UNAM_CHUNK
: {
417 TRACE_(dmfile
)(": name chunk\n");
418 This
->pDesc
->dwValidData
|= DMUS_OBJ_NAME
;
419 IStream_Read (pStm
, This
->pDesc
->wszName
, chunkSize
, NULL
);
422 case mmioFOURCC('I','A','R','T'):
423 case DMUS_FOURCC_UART_CHUNK
: {
424 TRACE_(dmfile
)(": artist chunk (ignored)\n");
425 liMove
.QuadPart
= chunkSize
;
426 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
429 case mmioFOURCC('I','C','O','P'):
430 case DMUS_FOURCC_UCOP_CHUNK
: {
431 TRACE_(dmfile
)(": copyright chunk (ignored)\n");
432 liMove
.QuadPart
= chunkSize
;
433 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
436 case mmioFOURCC('I','S','B','J'):
437 case DMUS_FOURCC_USBJ_CHUNK
: {
438 TRACE_(dmfile
)(": subject chunk (ignored)\n");
439 liMove
.QuadPart
= chunkSize
;
440 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
443 case mmioFOURCC('I','C','M','T'):
444 case DMUS_FOURCC_UCMT_CHUNK
: {
445 TRACE_(dmfile
)(": comment chunk (ignored)\n");
446 liMove
.QuadPart
= chunkSize
;
447 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
451 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
452 liMove
.QuadPart
= chunkSize
;
453 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
457 TRACE_(dmfile
)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount
[0], ListSize
[0]);
458 } while (ListCount
[0] < ListSize
[0]);
462 TRACE_(dmfile
)(": unknown (skipping)\n");
463 liMove
.QuadPart
= chunkSize
- sizeof(FOURCC
);
464 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
471 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
472 liMove
.QuadPart
= chunkSize
;
473 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
477 TRACE_(dmfile
)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount
, StreamSize
);
478 } while (StreamCount
< StreamSize
);
482 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
483 liMove
.QuadPart
= StreamSize
;
484 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
488 TRACE_(dmfile
)(": reading finished\n");
492 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
493 liMove
.QuadPart
= chunkSize
;
494 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
502 static HRESULT WINAPI
IDirectMusicChordMapImpl_IPersistStream_Save (LPPERSISTSTREAM iface
, IStream
* pStm
, BOOL fClearDirty
) {
506 static HRESULT WINAPI
IDirectMusicChordMapImpl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface
, ULARGE_INTEGER
* pcbSize
) {
510 static const IPersistStreamVtbl DirectMusicChordMap_PersistStream_Vtbl
= {
511 IDirectMusicChordMapImpl_IPersistStream_QueryInterface
,
512 IDirectMusicChordMapImpl_IPersistStream_AddRef
,
513 IDirectMusicChordMapImpl_IPersistStream_Release
,
514 IDirectMusicChordMapImpl_IPersistStream_GetClassID
,
515 IDirectMusicChordMapImpl_IPersistStream_IsDirty
,
516 IDirectMusicChordMapImpl_IPersistStream_Load
,
517 IDirectMusicChordMapImpl_IPersistStream_Save
,
518 IDirectMusicChordMapImpl_IPersistStream_GetSizeMax
521 /* for ClassFactory */
522 HRESULT WINAPI
DMUSIC_CreateDirectMusicChordMapImpl (LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) {
523 IDirectMusicChordMapImpl
* obj
;
525 obj
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicChordMapImpl
));
528 return E_OUTOFMEMORY
;
530 obj
->UnknownVtbl
= &DirectMusicChordMap_Unknown_Vtbl
;
531 obj
->ChordMapVtbl
= &DirectMusicChordMap_ChordMap_Vtbl
;
532 obj
->ObjectVtbl
= &DirectMusicChordMap_Object_Vtbl
;
533 obj
->PersistStreamVtbl
= &DirectMusicChordMap_PersistStream_Vtbl
;
534 obj
->pDesc
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(DMUS_OBJECTDESC
));
535 DM_STRUCT_INIT(obj
->pDesc
);
536 obj
->pDesc
->dwValidData
|= DMUS_OBJ_CLASS
;
537 memcpy (&obj
->pDesc
->guidClass
, &CLSID_DirectMusicChordMap
, sizeof (CLSID
));
538 obj
->ref
= 0; /* will be inited by QueryInterface */
540 return IDirectMusicChordMapImpl_IUnknown_QueryInterface ((LPUNKNOWN
)&obj
->UnknownVtbl
, lpcGUID
, ppobj
);