3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Library General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "dmscript_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmscript
);
23 WINE_DECLARE_DEBUG_CHANNEL(dmfile
);
25 /*****************************************************************************
26 * IDirectMusicScriptImpl implementation
28 /* IDirectMusicScriptImpl IUnknown part: */
29 HRESULT WINAPI
IDirectMusicScriptImpl_IUnknown_QueryInterface (LPUNKNOWN iface
, REFIID riid
, LPVOID
*ppobj
) {
30 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, UnknownVtbl
, iface
);
32 if (IsEqualIID (riid
, &IID_IUnknown
)) {
33 *ppobj
= (LPVOID
)&This
->UnknownVtbl
;
34 IDirectMusicScriptImpl_IUnknown_AddRef ((LPUNKNOWN
)&This
->UnknownVtbl
);
36 } else if (IsEqualIID (riid
, &IID_IDirectMusicScript
)) {
37 *ppobj
= (LPVOID
)&This
->ScriptVtbl
;
38 IDirectMusicScriptImpl_IDirectMusicScript_AddRef ((LPDIRECTMUSICSCRIPT
)&This
->ScriptVtbl
);
40 } else if (IsEqualIID (riid
, &IID_IDirectMusicObject
)) {
41 *ppobj
= (LPVOID
)&This
->ObjectVtbl
;
42 IDirectMusicScriptImpl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT
)&This
->ObjectVtbl
);
44 } else if (IsEqualIID (riid
, &IID_IPersistStream
)) {
45 *ppobj
= (LPVOID
)&This
->PersistStreamVtbl
;
46 IDirectMusicScriptImpl_IPersistStream_AddRef ((LPPERSISTSTREAM
)&This
->PersistStreamVtbl
);
50 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
54 ULONG WINAPI
IDirectMusicScriptImpl_IUnknown_AddRef (LPUNKNOWN iface
) {
55 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, UnknownVtbl
, iface
);
56 TRACE("(%p) : AddRef from %ld\n", This
, This
->ref
);
60 ULONG WINAPI
IDirectMusicScriptImpl_IUnknown_Release (LPUNKNOWN iface
) {
61 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, UnknownVtbl
, iface
);
62 ULONG ref
= --This
->ref
;
63 TRACE("(%p) : ReleaseRef to %ld\n", This
, This
->ref
);
65 HeapFree(GetProcessHeap(), 0, This
);
70 ICOM_VTABLE(IUnknown
) DirectMusicScript_Unknown_Vtbl
= {
71 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
72 IDirectMusicScriptImpl_IUnknown_QueryInterface
,
73 IDirectMusicScriptImpl_IUnknown_AddRef
,
74 IDirectMusicScriptImpl_IUnknown_Release
77 /* IDirectMusicScriptImpl IDirectMusicScript part: */
78 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicScript_QueryInterface (LPDIRECTMUSICSCRIPT iface
, REFIID riid
, LPVOID
*ppobj
) {
79 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ScriptVtbl
, iface
);
80 return IDirectMusicScriptImpl_IUnknown_QueryInterface ((LPUNKNOWN
)&This
->UnknownVtbl
, riid
, ppobj
);
83 ULONG WINAPI
IDirectMusicScriptImpl_IDirectMusicScript_AddRef (LPDIRECTMUSICSCRIPT iface
) {
84 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ScriptVtbl
, iface
);
85 return IDirectMusicScriptImpl_IUnknown_AddRef ((LPUNKNOWN
)&This
->UnknownVtbl
);
88 ULONG WINAPI
IDirectMusicScriptImpl_IDirectMusicScript_Release (LPDIRECTMUSICSCRIPT iface
) {
89 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ScriptVtbl
, iface
);
90 return IDirectMusicScriptImpl_IUnknown_Release ((LPUNKNOWN
)&This
->UnknownVtbl
);
93 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicScript_Init (LPDIRECTMUSICSCRIPT iface
, IDirectMusicPerformance
* pPerformance
, DMUS_SCRIPT_ERRORINFO
* pErrorInfo
) {
94 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ScriptVtbl
, iface
);
95 FIXME("(%p, %p, %p): stub\n", This
, pPerformance
, pErrorInfo
);
99 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicScript_CallRoutine (LPDIRECTMUSICSCRIPT iface
, WCHAR
* pwszRoutineName
, DMUS_SCRIPT_ERRORINFO
* pErrorInfo
) {
100 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ScriptVtbl
, iface
);
101 FIXME("(%p, %s, %p): stub\n", This
, debugstr_w(pwszRoutineName
), pErrorInfo
);
105 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicScript_SetVariableVariant (LPDIRECTMUSICSCRIPT iface
, WCHAR
* pwszVariableName
, VARIANT varValue
, BOOL fSetRef
, DMUS_SCRIPT_ERRORINFO
* pErrorInfo
) {
106 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ScriptVtbl
, iface
);
107 FIXME("(%p, %p, FIXME, %d, %p): stub\n", This
, pwszVariableName
,/* varValue,*/ fSetRef
, pErrorInfo
);
111 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicScript_GetVariableVariant (LPDIRECTMUSICSCRIPT iface
, WCHAR
* pwszVariableName
, VARIANT
* pvarValue
, DMUS_SCRIPT_ERRORINFO
* pErrorInfo
) {
112 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ScriptVtbl
, iface
);
113 FIXME("(%p, %p, %p, %p): stub\n", This
, pwszVariableName
, pvarValue
, pErrorInfo
);
117 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicScript_SetVariableNumber (LPDIRECTMUSICSCRIPT iface
, WCHAR
* pwszVariableName
, LONG lValue
, DMUS_SCRIPT_ERRORINFO
* pErrorInfo
) {
118 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ScriptVtbl
, iface
);
119 FIXME("(%p, %p, %li, %p): stub\n", This
, pwszVariableName
, lValue
, pErrorInfo
);
123 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicScript_GetVariableNumber (LPDIRECTMUSICSCRIPT iface
, WCHAR
* pwszVariableName
, LONG
* plValue
, DMUS_SCRIPT_ERRORINFO
* pErrorInfo
) {
124 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ScriptVtbl
, iface
);
125 FIXME("(%p, %p, %p, %p): stub\n", This
, pwszVariableName
, plValue
, pErrorInfo
);
129 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicScript_SetVariableObject (LPDIRECTMUSICSCRIPT iface
, WCHAR
* pwszVariableName
, IUnknown
* punkValue
, DMUS_SCRIPT_ERRORINFO
* pErrorInfo
) {
130 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ScriptVtbl
, iface
);
131 FIXME("(%p, %p, %p, %p): stub\n", This
, pwszVariableName
, punkValue
, pErrorInfo
);
135 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicScript_GetVariableObject (LPDIRECTMUSICSCRIPT iface
, WCHAR
* pwszVariableName
, REFIID riid
, LPVOID
* ppv
, DMUS_SCRIPT_ERRORINFO
* pErrorInfo
) {
136 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ScriptVtbl
, iface
);
137 FIXME("(%p, %p, %s, %p, %p): stub\n", This
, pwszVariableName
, debugstr_guid(riid
), ppv
, pErrorInfo
);
141 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicScript_EnumRoutine (LPDIRECTMUSICSCRIPT iface
, DWORD dwIndex
, WCHAR
* pwszName
) {
142 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ScriptVtbl
, iface
);
143 FIXME("(%p, %ld, %p): stub\n", This
, dwIndex
, pwszName
);
147 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicScript_EnumVariable (LPDIRECTMUSICSCRIPT iface
, DWORD dwIndex
, WCHAR
* pwszName
) {
148 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ScriptVtbl
, iface
);
149 FIXME("(%p, %ld, %p): stub\n", This
, dwIndex
, pwszName
);
153 ICOM_VTABLE(IDirectMusicScript
) DirectMusicScript_Script_Vtbl
= {
154 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
155 IDirectMusicScriptImpl_IDirectMusicScript_QueryInterface
,
156 IDirectMusicScriptImpl_IDirectMusicScript_AddRef
,
157 IDirectMusicScriptImpl_IDirectMusicScript_Release
,
158 IDirectMusicScriptImpl_IDirectMusicScript_Init
,
159 IDirectMusicScriptImpl_IDirectMusicScript_CallRoutine
,
160 IDirectMusicScriptImpl_IDirectMusicScript_SetVariableVariant
,
161 IDirectMusicScriptImpl_IDirectMusicScript_GetVariableVariant
,
162 IDirectMusicScriptImpl_IDirectMusicScript_SetVariableNumber
,
163 IDirectMusicScriptImpl_IDirectMusicScript_GetVariableNumber
,
164 IDirectMusicScriptImpl_IDirectMusicScript_SetVariableObject
,
165 IDirectMusicScriptImpl_IDirectMusicScript_GetVariableObject
,
166 IDirectMusicScriptImpl_IDirectMusicScript_EnumRoutine
,
167 IDirectMusicScriptImpl_IDirectMusicScript_EnumVariable
170 /* IDirectMusicScriptImpl IDirectMusicObject part: */
171 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface
, REFIID riid
, LPVOID
*ppobj
) {
172 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ObjectVtbl
, iface
);
173 return IDirectMusicScriptImpl_IUnknown_QueryInterface ((LPUNKNOWN
)&This
->UnknownVtbl
, riid
, ppobj
);
176 ULONG WINAPI
IDirectMusicScriptImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface
) {
177 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ObjectVtbl
, iface
);
178 return IDirectMusicScriptImpl_IUnknown_AddRef ((LPUNKNOWN
)&This
->UnknownVtbl
);
181 ULONG WINAPI
IDirectMusicScriptImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface
) {
182 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ObjectVtbl
, iface
);
183 return IDirectMusicScriptImpl_IUnknown_Release ((LPUNKNOWN
)&This
->UnknownVtbl
);
186 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface
, LPDMUS_OBJECTDESC pDesc
) {
187 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ObjectVtbl
, iface
);
188 TRACE("(%p, %p)\n", This
, pDesc
);
189 /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
190 memcpy (pDesc
, This
->pDesc
, This
->pDesc
->dwSize
);
194 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface
, LPDMUS_OBJECTDESC pDesc
) {
195 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ObjectVtbl
, iface
);
196 TRACE("(%p, %p): setting descriptor:\n", This
, pDesc
);
197 if (TRACE_ON(dmscript
)) {
198 DMUSIC_dump_DMUS_OBJECTDESC (pDesc
);
201 /* According to MSDN, we should copy only given values, not whole struct */
202 if (pDesc
->dwValidData
& DMUS_OBJ_OBJECT
)
203 memcpy (&This
->pDesc
->guidObject
, &pDesc
->guidObject
, sizeof (pDesc
->guidObject
));
204 if (pDesc
->dwValidData
& DMUS_OBJ_CLASS
)
205 memcpy (&This
->pDesc
->guidClass
, &pDesc
->guidClass
, sizeof (pDesc
->guidClass
));
206 if (pDesc
->dwValidData
& DMUS_OBJ_NAME
)
207 strncpyW (This
->pDesc
->wszName
, pDesc
->wszName
, DMUS_MAX_NAME
);
208 if (pDesc
->dwValidData
& DMUS_OBJ_CATEGORY
)
209 strncpyW (This
->pDesc
->wszCategory
, pDesc
->wszCategory
, DMUS_MAX_CATEGORY
);
210 if (pDesc
->dwValidData
& DMUS_OBJ_FILENAME
)
211 strncpyW (This
->pDesc
->wszFileName
, pDesc
->wszFileName
, DMUS_MAX_FILENAME
);
212 if (pDesc
->dwValidData
& DMUS_OBJ_VERSION
)
213 memcpy (&This
->pDesc
->vVersion
, &pDesc
->vVersion
, sizeof (pDesc
->vVersion
));
214 if (pDesc
->dwValidData
& DMUS_OBJ_DATE
)
215 memcpy (&This
->pDesc
->ftDate
, &pDesc
->ftDate
, sizeof (pDesc
->ftDate
));
216 if (pDesc
->dwValidData
& DMUS_OBJ_MEMORY
) {
217 memcpy (&This
->pDesc
->llMemLength
, &pDesc
->llMemLength
, sizeof (pDesc
->llMemLength
));
218 memcpy (This
->pDesc
->pbMemData
, pDesc
->pbMemData
, sizeof (pDesc
->pbMemData
));
220 if (pDesc
->dwValidData
& DMUS_OBJ_STREAM
) {
221 /* according to MSDN, we copy the stream */
222 IStream_Clone (pDesc
->pStream
, &This
->pDesc
->pStream
);
226 This
->pDesc
->dwValidData
|= pDesc
->dwValidData
;
231 HRESULT WINAPI
IDirectMusicScriptImpl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface
, LPSTREAM pStream
, LPDMUS_OBJECTDESC pDesc
) {
232 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, ObjectVtbl
, iface
);
233 DMUS_PRIVATE_CHUNK Chunk
;
234 DWORD StreamSize
, StreamCount
, ListSize
[1], ListCount
[1];
235 LARGE_INTEGER liMove
; /* used when skipping chunks */
237 TRACE("(%p, %p, %p)\n", This
, pStream
, pDesc
);
239 /* FIXME: should this be determined from stream? */
240 pDesc
->dwValidData
|= DMUS_OBJ_CLASS
;
241 memcpy (&pDesc
->guidClass
, &CLSID_DirectMusicScript
, sizeof(CLSID
));
243 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
244 TRACE_(dmfile
)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
245 switch (Chunk
.fccID
) {
247 IStream_Read (pStream
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
248 TRACE_(dmfile
)(": RIFF chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
249 StreamSize
= Chunk
.dwSize
- sizeof(FOURCC
);
251 if (Chunk
.fccID
== DMUS_FOURCC_SCRIPT_FORM
) {
252 TRACE_(dmfile
)(": script form\n");
254 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
255 StreamCount
+= sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
256 TRACE_(dmfile
)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
257 switch (Chunk
.fccID
) {
258 case DMUS_FOURCC_GUID_CHUNK
: {
259 TRACE_(dmfile
)(": GUID chunk\n");
260 pDesc
->dwValidData
|= DMUS_OBJ_OBJECT
;
261 IStream_Read (pStream
, &pDesc
->guidObject
, Chunk
.dwSize
, NULL
);
264 case DMUS_FOURCC_VERSION_CHUNK
: {
265 TRACE_(dmfile
)(": version chunk\n");
266 pDesc
->dwValidData
|= DMUS_OBJ_VERSION
;
267 IStream_Read (pStream
, &pDesc
->vVersion
, Chunk
.dwSize
, NULL
);
270 case DMUS_FOURCC_CATEGORY_CHUNK
: {
271 TRACE_(dmfile
)(": category chunk\n");
272 pDesc
->dwValidData
|= DMUS_OBJ_CATEGORY
;
273 IStream_Read (pStream
, pDesc
->wszCategory
, Chunk
.dwSize
, NULL
);
277 IStream_Read (pStream
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
278 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
279 ListSize
[0] = Chunk
.dwSize
- sizeof(FOURCC
);
281 switch (Chunk
.fccID
) {
282 /* evil M$ UNFO list, which can (!?) contain INFO elements */
283 case DMUS_FOURCC_UNFO_LIST
: {
284 TRACE_(dmfile
)(": UNFO list\n");
286 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
287 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
288 TRACE_(dmfile
)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
289 switch (Chunk
.fccID
) {
290 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
291 (though strings seem to be valid unicode) */
292 case mmioFOURCC('I','N','A','M'):
293 case DMUS_FOURCC_UNAM_CHUNK
: {
294 TRACE_(dmfile
)(": name chunk\n");
295 pDesc
->dwValidData
|= DMUS_OBJ_NAME
;
296 IStream_Read (pStream
, pDesc
->wszName
, Chunk
.dwSize
, NULL
);
299 case mmioFOURCC('I','A','R','T'):
300 case DMUS_FOURCC_UART_CHUNK
: {
301 TRACE_(dmfile
)(": artist chunk (ignored)\n");
302 liMove
.QuadPart
= Chunk
.dwSize
;
303 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
306 case mmioFOURCC('I','C','O','P'):
307 case DMUS_FOURCC_UCOP_CHUNK
: {
308 TRACE_(dmfile
)(": copyright chunk (ignored)\n");
309 liMove
.QuadPart
= Chunk
.dwSize
;
310 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
313 case mmioFOURCC('I','S','B','J'):
314 case DMUS_FOURCC_USBJ_CHUNK
: {
315 TRACE_(dmfile
)(": subject chunk (ignored)\n");
316 liMove
.QuadPart
= Chunk
.dwSize
;
317 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
320 case mmioFOURCC('I','C','M','T'):
321 case DMUS_FOURCC_UCMT_CHUNK
: {
322 TRACE_(dmfile
)(": comment chunk (ignored)\n");
323 liMove
.QuadPart
= Chunk
.dwSize
;
324 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
328 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
329 liMove
.QuadPart
= Chunk
.dwSize
;
330 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
334 TRACE_(dmfile
)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount
[0], ListSize
[0]);
335 } while (ListCount
[0] < ListSize
[0]);
339 TRACE_(dmfile
)(": unknown (skipping)\n");
340 liMove
.QuadPart
= Chunk
.dwSize
- sizeof(FOURCC
);
341 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
348 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
349 liMove
.QuadPart
= Chunk
.dwSize
;
350 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
354 TRACE_(dmfile
)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount
, StreamSize
);
355 } while (StreamCount
< StreamSize
);
358 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
359 liMove
.QuadPart
= StreamSize
;
360 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
364 TRACE_(dmfile
)(": reading finished\n");
368 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
369 liMove
.QuadPart
= Chunk
.dwSize
;
370 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
371 return DMUS_E_INVALIDFILE
;
375 TRACE(": returning descriptor:\n");
376 if (TRACE_ON(dmscript
)) {
377 DMUSIC_dump_DMUS_OBJECTDESC (pDesc
);
383 ICOM_VTABLE(IDirectMusicObject
) DirectMusicScript_Object_Vtbl
= {
384 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
385 IDirectMusicScriptImpl_IDirectMusicObject_QueryInterface
,
386 IDirectMusicScriptImpl_IDirectMusicObject_AddRef
,
387 IDirectMusicScriptImpl_IDirectMusicObject_Release
,
388 IDirectMusicScriptImpl_IDirectMusicObject_GetDescriptor
,
389 IDirectMusicScriptImpl_IDirectMusicObject_SetDescriptor
,
390 IDirectMusicScriptImpl_IDirectMusicObject_ParseDescriptor
393 /* IDirectMusicScriptImpl IPersistStream part: */
394 HRESULT WINAPI
IDirectMusicScriptImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface
, REFIID riid
, LPVOID
*ppobj
) {
395 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, PersistStreamVtbl
, iface
);
396 return IDirectMusicScriptImpl_IUnknown_QueryInterface ((LPUNKNOWN
)&This
->UnknownVtbl
, riid
, ppobj
);
399 ULONG WINAPI
IDirectMusicScriptImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface
) {
400 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, PersistStreamVtbl
, iface
);
401 return IDirectMusicScriptImpl_IUnknown_AddRef ((LPUNKNOWN
)&This
->UnknownVtbl
);
404 ULONG WINAPI
IDirectMusicScriptImpl_IPersistStream_Release (LPPERSISTSTREAM iface
) {
405 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, PersistStreamVtbl
, iface
);
406 return IDirectMusicScriptImpl_IUnknown_Release ((LPUNKNOWN
)&This
->UnknownVtbl
);
409 HRESULT WINAPI
IDirectMusicScriptImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface
, CLSID
* pClassID
) {
413 HRESULT WINAPI
IDirectMusicScriptImpl_IPersistStream_IsDirty (LPPERSISTSTREAM iface
) {
417 HRESULT WINAPI
IDirectMusicScriptImpl_IPersistStream_Load (LPPERSISTSTREAM iface
, IStream
* pStm
) {
418 ICOM_THIS_MULTI(IDirectMusicScriptImpl
, PersistStreamVtbl
, iface
);
421 DWORD chunkSize
, StreamSize
, StreamCount
, ListSize
[3], ListCount
[3];
422 LARGE_INTEGER liMove
; /* used when skipping chunks */
424 FIXME("(%p, %p): Loading not implemented yet\n", This
, pStm
);
425 IStream_Read (pStm
, &chunkID
, sizeof(FOURCC
), NULL
);
426 IStream_Read (pStm
, &chunkSize
, sizeof(DWORD
), NULL
);
427 TRACE_(dmfile
)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID
), chunkSize
);
430 IStream_Read (pStm
, &chunkID
, sizeof(FOURCC
), NULL
);
431 TRACE_(dmfile
)(": RIFF chunk of type %s", debugstr_fourcc(chunkID
));
432 StreamSize
= chunkSize
- sizeof(FOURCC
);
435 case DMUS_FOURCC_SCRIPT_FORM
: {
436 TRACE_(dmfile
)(": script form\n");
438 IStream_Read (pStm
, &chunkID
, sizeof(FOURCC
), NULL
);
439 IStream_Read (pStm
, &chunkSize
, sizeof(FOURCC
), NULL
);
440 StreamCount
+= sizeof(FOURCC
) + sizeof(DWORD
) + chunkSize
;
441 TRACE_(dmfile
)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID
), chunkSize
);
443 case DMUS_FOURCC_GUID_CHUNK
: {
444 TRACE_(dmfile
)(": GUID chunk\n");
445 This
->pDesc
->dwValidData
|= DMUS_OBJ_OBJECT
;
446 IStream_Read (pStm
, &This
->pDesc
->guidObject
, chunkSize
, NULL
);
449 case DMUS_FOURCC_VERSION_CHUNK
: {
450 TRACE_(dmfile
)(": version chunk\n");
451 This
->pDesc
->dwValidData
|= DMUS_OBJ_VERSION
;
452 IStream_Read (pStm
, &This
->pDesc
->vVersion
, chunkSize
, NULL
);
455 case DMUS_FOURCC_CATEGORY_CHUNK
: {
456 TRACE_(dmfile
)(": category chunk\n");
457 This
->pDesc
->dwValidData
|= DMUS_OBJ_CATEGORY
;
458 IStream_Read (pStm
, This
->pDesc
->wszCategory
, chunkSize
, NULL
);
462 IStream_Read (pStm
, &chunkID
, sizeof(FOURCC
), NULL
);
463 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(chunkID
));
464 ListSize
[0] = chunkSize
- sizeof(FOURCC
);
467 case DMUS_FOURCC_UNFO_LIST
: {
468 TRACE_(dmfile
)(": UNFO list\n");
470 IStream_Read (pStm
, &chunkID
, sizeof(FOURCC
), NULL
);
471 IStream_Read (pStm
, &chunkSize
, sizeof(FOURCC
), NULL
);
472 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + chunkSize
;
473 TRACE_(dmfile
)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID
), chunkSize
);
475 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
476 (though strings seem to be valid unicode) */
477 case mmioFOURCC('I','N','A','M'):
478 case DMUS_FOURCC_UNAM_CHUNK
: {
479 TRACE_(dmfile
)(": name chunk\n");
480 This
->pDesc
->dwValidData
|= DMUS_OBJ_NAME
;
481 IStream_Read (pStm
, This
->pDesc
->wszName
, chunkSize
, NULL
);
484 case mmioFOURCC('I','A','R','T'):
485 case DMUS_FOURCC_UART_CHUNK
: {
486 TRACE_(dmfile
)(": artist chunk (ignored)\n");
487 liMove
.QuadPart
= chunkSize
;
488 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
491 case mmioFOURCC('I','C','O','P'):
492 case DMUS_FOURCC_UCOP_CHUNK
: {
493 TRACE_(dmfile
)(": copyright chunk (ignored)\n");
494 liMove
.QuadPart
= chunkSize
;
495 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
498 case mmioFOURCC('I','S','B','J'):
499 case DMUS_FOURCC_USBJ_CHUNK
: {
500 TRACE_(dmfile
)(": subject chunk (ignored)\n");
501 liMove
.QuadPart
= chunkSize
;
502 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
505 case mmioFOURCC('I','C','M','T'):
506 case DMUS_FOURCC_UCMT_CHUNK
: {
507 TRACE_(dmfile
)(": comment chunk (ignored)\n");
508 liMove
.QuadPart
= chunkSize
;
509 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
513 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
514 liMove
.QuadPart
= chunkSize
;
515 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
519 TRACE_(dmfile
)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount
[0], ListSize
[0]);
520 } while (ListCount
[0] < ListSize
[0]);
524 TRACE_(dmfile
)(": unknown (skipping)\n");
525 liMove
.QuadPart
= chunkSize
- sizeof(FOURCC
);
526 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
533 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
534 liMove
.QuadPart
= chunkSize
;
535 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
539 TRACE_(dmfile
)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount
, StreamSize
);
540 } while (StreamCount
< StreamSize
);
544 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
545 liMove
.QuadPart
= StreamSize
;
546 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
550 TRACE_(dmfile
)(": reading finished\n");
554 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
555 liMove
.QuadPart
= chunkSize
;
556 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
564 HRESULT WINAPI
IDirectMusicScriptImpl_IPersistStream_Save (LPPERSISTSTREAM iface
, IStream
* pStm
, BOOL fClearDirty
) {
568 HRESULT WINAPI
IDirectMusicScriptImpl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface
, ULARGE_INTEGER
* pcbSize
) {
572 ICOM_VTABLE(IPersistStream
) DirectMusicScript_PersistStream_Vtbl
= {
573 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
574 IDirectMusicScriptImpl_IPersistStream_QueryInterface
,
575 IDirectMusicScriptImpl_IPersistStream_AddRef
,
576 IDirectMusicScriptImpl_IPersistStream_Release
,
577 IDirectMusicScriptImpl_IPersistStream_GetClassID
,
578 IDirectMusicScriptImpl_IPersistStream_IsDirty
,
579 IDirectMusicScriptImpl_IPersistStream_Load
,
580 IDirectMusicScriptImpl_IPersistStream_Save
,
581 IDirectMusicScriptImpl_IPersistStream_GetSizeMax
584 /* for ClassFactory */
585 HRESULT WINAPI
DMUSIC_CreateDirectMusicScriptImpl (LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) {
586 IDirectMusicScriptImpl
* obj
;
588 obj
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicScriptImpl
));
590 *ppobj
= (LPVOID
) NULL
;
591 return E_OUTOFMEMORY
;
593 obj
->UnknownVtbl
= &DirectMusicScript_Unknown_Vtbl
;
594 obj
->ScriptVtbl
= &DirectMusicScript_Script_Vtbl
;
595 obj
->ObjectVtbl
= &DirectMusicScript_Object_Vtbl
;
596 obj
->PersistStreamVtbl
= &DirectMusicScript_PersistStream_Vtbl
;
597 obj
->pDesc
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(DMUS_OBJECTDESC
));
598 DM_STRUCT_INIT(obj
->pDesc
);
599 obj
->pDesc
->dwValidData
|= DMUS_OBJ_CLASS
;
600 memcpy (&obj
->pDesc
->guidClass
, &CLSID_DirectMusicScript
, sizeof (CLSID
));
601 obj
->ref
= 0; /* will be inited by QueryInterface */
603 return IDirectMusicScriptImpl_IUnknown_QueryInterface ((LPUNKNOWN
)&obj
->UnknownVtbl
, lpcGUID
, ppobj
);