1 /* IDirectMusicStyle8 Implementation
3 * Copyright (C) 2003-2004 Rok Mandeljc
4 * Copyright (C) 2003-2004 Raphael Junqueira
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Library General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "dmstyle_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
24 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
26 /*****************************************************************************
27 * IDirectMusicStyleImpl implementation
29 /* IDirectMusicStyleImpl IUnknown part: */
30 HRESULT WINAPI IDirectMusicStyle8Impl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
31 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, UnknownVtbl, iface);
32 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
34 if (IsEqualIID (riid, &IID_IUnknown)) {
35 *ppobj = (LPVOID)&This->UnknownVtbl;
36 IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
38 } else if (IsEqualIID (riid, &IID_IDirectMusicStyle)) {
39 *ppobj = (LPVOID)&This->StyleVtbl;
40 IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef ((LPDIRECTMUSICSTYLE8)&This->StyleVtbl);
42 } else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
43 *ppobj = (LPVOID)&This->ObjectVtbl;
44 IDirectMusicStyle8Impl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT)&This->ObjectVtbl);
46 } else if (IsEqualIID (riid, &IID_IPersistStream)) {
47 *ppobj = (LPVOID)&This->PersistStreamVtbl;
48 IDirectMusicStyle8Impl_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
52 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
56 ULONG WINAPI IDirectMusicStyle8Impl_IUnknown_AddRef (LPUNKNOWN iface) {
57 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, UnknownVtbl, iface);
58 TRACE("(%p): AddRef from %ld\n", This, This->ref);
62 ULONG WINAPI IDirectMusicStyle8Impl_IUnknown_Release (LPUNKNOWN iface) {
63 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, UnknownVtbl, iface);
64 ULONG ref = --This->ref;
65 TRACE("(%p): ReleaseRef to %ld\n", This, This->ref);
67 HeapFree(GetProcessHeap(), 0, This);
72 IUnknownVtbl DirectMusicStyle8_Unknown_Vtbl = {
73 IDirectMusicStyle8Impl_IUnknown_QueryInterface,
74 IDirectMusicStyle8Impl_IUnknown_AddRef,
75 IDirectMusicStyle8Impl_IUnknown_Release
78 /* IDirectMusicStyle8Impl IDirectMusicStyle8 part: */
79 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_QueryInterface (LPDIRECTMUSICSTYLE8 iface, REFIID riid, LPVOID *ppobj) {
80 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
81 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
84 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef (LPDIRECTMUSICSTYLE8 iface) {
85 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
86 return IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
89 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_Release (LPDIRECTMUSICSTYLE8 iface) {
90 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
91 return IDirectMusicStyle8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
94 /* IDirectMusicStyle8Impl IDirectMusicStyle(8) part: */
95 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetBand (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicBand** ppBand) {
96 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
97 FIXME("(%p, %p, %p): stub\n", This, pwszName, ppBand);
101 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumBand (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
102 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
103 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
107 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultBand (LPDIRECTMUSICSTYLE8 iface, IDirectMusicBand** ppBand) {
108 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
109 FIXME("(%p, %p): stub\n", This, ppBand);
113 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumMotif (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
114 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
115 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
119 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetMotif (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicSegment** ppSegment) {
120 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
121 FIXME("(%p, %p, %p): stub\n", This, pwszName, ppSegment);
125 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultChordMap (LPDIRECTMUSICSTYLE8 iface, IDirectMusicChordMap** ppChordMap) {
126 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
127 FIXME("(%p, %p): stub\n", This, ppChordMap);
131 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumChordMap (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
132 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
133 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
137 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetChordMap (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicChordMap** ppChordMap) {
138 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
139 FIXME("(%p, %p, %p): stub\n", This, pwszName, ppChordMap);
143 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTimeSignature (LPDIRECTMUSICSTYLE8 iface, DMUS_TIMESIGNATURE* pTimeSig) {
144 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
145 FIXME("(%p, %p): stub\n", This, pTimeSig);
149 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetEmbellishmentLength (LPDIRECTMUSICSTYLE8 iface, DWORD dwType, DWORD dwLevel, DWORD* pdwMin, DWORD* pdwMax) {
150 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
151 FIXME("(%p, %ld, %ld, %p, %p): stub\n", This, dwType, dwLevel, pdwMin, pdwMax);
155 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTempo (LPDIRECTMUSICSTYLE8 iface, double* pTempo) {
156 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
157 FIXME("(%p, %p): stub\n", This, pTempo);
161 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumPattern (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, DWORD dwPatternType, WCHAR* pwszName) {
162 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
163 FIXME("(%p, %ld, %ld, %p): stub\n", This, dwIndex, dwPatternType, pwszName);
167 IDirectMusicStyle8Vtbl DirectMusicStyle8_Style_Vtbl = {
168 IDirectMusicStyle8Impl_IDirectMusicStyle8_QueryInterface,
169 IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef,
170 IDirectMusicStyle8Impl_IDirectMusicStyle8_Release,
171 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetBand,
172 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumBand,
173 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultBand,
174 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumMotif,
175 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetMotif,
176 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultChordMap,
177 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumChordMap,
178 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetChordMap,
179 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTimeSignature,
180 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetEmbellishmentLength,
181 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTempo,
182 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumPattern
185 /* IDirectMusicStyle8Impl IDirectMusicObject part: */
186 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
187 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
188 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
191 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
192 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
193 return IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
196 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
197 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
198 return IDirectMusicStyle8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
201 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
202 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
203 TRACE("(%p, %p)\n", This, pDesc);
204 /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
205 memcpy (pDesc, This->pDesc, This->pDesc->dwSize);
209 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
210 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
211 TRACE("(%p, %p): setting descriptor:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC (pDesc));
213 /* According to MSDN, we should copy only given values, not whole struct */
214 if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
215 memcpy (&This->pDesc->guidObject, &pDesc->guidObject, sizeof (pDesc->guidObject));
216 if (pDesc->dwValidData & DMUS_OBJ_CLASS)
217 memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
218 if (pDesc->dwValidData & DMUS_OBJ_NAME)
219 strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
220 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
221 strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
222 if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
223 strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
224 if (pDesc->dwValidData & DMUS_OBJ_VERSION)
225 memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
226 if (pDesc->dwValidData & DMUS_OBJ_DATE)
227 memcpy (&This->pDesc->ftDate, &pDesc->ftDate, sizeof (pDesc->ftDate));
228 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
229 memcpy (&This->pDesc->llMemLength, &pDesc->llMemLength, sizeof (pDesc->llMemLength));
230 memcpy (This->pDesc->pbMemData, pDesc->pbMemData, sizeof (pDesc->pbMemData));
232 if (pDesc->dwValidData & DMUS_OBJ_STREAM) {
233 /* according to MSDN, we copy the stream */
234 IStream_Clone (pDesc->pStream, &This->pDesc->pStream);
238 This->pDesc->dwValidData |= pDesc->dwValidData;
243 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) {
244 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
245 DMUS_PRIVATE_CHUNK Chunk;
246 DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
247 LARGE_INTEGER liMove; /* used when skipping chunks */
249 TRACE("(%p, %p, %p)\n", This, pStream, pDesc);
251 /* FIXME: should this be determined from stream? */
252 pDesc->dwValidData |= DMUS_OBJ_CLASS;
253 memcpy (&pDesc->guidClass, &CLSID_DirectMusicStyle, sizeof(CLSID));
255 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
256 TRACE_(dmfile)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
257 switch (Chunk.fccID) {
259 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
260 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
261 StreamSize = Chunk.dwSize - sizeof(FOURCC);
263 if (Chunk.fccID == DMUS_FOURCC_STYLE_FORM) {
264 TRACE_(dmfile)(": style form\n");
266 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
267 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
268 TRACE_(dmfile)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
269 switch (Chunk.fccID) {
270 case DMUS_FOURCC_GUID_CHUNK: {
271 TRACE_(dmfile)(": GUID chunk\n");
272 pDesc->dwValidData |= DMUS_OBJ_OBJECT;
273 IStream_Read (pStream, &pDesc->guidObject, Chunk.dwSize, NULL);
276 case DMUS_FOURCC_VERSION_CHUNK: {
277 TRACE_(dmfile)(": version chunk\n");
278 pDesc->dwValidData |= DMUS_OBJ_VERSION;
279 IStream_Read (pStream, &pDesc->vVersion, Chunk.dwSize, NULL);
282 case DMUS_FOURCC_CATEGORY_CHUNK: {
283 TRACE_(dmfile)(": category chunk\n");
284 pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
285 IStream_Read (pStream, pDesc->wszCategory, Chunk.dwSize, NULL);
289 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
290 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
291 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
293 switch (Chunk.fccID) {
294 /* evil M$ UNFO list, which can (!?) contain INFO elements */
295 case DMUS_FOURCC_UNFO_LIST: {
296 TRACE_(dmfile)(": UNFO list\n");
298 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
299 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
300 TRACE_(dmfile)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
301 switch (Chunk.fccID) {
302 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
303 (though strings seem to be valid unicode) */
304 case mmioFOURCC('I','N','A','M'):
305 case DMUS_FOURCC_UNAM_CHUNK: {
306 TRACE_(dmfile)(": name chunk\n");
307 pDesc->dwValidData |= DMUS_OBJ_NAME;
308 IStream_Read (pStream, pDesc->wszName, Chunk.dwSize, NULL);
311 case mmioFOURCC('I','A','R','T'):
312 case DMUS_FOURCC_UART_CHUNK: {
313 TRACE_(dmfile)(": artist chunk (ignored)\n");
314 liMove.QuadPart = Chunk.dwSize;
315 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
318 case mmioFOURCC('I','C','O','P'):
319 case DMUS_FOURCC_UCOP_CHUNK: {
320 TRACE_(dmfile)(": copyright chunk (ignored)\n");
321 liMove.QuadPart = Chunk.dwSize;
322 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
325 case mmioFOURCC('I','S','B','J'):
326 case DMUS_FOURCC_USBJ_CHUNK: {
327 TRACE_(dmfile)(": subject chunk (ignored)\n");
328 liMove.QuadPart = Chunk.dwSize;
329 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
332 case mmioFOURCC('I','C','M','T'):
333 case DMUS_FOURCC_UCMT_CHUNK: {
334 TRACE_(dmfile)(": comment chunk (ignored)\n");
335 liMove.QuadPart = Chunk.dwSize;
336 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
340 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
341 liMove.QuadPart = Chunk.dwSize;
342 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
346 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
347 } while (ListCount[0] < ListSize[0]);
351 TRACE_(dmfile)(": unknown (skipping)\n");
352 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
353 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
360 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
361 liMove.QuadPart = Chunk.dwSize;
362 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
366 TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount, StreamSize);
367 } while (StreamCount < StreamSize);
370 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
371 liMove.QuadPart = StreamSize;
372 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
376 TRACE_(dmfile)(": reading finished\n");
380 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
381 liMove.QuadPart = Chunk.dwSize;
382 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
383 return DMUS_E_INVALIDFILE;
387 TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC (pDesc));
392 IDirectMusicObjectVtbl DirectMusicStyle8_Object_Vtbl = {
393 IDirectMusicStyle8Impl_IDirectMusicObject_QueryInterface,
394 IDirectMusicStyle8Impl_IDirectMusicObject_AddRef,
395 IDirectMusicStyle8Impl_IDirectMusicObject_Release,
396 IDirectMusicStyle8Impl_IDirectMusicObject_GetDescriptor,
397 IDirectMusicStyle8Impl_IDirectMusicObject_SetDescriptor,
398 IDirectMusicStyle8Impl_IDirectMusicObject_ParseDescriptor
401 /* IDirectMusicStyle8Impl IPersistStream part: */
402 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
403 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
404 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
407 ULONG WINAPI IDirectMusicStyle8Impl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
408 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
409 return IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
412 ULONG WINAPI IDirectMusicStyle8Impl_IPersistStream_Release (LPPERSISTSTREAM iface) {
413 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
414 return IDirectMusicStyle8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
417 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
418 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
419 TRACE("(%p, %p)\n", This, pClassID);
420 memcpy(pClassID, &CLSID_DirectMusicStyle, sizeof(CLSID));
424 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
425 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
426 FIXME("(%p): stub, always S_FALSE\n", This);
430 static HRESULT IDirectMusicStyle8Impl_IPersistStream_LoadBand (LPPERSISTSTREAM iface, IStream* pClonedStream, IDirectMusicBand** ppBand) {
433 IPersistStream* pPersistStream = NULL;
435 hr = CoCreateInstance (&CLSID_DirectMusicBand, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicBand, (LPVOID*) ppBand);
437 ERR(": could not create object\n");
440 /* acquire PersistStream interface */
441 hr = IDirectMusicBand_QueryInterface (*ppBand, &IID_IPersistStream, (LPVOID*) &pPersistStream);
443 ERR(": could not acquire IPersistStream\n");
447 hr = IPersistStream_Load (pPersistStream, pClonedStream);
449 ERR(": failed to load object\n");
453 /* release all loading-related stuff */
454 IPersistStream_Release (pPersistStream);
459 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePartRefList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, LPDMUS_PRIVATE_STYLE_MOTIF pNewMotif) {
460 /*ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);*/
462 DMUS_PRIVATE_CHUNK Chunk;
463 DWORD ListSize[3], ListCount[3];
464 LARGE_INTEGER liMove; /* used when skipping chunks */
466 DMUS_OBJECTDESC desc;
468 if (pChunk->fccID != DMUS_FOURCC_PARTREF_LIST) {
469 ERR_(dmfile)(": %s chunk should be a PARTREF list\n", debugstr_fourcc (pChunk->fccID));
473 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
477 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
478 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
479 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
480 switch (Chunk.fccID) {
481 case DMUS_FOURCC_PARTREF_CHUNK: {
482 TRACE_(dmfile)(": PartRef chunk (skipping for now)\n");
483 liMove.QuadPart = Chunk.dwSize;
484 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
488 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
489 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
490 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
492 switch (Chunk.fccID) {
493 case DMUS_FOURCC_UNFO_LIST: {
494 TRACE_(dmfile)(": UNFO list\n");
496 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
497 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
498 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
500 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &desc);
501 if (FAILED(hr)) return hr;
504 switch (Chunk.fccID) {
506 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
507 liMove.QuadPart = Chunk.dwSize;
508 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
513 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
514 } while (ListCount[1] < ListSize[1]);
518 TRACE_(dmfile)(": unknown chunk (skipping)\n");
519 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
520 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
527 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
528 liMove.QuadPart = Chunk.dwSize;
529 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
533 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
534 } while (ListCount[0] < ListSize[0]);
539 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePartList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
541 /*ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);*/
543 DMUS_PRIVATE_CHUNK Chunk;
544 DWORD ListSize[3], ListCount[3];
545 LARGE_INTEGER liMove; /* used when skipping chunks */
547 DMUS_OBJECTDESC desc;
549 if (pChunk->fccID != DMUS_FOURCC_PART_LIST) {
550 ERR_(dmfile)(": %s chunk should be a PART list\n", debugstr_fourcc (pChunk->fccID));
554 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
558 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
559 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
560 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
561 switch (Chunk.fccID) {
562 case DMUS_FOURCC_PART_CHUNK: {
563 TRACE_(dmfile)(": Part chunk (skipping for now)\n");
564 liMove.QuadPart = Chunk.dwSize;
565 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
568 case DMUS_FOURCC_NOTE_CHUNK: {
569 TRACE_(dmfile)(": Note chunk (skipping for now)\n");
570 liMove.QuadPart = Chunk.dwSize;
571 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
574 case DMUS_FOURCC_CURVE_CHUNK: {
575 TRACE_(dmfile)(": Curve chunk (skipping for now)\n");
576 liMove.QuadPart = Chunk.dwSize;
577 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
580 case DMUS_FOURCC_MARKER_CHUNK: {
581 TRACE_(dmfile)(": Marker chunk (skipping for now)\n");
582 liMove.QuadPart = Chunk.dwSize;
583 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
586 case DMUS_FOURCC_RESOLUTION_CHUNK: {
587 TRACE_(dmfile)(": Resolution chunk (skipping for now)\n");
588 liMove.QuadPart = Chunk.dwSize;
589 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
592 case DMUS_FOURCC_ANTICIPATION_CHUNK: {
593 TRACE_(dmfile)(": Anticipation chunk (skipping for now)\n");
594 liMove.QuadPart = Chunk.dwSize;
595 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
599 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
600 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
601 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
603 switch (Chunk.fccID) {
604 case DMUS_FOURCC_UNFO_LIST: {
605 TRACE_(dmfile)(": UNFO list\n");
607 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
608 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
609 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
611 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &desc);
612 if (FAILED(hr)) return hr;
615 switch (Chunk.fccID) {
617 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
618 liMove.QuadPart = Chunk.dwSize;
619 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
624 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
625 } while (ListCount[1] < ListSize[1]);
629 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
630 liMove.QuadPart = Chunk.dwSize;
631 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
638 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
639 liMove.QuadPart = Chunk.dwSize;
640 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
644 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
645 } while (ListCount[0] < ListSize[0]);
650 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
652 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
654 DMUS_PRIVATE_CHUNK Chunk;
655 DWORD ListSize[3], ListCount[3];
656 LARGE_INTEGER liMove; /* used when skipping chunks */
659 DMUS_OBJECTDESC desc;
660 IDirectMusicBand* pBand = NULL;
661 LPDMUS_PRIVATE_STYLE_MOTIF pNewMotif = NULL;
664 DM_STRUCT_INIT(&desc);
666 if (pChunk->fccID != DMUS_FOURCC_PATTERN_LIST) {
667 ERR_(dmfile)(": %s chunk should be a PATTERN list\n", debugstr_fourcc (pChunk->fccID));
671 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
675 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
676 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
677 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
678 switch (Chunk.fccID) {
679 case DMUS_FOURCC_PATTERN_CHUNK: {
680 TRACE_(dmfile)(": Pattern chunk\n");
681 /** alloc new motif entry */
682 pNewMotif = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_MOTIF));
683 list_add_tail (&This->Motifs, &pNewMotif->entry);
684 if (NULL == pNewMotif) {
685 ERR(": no more memory\n");
686 return E_OUTOFMEMORY;
689 IStream_Read (pStm, &pNewMotif->pattern, Chunk.dwSize, NULL);
690 /** TODO trace pattern */
692 /** reset all datas, as a new pattern begin */
694 DM_STRUCT_INIT(&pNewMotif->desc);
697 case DMUS_FOURCC_RHYTHM_CHUNK: {
698 TRACE_(dmfile)(": Rythm chunk\n");
699 IStream_Read (pStm, &dwRythm, sizeof(DWORD), NULL);
700 TRACE_(dmfile)(" - dwRythm: %lu\n", dwRythm);
701 /** TODO understand why some Chunks have size > 4 */
702 liMove.QuadPart = Chunk.dwSize - sizeof(DWORD);
703 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
706 case DMUS_FOURCC_MOTIFSETTINGS_CHUNK: {
707 TRACE_(dmfile)(": MotifSettigns chunk (skipping for now)\n");
708 IStream_Read (pStm, &pNewMotif->settings, Chunk.dwSize, NULL);
709 /** TODO trace settings */
714 * sould be embededs Bands into pattern
716 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
717 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
718 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
720 switch (Chunk.fccID) {
721 case DMUS_FOURCC_BAND_FORM: {
722 LPSTREAM pClonedStream = NULL;
724 TRACE_(dmfile)(": BAND RIFF\n");
726 IStream_Clone (pStm, &pClonedStream);
729 liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD));
730 IStream_Seek (pClonedStream, liMove, STREAM_SEEK_CUR, NULL);
732 hr = IDirectMusicStyle8Impl_IPersistStream_LoadBand (iface, pClonedStream, &pBand);
734 ERR(": could not load track\n");
737 IStream_Release (pClonedStream);
739 pNewMotif->pBand = pBand;
740 IDirectMusicBand_AddRef(pBand);
742 IDirectMusicTrack_Release(pBand); pBand = NULL; /* now we can release at as it inserted */
744 /** now safe move the cursor */
745 liMove.QuadPart = ListSize[1];
746 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
751 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
752 liMove.QuadPart = ListSize[1];
753 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
760 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
761 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
762 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
764 switch (Chunk.fccID) {
765 case DMUS_FOURCC_UNFO_LIST: {
766 TRACE_(dmfile)(": UNFO list\n");
768 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
769 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
770 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
772 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &pNewMotif->desc);
773 if (FAILED(hr)) return hr;
776 switch (Chunk.fccID) {
778 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
779 liMove.QuadPart = Chunk.dwSize;
780 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
785 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
786 } while (ListCount[1] < ListSize[1]);
789 case DMUS_FOURCC_PARTREF_LIST: {
790 TRACE_(dmfile)(": PartRef list\n");
791 hr = IDirectMusicStyle8Impl_IPersistStream_ParsePartRefList (iface, &Chunk, pStm, pNewMotif);
792 if (FAILED(hr)) return hr;
796 TRACE_(dmfile)(": unknown (skipping)\n");
797 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
798 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
805 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
806 liMove.QuadPart = Chunk.dwSize;
807 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
811 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
812 } while (ListCount[0] < ListSize[0]);
817 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParseStyleForm (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
818 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
821 DMUS_PRIVATE_CHUNK Chunk;
822 DWORD StreamSize, StreamCount, ListSize[3], ListCount[3];
823 LARGE_INTEGER liMove; /* used when skipping chunks */
825 IDirectMusicBand* pBand = NULL;
827 if (pChunk->fccID != DMUS_FOURCC_STYLE_FORM) {
828 ERR_(dmfile)(": %s chunk should be a STYLE form\n", debugstr_fourcc (pChunk->fccID));
832 StreamSize = pChunk->dwSize - sizeof(FOURCC);
836 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
837 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
838 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
840 hr = IDirectMusicUtils_IPersistStream_ParseDescGeneric(&Chunk, pStm, This->pDesc);
841 if (FAILED(hr)) return hr;
844 switch (Chunk.fccID) {
845 case DMUS_FOURCC_STYLE_CHUNK: {
846 TRACE_(dmfile)(": Style chunk\n");
847 IStream_Read (pStm, &This->style, sizeof(DMUS_IO_STYLE), NULL);
848 /** TODO dump DMUS_IO_TIMESIG style.timeSig */
849 TRACE_(dmfile)(" - dblTempo: %g\n", This->style.dblTempo);
854 * sould be embededs Bands into style
856 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
857 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
858 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
860 switch (Chunk.fccID) {
861 case DMUS_FOURCC_BAND_FORM: {
862 LPSTREAM pClonedStream = NULL;
863 LPDMUS_PRIVATE_STYLE_BAND pNewBand;
865 TRACE_(dmfile)(": BAND RIFF\n");
867 IStream_Clone (pStm, &pClonedStream);
870 liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD));
871 IStream_Seek (pClonedStream, liMove, STREAM_SEEK_CUR, NULL);
873 hr = IDirectMusicStyle8Impl_IPersistStream_LoadBand (iface, pClonedStream, &pBand);
875 ERR(": could not load track\n");
878 IStream_Release (pClonedStream);
880 pNewBand = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_BAND));
881 if (NULL == pNewBand) {
882 ERR(": no more memory\n");
883 return E_OUTOFMEMORY;
885 pNewBand->pBand = pBand;
886 IDirectMusicBand_AddRef(pBand);
887 list_add_tail (&This->Bands, &pNewBand->entry);
889 IDirectMusicTrack_Release(pBand); pBand = NULL; /* now we can release at as it inserted */
891 /** now safe move the cursor */
892 liMove.QuadPart = ListSize[0];
893 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
898 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
899 liMove.QuadPart = ListSize[0];
900 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
907 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
908 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
909 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
911 switch (Chunk.fccID) {
912 case DMUS_FOURCC_UNFO_LIST: {
913 TRACE_(dmfile)(": UNFO list\n");
915 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
916 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
917 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
919 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, This->pDesc);
920 if (FAILED(hr)) return hr;
923 switch (Chunk.fccID) {
925 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
926 liMove.QuadPart = Chunk.dwSize;
927 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
932 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
933 } while (ListCount[0] < ListSize[0]);
936 case DMUS_FOURCC_PART_LIST: {
937 TRACE_(dmfile)(": PART list\n");
938 hr = IDirectMusicStyle8Impl_IPersistStream_ParsePartList (iface, &Chunk, pStm);
939 if (FAILED(hr)) return hr;
942 case DMUS_FOURCC_PATTERN_LIST: {
943 TRACE_(dmfile)(": PATTERN list\n");
944 hr = IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (iface, &Chunk, pStm);
945 if (FAILED(hr)) return hr;
949 TRACE_(dmfile)(": unknown (skipping)\n");
950 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
951 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
958 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
959 liMove.QuadPart = Chunk.dwSize;
960 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
965 TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount, StreamSize);
966 } while (StreamCount < StreamSize);
971 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
972 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
974 DMUS_PRIVATE_CHUNK Chunk;
975 LARGE_INTEGER liMove; /* used when skipping chunks */
978 FIXME("(%p, %p): Loading\n", This, pStm);
980 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
981 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
982 switch (Chunk.fccID) {
984 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
985 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
986 switch (Chunk.fccID) {
987 case DMUS_FOURCC_STYLE_FORM: {
988 TRACE_(dmfile)(": Style form\n");
989 hr = IDirectMusicStyle8Impl_IPersistStream_ParseStyleForm (iface, &Chunk, pStm);
990 if (FAILED(hr)) return hr;
994 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
995 liMove.QuadPart = Chunk.dwSize;
996 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
1000 TRACE_(dmfile)(": reading finished\n");
1004 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
1005 liMove.QuadPart = Chunk.dwSize;
1006 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
1014 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
1015 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
1016 FIXME("(%p): Saving not implemented yet\n", This);
1020 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
1021 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
1022 FIXME("(%p, %p): stub\n", This, pcbSize);
1027 IPersistStreamVtbl DirectMusicStyle8_PersistStream_Vtbl = {
1028 IDirectMusicStyle8Impl_IPersistStream_QueryInterface,
1029 IDirectMusicStyle8Impl_IPersistStream_AddRef,
1030 IDirectMusicStyle8Impl_IPersistStream_Release,
1031 IDirectMusicStyle8Impl_IPersistStream_GetClassID,
1032 IDirectMusicStyle8Impl_IPersistStream_IsDirty,
1033 IDirectMusicStyle8Impl_IPersistStream_Load,
1034 IDirectMusicStyle8Impl_IPersistStream_Save,
1035 IDirectMusicStyle8Impl_IPersistStream_GetSizeMax
1038 /* for ClassFactory */
1039 HRESULT WINAPI DMUSIC_CreateDirectMusicStyleImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
1040 IDirectMusicStyle8Impl* obj;
1042 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicStyle8Impl));
1044 *ppobj = (LPVOID) NULL;
1045 return E_OUTOFMEMORY;
1047 obj->UnknownVtbl = &DirectMusicStyle8_Unknown_Vtbl;
1048 obj->StyleVtbl = &DirectMusicStyle8_Style_Vtbl;
1049 obj->ObjectVtbl = &DirectMusicStyle8_Object_Vtbl;
1050 obj->PersistStreamVtbl = &DirectMusicStyle8_PersistStream_Vtbl;
1051 obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
1052 DM_STRUCT_INIT(obj->pDesc);
1053 obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
1054 memcpy (&obj->pDesc->guidClass, &CLSID_DirectMusicStyle, sizeof (CLSID));
1055 obj->ref = 0; /* will be inited by QueryInterface */
1056 list_init (&obj->Bands);
1057 list_init (&obj->Motifs);
1059 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);