ole32: Verify arguments for CoWaitForMultipleHandles, always initialize index to...
[wine/multimedia.git] / dlls / dmcompos / chordmap.c
blobc3483cdcfd3ad246d1b24c3491a7ef483058cad9
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 /*****************************************************************************
26 * IDirectMusicChordMapImpl implementation
28 typedef struct IDirectMusicChordMapImpl {
29 IDirectMusicChordMap IDirectMusicChordMap_iface;
30 const IDirectMusicObjectVtbl *ObjectVtbl;
31 const IPersistStreamVtbl *PersistStreamVtbl;
32 LONG ref;
33 DMUS_OBJECTDESC *pDesc;
34 } IDirectMusicChordMapImpl;
36 /* IDirectMusicChordMapImpl IDirectMusicChordMap part: */
37 static inline IDirectMusicChordMapImpl *impl_from_IDirectMusicChordMap(IDirectMusicChordMap *iface)
39 return CONTAINING_RECORD(iface, IDirectMusicChordMapImpl, IDirectMusicChordMap_iface);
42 static HRESULT WINAPI IDirectMusicChordMapImpl_QueryInterface(IDirectMusicChordMap *iface,
43 REFIID riid, void **ret_iface)
45 IDirectMusicChordMapImpl *This = impl_from_IDirectMusicChordMap(iface);
47 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
49 *ret_iface = NULL;
51 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicChordMap))
52 *ret_iface = iface;
53 else if (IsEqualIID(riid, &IID_IDirectMusicObject))
54 *ret_iface = &This->ObjectVtbl;
55 else if (IsEqualIID(riid, &IID_IPersistStream))
56 *ret_iface = &This->PersistStreamVtbl;
57 else {
58 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
59 return E_NOINTERFACE;
62 IUnknown_AddRef((IUnknown*)*ret_iface);
63 return S_OK;
66 static ULONG WINAPI IDirectMusicChordMapImpl_AddRef(IDirectMusicChordMap *iface)
68 IDirectMusicChordMapImpl *This = impl_from_IDirectMusicChordMap(iface);
69 LONG ref = InterlockedIncrement(&This->ref);
71 TRACE("(%p) ref=%d\n", This, ref);
73 return ref;
76 static ULONG WINAPI IDirectMusicChordMapImpl_Release(IDirectMusicChordMap *iface)
78 IDirectMusicChordMapImpl *This = impl_from_IDirectMusicChordMap(iface);
79 LONG ref = InterlockedDecrement(&This->ref);
81 TRACE("(%p) ref=%d\n", This, ref);
83 if (!ref) {
84 HeapFree(GetProcessHeap(), 0, This->pDesc);
85 HeapFree(GetProcessHeap(), 0, This);
86 DMCOMPOS_UnlockModule();
89 return ref;
92 static HRESULT WINAPI IDirectMusicChordMapImpl_GetScale(IDirectMusicChordMap *iface,
93 DWORD *pdwScale)
95 IDirectMusicChordMapImpl *This = impl_from_IDirectMusicChordMap(iface);
96 FIXME("(%p, %p): stub\n", This, pdwScale);
97 return S_OK;
100 static const IDirectMusicChordMapVtbl dmchordmap_vtbl = {
101 IDirectMusicChordMapImpl_QueryInterface,
102 IDirectMusicChordMapImpl_AddRef,
103 IDirectMusicChordMapImpl_Release,
104 IDirectMusicChordMapImpl_GetScale
107 /* IDirectMusicChordMapImpl IDirectMusicObject part: */
108 static HRESULT WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
109 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ObjectVtbl, iface);
110 return IDirectMusicChordMap_QueryInterface(&This->IDirectMusicChordMap_iface, riid, ppobj);
113 static ULONG WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
114 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ObjectVtbl, iface);
115 return IDirectMusicChordMap_AddRef(&This->IDirectMusicChordMap_iface);
118 static ULONG WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
119 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ObjectVtbl, iface);
120 return IDirectMusicChordMap_Release(&This->IDirectMusicChordMap_iface);
123 static HRESULT WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
124 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ObjectVtbl, iface);
125 TRACE("(%p, %p)\n", This, pDesc);
126 /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
127 memcpy (pDesc, This->pDesc, This->pDesc->dwSize);
128 return S_OK;
131 static HRESULT WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
132 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, ObjectVtbl, iface);
133 TRACE("(%p, %p): setting descriptor:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC (pDesc));
135 /* According to MSDN, we should copy only given values, not whole struct */
136 if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
137 This->pDesc->guidObject = pDesc->guidObject;
138 if (pDesc->dwValidData & DMUS_OBJ_CLASS)
139 This->pDesc->guidClass = pDesc->guidClass;
140 if (pDesc->dwValidData & DMUS_OBJ_NAME)
141 lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
142 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
143 lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
144 if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
145 lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
146 if (pDesc->dwValidData & DMUS_OBJ_VERSION)
147 This->pDesc->vVersion = pDesc->vVersion;
148 if (pDesc->dwValidData & DMUS_OBJ_DATE)
149 This->pDesc->ftDate = pDesc->ftDate;
150 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
151 This->pDesc->llMemLength = pDesc->llMemLength;
152 memcpy (This->pDesc->pbMemData, pDesc->pbMemData, pDesc->llMemLength);
154 if (pDesc->dwValidData & DMUS_OBJ_STREAM) {
155 /* according to MSDN, we copy the stream */
156 IStream_Clone (pDesc->pStream, &This->pDesc->pStream);
159 /* add new flags */
160 This->pDesc->dwValidData |= pDesc->dwValidData;
162 return S_OK;
165 static HRESULT WINAPI IDirectMusicChordMapImpl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) {
166 DMUS_PRIVATE_CHUNK Chunk;
167 DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
168 LARGE_INTEGER liMove; /* used when skipping chunks */
170 TRACE("(%p, %p)\n", pStream, pDesc);
172 /* FIXME: should this be determined from stream? */
173 pDesc->dwValidData |= DMUS_OBJ_CLASS;
174 pDesc->guidClass = CLSID_DirectMusicChordMap;
176 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
177 TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
178 switch (Chunk.fccID) {
179 case FOURCC_RIFF: {
180 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
181 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
182 StreamSize = Chunk.dwSize - sizeof(FOURCC);
183 StreamCount = 0;
184 if (Chunk.fccID == DMUS_FOURCC_CHORDMAP_FORM) {
185 TRACE_(dmfile)(": chord map form\n");
186 do {
187 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
188 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
189 TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
190 switch (Chunk.fccID) {
191 case DMUS_FOURCC_GUID_CHUNK: {
192 TRACE_(dmfile)(": GUID chunk\n");
193 pDesc->dwValidData |= DMUS_OBJ_OBJECT;
194 IStream_Read (pStream, &pDesc->guidObject, Chunk.dwSize, NULL);
195 break;
197 case DMUS_FOURCC_VERSION_CHUNK: {
198 TRACE_(dmfile)(": version chunk\n");
199 pDesc->dwValidData |= DMUS_OBJ_VERSION;
200 IStream_Read (pStream, &pDesc->vVersion, Chunk.dwSize, NULL);
201 break;
203 case DMUS_FOURCC_CATEGORY_CHUNK: {
204 TRACE_(dmfile)(": category chunk\n");
205 pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
206 IStream_Read (pStream, pDesc->wszCategory, Chunk.dwSize, NULL);
207 break;
209 case FOURCC_LIST: {
210 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
211 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
212 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
213 ListCount[0] = 0;
214 switch (Chunk.fccID) {
215 /* evil M$ UNFO list, which can (!?) contain INFO elements */
216 case DMUS_FOURCC_UNFO_LIST: {
217 TRACE_(dmfile)(": UNFO list\n");
218 do {
219 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
220 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
221 TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
222 switch (Chunk.fccID) {
223 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
224 (though strings seem to be valid unicode) */
225 case mmioFOURCC('I','N','A','M'):
226 case DMUS_FOURCC_UNAM_CHUNK: {
227 TRACE_(dmfile)(": name chunk\n");
228 pDesc->dwValidData |= DMUS_OBJ_NAME;
229 IStream_Read (pStream, pDesc->wszName, Chunk.dwSize, NULL);
230 break;
232 case mmioFOURCC('I','A','R','T'):
233 case DMUS_FOURCC_UART_CHUNK: {
234 TRACE_(dmfile)(": artist chunk (ignored)\n");
235 liMove.QuadPart = Chunk.dwSize;
236 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
237 break;
239 case mmioFOURCC('I','C','O','P'):
240 case DMUS_FOURCC_UCOP_CHUNK: {
241 TRACE_(dmfile)(": copyright chunk (ignored)\n");
242 liMove.QuadPart = Chunk.dwSize;
243 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
244 break;
246 case mmioFOURCC('I','S','B','J'):
247 case DMUS_FOURCC_USBJ_CHUNK: {
248 TRACE_(dmfile)(": subject chunk (ignored)\n");
249 liMove.QuadPart = Chunk.dwSize;
250 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
251 break;
253 case mmioFOURCC('I','C','M','T'):
254 case DMUS_FOURCC_UCMT_CHUNK: {
255 TRACE_(dmfile)(": comment chunk (ignored)\n");
256 liMove.QuadPart = Chunk.dwSize;
257 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
258 break;
260 default: {
261 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
262 liMove.QuadPart = Chunk.dwSize;
263 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
264 break;
267 TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
268 } while (ListCount[0] < ListSize[0]);
269 break;
271 default: {
272 TRACE_(dmfile)(": unknown (skipping)\n");
273 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
274 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
275 break;
278 break;
280 default: {
281 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
282 liMove.QuadPart = Chunk.dwSize;
283 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
284 break;
287 TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
288 } while (StreamCount < StreamSize);
289 } else {
290 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
291 liMove.QuadPart = StreamSize;
292 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
293 return E_FAIL;
296 TRACE_(dmfile)(": reading finished\n");
297 break;
299 default: {
300 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
301 liMove.QuadPart = Chunk.dwSize;
302 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
303 return DMUS_E_INVALIDFILE;
307 TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC (pDesc));
309 return S_OK;
312 static const IDirectMusicObjectVtbl DirectMusicChordMap_Object_Vtbl = {
313 IDirectMusicChordMapImpl_IDirectMusicObject_QueryInterface,
314 IDirectMusicChordMapImpl_IDirectMusicObject_AddRef,
315 IDirectMusicChordMapImpl_IDirectMusicObject_Release,
316 IDirectMusicChordMapImpl_IDirectMusicObject_GetDescriptor,
317 IDirectMusicChordMapImpl_IDirectMusicObject_SetDescriptor,
318 IDirectMusicChordMapImpl_IDirectMusicObject_ParseDescriptor
322 /* IDirectMusicChordMapImpl IPersistStream part: */
323 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
324 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, PersistStreamVtbl, iface);
325 return IDirectMusicChordMap_QueryInterface(&This->IDirectMusicChordMap_iface, riid, ppobj);
328 static ULONG WINAPI IDirectMusicChordMapImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
329 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, PersistStreamVtbl, iface);
330 return IDirectMusicChordMap_AddRef(&This->IDirectMusicChordMap_iface);
333 static ULONG WINAPI IDirectMusicChordMapImpl_IPersistStream_Release (LPPERSISTSTREAM iface) {
334 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, PersistStreamVtbl, iface);
335 return IDirectMusicChordMap_Release(&This->IDirectMusicChordMap_iface);
338 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
339 return E_NOTIMPL;
342 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
343 return E_NOTIMPL;
346 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
347 ICOM_THIS_MULTI(IDirectMusicChordMapImpl, PersistStreamVtbl, iface);
349 FOURCC chunkID;
350 DWORD chunkSize, StreamSize, StreamCount, ListSize[3], ListCount[3];
351 LARGE_INTEGER liMove; /* used when skipping chunks */
353 FIXME("(%p, %p): Loading not implemented yet\n", This, pStm);
354 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
355 IStream_Read (pStm, &chunkSize, sizeof(DWORD), NULL);
356 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (chunkID), chunkSize);
357 switch (chunkID) {
358 case FOURCC_RIFF: {
359 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
360 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunkID));
361 StreamSize = chunkSize - sizeof(FOURCC);
362 StreamCount = 0;
363 switch (chunkID) {
364 case DMUS_FOURCC_CHORDMAP_FORM: {
365 TRACE_(dmfile)(": chordmap form\n");
366 do {
367 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
368 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
369 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
370 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (chunkID), chunkSize);
371 switch (chunkID) {
372 case DMUS_FOURCC_GUID_CHUNK: {
373 TRACE_(dmfile)(": GUID chunk\n");
374 This->pDesc->dwValidData |= DMUS_OBJ_OBJECT;
375 IStream_Read (pStm, &This->pDesc->guidObject, chunkSize, NULL);
376 break;
378 case DMUS_FOURCC_VERSION_CHUNK: {
379 TRACE_(dmfile)(": version chunk\n");
380 This->pDesc->dwValidData |= DMUS_OBJ_VERSION;
381 IStream_Read (pStm, &This->pDesc->vVersion, chunkSize, NULL);
382 break;
384 case DMUS_FOURCC_CATEGORY_CHUNK: {
385 TRACE_(dmfile)(": category chunk\n");
386 This->pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
387 IStream_Read (pStm, This->pDesc->wszCategory, chunkSize, NULL);
388 break;
390 case FOURCC_LIST: {
391 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
392 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
393 ListSize[0] = chunkSize - sizeof(FOURCC);
394 ListCount[0] = 0;
395 switch (chunkID) {
396 case DMUS_FOURCC_UNFO_LIST: {
397 TRACE_(dmfile)(": UNFO list\n");
398 do {
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 = %d)", debugstr_fourcc (chunkID), chunkSize);
403 switch (chunkID) {
404 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
405 (though strings seem to be valid unicode) */
406 case mmioFOURCC('I','N','A','M'):
407 case DMUS_FOURCC_UNAM_CHUNK: {
408 TRACE_(dmfile)(": name chunk\n");
409 This->pDesc->dwValidData |= DMUS_OBJ_NAME;
410 IStream_Read (pStm, This->pDesc->wszName, chunkSize, NULL);
411 break;
413 case mmioFOURCC('I','A','R','T'):
414 case DMUS_FOURCC_UART_CHUNK: {
415 TRACE_(dmfile)(": artist chunk (ignored)\n");
416 liMove.QuadPart = chunkSize;
417 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
418 break;
420 case mmioFOURCC('I','C','O','P'):
421 case DMUS_FOURCC_UCOP_CHUNK: {
422 TRACE_(dmfile)(": copyright chunk (ignored)\n");
423 liMove.QuadPart = chunkSize;
424 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
425 break;
427 case mmioFOURCC('I','S','B','J'):
428 case DMUS_FOURCC_USBJ_CHUNK: {
429 TRACE_(dmfile)(": subject chunk (ignored)\n");
430 liMove.QuadPart = chunkSize;
431 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
432 break;
434 case mmioFOURCC('I','C','M','T'):
435 case DMUS_FOURCC_UCMT_CHUNK: {
436 TRACE_(dmfile)(": comment chunk (ignored)\n");
437 liMove.QuadPart = chunkSize;
438 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
439 break;
441 default: {
442 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
443 liMove.QuadPart = chunkSize;
444 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
445 break;
448 TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
449 } while (ListCount[0] < ListSize[0]);
450 break;
452 default: {
453 TRACE_(dmfile)(": unknown (skipping)\n");
454 liMove.QuadPart = chunkSize - sizeof(FOURCC);
455 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
456 break;
459 break;
461 default: {
462 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
463 liMove.QuadPart = chunkSize;
464 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
465 break;
468 TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
469 } while (StreamCount < StreamSize);
470 break;
472 default: {
473 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
474 liMove.QuadPart = StreamSize;
475 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
476 return E_FAIL;
479 TRACE_(dmfile)(": reading finished\n");
480 break;
482 default: {
483 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
484 liMove.QuadPart = chunkSize;
485 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
486 return E_FAIL;
490 return S_OK;
493 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
494 return E_NOTIMPL;
497 static HRESULT WINAPI IDirectMusicChordMapImpl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
498 return E_NOTIMPL;
501 static const IPersistStreamVtbl DirectMusicChordMap_PersistStream_Vtbl = {
502 IDirectMusicChordMapImpl_IPersistStream_QueryInterface,
503 IDirectMusicChordMapImpl_IPersistStream_AddRef,
504 IDirectMusicChordMapImpl_IPersistStream_Release,
505 IDirectMusicChordMapImpl_IPersistStream_GetClassID,
506 IDirectMusicChordMapImpl_IPersistStream_IsDirty,
507 IDirectMusicChordMapImpl_IPersistStream_Load,
508 IDirectMusicChordMapImpl_IPersistStream_Save,
509 IDirectMusicChordMapImpl_IPersistStream_GetSizeMax
512 /* for ClassFactory */
513 HRESULT WINAPI create_dmchordmap(REFIID lpcGUID, void **ppobj)
515 IDirectMusicChordMapImpl* obj;
516 HRESULT hr;
518 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicChordMapImpl));
519 if (NULL == obj) {
520 *ppobj = NULL;
521 return E_OUTOFMEMORY;
523 obj->IDirectMusicChordMap_iface.lpVtbl = &dmchordmap_vtbl;
524 obj->ObjectVtbl = &DirectMusicChordMap_Object_Vtbl;
525 obj->PersistStreamVtbl = &DirectMusicChordMap_PersistStream_Vtbl;
526 obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
527 DM_STRUCT_INIT(obj->pDesc);
528 obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
529 obj->pDesc->guidClass = CLSID_DirectMusicChordMap;
530 obj->ref = 1;
532 DMCOMPOS_LockModule();
533 hr = IDirectMusicChordMap_QueryInterface(&obj->IDirectMusicChordMap_iface, lpcGUID, ppobj);
534 IDirectMusicChordMap_Release(&obj->IDirectMusicChordMap_iface);
536 return hr;