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_IDirectMusicStyle8)) {
43 *ppobj = (LPVOID)&This->StyleVtbl;
44 IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef ((LPDIRECTMUSICSTYLE8)&This->StyleVtbl);
46 } else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
47 *ppobj = (LPVOID)&This->ObjectVtbl;
48 IDirectMusicStyle8Impl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT)&This->ObjectVtbl);
50 } else if (IsEqualIID (riid, &IID_IPersistStream)) {
51 *ppobj = (LPVOID)&This->PersistStreamVtbl;
52 IDirectMusicStyle8Impl_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
56 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
60 ULONG WINAPI IDirectMusicStyle8Impl_IUnknown_AddRef (LPUNKNOWN iface) {
61 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, UnknownVtbl, iface);
62 TRACE("(%p): AddRef from %ld\n", This, This->ref);
66 ULONG WINAPI IDirectMusicStyle8Impl_IUnknown_Release (LPUNKNOWN iface) {
67 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, UnknownVtbl, iface);
68 ULONG ref = --This->ref;
69 TRACE("(%p): ReleaseRef to %ld\n", This, This->ref);
71 HeapFree(GetProcessHeap(), 0, This);
76 IUnknownVtbl DirectMusicStyle8_Unknown_Vtbl = {
77 IDirectMusicStyle8Impl_IUnknown_QueryInterface,
78 IDirectMusicStyle8Impl_IUnknown_AddRef,
79 IDirectMusicStyle8Impl_IUnknown_Release
82 /* IDirectMusicStyle8Impl IDirectMusicStyle8 part: */
83 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_QueryInterface (LPDIRECTMUSICSTYLE8 iface, REFIID riid, LPVOID *ppobj) {
84 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
85 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
88 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef (LPDIRECTMUSICSTYLE8 iface) {
89 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
90 return IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
93 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_Release (LPDIRECTMUSICSTYLE8 iface) {
94 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
95 return IDirectMusicStyle8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
98 /* IDirectMusicStyle8Impl IDirectMusicStyle(8) part: */
99 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetBand (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicBand** ppBand) {
100 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
101 FIXME("(%p, %p, %p): stub\n", This, pwszName, ppBand);
105 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumBand (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
106 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
107 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
111 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultBand (LPDIRECTMUSICSTYLE8 iface, IDirectMusicBand** ppBand) {
112 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
113 FIXME("(%p, %p): stub\n", This, ppBand);
117 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumMotif (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
118 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
119 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
123 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetMotif (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicSegment** ppSegment) {
124 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
125 FIXME("(%p, %p, %p): stub\n", This, pwszName, ppSegment);
129 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultChordMap (LPDIRECTMUSICSTYLE8 iface, IDirectMusicChordMap** ppChordMap) {
130 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
131 FIXME("(%p, %p): stub\n", This, ppChordMap);
135 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumChordMap (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
136 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
137 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
141 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetChordMap (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicChordMap** ppChordMap) {
142 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
143 FIXME("(%p, %p, %p): stub\n", This, pwszName, ppChordMap);
147 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTimeSignature (LPDIRECTMUSICSTYLE8 iface, DMUS_TIMESIGNATURE* pTimeSig) {
148 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
149 FIXME("(%p, %p): stub\n", This, pTimeSig);
153 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetEmbellishmentLength (LPDIRECTMUSICSTYLE8 iface, DWORD dwType, DWORD dwLevel, DWORD* pdwMin, DWORD* pdwMax) {
154 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
155 FIXME("(%p, %ld, %ld, %p, %p): stub\n", This, dwType, dwLevel, pdwMin, pdwMax);
159 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTempo (LPDIRECTMUSICSTYLE8 iface, double* pTempo) {
160 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
161 FIXME("(%p, %p): stub\n", This, pTempo);
165 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumPattern (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, DWORD dwPatternType, WCHAR* pwszName) {
166 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
167 FIXME("(%p, %ld, %ld, %p): stub\n", This, dwIndex, dwPatternType, pwszName);
171 IDirectMusicStyle8Vtbl DirectMusicStyle8_Style_Vtbl = {
172 IDirectMusicStyle8Impl_IDirectMusicStyle8_QueryInterface,
173 IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef,
174 IDirectMusicStyle8Impl_IDirectMusicStyle8_Release,
175 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetBand,
176 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumBand,
177 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultBand,
178 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumMotif,
179 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetMotif,
180 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultChordMap,
181 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumChordMap,
182 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetChordMap,
183 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTimeSignature,
184 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetEmbellishmentLength,
185 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTempo,
186 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumPattern
189 /* IDirectMusicStyle8Impl IDirectMusicObject part: */
190 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
191 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
192 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
195 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
196 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
197 return IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
200 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
201 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
202 return IDirectMusicStyle8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
205 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
206 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
207 TRACE("(%p, %p)\n", This, pDesc);
208 /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
209 memcpy (pDesc, This->pDesc, This->pDesc->dwSize);
213 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
214 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
215 TRACE("(%p, %p): setting descriptor:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC (pDesc));
217 /* According to MSDN, we should copy only given values, not whole struct */
218 if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
219 memcpy (&This->pDesc->guidObject, &pDesc->guidObject, sizeof (pDesc->guidObject));
220 if (pDesc->dwValidData & DMUS_OBJ_CLASS)
221 memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
222 if (pDesc->dwValidData & DMUS_OBJ_NAME)
223 strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
224 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
225 strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
226 if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
227 strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
228 if (pDesc->dwValidData & DMUS_OBJ_VERSION)
229 memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
230 if (pDesc->dwValidData & DMUS_OBJ_DATE)
231 memcpy (&This->pDesc->ftDate, &pDesc->ftDate, sizeof (pDesc->ftDate));
232 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
233 memcpy (&This->pDesc->llMemLength, &pDesc->llMemLength, sizeof (pDesc->llMemLength));
234 memcpy (This->pDesc->pbMemData, pDesc->pbMemData, sizeof (pDesc->pbMemData));
236 if (pDesc->dwValidData & DMUS_OBJ_STREAM) {
237 /* according to MSDN, we copy the stream */
238 IStream_Clone (pDesc->pStream, &This->pDesc->pStream);
242 This->pDesc->dwValidData |= pDesc->dwValidData;
247 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) {
248 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
249 DMUS_PRIVATE_CHUNK Chunk;
250 DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
251 LARGE_INTEGER liMove; /* used when skipping chunks */
253 TRACE("(%p, %p, %p)\n", This, pStream, pDesc);
255 /* FIXME: should this be determined from stream? */
256 pDesc->dwValidData |= DMUS_OBJ_CLASS;
257 memcpy (&pDesc->guidClass, &CLSID_DirectMusicStyle, sizeof(CLSID));
259 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
260 TRACE_(dmfile)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
261 switch (Chunk.fccID) {
263 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
264 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
265 StreamSize = Chunk.dwSize - sizeof(FOURCC);
267 if (Chunk.fccID == DMUS_FOURCC_STYLE_FORM) {
268 TRACE_(dmfile)(": style form\n");
270 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
271 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
272 TRACE_(dmfile)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
273 switch (Chunk.fccID) {
274 case DMUS_FOURCC_GUID_CHUNK: {
275 TRACE_(dmfile)(": GUID chunk\n");
276 pDesc->dwValidData |= DMUS_OBJ_OBJECT;
277 IStream_Read (pStream, &pDesc->guidObject, Chunk.dwSize, NULL);
280 case DMUS_FOURCC_VERSION_CHUNK: {
281 TRACE_(dmfile)(": version chunk\n");
282 pDesc->dwValidData |= DMUS_OBJ_VERSION;
283 IStream_Read (pStream, &pDesc->vVersion, Chunk.dwSize, NULL);
286 case DMUS_FOURCC_CATEGORY_CHUNK: {
287 TRACE_(dmfile)(": category chunk\n");
288 pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
289 IStream_Read (pStream, pDesc->wszCategory, Chunk.dwSize, NULL);
293 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
294 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
295 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
297 switch (Chunk.fccID) {
298 /* evil M$ UNFO list, which can (!?) contain INFO elements */
299 case DMUS_FOURCC_UNFO_LIST: {
300 TRACE_(dmfile)(": UNFO list\n");
302 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
303 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
304 TRACE_(dmfile)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
305 switch (Chunk.fccID) {
306 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
307 (though strings seem to be valid unicode) */
308 case mmioFOURCC('I','N','A','M'):
309 case DMUS_FOURCC_UNAM_CHUNK: {
310 TRACE_(dmfile)(": name chunk\n");
311 pDesc->dwValidData |= DMUS_OBJ_NAME;
312 IStream_Read (pStream, pDesc->wszName, Chunk.dwSize, NULL);
315 case mmioFOURCC('I','A','R','T'):
316 case DMUS_FOURCC_UART_CHUNK: {
317 TRACE_(dmfile)(": artist chunk (ignored)\n");
318 liMove.QuadPart = Chunk.dwSize;
319 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
322 case mmioFOURCC('I','C','O','P'):
323 case DMUS_FOURCC_UCOP_CHUNK: {
324 TRACE_(dmfile)(": copyright chunk (ignored)\n");
325 liMove.QuadPart = Chunk.dwSize;
326 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
329 case mmioFOURCC('I','S','B','J'):
330 case DMUS_FOURCC_USBJ_CHUNK: {
331 TRACE_(dmfile)(": subject chunk (ignored)\n");
332 liMove.QuadPart = Chunk.dwSize;
333 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
336 case mmioFOURCC('I','C','M','T'):
337 case DMUS_FOURCC_UCMT_CHUNK: {
338 TRACE_(dmfile)(": comment chunk (ignored)\n");
339 liMove.QuadPart = Chunk.dwSize;
340 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
344 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
345 liMove.QuadPart = Chunk.dwSize;
346 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
350 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
351 } while (ListCount[0] < ListSize[0]);
355 TRACE_(dmfile)(": unknown (skipping)\n");
356 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
357 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
364 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
365 liMove.QuadPart = Chunk.dwSize;
366 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
370 TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount, StreamSize);
371 } while (StreamCount < StreamSize);
373 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
374 liMove.QuadPart = StreamSize;
375 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
379 TRACE_(dmfile)(": reading finished\n");
383 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
384 liMove.QuadPart = Chunk.dwSize;
385 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
386 return DMUS_E_INVALIDFILE;
390 TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC (pDesc));
395 IDirectMusicObjectVtbl DirectMusicStyle8_Object_Vtbl = {
396 IDirectMusicStyle8Impl_IDirectMusicObject_QueryInterface,
397 IDirectMusicStyle8Impl_IDirectMusicObject_AddRef,
398 IDirectMusicStyle8Impl_IDirectMusicObject_Release,
399 IDirectMusicStyle8Impl_IDirectMusicObject_GetDescriptor,
400 IDirectMusicStyle8Impl_IDirectMusicObject_SetDescriptor,
401 IDirectMusicStyle8Impl_IDirectMusicObject_ParseDescriptor
404 /* IDirectMusicStyle8Impl IPersistStream part: */
405 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
406 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
407 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
410 ULONG WINAPI IDirectMusicStyle8Impl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
411 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
412 return IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
415 ULONG WINAPI IDirectMusicStyle8Impl_IPersistStream_Release (LPPERSISTSTREAM iface) {
416 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
417 return IDirectMusicStyle8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
420 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
421 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
422 TRACE("(%p, %p)\n", This, pClassID);
423 memcpy(pClassID, &CLSID_DirectMusicStyle, sizeof(CLSID));
427 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
428 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
429 FIXME("(%p): stub, always S_FALSE\n", This);
433 static HRESULT IDirectMusicStyle8Impl_IPersistStream_LoadBand (LPPERSISTSTREAM iface, IStream* pClonedStream, IDirectMusicBand** ppBand) {
436 IPersistStream* pPersistStream = NULL;
438 hr = CoCreateInstance (&CLSID_DirectMusicBand, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicBand, (LPVOID*) ppBand);
440 ERR(": could not create object\n");
443 /* acquire PersistStream interface */
444 hr = IDirectMusicBand_QueryInterface (*ppBand, &IID_IPersistStream, (LPVOID*) &pPersistStream);
446 ERR(": could not acquire IPersistStream\n");
450 hr = IPersistStream_Load (pPersistStream, pClonedStream);
452 ERR(": failed to load object\n");
456 /* release all loading-related stuff */
457 IPersistStream_Release (pPersistStream);
462 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePartRefList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, LPDMUS_PRIVATE_STYLE_MOTIF pNewMotif) {
463 /*ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);*/
465 DMUS_PRIVATE_CHUNK Chunk;
466 DWORD ListSize[3], ListCount[3];
467 LARGE_INTEGER liMove; /* used when skipping chunks */
469 LPDMUS_PRIVATE_STYLE_PARTREF_ITEM pNewItem = NULL;
472 if (pChunk->fccID != DMUS_FOURCC_PARTREF_LIST) {
473 ERR_(dmfile)(": %s chunk should be a PARTREF list\n", debugstr_fourcc (pChunk->fccID));
477 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
481 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
482 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
483 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
484 switch (Chunk.fccID) {
485 case DMUS_FOURCC_PARTREF_CHUNK: {
486 TRACE_(dmfile)(": PartRef chunk\n");
487 pNewItem = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_PARTREF_ITEM));
488 if (NULL == pNewItem) {
489 ERR(": no more memory\n");
490 return E_OUTOFMEMORY;
492 hr = IStream_Read (pStm, &pNewItem->part_ref, sizeof(DMUS_IO_PARTREF), NULL);
493 /*TRACE_(dmfile)(" - sizeof %lu\n", sizeof(DMUS_IO_PARTREF));*/
494 list_add_tail (&pNewMotif->Items, &pNewItem->entry);
495 DM_STRUCT_INIT(&pNewItem->desc);
499 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
500 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
501 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
503 switch (Chunk.fccID) {
504 case DMUS_FOURCC_UNFO_LIST: {
505 TRACE_(dmfile)(": UNFO list\n");
507 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
508 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
509 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
511 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &pNewItem->desc);
512 if (FAILED(hr)) return hr;
515 switch (Chunk.fccID) {
517 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
518 liMove.QuadPart = Chunk.dwSize;
519 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
524 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
525 } while (ListCount[1] < ListSize[1]);
529 TRACE_(dmfile)(": unknown chunk (skipping)\n");
530 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
531 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
538 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
539 liMove.QuadPart = Chunk.dwSize;
540 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
544 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
545 } while (ListCount[0] < ListSize[0]);
550 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePartList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
552 /*ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);*/
554 DMUS_PRIVATE_CHUNK Chunk;
555 DWORD ListSize[3], ListCount[3];
556 LARGE_INTEGER liMove; /* used when skipping chunks */
558 DMUS_OBJECTDESC desc;
562 if (pChunk->fccID != DMUS_FOURCC_PART_LIST) {
563 ERR_(dmfile)(": %s chunk should be a PART list\n", debugstr_fourcc (pChunk->fccID));
567 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
571 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
572 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
573 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
574 switch (Chunk.fccID) {
575 case DMUS_FOURCC_PART_CHUNK: {
576 TRACE_(dmfile)(": Part chunk (skipping for now) (sizeof %u)\n", sizeof(DMUS_IO_STYLEPART));
577 liMove.QuadPart = Chunk.dwSize;
578 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
581 case DMUS_FOURCC_NOTE_CHUNK: {
582 TRACE_(dmfile)(": Note chunk (skipping for now) (sizeof %u)\n", sizeof(DMUS_IO_STYLENOTE));
583 IStream_Read (pStm, &dwSize, sizeof(DWORD), NULL);
584 cnt = (Chunk.dwSize - sizeof(DWORD));
585 TRACE_(dmfile)(" - dwSize: %lu\n", dwSize);
586 TRACE_(dmfile)(" - cnt: %lu (%lu / %lu)\n", cnt / dwSize, (Chunk.dwSize - sizeof(DWORD)), dwSize);
587 if (cnt % dwSize != 0) {
588 ERR("Invalid Array Size");
593 liMove.QuadPart = cnt * dwSize;
594 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
597 case DMUS_FOURCC_CURVE_CHUNK: {
598 TRACE_(dmfile)(": Curve chunk (skipping for now) (sizeof %u)\n", sizeof(DMUS_IO_STYLECURVE));
599 IStream_Read (pStm, &dwSize, sizeof(DWORD), NULL);
600 cnt = (Chunk.dwSize - sizeof(DWORD));
601 TRACE_(dmfile)(" - dwSize: %lu\n", dwSize);
602 TRACE_(dmfile)(" - cnt: %lu (%lu / %lu)\n", cnt / dwSize, (Chunk.dwSize - sizeof(DWORD)), dwSize);
603 if (cnt % dwSize != 0) {
604 ERR("Invalid Array Size");
609 liMove.QuadPart = cnt * dwSize;
610 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
613 case DMUS_FOURCC_MARKER_CHUNK: {
614 TRACE_(dmfile)(": Marker chunk (skipping for now)\n");
615 liMove.QuadPart = Chunk.dwSize;
616 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
619 case DMUS_FOURCC_RESOLUTION_CHUNK: {
620 TRACE_(dmfile)(": Resolution chunk (skipping for now)\n");
621 liMove.QuadPart = Chunk.dwSize;
622 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
625 case DMUS_FOURCC_ANTICIPATION_CHUNK: {
626 TRACE_(dmfile)(": Anticipation chunk (skipping for now)\n");
627 liMove.QuadPart = Chunk.dwSize;
628 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
632 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
633 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
634 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
636 switch (Chunk.fccID) {
637 case DMUS_FOURCC_UNFO_LIST: {
638 TRACE_(dmfile)(": UNFO list\n");
640 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
641 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
642 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
644 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &desc);
645 if (FAILED(hr)) return hr;
648 switch (Chunk.fccID) {
650 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
651 liMove.QuadPart = Chunk.dwSize;
652 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
657 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
658 } while (ListCount[1] < ListSize[1]);
662 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
663 liMove.QuadPart = Chunk.dwSize;
664 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
671 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
672 liMove.QuadPart = Chunk.dwSize;
673 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
677 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
678 } while (ListCount[0] < ListSize[0]);
683 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
685 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
687 DMUS_PRIVATE_CHUNK Chunk;
688 DWORD ListSize[3], ListCount[3];
689 LARGE_INTEGER liMove; /* used when skipping chunks */
691 DMUS_OBJECTDESC desc;
692 IDirectMusicBand* pBand = NULL;
693 LPDMUS_PRIVATE_STYLE_MOTIF pNewMotif = NULL;
695 DM_STRUCT_INIT(&desc);
697 if (pChunk->fccID != DMUS_FOURCC_PATTERN_LIST) {
698 ERR_(dmfile)(": %s chunk should be a PATTERN list\n", debugstr_fourcc (pChunk->fccID));
702 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
706 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
707 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
708 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
709 switch (Chunk.fccID) {
710 case DMUS_FOURCC_PATTERN_CHUNK: {
711 TRACE_(dmfile)(": Pattern chunk\n");
712 /** alloc new motif entry */
713 pNewMotif = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_MOTIF));
714 list_add_tail (&This->Motifs, &pNewMotif->entry);
715 if (NULL == pNewMotif) {
716 ERR(": no more memory\n");
717 return E_OUTOFMEMORY;
720 IStream_Read (pStm, &pNewMotif->pattern, Chunk.dwSize, NULL);
721 /** TODO trace pattern */
723 /** reset all datas, as a new pattern begin */
724 DM_STRUCT_INIT(&pNewMotif->desc);
725 list_init (&pNewMotif->Items);
728 case DMUS_FOURCC_RHYTHM_CHUNK: {
729 TRACE_(dmfile)(": Rythm chunk\n");
730 IStream_Read (pStm, &pNewMotif->dwRythm, sizeof(DWORD), NULL);
731 TRACE_(dmfile)(" - dwRythm: %lu\n", pNewMotif->dwRythm);
732 /** TODO understand why some Chunks have size > 4 */
733 liMove.QuadPart = Chunk.dwSize - sizeof(DWORD);
734 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
737 case DMUS_FOURCC_MOTIFSETTINGS_CHUNK: {
738 TRACE_(dmfile)(": MotifSettigns chunk (skipping for now)\n");
739 IStream_Read (pStm, &pNewMotif->settings, Chunk.dwSize, NULL);
740 /** TODO trace settings */
745 * sould be embededs Bands into pattern
747 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
748 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
749 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
751 switch (Chunk.fccID) {
752 case DMUS_FOURCC_BAND_FORM: {
753 LPSTREAM pClonedStream = NULL;
755 TRACE_(dmfile)(": BAND RIFF\n");
757 IStream_Clone (pStm, &pClonedStream);
760 liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD));
761 IStream_Seek (pClonedStream, liMove, STREAM_SEEK_CUR, NULL);
763 hr = IDirectMusicStyle8Impl_IPersistStream_LoadBand (iface, pClonedStream, &pBand);
765 ERR(": could not load track\n");
768 IStream_Release (pClonedStream);
770 pNewMotif->pBand = pBand;
771 IDirectMusicBand_AddRef(pBand);
773 IDirectMusicTrack_Release(pBand); pBand = NULL; /* now we can release at as it inserted */
775 /** now safe move the cursor */
776 liMove.QuadPart = ListSize[1];
777 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
782 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
783 liMove.QuadPart = ListSize[1];
784 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
791 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
792 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
793 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
795 switch (Chunk.fccID) {
796 case DMUS_FOURCC_UNFO_LIST: {
797 TRACE_(dmfile)(": UNFO list\n");
799 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
800 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
801 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
803 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &pNewMotif->desc);
804 if (FAILED(hr)) return hr;
807 switch (Chunk.fccID) {
809 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
810 liMove.QuadPart = Chunk.dwSize;
811 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
816 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
817 } while (ListCount[1] < ListSize[1]);
820 case DMUS_FOURCC_PARTREF_LIST: {
821 TRACE_(dmfile)(": PartRef list\n");
822 hr = IDirectMusicStyle8Impl_IPersistStream_ParsePartRefList (iface, &Chunk, pStm, pNewMotif);
823 if (FAILED(hr)) return hr;
827 TRACE_(dmfile)(": unknown (skipping)\n");
828 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
829 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
836 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
837 liMove.QuadPart = Chunk.dwSize;
838 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
842 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
843 } while (ListCount[0] < ListSize[0]);
848 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParseStyleForm (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
849 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
852 DMUS_PRIVATE_CHUNK Chunk;
853 DWORD StreamSize, StreamCount, ListSize[3], ListCount[3];
854 LARGE_INTEGER liMove; /* used when skipping chunks */
856 IDirectMusicBand* pBand = NULL;
858 if (pChunk->fccID != DMUS_FOURCC_STYLE_FORM) {
859 ERR_(dmfile)(": %s chunk should be a STYLE form\n", debugstr_fourcc (pChunk->fccID));
863 StreamSize = pChunk->dwSize - sizeof(FOURCC);
867 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
868 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
869 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
871 hr = IDirectMusicUtils_IPersistStream_ParseDescGeneric(&Chunk, pStm, This->pDesc);
872 if (FAILED(hr)) return hr;
875 switch (Chunk.fccID) {
876 case DMUS_FOURCC_STYLE_CHUNK: {
877 TRACE_(dmfile)(": Style chunk\n");
878 IStream_Read (pStm, &This->style, sizeof(DMUS_IO_STYLE), NULL);
879 /** TODO dump DMUS_IO_TIMESIG style.timeSig */
880 TRACE_(dmfile)(" - dblTempo: %g\n", This->style.dblTempo);
885 * sould be embededs Bands into style
887 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
888 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
889 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
891 switch (Chunk.fccID) {
892 case DMUS_FOURCC_BAND_FORM: {
893 LPSTREAM pClonedStream = NULL;
894 LPDMUS_PRIVATE_STYLE_BAND pNewBand;
896 TRACE_(dmfile)(": BAND RIFF\n");
898 IStream_Clone (pStm, &pClonedStream);
901 liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD));
902 IStream_Seek (pClonedStream, liMove, STREAM_SEEK_CUR, NULL);
904 hr = IDirectMusicStyle8Impl_IPersistStream_LoadBand (iface, pClonedStream, &pBand);
906 ERR(": could not load track\n");
909 IStream_Release (pClonedStream);
911 pNewBand = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_BAND));
912 if (NULL == pNewBand) {
913 ERR(": no more memory\n");
914 return E_OUTOFMEMORY;
916 pNewBand->pBand = pBand;
917 IDirectMusicBand_AddRef(pBand);
918 list_add_tail (&This->Bands, &pNewBand->entry);
920 IDirectMusicTrack_Release(pBand); pBand = NULL; /* now we can release at as it inserted */
922 /** now safe move the cursor */
923 liMove.QuadPart = ListSize[0];
924 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
929 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
930 liMove.QuadPart = ListSize[0];
931 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
938 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
939 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
940 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
942 switch (Chunk.fccID) {
943 case DMUS_FOURCC_UNFO_LIST: {
944 TRACE_(dmfile)(": UNFO list\n");
946 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
947 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
948 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
950 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, This->pDesc);
951 if (FAILED(hr)) return hr;
954 switch (Chunk.fccID) {
956 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
957 liMove.QuadPart = Chunk.dwSize;
958 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
963 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
964 } while (ListCount[0] < ListSize[0]);
967 case DMUS_FOURCC_PART_LIST: {
968 TRACE_(dmfile)(": PART list\n");
969 hr = IDirectMusicStyle8Impl_IPersistStream_ParsePartList (iface, &Chunk, pStm);
970 if (FAILED(hr)) return hr;
973 case DMUS_FOURCC_PATTERN_LIST: {
974 TRACE_(dmfile)(": PATTERN list\n");
975 hr = IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (iface, &Chunk, pStm);
976 if (FAILED(hr)) return hr;
980 TRACE_(dmfile)(": unknown (skipping)\n");
981 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
982 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
989 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
990 liMove.QuadPart = Chunk.dwSize;
991 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
996 TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount, StreamSize);
997 } while (StreamCount < StreamSize);
1002 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
1003 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
1005 DMUS_PRIVATE_CHUNK Chunk;
1006 LARGE_INTEGER liMove; /* used when skipping chunks */
1009 FIXME("(%p, %p): Loading\n", This, pStm);
1011 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
1012 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
1013 switch (Chunk.fccID) {
1015 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
1016 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
1017 switch (Chunk.fccID) {
1018 case DMUS_FOURCC_STYLE_FORM: {
1019 TRACE_(dmfile)(": Style form\n");
1020 hr = IDirectMusicStyle8Impl_IPersistStream_ParseStyleForm (iface, &Chunk, pStm);
1021 if (FAILED(hr)) return hr;
1025 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
1026 liMove.QuadPart = Chunk.dwSize;
1027 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
1031 TRACE_(dmfile)(": reading finished\n");
1035 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
1036 liMove.QuadPart = Chunk.dwSize;
1037 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
1045 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
1046 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
1047 FIXME("(%p): Saving not implemented yet\n", This);
1051 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
1052 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
1053 FIXME("(%p, %p): stub\n", This, pcbSize);
1058 IPersistStreamVtbl DirectMusicStyle8_PersistStream_Vtbl = {
1059 IDirectMusicStyle8Impl_IPersistStream_QueryInterface,
1060 IDirectMusicStyle8Impl_IPersistStream_AddRef,
1061 IDirectMusicStyle8Impl_IPersistStream_Release,
1062 IDirectMusicStyle8Impl_IPersistStream_GetClassID,
1063 IDirectMusicStyle8Impl_IPersistStream_IsDirty,
1064 IDirectMusicStyle8Impl_IPersistStream_Load,
1065 IDirectMusicStyle8Impl_IPersistStream_Save,
1066 IDirectMusicStyle8Impl_IPersistStream_GetSizeMax
1069 /* for ClassFactory */
1070 HRESULT WINAPI DMUSIC_CreateDirectMusicStyleImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
1071 IDirectMusicStyle8Impl* obj;
1073 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicStyle8Impl));
1076 return E_OUTOFMEMORY;
1078 obj->UnknownVtbl = &DirectMusicStyle8_Unknown_Vtbl;
1079 obj->StyleVtbl = &DirectMusicStyle8_Style_Vtbl;
1080 obj->ObjectVtbl = &DirectMusicStyle8_Object_Vtbl;
1081 obj->PersistStreamVtbl = &DirectMusicStyle8_PersistStream_Vtbl;
1082 obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
1083 DM_STRUCT_INIT(obj->pDesc);
1084 obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
1085 memcpy (&obj->pDesc->guidClass, &CLSID_DirectMusicStyle, sizeof (CLSID));
1086 obj->ref = 0; /* will be inited by QueryInterface */
1087 list_init (&obj->Bands);
1088 list_init (&obj->Motifs);
1090 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);