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 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
74 IDirectMusicStyle8Impl_IUnknown_QueryInterface,
75 IDirectMusicStyle8Impl_IUnknown_AddRef,
76 IDirectMusicStyle8Impl_IUnknown_Release
79 /* IDirectMusicStyle8Impl IDirectMusicStyle8 part: */
80 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_QueryInterface (LPDIRECTMUSICSTYLE8 iface, REFIID riid, LPVOID *ppobj) {
81 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
82 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
85 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef (LPDIRECTMUSICSTYLE8 iface) {
86 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
87 return IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
90 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_Release (LPDIRECTMUSICSTYLE8 iface) {
91 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
92 return IDirectMusicStyle8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
95 /* IDirectMusicStyle8Impl IDirectMusicStyle(8) part: */
96 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetBand (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicBand** ppBand) {
97 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
98 FIXME("(%p, %p, %p): stub\n", This, pwszName, ppBand);
102 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumBand (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
103 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
104 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
108 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultBand (LPDIRECTMUSICSTYLE8 iface, IDirectMusicBand** ppBand) {
109 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
110 FIXME("(%p, %p): stub\n", This, ppBand);
114 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumMotif (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
115 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
116 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
120 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetMotif (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicSegment** ppSegment) {
121 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
122 FIXME("(%p, %p, %p): stub\n", This, pwszName, ppSegment);
126 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultChordMap (LPDIRECTMUSICSTYLE8 iface, IDirectMusicChordMap** ppChordMap) {
127 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
128 FIXME("(%p, %p): stub\n", This, ppChordMap);
132 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumChordMap (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
133 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
134 FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName);
138 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetChordMap (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicChordMap** ppChordMap) {
139 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
140 FIXME("(%p, %p, %p): stub\n", This, pwszName, ppChordMap);
144 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTimeSignature (LPDIRECTMUSICSTYLE8 iface, DMUS_TIMESIGNATURE* pTimeSig) {
145 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
146 FIXME("(%p, %p): stub\n", This, pTimeSig);
150 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetEmbellishmentLength (LPDIRECTMUSICSTYLE8 iface, DWORD dwType, DWORD dwLevel, DWORD* pdwMin, DWORD* pdwMax) {
151 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
152 FIXME("(%p, %ld, %ld, %p, %p): stub\n", This, dwType, dwLevel, pdwMin, pdwMax);
156 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTempo (LPDIRECTMUSICSTYLE8 iface, double* pTempo) {
157 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
158 FIXME("(%p, %p): stub\n", This, pTempo);
162 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumPattern (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, DWORD dwPatternType, WCHAR* pwszName) {
163 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
164 FIXME("(%p, %ld, %ld, %p): stub\n", This, dwIndex, dwPatternType, pwszName);
168 IDirectMusicStyle8Vtbl DirectMusicStyle8_Style_Vtbl = {
169 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
170 IDirectMusicStyle8Impl_IDirectMusicStyle8_QueryInterface,
171 IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef,
172 IDirectMusicStyle8Impl_IDirectMusicStyle8_Release,
173 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetBand,
174 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumBand,
175 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultBand,
176 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumMotif,
177 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetMotif,
178 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultChordMap,
179 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumChordMap,
180 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetChordMap,
181 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTimeSignature,
182 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetEmbellishmentLength,
183 IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTempo,
184 IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumPattern
187 /* IDirectMusicStyle8Impl IDirectMusicObject part: */
188 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
189 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
190 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
193 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
194 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
195 return IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
198 ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
199 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
200 return IDirectMusicStyle8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
203 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
204 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
205 TRACE("(%p, %p)\n", This, pDesc);
206 /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
207 memcpy (pDesc, This->pDesc, This->pDesc->dwSize);
211 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
212 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
213 TRACE("(%p, %p): setting descriptor:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC (pDesc));
215 /* According to MSDN, we should copy only given values, not whole struct */
216 if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
217 memcpy (&This->pDesc->guidObject, &pDesc->guidObject, sizeof (pDesc->guidObject));
218 if (pDesc->dwValidData & DMUS_OBJ_CLASS)
219 memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
220 if (pDesc->dwValidData & DMUS_OBJ_NAME)
221 strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
222 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
223 strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
224 if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
225 strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
226 if (pDesc->dwValidData & DMUS_OBJ_VERSION)
227 memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
228 if (pDesc->dwValidData & DMUS_OBJ_DATE)
229 memcpy (&This->pDesc->ftDate, &pDesc->ftDate, sizeof (pDesc->ftDate));
230 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
231 memcpy (&This->pDesc->llMemLength, &pDesc->llMemLength, sizeof (pDesc->llMemLength));
232 memcpy (This->pDesc->pbMemData, pDesc->pbMemData, sizeof (pDesc->pbMemData));
234 if (pDesc->dwValidData & DMUS_OBJ_STREAM) {
235 /* according to MSDN, we copy the stream */
236 IStream_Clone (pDesc->pStream, &This->pDesc->pStream);
240 This->pDesc->dwValidData |= pDesc->dwValidData;
245 HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) {
246 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
247 DMUS_PRIVATE_CHUNK Chunk;
248 DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
249 LARGE_INTEGER liMove; /* used when skipping chunks */
251 TRACE("(%p, %p, %p)\n", This, pStream, pDesc);
253 /* FIXME: should this be determined from stream? */
254 pDesc->dwValidData |= DMUS_OBJ_CLASS;
255 memcpy (&pDesc->guidClass, &CLSID_DirectMusicStyle, sizeof(CLSID));
257 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
258 TRACE_(dmfile)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
259 switch (Chunk.fccID) {
261 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
262 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
263 StreamSize = Chunk.dwSize - sizeof(FOURCC);
265 if (Chunk.fccID == DMUS_FOURCC_STYLE_FORM) {
266 TRACE_(dmfile)(": style form\n");
268 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
269 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
270 TRACE_(dmfile)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
271 switch (Chunk.fccID) {
272 case DMUS_FOURCC_GUID_CHUNK: {
273 TRACE_(dmfile)(": GUID chunk\n");
274 pDesc->dwValidData |= DMUS_OBJ_OBJECT;
275 IStream_Read (pStream, &pDesc->guidObject, Chunk.dwSize, NULL);
278 case DMUS_FOURCC_VERSION_CHUNK: {
279 TRACE_(dmfile)(": version chunk\n");
280 pDesc->dwValidData |= DMUS_OBJ_VERSION;
281 IStream_Read (pStream, &pDesc->vVersion, Chunk.dwSize, NULL);
284 case DMUS_FOURCC_CATEGORY_CHUNK: {
285 TRACE_(dmfile)(": category chunk\n");
286 pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
287 IStream_Read (pStream, pDesc->wszCategory, Chunk.dwSize, NULL);
291 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
292 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
293 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
295 switch (Chunk.fccID) {
296 /* evil M$ UNFO list, which can (!?) contain INFO elements */
297 case DMUS_FOURCC_UNFO_LIST: {
298 TRACE_(dmfile)(": UNFO list\n");
300 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
301 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
302 TRACE_(dmfile)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
303 switch (Chunk.fccID) {
304 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
305 (though strings seem to be valid unicode) */
306 case mmioFOURCC('I','N','A','M'):
307 case DMUS_FOURCC_UNAM_CHUNK: {
308 TRACE_(dmfile)(": name chunk\n");
309 pDesc->dwValidData |= DMUS_OBJ_NAME;
310 IStream_Read (pStream, pDesc->wszName, Chunk.dwSize, NULL);
313 case mmioFOURCC('I','A','R','T'):
314 case DMUS_FOURCC_UART_CHUNK: {
315 TRACE_(dmfile)(": artist chunk (ignored)\n");
316 liMove.QuadPart = Chunk.dwSize;
317 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
320 case mmioFOURCC('I','C','O','P'):
321 case DMUS_FOURCC_UCOP_CHUNK: {
322 TRACE_(dmfile)(": copyright chunk (ignored)\n");
323 liMove.QuadPart = Chunk.dwSize;
324 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
327 case mmioFOURCC('I','S','B','J'):
328 case DMUS_FOURCC_USBJ_CHUNK: {
329 TRACE_(dmfile)(": subject chunk (ignored)\n");
330 liMove.QuadPart = Chunk.dwSize;
331 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
334 case mmioFOURCC('I','C','M','T'):
335 case DMUS_FOURCC_UCMT_CHUNK: {
336 TRACE_(dmfile)(": comment chunk (ignored)\n");
337 liMove.QuadPart = Chunk.dwSize;
338 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
342 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
343 liMove.QuadPart = Chunk.dwSize;
344 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
348 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
349 } while (ListCount[0] < ListSize[0]);
353 TRACE_(dmfile)(": unknown (skipping)\n");
354 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
355 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
362 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
363 liMove.QuadPart = Chunk.dwSize;
364 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
368 TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount, StreamSize);
369 } while (StreamCount < StreamSize);
372 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
373 liMove.QuadPart = StreamSize;
374 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
378 TRACE_(dmfile)(": reading finished\n");
382 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
383 liMove.QuadPart = Chunk.dwSize;
384 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
385 return DMUS_E_INVALIDFILE;
389 TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC (pDesc));
394 IDirectMusicObjectVtbl DirectMusicStyle8_Object_Vtbl = {
395 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
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 DMUS_OBJECTDESC desc;
471 if (pChunk->fccID != DMUS_FOURCC_PARTREF_LIST) {
472 ERR_(dmfile)(": %s chunk should be a PARTREF list\n", debugstr_fourcc (pChunk->fccID));
476 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
480 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
481 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
482 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
483 switch (Chunk.fccID) {
484 case DMUS_FOURCC_PARTREF_CHUNK: {
485 TRACE_(dmfile)(": PartRef chunk (skipping for now)\n");
486 liMove.QuadPart = Chunk.dwSize;
487 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
491 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
492 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
493 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
495 switch (Chunk.fccID) {
496 case DMUS_FOURCC_UNFO_LIST: {
497 TRACE_(dmfile)(": UNFO list\n");
499 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
500 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
501 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
503 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &desc);
504 if (FAILED(hr)) return hr;
507 switch (Chunk.fccID) {
509 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
510 liMove.QuadPart = Chunk.dwSize;
511 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
516 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
517 } while (ListCount[1] < ListSize[1]);
521 TRACE_(dmfile)(": unknown chunk (skipping)\n");
522 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
523 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
530 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
531 liMove.QuadPart = Chunk.dwSize;
532 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
536 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
537 } while (ListCount[0] < ListSize[0]);
542 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePartList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
544 /*ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);*/
546 DMUS_PRIVATE_CHUNK Chunk;
547 DWORD ListSize[3], ListCount[3];
548 LARGE_INTEGER liMove; /* used when skipping chunks */
550 DMUS_OBJECTDESC desc;
552 if (pChunk->fccID != DMUS_FOURCC_PART_LIST) {
553 ERR_(dmfile)(": %s chunk should be a PART list\n", debugstr_fourcc (pChunk->fccID));
557 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
561 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
562 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
563 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
564 switch (Chunk.fccID) {
565 case DMUS_FOURCC_PART_CHUNK: {
566 TRACE_(dmfile)(": Part chunk (skipping for now)\n");
567 liMove.QuadPart = Chunk.dwSize;
568 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
571 case DMUS_FOURCC_NOTE_CHUNK: {
572 TRACE_(dmfile)(": Note chunk (skipping for now)\n");
573 liMove.QuadPart = Chunk.dwSize;
574 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
577 case DMUS_FOURCC_CURVE_CHUNK: {
578 TRACE_(dmfile)(": Curve chunk (skipping for now)\n");
579 liMove.QuadPart = Chunk.dwSize;
580 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
583 case DMUS_FOURCC_MARKER_CHUNK: {
584 TRACE_(dmfile)(": Marker chunk (skipping for now)\n");
585 liMove.QuadPart = Chunk.dwSize;
586 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
589 case DMUS_FOURCC_RESOLUTION_CHUNK: {
590 TRACE_(dmfile)(": Resolution chunk (skipping for now)\n");
591 liMove.QuadPart = Chunk.dwSize;
592 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
595 case DMUS_FOURCC_ANTICIPATION_CHUNK: {
596 TRACE_(dmfile)(": Anticipation chunk (skipping for now)\n");
597 liMove.QuadPart = Chunk.dwSize;
598 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
602 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
603 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
604 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
606 switch (Chunk.fccID) {
607 case DMUS_FOURCC_UNFO_LIST: {
608 TRACE_(dmfile)(": UNFO list\n");
610 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
611 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
612 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
614 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &desc);
615 if (FAILED(hr)) return hr;
618 switch (Chunk.fccID) {
620 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
621 liMove.QuadPart = Chunk.dwSize;
622 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
627 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
628 } while (ListCount[1] < ListSize[1]);
632 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
633 liMove.QuadPart = Chunk.dwSize;
634 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
641 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
642 liMove.QuadPart = Chunk.dwSize;
643 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
647 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
648 } while (ListCount[0] < ListSize[0]);
653 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
655 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
657 DMUS_PRIVATE_CHUNK Chunk;
658 DWORD ListSize[3], ListCount[3];
659 LARGE_INTEGER liMove; /* used when skipping chunks */
662 DMUS_OBJECTDESC desc;
663 IDirectMusicBand* pBand = NULL;
664 LPDMUS_PRIVATE_STYLE_MOTIF pNewMotif = NULL;
667 DM_STRUCT_INIT(&desc);
669 if (pChunk->fccID != DMUS_FOURCC_PATTERN_LIST) {
670 ERR_(dmfile)(": %s chunk should be a PATTERN list\n", debugstr_fourcc (pChunk->fccID));
674 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
678 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
679 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
680 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
681 switch (Chunk.fccID) {
682 case DMUS_FOURCC_PATTERN_CHUNK: {
683 TRACE_(dmfile)(": Pattern chunk\n");
684 /** alloc new motif entry */
685 pNewMotif = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_MOTIF));
686 list_add_tail (&This->Motifs, &pNewMotif->entry);
687 if (NULL == pNewMotif) {
688 ERR(": no more memory\n");
689 return E_OUTOFMEMORY;
692 IStream_Read (pStm, &pNewMotif->pattern, Chunk.dwSize, NULL);
693 /** TODO trace pattern */
695 /** reset all datas, as a new pattern begin */
697 DM_STRUCT_INIT(&pNewMotif->desc);
700 case DMUS_FOURCC_RHYTHM_CHUNK: {
701 TRACE_(dmfile)(": Rythm chunk\n");
702 IStream_Read (pStm, &dwRythm, sizeof(DWORD), NULL);
703 TRACE_(dmfile)(" - dwRythm: %lu\n", dwRythm);
704 /** TODO understand why some Chunks have size > 4 */
705 liMove.QuadPart = Chunk.dwSize - sizeof(DWORD);
706 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
709 case DMUS_FOURCC_MOTIFSETTINGS_CHUNK: {
710 TRACE_(dmfile)(": MotifSettigns chunk (skipping for now)\n");
711 IStream_Read (pStm, &pNewMotif->settings, Chunk.dwSize, NULL);
712 /** TODO trace settings */
717 * sould be embededs Bands into pattern
719 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
720 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
721 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
723 switch (Chunk.fccID) {
724 case DMUS_FOURCC_BAND_FORM: {
725 LPSTREAM pClonedStream = NULL;
727 TRACE_(dmfile)(": BAND RIFF\n");
729 IStream_Clone (pStm, &pClonedStream);
732 liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD));
733 IStream_Seek (pClonedStream, liMove, STREAM_SEEK_CUR, NULL);
735 hr = IDirectMusicStyle8Impl_IPersistStream_LoadBand (iface, pClonedStream, &pBand);
737 ERR(": could not load track\n");
740 IStream_Release (pClonedStream);
742 pNewMotif->pBand = pBand;
743 IDirectMusicBand_AddRef(pBand);
745 IDirectMusicTrack_Release(pBand); pBand = NULL; /* now we can release at as it inserted */
747 /** now safe move the cursor */
748 liMove.QuadPart = ListSize[1];
749 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
754 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
755 liMove.QuadPart = ListSize[1];
756 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
763 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
764 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
765 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
767 switch (Chunk.fccID) {
768 case DMUS_FOURCC_UNFO_LIST: {
769 TRACE_(dmfile)(": UNFO list\n");
771 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
772 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
773 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
775 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &pNewMotif->desc);
776 if (FAILED(hr)) return hr;
779 switch (Chunk.fccID) {
781 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
782 liMove.QuadPart = Chunk.dwSize;
783 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
788 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
789 } while (ListCount[1] < ListSize[1]);
792 case DMUS_FOURCC_PARTREF_LIST: {
793 TRACE_(dmfile)(": PartRef list\n");
794 hr = IDirectMusicStyle8Impl_IPersistStream_ParsePartRefList (iface, &Chunk, pStm, pNewMotif);
795 if (FAILED(hr)) return hr;
799 TRACE_(dmfile)(": unknown (skipping)\n");
800 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
801 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
808 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
809 liMove.QuadPart = Chunk.dwSize;
810 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
814 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
815 } while (ListCount[0] < ListSize[0]);
820 static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParseStyleForm (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
821 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
824 DMUS_PRIVATE_CHUNK Chunk;
825 DWORD StreamSize, StreamCount, ListSize[3], ListCount[3];
826 LARGE_INTEGER liMove; /* used when skipping chunks */
828 IDirectMusicBand* pBand = NULL;
830 if (pChunk->fccID != DMUS_FOURCC_STYLE_FORM) {
831 ERR_(dmfile)(": %s chunk should be a STYLE form\n", debugstr_fourcc (pChunk->fccID));
835 StreamSize = pChunk->dwSize - sizeof(FOURCC);
839 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
840 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
841 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
843 hr = IDirectMusicUtils_IPersistStream_ParseDescGeneric(&Chunk, pStm, This->pDesc);
844 if (FAILED(hr)) return hr;
847 switch (Chunk.fccID) {
848 case DMUS_FOURCC_STYLE_CHUNK: {
849 TRACE_(dmfile)(": Style chunk\n");
850 IStream_Read (pStm, &This->style, sizeof(DMUS_IO_STYLE), NULL);
851 /** TODO dump DMUS_IO_TIMESIG style.timeSig */
852 TRACE_(dmfile)(" - dblTempo: %g\n", This->style.dblTempo);
857 * sould be embededs Bands into style
859 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
860 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
861 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
863 switch (Chunk.fccID) {
864 case DMUS_FOURCC_BAND_FORM: {
865 LPSTREAM pClonedStream = NULL;
866 LPDMUS_PRIVATE_STYLE_BAND pNewBand;
868 TRACE_(dmfile)(": BAND RIFF\n");
870 IStream_Clone (pStm, &pClonedStream);
873 liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD));
874 IStream_Seek (pClonedStream, liMove, STREAM_SEEK_CUR, NULL);
876 hr = IDirectMusicStyle8Impl_IPersistStream_LoadBand (iface, pClonedStream, &pBand);
878 ERR(": could not load track\n");
881 IStream_Release (pClonedStream);
883 pNewBand = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_BAND));
884 if (NULL == pNewBand) {
885 ERR(": no more memory\n");
886 return E_OUTOFMEMORY;
888 pNewBand->pBand = pBand;
889 IDirectMusicBand_AddRef(pBand);
890 list_add_tail (&This->Bands, &pNewBand->entry);
892 IDirectMusicTrack_Release(pBand); pBand = NULL; /* now we can release at as it inserted */
894 /** now safe move the cursor */
895 liMove.QuadPart = ListSize[0];
896 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
901 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
902 liMove.QuadPart = ListSize[0];
903 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
910 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
911 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
912 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
914 switch (Chunk.fccID) {
915 case DMUS_FOURCC_UNFO_LIST: {
916 TRACE_(dmfile)(": UNFO list\n");
918 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
919 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
920 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
922 hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, This->pDesc);
923 if (FAILED(hr)) return hr;
926 switch (Chunk.fccID) {
928 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
929 liMove.QuadPart = Chunk.dwSize;
930 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
935 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
936 } while (ListCount[0] < ListSize[0]);
939 case DMUS_FOURCC_PART_LIST: {
940 TRACE_(dmfile)(": PART list\n");
941 hr = IDirectMusicStyle8Impl_IPersistStream_ParsePartList (iface, &Chunk, pStm);
942 if (FAILED(hr)) return hr;
945 case DMUS_FOURCC_PATTERN_LIST: {
946 TRACE_(dmfile)(": PATTERN list\n");
947 hr = IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (iface, &Chunk, pStm);
948 if (FAILED(hr)) return hr;
952 TRACE_(dmfile)(": unknown (skipping)\n");
953 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
954 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
961 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
962 liMove.QuadPart = Chunk.dwSize;
963 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
968 TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount, StreamSize);
969 } while (StreamCount < StreamSize);
974 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
975 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
977 DMUS_PRIVATE_CHUNK Chunk;
978 LARGE_INTEGER liMove; /* used when skipping chunks */
981 FIXME("(%p, %p): Loading\n", This, pStm);
983 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
984 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
985 switch (Chunk.fccID) {
987 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
988 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
989 switch (Chunk.fccID) {
990 case DMUS_FOURCC_STYLE_FORM: {
991 TRACE_(dmfile)(": Style form\n");
992 hr = IDirectMusicStyle8Impl_IPersistStream_ParseStyleForm (iface, &Chunk, pStm);
993 if (FAILED(hr)) return hr;
997 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
998 liMove.QuadPart = Chunk.dwSize;
999 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
1003 TRACE_(dmfile)(": reading finished\n");
1007 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
1008 liMove.QuadPart = Chunk.dwSize;
1009 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
1017 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
1018 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
1019 FIXME("(%p): Saving not implemented yet\n", This);
1023 HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
1024 ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
1025 FIXME("(%p, %p): stub\n", This, pcbSize);
1030 IPersistStreamVtbl DirectMusicStyle8_PersistStream_Vtbl = {
1031 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1032 IDirectMusicStyle8Impl_IPersistStream_QueryInterface,
1033 IDirectMusicStyle8Impl_IPersistStream_AddRef,
1034 IDirectMusicStyle8Impl_IPersistStream_Release,
1035 IDirectMusicStyle8Impl_IPersistStream_GetClassID,
1036 IDirectMusicStyle8Impl_IPersistStream_IsDirty,
1037 IDirectMusicStyle8Impl_IPersistStream_Load,
1038 IDirectMusicStyle8Impl_IPersistStream_Save,
1039 IDirectMusicStyle8Impl_IPersistStream_GetSizeMax
1042 /* for ClassFactory */
1043 HRESULT WINAPI DMUSIC_CreateDirectMusicStyleImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
1044 IDirectMusicStyle8Impl* obj;
1046 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicStyle8Impl));
1048 *ppobj = (LPVOID) NULL;
1049 return E_OUTOFMEMORY;
1051 obj->UnknownVtbl = &DirectMusicStyle8_Unknown_Vtbl;
1052 obj->StyleVtbl = &DirectMusicStyle8_Style_Vtbl;
1053 obj->ObjectVtbl = &DirectMusicStyle8_Object_Vtbl;
1054 obj->PersistStreamVtbl = &DirectMusicStyle8_PersistStream_Vtbl;
1055 obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
1056 DM_STRUCT_INIT(obj->pDesc);
1057 obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
1058 memcpy (&obj->pDesc->guidClass, &CLSID_DirectMusicStyle, sizeof (CLSID));
1059 obj->ref = 0; /* will be inited by QueryInterface */
1060 list_init (&obj->Bands);
1061 list_init (&obj->Motifs);
1063 return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);