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 ULONG ref = InterlockedIncrement(&This->ref);
64 TRACE("(%p): AddRef from %ld\n", This, ref - 1);
71 ULONG WINAPI IDirectMusicStyle8Impl_IUnknown_Release (LPUNKNOWN iface) {
72 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, UnknownVtbl, iface);
73 ULONG ref = InterlockedDecrement(&This->ref);
75 TRACE("(%p): ReleaseRef to %ld\n", This, ref);
78 HeapFree(GetProcessHeap(), 0, This);
81 DMSTYLE_UnlockModule();
86 static const IUnknownVtbl DirectMusicStyle8_Unknown_Vtbl = {
87 IDirectMusicStyle8Impl_IUnknown_QueryInterface,
88 IDirectMusicStyle8Impl_IUnknown_AddRef,
89 IDirectMusicStyle8Impl_IUnknown_Release
92 /* IDirectMusicStyle8Impl IDirectMusicStyle8 part: */
93 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_QueryInterface (LPDIRECTMUSICSTYLE8 iface, REFIID riid, LPVOID *ppobj) {
94 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
95 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
98 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef (LPDIRECTMUSICSTYLE8 iface) {
99 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
100 return IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
103 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_Release (LPDIRECTMUSICSTYLE8 iface) {
104 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
105 return IDirectMusicStyle8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
108 /* IDirectMusicStyle8Impl IDirectMusicStyle(8) part: */
109 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetBand (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicBand** ppBand) {
110 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
111 FIXME("(%p, %p, %p): stub\n", This, pwszName, ppBand);
115 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumBand (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
116 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
117 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
121 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultBand (LPDIRECTMUSICSTYLE8 iface, IDirectMusicBand** ppBand) {
122 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
123 FIXME("(%p, %p): stub\n", This, ppBand);
127 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumMotif (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
128 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
129 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
133 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetMotif (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicSegment** ppSegment) {
134 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
135 FIXME("(%p, %p, %p): stub\n", This, pwszName, ppSegment);
139 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultChordMap (LPDIRECTMUSICSTYLE8 iface, IDirectMusicChordMap** ppChordMap) {
140 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
141 FIXME("(%p, %p): stub\n", This, ppChordMap);
145 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumChordMap (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
146 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
147 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
151 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetChordMap (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicChordMap** ppChordMap) {
152 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
153 FIXME("(%p, %p, %p): stub\n", This, pwszName, ppChordMap);
157 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTimeSignature (LPDIRECTMUSICSTYLE8 iface, DMUS_TIMESIGNATURE* pTimeSig) {
158 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
159 FIXME("(%p, %p): stub\n", This, pTimeSig);
163 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetEmbellishmentLength (LPDIRECTMUSICSTYLE8 iface, DWORD dwType, DWORD dwLevel, DWORD* pdwMin, DWORD* pdwMax) {
164 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
165 FIXME("(%p, %ld, %ld, %p, %p): stub\n", This, dwType, dwLevel, pdwMin, pdwMax);
169 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTempo (LPDIRECTMUSICSTYLE8 iface, double* pTempo) {
170 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
171 FIXME("(%p, %p): stub\n", This, pTempo);
175 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumPattern (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, DWORD dwPatternType, WCHAR* pwszName) {
176 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
177 FIXME("(%p, %ld, %ld, %p): stub\n", This, dwIndex, dwPatternType, pwszName);
181 static const IDirectMusicStyle8Vtbl DirectMusicStyle8_Style_Vtbl = {
182 IDirectMusicStyle8Impl_IDirectMusicStyle8_QueryInterface,
183 IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef,
184 IDirectMusicStyle8Impl_IDirectMusicStyle8_Release,
185 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetBand,
186 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumBand,
187 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultBand,
188 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumMotif,
189 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetMotif,
190 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultChordMap,
191 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumChordMap,
192 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetChordMap,
193 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTimeSignature,
194 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetEmbellishmentLength,
195 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTempo,
196 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumPattern
199 /* IDirectMusicStyle8Impl IDirectMusicObject part: */
200 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
201 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
202 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
205 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
206 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
207 return IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
210 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
211 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
212 return IDirectMusicStyle8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
215 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
216 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
217 TRACE("(%p, %p)\n", This, pDesc);
218 /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
219 memcpy (pDesc, This->pDesc, This->pDesc->dwSize);
223 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
224 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
225 TRACE("(%p, %p): setting descriptor:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC (pDesc));
227 /* According to MSDN, we should copy only given values, not whole struct */
228 if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
229 memcpy (&This->pDesc->guidObject, &pDesc->guidObject, sizeof (pDesc->guidObject));
230 if (pDesc->dwValidData & DMUS_OBJ_CLASS)
231 memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
232 if (pDesc->dwValidData & DMUS_OBJ_NAME)
233 lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
234 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
235 lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
236 if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
237 lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
238 if (pDesc->dwValidData & DMUS_OBJ_VERSION)
239 memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
240 if (pDesc->dwValidData & DMUS_OBJ_DATE)
241 memcpy (&This->pDesc->ftDate, &pDesc->ftDate, sizeof (pDesc->ftDate));
242 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
243 memcpy (&This->pDesc->llMemLength, &pDesc->llMemLength, sizeof (pDesc->llMemLength));
244 memcpy (This->pDesc->pbMemData, pDesc->pbMemData, sizeof (pDesc->pbMemData));
246 if (pDesc->dwValidData & DMUS_OBJ_STREAM) {
247 /* according to MSDN, we copy the stream */
248 IStream_Clone (pDesc->pStream, &This->pDesc->pStream);
252 This->pDesc->dwValidData |= pDesc->dwValidData;
257 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) {
258 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
259 DMUS_PRIVATE_CHUNK Chunk;
260 DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
261 LARGE_INTEGER liMove; /* used when skipping chunks */
263 TRACE("(%p, %p, %p)\n", This, pStream, pDesc);
265 /* FIXME: should this be determined from stream? */
266 pDesc->dwValidData |= DMUS_OBJ_CLASS;
267 memcpy (&pDesc->guidClass, &CLSID_DirectMusicStyle, sizeof(CLSID));
269 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
270 TRACE_(dmfile)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
271 switch (Chunk.fccID) {
273 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
274 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
275 StreamSize = Chunk.dwSize - sizeof(FOURCC);
277 if (Chunk.fccID == DMUS_FOURCC_STYLE_FORM) {
278 TRACE_(dmfile)(": style form\n");
280 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
281 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
282 TRACE_(dmfile)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
283 switch (Chunk.fccID) {
284 case DMUS_FOURCC_GUID_CHUNK: {
285 TRACE_(dmfile)(": GUID chunk\n");
286 pDesc->dwValidData |= DMUS_OBJ_OBJECT;
287 IStream_Read (pStream, &pDesc->guidObject, Chunk.dwSize, NULL);
290 case DMUS_FOURCC_VERSION_CHUNK: {
291 TRACE_(dmfile)(": version chunk\n");
292 pDesc->dwValidData |= DMUS_OBJ_VERSION;
293 IStream_Read (pStream, &pDesc->vVersion, Chunk.dwSize, NULL);
296 case DMUS_FOURCC_CATEGORY_CHUNK: {
297 TRACE_(dmfile)(": category chunk\n");
298 pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
299 IStream_Read (pStream, pDesc->wszCategory, Chunk.dwSize, NULL);
303 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
304 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
305 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
307 switch (Chunk.fccID) {
308 /* evil M$ UNFO list, which can (!?) contain INFO elements */
309 case DMUS_FOURCC_UNFO_LIST: {
310 TRACE_(dmfile)(": UNFO list\n");
312 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
313 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
314 TRACE_(dmfile)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
315 switch (Chunk.fccID) {
316 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
317 (though strings seem to be valid unicode) */
318 case mmioFOURCC('I','N','A','M'):
319 case DMUS_FOURCC_UNAM_CHUNK: {
320 TRACE_(dmfile)(": name chunk\n");
321 pDesc->dwValidData |= DMUS_OBJ_NAME;
322 IStream_Read (pStream, pDesc->wszName, Chunk.dwSize, NULL);
325 case mmioFOURCC('I','A','R','T'):
326 case DMUS_FOURCC_UART_CHUNK: {
327 TRACE_(dmfile)(": artist chunk (ignored)\n");
328 liMove.QuadPart = Chunk.dwSize;
329 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
332 case mmioFOURCC('I','C','O','P'):
333 case DMUS_FOURCC_UCOP_CHUNK: {
334 TRACE_(dmfile)(": copyright chunk (ignored)\n");
335 liMove.QuadPart = Chunk.dwSize;
336 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
339 case mmioFOURCC('I','S','B','J'):
340 case DMUS_FOURCC_USBJ_CHUNK: {
341 TRACE_(dmfile)(": subject chunk (ignored)\n");
342 liMove.QuadPart = Chunk.dwSize;
343 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
346 case mmioFOURCC('I','C','M','T'):
347 case DMUS_FOURCC_UCMT_CHUNK: {
348 TRACE_(dmfile)(": comment chunk (ignored)\n");
349 liMove.QuadPart = Chunk.dwSize;
350 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
354 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
355 liMove.QuadPart = Chunk.dwSize;
356 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
360 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
361 } while (ListCount[0] < ListSize[0]);
365 TRACE_(dmfile)(": unknown (skipping)\n");
366 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
367 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
374 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
375 liMove.QuadPart = Chunk.dwSize;
376 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
380 TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount, StreamSize);
381 } while (StreamCount < StreamSize);
383 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
384 liMove.QuadPart = StreamSize;
385 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
389 TRACE_(dmfile)(": reading finished\n");
393 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
394 liMove.QuadPart = Chunk.dwSize;
395 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
396 return DMUS_E_INVALIDFILE;
400 TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC (pDesc));
405 static const IDirectMusicObjectVtbl DirectMusicStyle8_Object_Vtbl = {
406 IDirectMusicStyle8Impl_IDirectMusicObject_QueryInterface,
407 IDirectMusicStyle8Impl_IDirectMusicObject_AddRef,
408 IDirectMusicStyle8Impl_IDirectMusicObject_Release,
409 IDirectMusicStyle8Impl_IDirectMusicObject_GetDescriptor,
410 IDirectMusicStyle8Impl_IDirectMusicObject_SetDescriptor,
411 IDirectMusicStyle8Impl_IDirectMusicObject_ParseDescriptor
414 /* IDirectMusicStyle8Impl IPersistStream part: */
415 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
416 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
417 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
420 ULONG WINAPI IDirectMusicStyle8Impl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
421 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
422 return IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
425 ULONG WINAPI IDirectMusicStyle8Impl_IPersistStream_Release (LPPERSISTSTREAM iface) {
426 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
427 return IDirectMusicStyle8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
430 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
431 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
432 TRACE("(%p, %p)\n", This, pClassID);
433 memcpy(pClassID, &CLSID_DirectMusicStyle, sizeof(CLSID));
437 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
438 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
439 FIXME("(%p): stub, always S_FALSE\n", This);
443 static HRESULT IDirectMusicStyle8Impl_IPersistStream_LoadBand (LPPERSISTSTREAM iface, IStream* pClonedStream, IDirectMusicBand** ppBand) {
446 IPersistStream* pPersistStream = NULL;
448 hr = CoCreateInstance (&CLSID_DirectMusicBand, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicBand, (LPVOID*) ppBand);
450 ERR(": could not create object\n");
453 /* acquire PersistStream interface */
454 hr = IDirectMusicBand_QueryInterface (*ppBand, &IID_IPersistStream, (LPVOID*) &pPersistStream);
456 ERR(": could not acquire IPersistStream\n");
460 hr = IPersistStream_Load (pPersistStream, pClonedStream);
462 ERR(": failed to load object\n");
466 /* release all loading-related stuff */
467 IPersistStream_Release (pPersistStream);
472 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePartRefList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, LPDMUS_PRIVATE_STYLE_MOTIF pNewMotif) {
473 /*ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);*/
475 DMUS_PRIVATE_CHUNK Chunk;
476 DWORD ListSize[3], ListCount[3];
477 LARGE_INTEGER liMove; /* used when skipping chunks */
479 LPDMUS_PRIVATE_STYLE_PARTREF_ITEM pNewItem = NULL;
482 if (pChunk->fccID != DMUS_FOURCC_PARTREF_LIST) {
483 ERR_(dmfile)(": %s chunk should be a PARTREF list\n", debugstr_fourcc (pChunk->fccID));
487 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
491 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
492 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
493 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
494 switch (Chunk.fccID) {
495 case DMUS_FOURCC_PARTREF_CHUNK: {
496 TRACE_(dmfile)(": PartRef chunk\n");
497 pNewItem = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_PARTREF_ITEM));
498 if (NULL == pNewItem) {
499 ERR(": no more memory\n");
500 return E_OUTOFMEMORY;
502 hr = IStream_Read (pStm, &pNewItem->part_ref, sizeof(DMUS_IO_PARTREF), NULL);
503 /*TRACE_(dmfile)(" - sizeof %lu\n", sizeof(DMUS_IO_PARTREF));*/
504 list_add_tail (&pNewMotif->Items, &pNewItem->entry);
505 DM_STRUCT_INIT(&pNewItem->desc);
509 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
510 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
511 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
513 switch (Chunk.fccID) {
514 case DMUS_FOURCC_UNFO_LIST: {
515 TRACE_(dmfile)(": UNFO list\n");
517 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
518 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
519 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
521 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &pNewItem->desc);
522 if (FAILED(hr)) return hr;
525 switch (Chunk.fccID) {
527 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
528 liMove.QuadPart = Chunk.dwSize;
529 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
534 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
535 } while (ListCount[1] < ListSize[1]);
539 TRACE_(dmfile)(": unknown chunk (skipping)\n");
540 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
541 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
548 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
549 liMove.QuadPart = Chunk.dwSize;
550 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
554 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
555 } while (ListCount[0] < ListSize[0]);
560 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePartList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
562 /*ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);*/
564 DMUS_PRIVATE_CHUNK Chunk;
565 DWORD ListSize[3], ListCount[3];
566 LARGE_INTEGER liMove; /* used when skipping chunks */
568 DMUS_OBJECTDESC desc;
572 if (pChunk->fccID != DMUS_FOURCC_PART_LIST) {
573 ERR_(dmfile)(": %s chunk should be a PART list\n", debugstr_fourcc (pChunk->fccID));
577 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
581 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
582 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
583 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
584 switch (Chunk.fccID) {
585 case DMUS_FOURCC_PART_CHUNK: {
586 TRACE_(dmfile)(": Part chunk (skipping for now) (sizeof %u)\n", sizeof(DMUS_IO_STYLEPART));
587 liMove.QuadPart = Chunk.dwSize;
588 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
591 case DMUS_FOURCC_NOTE_CHUNK: {
592 TRACE_(dmfile)(": Note chunk (skipping for now) (sizeof %u)\n", sizeof(DMUS_IO_STYLENOTE));
593 IStream_Read (pStm, &dwSize, sizeof(DWORD), NULL);
594 cnt = (Chunk.dwSize - sizeof(DWORD));
595 TRACE_(dmfile)(" - dwSize: %lu\n", dwSize);
596 TRACE_(dmfile)(" - cnt: %lu (%lu / %lu)\n", cnt / dwSize, (Chunk.dwSize - sizeof(DWORD)), dwSize);
597 if (cnt % dwSize != 0) {
598 ERR("Invalid Array Size");
603 liMove.QuadPart = cnt * dwSize;
604 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
607 case DMUS_FOURCC_CURVE_CHUNK: {
608 TRACE_(dmfile)(": Curve chunk (skipping for now) (sizeof %u)\n", sizeof(DMUS_IO_STYLECURVE));
609 IStream_Read (pStm, &dwSize, sizeof(DWORD), NULL);
610 cnt = (Chunk.dwSize - sizeof(DWORD));
611 TRACE_(dmfile)(" - dwSize: %lu\n", dwSize);
612 TRACE_(dmfile)(" - cnt: %lu (%lu / %lu)\n", cnt / dwSize, (Chunk.dwSize - sizeof(DWORD)), dwSize);
613 if (cnt % dwSize != 0) {
614 ERR("Invalid Array Size");
619 liMove.QuadPart = cnt * dwSize;
620 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
623 case DMUS_FOURCC_MARKER_CHUNK: {
624 TRACE_(dmfile)(": Marker chunk (skipping for now)\n");
625 liMove.QuadPart = Chunk.dwSize;
626 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
629 case DMUS_FOURCC_RESOLUTION_CHUNK: {
630 TRACE_(dmfile)(": Resolution chunk (skipping for now)\n");
631 liMove.QuadPart = Chunk.dwSize;
632 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
635 case DMUS_FOURCC_ANTICIPATION_CHUNK: {
636 TRACE_(dmfile)(": Anticipation chunk (skipping for now)\n");
637 liMove.QuadPart = Chunk.dwSize;
638 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
642 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
643 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
644 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
646 switch (Chunk.fccID) {
647 case DMUS_FOURCC_UNFO_LIST: {
648 TRACE_(dmfile)(": UNFO list\n");
650 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
651 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
652 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
654 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &desc);
655 if (FAILED(hr)) return hr;
658 switch (Chunk.fccID) {
660 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
661 liMove.QuadPart = Chunk.dwSize;
662 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
667 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
668 } while (ListCount[1] < ListSize[1]);
672 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
673 liMove.QuadPart = Chunk.dwSize;
674 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
681 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
682 liMove.QuadPart = Chunk.dwSize;
683 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
687 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
688 } while (ListCount[0] < ListSize[0]);
693 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
695 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
697 DMUS_PRIVATE_CHUNK Chunk;
698 DWORD ListSize[3], ListCount[3];
699 LARGE_INTEGER liMove; /* used when skipping chunks */
701 DMUS_OBJECTDESC desc;
702 IDirectMusicBand* pBand = NULL;
703 LPDMUS_PRIVATE_STYLE_MOTIF pNewMotif = NULL;
705 DM_STRUCT_INIT(&desc);
707 if (pChunk->fccID != DMUS_FOURCC_PATTERN_LIST) {
708 ERR_(dmfile)(": %s chunk should be a PATTERN list\n", debugstr_fourcc (pChunk->fccID));
712 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
716 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
717 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
718 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
719 switch (Chunk.fccID) {
720 case DMUS_FOURCC_PATTERN_CHUNK: {
721 TRACE_(dmfile)(": Pattern chunk\n");
722 /** alloc new motif entry */
723 pNewMotif = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_MOTIF));
724 list_add_tail (&This->Motifs, &pNewMotif->entry);
725 if (NULL == pNewMotif) {
726 ERR(": no more memory\n");
727 return E_OUTOFMEMORY;
730 IStream_Read (pStm, &pNewMotif->pattern, Chunk.dwSize, NULL);
731 /** TODO trace pattern */
733 /** reset all datas, as a new pattern begin */
734 DM_STRUCT_INIT(&pNewMotif->desc);
735 list_init (&pNewMotif->Items);
738 case DMUS_FOURCC_RHYTHM_CHUNK: {
739 TRACE_(dmfile)(": Rythm chunk\n");
740 IStream_Read (pStm, &pNewMotif->dwRythm, sizeof(DWORD), NULL);
741 TRACE_(dmfile)(" - dwRythm: %lu\n", pNewMotif->dwRythm);
742 /** TODO understand why some Chunks have size > 4 */
743 liMove.QuadPart = Chunk.dwSize - sizeof(DWORD);
744 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
747 case DMUS_FOURCC_MOTIFSETTINGS_CHUNK: {
748 TRACE_(dmfile)(": MotifSettigns chunk (skipping for now)\n");
749 IStream_Read (pStm, &pNewMotif->settings, Chunk.dwSize, NULL);
750 /** TODO trace settings */
755 * sould be embededs Bands into pattern
757 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
758 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
759 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
761 switch (Chunk.fccID) {
762 case DMUS_FOURCC_BAND_FORM: {
763 LPSTREAM pClonedStream = NULL;
765 TRACE_(dmfile)(": BAND RIFF\n");
767 IStream_Clone (pStm, &pClonedStream);
770 liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD));
771 IStream_Seek (pClonedStream, liMove, STREAM_SEEK_CUR, NULL);
773 hr = IDirectMusicStyle8Impl_IPersistStream_LoadBand (iface, pClonedStream, &pBand);
775 ERR(": could not load track\n");
778 IStream_Release (pClonedStream);
780 pNewMotif->pBand = pBand;
781 IDirectMusicBand_AddRef(pBand);
783 IDirectMusicTrack_Release(pBand); pBand = NULL; /* now we can release at as it inserted */
785 /** now safe move the cursor */
786 liMove.QuadPart = ListSize[1];
787 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
792 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
793 liMove.QuadPart = ListSize[1];
794 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
801 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
802 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
803 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
805 switch (Chunk.fccID) {
806 case DMUS_FOURCC_UNFO_LIST: {
807 TRACE_(dmfile)(": UNFO list\n");
809 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
810 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
811 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
813 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &pNewMotif->desc);
814 if (FAILED(hr)) return hr;
817 switch (Chunk.fccID) {
819 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
820 liMove.QuadPart = Chunk.dwSize;
821 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
826 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
827 } while (ListCount[1] < ListSize[1]);
830 case DMUS_FOURCC_PARTREF_LIST: {
831 TRACE_(dmfile)(": PartRef list\n");
832 hr = IDirectMusicStyle8Impl_IPersistStream_ParsePartRefList (iface, &Chunk, pStm, pNewMotif);
833 if (FAILED(hr)) return hr;
837 TRACE_(dmfile)(": unknown (skipping)\n");
838 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
839 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
846 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
847 liMove.QuadPart = Chunk.dwSize;
848 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
852 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
853 } while (ListCount[0] < ListSize[0]);
858 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParseStyleForm (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
859 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
862 DMUS_PRIVATE_CHUNK Chunk;
863 DWORD StreamSize, StreamCount, ListSize[3], ListCount[3];
864 LARGE_INTEGER liMove; /* used when skipping chunks */
866 IDirectMusicBand* pBand = NULL;
868 if (pChunk->fccID != DMUS_FOURCC_STYLE_FORM) {
869 ERR_(dmfile)(": %s chunk should be a STYLE form\n", debugstr_fourcc (pChunk->fccID));
873 StreamSize = pChunk->dwSize - sizeof(FOURCC);
877 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
878 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
879 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
881 hr = IDirectMusicUtils_IPersistStream_ParseDescGeneric(&Chunk, pStm, This->pDesc);
882 if (FAILED(hr)) return hr;
885 switch (Chunk.fccID) {
886 case DMUS_FOURCC_STYLE_CHUNK: {
887 TRACE_(dmfile)(": Style chunk\n");
888 IStream_Read (pStm, &This->style, sizeof(DMUS_IO_STYLE), NULL);
889 /** TODO dump DMUS_IO_TIMESIG style.timeSig */
890 TRACE_(dmfile)(" - dblTempo: %g\n", This->style.dblTempo);
895 * sould be embededs Bands into style
897 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
898 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
899 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
901 switch (Chunk.fccID) {
902 case DMUS_FOURCC_BAND_FORM: {
903 LPSTREAM pClonedStream = NULL;
904 LPDMUS_PRIVATE_STYLE_BAND pNewBand;
906 TRACE_(dmfile)(": BAND RIFF\n");
908 IStream_Clone (pStm, &pClonedStream);
911 liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD));
912 IStream_Seek (pClonedStream, liMove, STREAM_SEEK_CUR, NULL);
914 hr = IDirectMusicStyle8Impl_IPersistStream_LoadBand (iface, pClonedStream, &pBand);
916 ERR(": could not load track\n");
919 IStream_Release (pClonedStream);
921 pNewBand = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_BAND));
922 if (NULL == pNewBand) {
923 ERR(": no more memory\n");
924 return E_OUTOFMEMORY;
926 pNewBand->pBand = pBand;
927 IDirectMusicBand_AddRef(pBand);
928 list_add_tail (&This->Bands, &pNewBand->entry);
930 IDirectMusicTrack_Release(pBand); pBand = NULL; /* now we can release at as it inserted */
932 /** now safe move the cursor */
933 liMove.QuadPart = ListSize[0];
934 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
939 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
940 liMove.QuadPart = ListSize[0];
941 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
948 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
949 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
950 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
952 switch (Chunk.fccID) {
953 case DMUS_FOURCC_UNFO_LIST: {
954 TRACE_(dmfile)(": UNFO list\n");
956 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
957 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
958 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
960 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, This->pDesc);
961 if (FAILED(hr)) return hr;
964 switch (Chunk.fccID) {
966 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
967 liMove.QuadPart = Chunk.dwSize;
968 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
973 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
974 } while (ListCount[0] < ListSize[0]);
977 case DMUS_FOURCC_PART_LIST: {
978 TRACE_(dmfile)(": PART list\n");
979 hr = IDirectMusicStyle8Impl_IPersistStream_ParsePartList (iface, &Chunk, pStm);
980 if (FAILED(hr)) return hr;
983 case DMUS_FOURCC_PATTERN_LIST: {
984 TRACE_(dmfile)(": PATTERN list\n");
985 hr = IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (iface, &Chunk, pStm);
986 if (FAILED(hr)) return hr;
990 TRACE_(dmfile)(": unknown (skipping)\n");
991 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
992 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
999 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
1000 liMove.QuadPart = Chunk.dwSize;
1001 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
1006 TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount, StreamSize);
1007 } while (StreamCount < StreamSize);
1012 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
1013 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
1015 DMUS_PRIVATE_CHUNK Chunk;
1016 LARGE_INTEGER liMove; /* used when skipping chunks */
1019 FIXME("(%p, %p): Loading\n", This, pStm);
1021 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
1022 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
1023 switch (Chunk.fccID) {
1025 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
1026 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
1027 switch (Chunk.fccID) {
1028 case DMUS_FOURCC_STYLE_FORM: {
1029 TRACE_(dmfile)(": Style form\n");
1030 hr = IDirectMusicStyle8Impl_IPersistStream_ParseStyleForm (iface, &Chunk, pStm);
1031 if (FAILED(hr)) return hr;
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 */
1041 TRACE_(dmfile)(": reading finished\n");
1045 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
1046 liMove.QuadPart = Chunk.dwSize;
1047 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
1055 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
1056 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
1057 FIXME("(%p): Saving not implemented yet\n", This);
1061 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
1062 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
1063 FIXME("(%p, %p): stub\n", This, pcbSize);
1068 static const IPersistStreamVtbl DirectMusicStyle8_PersistStream_Vtbl = {
1069 IDirectMusicStyle8Impl_IPersistStream_QueryInterface,
1070 IDirectMusicStyle8Impl_IPersistStream_AddRef,
1071 IDirectMusicStyle8Impl_IPersistStream_Release,
1072 IDirectMusicStyle8Impl_IPersistStream_GetClassID,
1073 IDirectMusicStyle8Impl_IPersistStream_IsDirty,
1074 IDirectMusicStyle8Impl_IPersistStream_Load,
1075 IDirectMusicStyle8Impl_IPersistStream_Save,
1076 IDirectMusicStyle8Impl_IPersistStream_GetSizeMax
1079 /* for ClassFactory */
1080 HRESULT WINAPI DMUSIC_CreateDirectMusicStyleImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
1081 IDirectMusicStyle8Impl* obj;
1083 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicStyle8Impl));
1086 return E_OUTOFMEMORY;
1088 obj->UnknownVtbl = &DirectMusicStyle8_Unknown_Vtbl;
1089 obj->StyleVtbl = &DirectMusicStyle8_Style_Vtbl;
1090 obj->ObjectVtbl = &DirectMusicStyle8_Object_Vtbl;
1091 obj->PersistStreamVtbl = &DirectMusicStyle8_PersistStream_Vtbl;
1092 obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
1093 DM_STRUCT_INIT(obj->pDesc);
1094 obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
1095 memcpy (&obj->pDesc->guidClass, &CLSID_DirectMusicStyle, sizeof (CLSID));
1096 obj->ref = 0; /* will be inited by QueryInterface */
1097 list_init (&obj->Bands);
1098 list_init (&obj->Motifs);
1100 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);