1 /* IDirectMusicContainerImpl
3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "dmloader_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmloader
);
23 WINE_DECLARE_DEBUG_CHANNEL(dmfile
);
24 WINE_DECLARE_DEBUG_CHANNEL(dmdump
);
26 #define DMUS_MAX_CATEGORY_SIZE DMUS_MAX_CATEGORY*sizeof(WCHAR)
27 #define DMUS_MAX_NAME_SIZE DMUS_MAX_NAME*sizeof(WCHAR)
28 #define DMUS_MAX_FILENAME_SIZE DMUS_MAX_FILENAME*sizeof(WCHAR)
30 static ULONG WINAPI
IDirectMusicContainerImpl_IDirectMusicContainer_AddRef (LPDIRECTMUSICCONTAINER iface
);
31 static ULONG WINAPI
IDirectMusicContainerImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface
);
32 static ULONG WINAPI
IDirectMusicContainerImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface
);
34 /*****************************************************************************
35 * IDirectMusicContainerImpl implementation
37 /* IUnknown/IDirectMusicContainer part: */
39 static HRESULT
DMUSIC_DestroyDirectMusicContainerImpl (LPDIRECTMUSICCONTAINER iface
) {
40 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ContainerVtbl
, iface
);
41 LPDIRECTMUSICLOADER pLoader
;
42 LPDIRECTMUSICGETLOADER pGetLoader
;
44 LPWINE_CONTAINER_ENTRY pContainedObject
;
46 /* get loader (from stream we loaded from) */
47 TRACE(": getting loader\n");
48 IStream_QueryInterface (This
->pStream
, &IID_IDirectMusicGetLoader
, (LPVOID
*)&pGetLoader
);
49 IDirectMusicGetLoader_GetLoader (pGetLoader
, &pLoader
);
50 IDirectMusicGetLoader_Release (pGetLoader
);
52 /* release objects from loader's cache (if appropriate) */
53 TRACE(": releasing objects from loader's cache\n");
54 LIST_FOR_EACH (pEntry
, This
->pContainedObjects
) {
55 pContainedObject
= LIST_ENTRY (pEntry
, WINE_CONTAINER_ENTRY
, entry
);
56 /* my tests indicate that container releases objects *only*
57 if they were loaded at its load-time (makes sense, it doesn't
58 have pointers to objects otherwise); BTW: native container seems
59 to ignore the flags (I won't) */
60 if (pContainedObject
->pObject
&& !(pContainedObject
->dwFlags
& DMUS_CONTAINED_OBJF_KEEP
)) {
61 /* flags say it shouldn't be kept in loader's cache */
62 IDirectMusicLoader_ReleaseObject (pLoader
, pContainedObject
->pObject
);
65 IDirectMusicLoader_Release (pLoader
);
67 /* release stream we loaded from */
68 IStream_Release (This
->pStream
);
70 /* FIXME: release allocated entries */
72 /* decrease number of instances */
73 InterlockedDecrement (&dwDirectMusicContainer
);
78 static HRESULT WINAPI
IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface (LPDIRECTMUSICCONTAINER iface
, REFIID riid
, LPVOID
*ppobj
) {
79 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ContainerVtbl
, iface
);
81 TRACE("(%p, %s, %p)\n", This
, debugstr_dmguid(riid
), ppobj
);
82 if (IsEqualIID (riid
, &IID_IUnknown
) ||
83 IsEqualIID (riid
, &IID_IDirectMusicContainer
)) {
84 *ppobj
= &This
->ContainerVtbl
;
85 IDirectMusicContainerImpl_IDirectMusicContainer_AddRef ((LPDIRECTMUSICCONTAINER
)&This
->ContainerVtbl
);
87 } else if (IsEqualIID (riid
, &IID_IDirectMusicObject
)) {
88 *ppobj
= &This
->ObjectVtbl
;
89 IDirectMusicContainerImpl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT
)&This
->ObjectVtbl
);
91 } else if (IsEqualIID (riid
, &IID_IPersistStream
)) {
92 *ppobj
= &This
->PersistStreamVtbl
;
93 IDirectMusicContainerImpl_IPersistStream_AddRef ((LPPERSISTSTREAM
)&This
->PersistStreamVtbl
);
97 WARN(": not found\n");
101 static ULONG WINAPI
IDirectMusicContainerImpl_IDirectMusicContainer_AddRef (LPDIRECTMUSICCONTAINER iface
) {
102 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ContainerVtbl
, iface
);
103 TRACE("(%p): AddRef from %d\n", This
, This
->dwRef
);
104 return InterlockedIncrement (&This
->dwRef
);
107 static ULONG WINAPI
IDirectMusicContainerImpl_IDirectMusicContainer_Release (LPDIRECTMUSICCONTAINER iface
) {
108 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ContainerVtbl
, iface
);
110 DWORD dwRef
= InterlockedDecrement (&This
->dwRef
);
111 TRACE("(%p): ReleaseRef to %d\n", This
, dwRef
);
113 DMUSIC_DestroyDirectMusicContainerImpl (iface
);
114 HeapFree(GetProcessHeap(), 0, This
);
120 static HRESULT WINAPI
IDirectMusicContainerImpl_IDirectMusicContainer_EnumObject (LPDIRECTMUSICCONTAINER iface
, REFGUID rguidClass
, DWORD dwIndex
, LPDMUS_OBJECTDESC pDesc
, WCHAR
* pwszAlias
) {
121 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ContainerVtbl
, iface
);
123 LPWINE_CONTAINER_ENTRY pContainedObject
;
126 TRACE("(%p, %s, %d, %p, %p)\n", This
, debugstr_dmguid(rguidClass
), dwIndex
, pDesc
, pwszAlias
);
130 if (pDesc
->dwSize
!= sizeof(DMUS_OBJECTDESC
)) {
131 ERR(": invalid pDesc->dwSize %d\n", pDesc
->dwSize
);
135 DM_STRUCT_INIT(pDesc
);
137 LIST_FOR_EACH (pEntry
, This
->pContainedObjects
) {
138 pContainedObject
= LIST_ENTRY (pEntry
, WINE_CONTAINER_ENTRY
, entry
);
140 if (IsEqualGUID (rguidClass
, &GUID_DirectMusicAllTypes
) || IsEqualGUID (rguidClass
, &pContainedObject
->Desc
.guidClass
)) {
141 if (dwCount
== dwIndex
) {
142 HRESULT result
= S_OK
;
144 lstrcpynW (pwszAlias
, pContainedObject
->wszAlias
, DMUS_MAX_FILENAME
);
145 if (strlenW (pContainedObject
->wszAlias
) > DMUS_MAX_FILENAME
)
146 result
= DMUS_S_STRING_TRUNCATED
;
149 *pDesc
= pContainedObject
->Desc
;
156 TRACE(": not found\n");
160 static const IDirectMusicContainerVtbl DirectMusicContainer_Container_Vtbl
= {
161 IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface
,
162 IDirectMusicContainerImpl_IDirectMusicContainer_AddRef
,
163 IDirectMusicContainerImpl_IDirectMusicContainer_Release
,
164 IDirectMusicContainerImpl_IDirectMusicContainer_EnumObject
167 /* IDirectMusicObject part: */
168 static HRESULT WINAPI
IDirectMusicContainerImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface
, REFIID riid
, LPVOID
*ppobj
) {
169 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ObjectVtbl
, iface
);
170 return IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface ((LPDIRECTMUSICCONTAINER
)&This
->ContainerVtbl
, riid
, ppobj
);
173 static ULONG WINAPI
IDirectMusicContainerImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface
) {
174 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ObjectVtbl
, iface
);
175 return IDirectMusicContainerImpl_IDirectMusicContainer_AddRef ((LPDIRECTMUSICCONTAINER
)&This
->ContainerVtbl
);
178 static ULONG WINAPI
IDirectMusicContainerImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface
) {
179 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ObjectVtbl
, iface
);
180 return IDirectMusicContainerImpl_IDirectMusicContainer_Release ((LPDIRECTMUSICCONTAINER
)&This
->ContainerVtbl
);
183 static HRESULT WINAPI
IDirectMusicContainerImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface
, LPDMUS_OBJECTDESC pDesc
) {
184 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ObjectVtbl
, iface
);
185 TRACE("(%p, %p):\n", This
, pDesc
);
187 /* check if we can write to whole pDesc */
188 if (IsBadReadPtr (pDesc
, sizeof(DWORD
))) {
189 ERR(": pDesc->dwSize bad read pointer\n");
192 if (pDesc
->dwSize
!= sizeof(DMUS_OBJECTDESC
)) {
193 ERR(": invalid pDesc->dwSize\n");
196 if (IsBadWritePtr (pDesc
, sizeof(DMUS_OBJECTDESC
))) {
197 ERR(": pDesc bad write pointer\n");
201 DM_STRUCT_INIT(pDesc
);
207 static HRESULT WINAPI
IDirectMusicContainerImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface
, LPDMUS_OBJECTDESC pDesc
) {
208 DWORD dwNewFlags
= 0;
209 DWORD dwFlagDifference
;
210 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ObjectVtbl
, iface
);
211 TRACE("(%p, %p):\n", This
, pDesc
);
213 /* check if we can read whole pDesc */
214 if (IsBadReadPtr (pDesc
, sizeof(DWORD
))) {
215 ERR(": pDesc->dwSize bad read pointer\n");
218 if (pDesc
->dwSize
!= sizeof(DMUS_OBJECTDESC
)) {
219 ERR(": invalid pDesc->dwSize\n");
222 if (IsBadReadPtr (pDesc
, sizeof(DMUS_OBJECTDESC
))) {
223 ERR(": pDesc bad read pointer\n");
227 if (pDesc
->dwValidData
& DMUS_OBJ_OBJECT
) {
228 This
->Desc
.guidObject
= pDesc
->guidObject
;
229 dwNewFlags
|= DMUS_OBJ_OBJECT
;
231 if (pDesc
->dwValidData
& DMUS_OBJ_NAME
) {
232 lstrcpynW (This
->Desc
.wszName
, pDesc
->wszName
, DMUS_MAX_NAME
);
233 dwNewFlags
|= DMUS_OBJ_NAME
;
235 if (pDesc
->dwValidData
& DMUS_OBJ_CATEGORY
) {
236 lstrcpynW (This
->Desc
.wszCategory
, pDesc
->wszCategory
, DMUS_MAX_CATEGORY
);
237 dwNewFlags
|= DMUS_OBJ_CATEGORY
;
239 if (pDesc
->dwValidData
& (DMUS_OBJ_FILENAME
| DMUS_OBJ_FULLPATH
)) {
240 lstrcpynW (This
->Desc
.wszFileName
, pDesc
->wszFileName
, DMUS_MAX_FILENAME
);
241 dwNewFlags
|= (pDesc
->dwValidData
& (DMUS_OBJ_FILENAME
| DMUS_OBJ_FULLPATH
));
243 if (pDesc
->dwValidData
& DMUS_OBJ_VERSION
) {
244 This
->Desc
.vVersion
.dwVersionLS
= pDesc
->vVersion
.dwVersionLS
;
245 This
->Desc
.vVersion
.dwVersionMS
= pDesc
->vVersion
.dwVersionMS
;
246 dwNewFlags
|= DMUS_OBJ_VERSION
;
248 if (pDesc
->dwValidData
& DMUS_OBJ_DATE
) {
249 This
->Desc
.ftDate
.dwHighDateTime
= pDesc
->ftDate
.dwHighDateTime
;
250 This
->Desc
.ftDate
.dwLowDateTime
= pDesc
->ftDate
.dwLowDateTime
;
251 dwNewFlags
|= DMUS_OBJ_DATE
;
254 This
->Desc
.dwValidData
|= dwNewFlags
;
256 dwFlagDifference
= pDesc
->dwValidData
- dwNewFlags
;
257 if (dwFlagDifference
) {
258 pDesc
->dwValidData
&= ~dwFlagDifference
; /* and with bitwise complement */
263 static HRESULT WINAPI
IDirectMusicContainerImpl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface
, LPSTREAM pStream
, LPDMUS_OBJECTDESC pDesc
) {
264 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ObjectVtbl
, iface
);
266 DWORD StreamSize
, StreamCount
, ListSize
[1], ListCount
[1];
267 LARGE_INTEGER liMove
; /* used when skipping chunks */
269 TRACE("(%p, %p, %p)\n", This
, pStream
, pDesc
);
271 /* check whether arguments are OK */
272 if (IsBadReadPtr (pStream
, sizeof(LPVOID
))) {
273 ERR(": pStream bad read pointer\n");
276 /* check whether pDesc is OK */
277 if (IsBadReadPtr (pDesc
, sizeof(DWORD
))) {
278 ERR(": pDesc->dwSize bad read pointer\n");
281 if (pDesc
->dwSize
!= sizeof(DMUS_OBJECTDESC
)) {
282 ERR(": invalid pDesc->dwSize\n");
285 if (IsBadWritePtr (pDesc
, sizeof(DMUS_OBJECTDESC
))) {
286 ERR(": pDesc bad write pointer\n");
290 DM_STRUCT_INIT(pDesc
);
293 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
294 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
295 switch (Chunk
.fccID
) {
297 IStream_Read (pStream
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
298 TRACE_(dmfile
)(": RIFF chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
299 StreamSize
= Chunk
.dwSize
- sizeof(FOURCC
);
301 if (Chunk
.fccID
== DMUS_FOURCC_CONTAINER_FORM
) {
302 TRACE_(dmfile
)(": container form\n");
304 pDesc
->dwValidData
|= DMUS_OBJ_CLASS
;
305 pDesc
->guidClass
= CLSID_DirectMusicContainer
;
307 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
308 StreamCount
+= sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
309 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
310 switch (Chunk
.fccID
) {
311 case DMUS_FOURCC_GUID_CHUNK
: {
312 TRACE_(dmfile
)(": GUID chunk\n");
313 pDesc
->dwValidData
|= DMUS_OBJ_OBJECT
;
314 IStream_Read (pStream
, &pDesc
->guidObject
, Chunk
.dwSize
, NULL
);
315 TRACE_(dmdump
)(": GUID: %s\n", debugstr_guid(&pDesc
->guidObject
));
318 case DMUS_FOURCC_VERSION_CHUNK
: {
319 TRACE_(dmfile
)(": version chunk\n");
320 pDesc
->dwValidData
|= DMUS_OBJ_VERSION
;
321 IStream_Read (pStream
, &pDesc
->vVersion
, Chunk
.dwSize
, NULL
);
322 TRACE_(dmdump
)(": version: %s\n", debugstr_dmversion(&pDesc
->vVersion
));
325 case DMUS_FOURCC_DATE_CHUNK
: {
326 TRACE_(dmfile
)(": date chunk\n");
327 IStream_Read (pStream
, &pDesc
->ftDate
, Chunk
.dwSize
, NULL
);
328 pDesc
->dwValidData
|= DMUS_OBJ_DATE
;
329 TRACE_(dmdump
)(": date: %s\n", debugstr_filetime(&pDesc
->ftDate
));
332 case DMUS_FOURCC_CATEGORY_CHUNK
: {
333 TRACE_(dmfile
)(": category chunk\n");
334 /* if it happens that string is too long,
335 read what we can and skip the rest*/
336 if (Chunk
.dwSize
> DMUS_MAX_CATEGORY_SIZE
) {
337 IStream_Read (pStream
, pDesc
->wszCategory
, DMUS_MAX_CATEGORY_SIZE
, NULL
);
338 liMove
.QuadPart
= Chunk
.dwSize
- DMUS_MAX_CATEGORY_SIZE
;
339 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
341 IStream_Read (pStream
, pDesc
->wszCategory
, Chunk
.dwSize
, NULL
);
343 pDesc
->dwValidData
|= DMUS_OBJ_CATEGORY
;
344 TRACE_(dmdump
)(": category: %s\n", debugstr_w(pDesc
->wszCategory
));
348 IStream_Read (pStream
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
349 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
350 ListSize
[0] = Chunk
.dwSize
- sizeof(FOURCC
);
352 switch (Chunk
.fccID
) {
353 /* evil M$ UNFO list, which can (!?) contain INFO elements */
354 case DMUS_FOURCC_UNFO_LIST
: {
355 TRACE_(dmfile
)(": UNFO list\n");
357 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
358 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
359 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
360 switch (Chunk
.fccID
) {
361 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
362 (though strings seem to be valid unicode) */
363 case mmioFOURCC('I','N','A','M'):
364 case DMUS_FOURCC_UNAM_CHUNK
: {
365 TRACE_(dmfile
)(": name chunk\n");
366 /* if it happens that string is too long,
367 read what we can and skip the rest*/
368 if (Chunk
.dwSize
> DMUS_MAX_NAME_SIZE
) {
369 IStream_Read (pStream
, pDesc
->wszName
, DMUS_MAX_NAME_SIZE
, NULL
);
370 liMove
.QuadPart
= Chunk
.dwSize
- DMUS_MAX_NAME_SIZE
;
371 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
373 IStream_Read (pStream
, pDesc
->wszName
, Chunk
.dwSize
, NULL
);
375 pDesc
->dwValidData
|= DMUS_OBJ_NAME
;
376 TRACE_(dmdump
)(": name: %s\n", debugstr_w(pDesc
->wszName
));
380 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
381 liMove
.QuadPart
= Chunk
.dwSize
;
382 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
386 TRACE_(dmfile
)(": ListCount[0] = 0x%08X < ListSize[0] = 0x%08X\n", ListCount
[0], ListSize
[0]);
387 } while (ListCount
[0] < ListSize
[0]);
391 TRACE_(dmfile
)(": unknown (skipping)\n");
392 liMove
.QuadPart
= Chunk
.dwSize
- sizeof(FOURCC
);
393 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
400 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
401 liMove
.QuadPart
= Chunk
.dwSize
;
402 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
406 TRACE_(dmfile
)(": StreamCount[0] = 0x%08X < StreamSize[0] = 0x%08X\n", StreamCount
, StreamSize
);
407 } while (StreamCount
< StreamSize
);
409 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
410 liMove
.QuadPart
= StreamSize
;
411 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
415 TRACE_(dmfile
)(": reading finished\n");
419 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
420 liMove
.QuadPart
= Chunk
.dwSize
;
421 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
422 return DMUS_E_INVALIDFILE
;
426 TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC(pDesc
));
430 static const IDirectMusicObjectVtbl DirectMusicContainer_Object_Vtbl
= {
431 IDirectMusicContainerImpl_IDirectMusicObject_QueryInterface
,
432 IDirectMusicContainerImpl_IDirectMusicObject_AddRef
,
433 IDirectMusicContainerImpl_IDirectMusicObject_Release
,
434 IDirectMusicContainerImpl_IDirectMusicObject_GetDescriptor
,
435 IDirectMusicContainerImpl_IDirectMusicObject_SetDescriptor
,
436 IDirectMusicContainerImpl_IDirectMusicObject_ParseDescriptor
439 /* IPersistStream part: */
440 static HRESULT WINAPI
IDirectMusicContainerImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface
, REFIID riid
, LPVOID
*ppobj
) {
441 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, PersistStreamVtbl
, iface
);
442 return IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface ((LPDIRECTMUSICCONTAINER
)&This
->ContainerVtbl
, riid
, ppobj
);
445 static ULONG WINAPI
IDirectMusicContainerImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface
) {
446 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, PersistStreamVtbl
, iface
);
447 return IDirectMusicContainerImpl_IDirectMusicContainer_AddRef ((LPDIRECTMUSICCONTAINER
)&This
->ContainerVtbl
);
450 static ULONG WINAPI
IDirectMusicContainerImpl_IPersistStream_Release (LPPERSISTSTREAM iface
) {
451 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, PersistStreamVtbl
, iface
);
452 return IDirectMusicContainerImpl_IDirectMusicContainer_Release ((LPDIRECTMUSICCONTAINER
)&This
->ContainerVtbl
);
455 static HRESULT WINAPI
IDirectMusicContainerImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface
, CLSID
* pClassID
) {
456 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, PersistStreamVtbl
, iface
);
458 TRACE("(%p, %p)\n", This
, pClassID
);
459 if (IsBadWritePtr (pClassID
, sizeof(CLSID
))) {
460 ERR(": pClassID bad write pointer\n");
464 *pClassID
= CLSID_DirectMusicContainer
;
468 static HRESULT WINAPI
IDirectMusicContainerImpl_IPersistStream_IsDirty (LPPERSISTSTREAM iface
) {
469 /* FIXME: is implemented (somehow) */
473 static HRESULT WINAPI
IDirectMusicContainerImpl_IPersistStream_Load (LPPERSISTSTREAM iface
, IStream
* pStm
) {
474 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, PersistStreamVtbl
, iface
);
476 DWORD StreamSize
, StreamCount
, ListSize
[3], ListCount
[3];
477 LARGE_INTEGER liMove
; /* used when skipping chunks */
478 ULARGE_INTEGER uliPos
; /* needed when dealing with RIFF chunks */
479 LPDIRECTMUSICGETLOADER pGetLoader
;
480 LPDIRECTMUSICLOADER pLoader
;
481 HRESULT result
= S_OK
;
483 TRACE("(%p, %p):\n", This
, pStm
);
485 /* check whether pStm is valid read pointer */
486 if (IsBadReadPtr (pStm
, sizeof(LPVOID
))) {
487 ERR(": pStm bad read pointer\n");
490 /* if stream is already set, this means the container is already loaded */
492 TRACE(": stream is already set, which means container is already loaded\n");
493 return DMUS_E_ALREADY_LOADED
;
496 /* get loader since it will be needed later */
497 if (FAILED(IStream_QueryInterface (pStm
, &IID_IDirectMusicGetLoader
, (LPVOID
*)&pGetLoader
))) {
498 ERR(": stream not supported\n");
499 return DMUS_E_UNSUPPORTED_STREAM
;
501 IDirectMusicGetLoader_GetLoader (pGetLoader
, &pLoader
);
502 IDirectMusicGetLoader_Release (pGetLoader
);
504 This
->pStream
= pStm
;
505 IStream_AddRef (pStm
); /* add count for later references */
507 /* start with load */
508 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
509 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
510 switch (Chunk
.fccID
) {
512 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
513 TRACE_(dmfile
)(": RIFF chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
514 StreamSize
= Chunk
.dwSize
- sizeof(FOURCC
);
516 switch (Chunk
.fccID
) {
517 case DMUS_FOURCC_CONTAINER_FORM
: {
518 TRACE_(dmfile
)(": container form\n");
519 This
->Desc
.guidClass
= CLSID_DirectMusicContainer
;
520 This
->Desc
.dwValidData
|= DMUS_OBJ_CLASS
;
522 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
523 StreamCount
+= sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
524 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
525 switch (Chunk
.fccID
) {
526 case DMUS_FOURCC_CONTAINER_CHUNK
: {
527 TRACE_(dmfile
)(": container header chunk\n");
528 IStream_Read (pStm
, &This
->Header
, Chunk
.dwSize
, NULL
);
529 TRACE_(dmdump
)(": container header chunk:\n%s\n", debugstr_DMUS_IO_CONTAINER_HEADER(&This
->Header
));
532 case DMUS_FOURCC_GUID_CHUNK
: {
533 TRACE_(dmfile
)(": GUID chunk\n");
534 IStream_Read (pStm
, &This
->Desc
.guidObject
, Chunk
.dwSize
, NULL
);
535 This
->Desc
.dwValidData
|= DMUS_OBJ_OBJECT
;
536 TRACE_(dmdump
)(": GUID: %s\n", debugstr_guid(&This
->Desc
.guidObject
));
539 case DMUS_FOURCC_VERSION_CHUNK
: {
540 TRACE_(dmfile
)(": version chunk\n");
541 IStream_Read (pStm
, &This
->Desc
.vVersion
, Chunk
.dwSize
, NULL
);
542 This
->Desc
.dwValidData
|= DMUS_OBJ_VERSION
;
543 TRACE_(dmdump
)(": version: %s\n", debugstr_dmversion(&This
->Desc
.vVersion
));
546 case DMUS_FOURCC_DATE_CHUNK
: {
547 TRACE_(dmfile
)(": date chunk\n");
548 IStream_Read (pStm
, &This
->Desc
.ftDate
, Chunk
.dwSize
, NULL
);
549 This
->Desc
.dwValidData
|= DMUS_OBJ_DATE
;
550 TRACE_(dmdump
)(": date: %s\n", debugstr_filetime(&This
->Desc
.ftDate
));
553 case DMUS_FOURCC_CATEGORY_CHUNK
: {
554 TRACE_(dmfile
)(": category chunk\n");
555 /* if it happens that string is too long,
556 read what we can and skip the rest*/
557 if (Chunk
.dwSize
> DMUS_MAX_CATEGORY_SIZE
) {
558 IStream_Read (pStm
, This
->Desc
.wszCategory
, DMUS_MAX_CATEGORY_SIZE
, NULL
);
559 liMove
.QuadPart
= Chunk
.dwSize
- DMUS_MAX_CATEGORY_SIZE
;
560 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
562 IStream_Read (pStm
, This
->Desc
.wszCategory
, Chunk
.dwSize
, NULL
);
564 This
->Desc
.dwValidData
|= DMUS_OBJ_CATEGORY
;
565 TRACE_(dmdump
)(": category: %s\n", debugstr_w(This
->Desc
.wszCategory
));
569 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
570 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
571 ListSize
[0] = Chunk
.dwSize
- sizeof(FOURCC
);
573 switch (Chunk
.fccID
) {
574 case DMUS_FOURCC_UNFO_LIST
: {
575 TRACE_(dmfile
)(": UNFO list\n");
577 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
578 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
579 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
580 switch (Chunk
.fccID
) {
581 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
582 (though strings seem to be valid unicode) */
583 case mmioFOURCC('I','N','A','M'):
584 case DMUS_FOURCC_UNAM_CHUNK
: {
585 TRACE_(dmfile
)(": name chunk\n");
586 /* if it happens that string is too long,
587 read what we can and skip the rest*/
588 if (Chunk
.dwSize
> DMUS_MAX_NAME_SIZE
) {
589 IStream_Read (pStm
, This
->Desc
.wszName
, DMUS_MAX_NAME_SIZE
, NULL
);
590 liMove
.QuadPart
= Chunk
.dwSize
- DMUS_MAX_NAME_SIZE
;
591 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
593 IStream_Read (pStm
, This
->Desc
.wszName
, Chunk
.dwSize
, NULL
);
595 This
->Desc
.dwValidData
|= DMUS_OBJ_NAME
;
596 TRACE_(dmdump
)(": name: %s\n", debugstr_w(This
->Desc
.wszName
));
600 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
601 liMove
.QuadPart
= Chunk
.dwSize
;
602 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
606 TRACE_(dmfile
)(": ListCount[0] = 0x%08X < ListSize[0] = 0x%08X\n", ListCount
[0], ListSize
[0]);
607 } while (ListCount
[0] < ListSize
[0]);
610 case DMUS_FOURCC_CONTAINED_OBJECTS_LIST
: {
611 TRACE_(dmfile
)(": contained objects list\n");
613 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
614 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
615 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
616 switch (Chunk
.fccID
) {
618 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
619 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
620 ListSize
[1] = Chunk
.dwSize
- sizeof(FOURCC
);
622 switch (Chunk
.fccID
) {
623 case DMUS_FOURCC_CONTAINED_OBJECT_LIST
: {
624 LPWINE_CONTAINER_ENTRY pNewEntry
;
625 TRACE_(dmfile
)(": contained object list\n");
626 pNewEntry
= HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
, sizeof(WINE_CONTAINER_ENTRY
));
627 DM_STRUCT_INIT(&pNewEntry
->Desc
);
629 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
630 ListCount
[1] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
631 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
632 switch (Chunk
.fccID
) {
633 case DMUS_FOURCC_CONTAINED_ALIAS_CHUNK
: {
634 TRACE_(dmfile
)(": alias chunk\n");
635 pNewEntry
->wszAlias
= HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
, Chunk
.dwSize
);
636 IStream_Read (pStm
, pNewEntry
->wszAlias
, Chunk
.dwSize
, NULL
);
637 TRACE_(dmdump
)(": alias: %s\n", debugstr_w(pNewEntry
->wszAlias
));
640 case DMUS_FOURCC_CONTAINED_OBJECT_CHUNK
: {
641 DMUS_IO_CONTAINED_OBJECT_HEADER tmpObjectHeader
;
642 TRACE_(dmfile
)(": contained object header chunk\n");
643 IStream_Read (pStm
, &tmpObjectHeader
, Chunk
.dwSize
, NULL
);
644 TRACE_(dmdump
)(": contained object header:\n%s\n", debugstr_DMUS_IO_CONTAINED_OBJECT_HEADER(&tmpObjectHeader
));
646 pNewEntry
->Desc
.dwValidData
|= DMUS_OBJ_CLASS
;
647 pNewEntry
->Desc
.guidClass
= tmpObjectHeader
.guidClassID
;
649 pNewEntry
->dwFlags
= tmpObjectHeader
.dwFlags
;
652 /* now read data... it may be safe to read everything after object header chunk,
653 but I'm not comfortable with MSDN's "the header is *normally* followed by ..." */
655 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
656 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
657 ListSize
[2] = Chunk
.dwSize
- sizeof(FOURCC
);
659 switch (Chunk
.fccID
) {
660 case DMUS_FOURCC_REF_LIST
: {
661 TRACE_(dmfile
)(": reference list\n");
662 pNewEntry
->bIsRIFF
= 0;
664 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
665 ListCount
[2] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
666 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
667 switch (Chunk
.fccID
) {
668 case DMUS_FOURCC_REF_CHUNK
: {
669 DMUS_IO_REFERENCE tmpReferenceHeader
; /* temporary structure */
670 TRACE_(dmfile
)(": reference header chunk\n");
671 memset (&tmpReferenceHeader
, 0, sizeof(DMUS_IO_REFERENCE
));
672 IStream_Read (pStm
, &tmpReferenceHeader
, Chunk
.dwSize
, NULL
);
673 /* copy retrieved data to DMUS_OBJECTDESC */
674 if (!IsEqualCLSID (&pNewEntry
->Desc
.guidClass
, &tmpReferenceHeader
.guidClassID
)) ERR(": object header declares different CLSID than reference header?\n");
675 /* it shouldn't be necessary to copy guidClass, since it was set in contained object header already...
676 yet if they happen to be different, I'd rather stick to this one */
677 pNewEntry
->Desc
.guidClass
= tmpReferenceHeader
.guidClassID
;
678 pNewEntry
->Desc
.dwValidData
|= tmpReferenceHeader
.dwValidData
;
681 case DMUS_FOURCC_GUID_CHUNK
: {
682 TRACE_(dmfile
)(": guid chunk\n");
683 /* no need to set flags since they were copied from reference header */
684 IStream_Read (pStm
, &pNewEntry
->Desc
.guidObject
, Chunk
.dwSize
, NULL
);
687 case DMUS_FOURCC_DATE_CHUNK
: {
688 TRACE_(dmfile
)(": file date chunk\n");
689 /* no need to set flags since they were copied from reference header */
690 IStream_Read (pStm
, &pNewEntry
->Desc
.ftDate
, Chunk
.dwSize
, NULL
);
693 case DMUS_FOURCC_NAME_CHUNK
: {
694 TRACE_(dmfile
)(": name chunk\n");
695 /* no need to set flags since they were copied from reference header */
696 IStream_Read (pStm
, pNewEntry
->Desc
.wszName
, Chunk
.dwSize
, NULL
);
699 case DMUS_FOURCC_FILE_CHUNK
: {
700 TRACE_(dmfile
)(": file name chunk\n");
701 /* no need to set flags since they were copied from reference header */
702 IStream_Read (pStm
, pNewEntry
->Desc
.wszFileName
, Chunk
.dwSize
, NULL
);
705 case DMUS_FOURCC_CATEGORY_CHUNK
: {
706 TRACE_(dmfile
)(": category chunk\n");
707 /* no need to set flags since they were copied from reference header */
708 IStream_Read (pStm
, pNewEntry
->Desc
.wszCategory
, Chunk
.dwSize
, NULL
);
711 case DMUS_FOURCC_VERSION_CHUNK
: {
712 TRACE_(dmfile
)(": version chunk\n");
713 /* no need to set flags since they were copied from reference header */
714 IStream_Read (pStm
, &pNewEntry
->Desc
.vVersion
, Chunk
.dwSize
, NULL
);
718 TRACE_(dmfile
)(": unknown chunk (skipping)\n");
719 liMove
.QuadPart
= Chunk
.dwSize
;
720 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip this chunk */
724 TRACE_(dmfile
)(": ListCount[2] = 0x%08X < ListSize[2] = 0x%08X\n", ListCount
[2], ListSize
[2]);
725 } while (ListCount
[2] < ListSize
[2]);
729 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
737 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
738 TRACE_(dmfile
)(": RIFF chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
739 if (IS_VALID_DMFORM (Chunk
.fccID
)) {
740 TRACE_(dmfile
)(": valid DMUSIC form\n");
741 pNewEntry
->bIsRIFF
= 1;
742 /* we'll have to skip whole RIFF chunk after SetObject is called */
744 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, &uliPos
);
745 uliPos
.QuadPart
+= (Chunk
.dwSize
- sizeof(FOURCC
)); /* set uliPos at the end of RIFF chunk */
746 /* move at the beginning of RIFF chunk */
748 liMove
.QuadPart
-= (sizeof(FOURCC
)+sizeof(DWORD
)+sizeof(FOURCC
));
749 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
750 /* put pointer to stream in descriptor */
751 pNewEntry
->Desc
.dwValidData
|= DMUS_OBJ_STREAM
;
752 pNewEntry
->Desc
.pStream
= pStm
; /* we don't have to worry about cloning, since SetObject will perform it */
753 /* wait till we get on the end of object list */
755 TRACE_(dmfile
)(": invalid DMUSIC form (skipping)\n");
756 liMove
.QuadPart
= Chunk
.dwSize
- sizeof(FOURCC
);
757 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
758 /* FIXME: should we return E_FAIL? */
763 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
764 liMove
.QuadPart
= Chunk
.dwSize
;
765 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
769 TRACE_(dmfile
)(": ListCount[1] = 0x%08X < ListSize[1] = 0x%08X\n", ListCount
[1], ListSize
[1]);
770 } while (ListCount
[1] < ListSize
[1]);
771 /* SetObject: this will fill descriptor with additional info and add alias in loader's cache */
772 IDirectMusicLoader_SetObject (pLoader
, &pNewEntry
->Desc
);
773 /* now that SetObject collected appropriate info into descriptor we can live happily ever after;
774 or not, since we have to clean evidence of loading through stream... *sigh*
775 and we have to skip rest of the chunk, if we loaded through RIFF */
776 if (pNewEntry
->bIsRIFF
) {
777 liMove
.QuadPart
= uliPos
.QuadPart
;
778 IStream_Seek (pStm
, liMove
, STREAM_SEEK_SET
, NULL
);
779 pNewEntry
->Desc
.dwValidData
&= ~DMUS_OBJ_STREAM
; /* clear flag (and with bitwise complement) */
780 pNewEntry
->Desc
.pStream
= NULL
;
782 /* add entry to list of objects */
783 list_add_tail (This
->pContainedObjects
, &pNewEntry
->entry
);
787 TRACE_(dmfile
)(": unknown (skipping)\n");
788 liMove
.QuadPart
= Chunk
.dwSize
- sizeof(FOURCC
);
789 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
796 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
797 liMove
.QuadPart
= Chunk
.dwSize
;
798 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
802 TRACE_(dmfile
)(": ListCount[0] = 0x%08X < ListSize[0] = 0x%08X\n", ListCount
[0], ListSize
[0]);
803 } while (ListCount
[0] < ListSize
[0]);
807 TRACE_(dmfile
)(": unknown (skipping)\n");
808 liMove
.QuadPart
= Chunk
.dwSize
- sizeof(FOURCC
);
809 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
816 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
817 liMove
.QuadPart
= Chunk
.dwSize
;
818 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
822 TRACE_(dmfile
)(": StreamCount[0] = 0x%08X < StreamSize[0] = 0x%08X\n", StreamCount
, StreamSize
);
823 } while (StreamCount
< StreamSize
);
827 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
828 liMove
.QuadPart
= StreamSize
;
829 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
833 TRACE_(dmfile
)(": reading finished\n");
834 This
->Desc
.dwValidData
|= DMUS_OBJ_LOADED
;
838 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
839 liMove
.QuadPart
= Chunk
.dwSize
;
840 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
845 /* now, if DMUS_CONTAINER_NOLOADS is not set, we are supposed to load contained objects;
846 so when we call GetObject later, they'll already be in cache */
847 if (!(This
->Header
.dwFlags
& DMUS_CONTAINER_NOLOADS
)) {
849 LPWINE_CONTAINER_ENTRY pContainedObject
;
851 TRACE(": DMUS_CONTAINER_NOLOADS not set... load all objects\n");
853 LIST_FOR_EACH (pEntry
, This
->pContainedObjects
) {
854 IDirectMusicObject
* pObject
;
855 pContainedObject
= LIST_ENTRY (pEntry
, WINE_CONTAINER_ENTRY
, entry
);
856 /* get object from loader and then release it */
857 if (SUCCEEDED(IDirectMusicLoader_GetObject (pLoader
, &pContainedObject
->Desc
, &IID_IDirectMusicObject
, (LPVOID
*)&pObject
))) {
858 pContainedObject
->pObject
= pObject
; /* for final release */
859 IDirectMusicObject_Release (pObject
); /* we don't really need this one */
861 WARN(": failed to load contained object\n");
862 result
= DMUS_S_PARTIALLOAD
;
867 IDirectMusicLoader_Release (pLoader
); /* release loader */
870 /* DEBUG: dumps whole container object tree: */
871 if (TRACE_ON(dmloader
)) {
873 LPWINE_CONTAINER_ENTRY tmpEntry
;
874 struct list
*listEntry
;
876 TRACE("*** IDirectMusicContainer (%p) ***\n", This
->ContainerVtbl
);
877 TRACE(" - Objects:\n");
878 LIST_FOR_EACH (listEntry
, This
->pContainedObjects
) {
879 tmpEntry
= LIST_ENTRY( listEntry
, WINE_CONTAINER_ENTRY
, entry
);
880 TRACE(" - Object[%i]:\n", r
);
881 TRACE(" - wszAlias: %s\n", debugstr_w(tmpEntry
->wszAlias
));
882 TRACE(" - Object descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC(&tmpEntry
->Desc
));
891 static HRESULT WINAPI
IDirectMusicContainerImpl_IPersistStream_Save (LPPERSISTSTREAM iface
, IStream
* pStm
, BOOL fClearDirty
) {
892 ERR(": should not be needed\n");
896 static HRESULT WINAPI
IDirectMusicContainerImpl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface
, ULARGE_INTEGER
* pcbSize
) {
897 ERR(": should not be needed\n");
901 static const IPersistStreamVtbl DirectMusicContainer_PersistStream_Vtbl
= {
902 IDirectMusicContainerImpl_IPersistStream_QueryInterface
,
903 IDirectMusicContainerImpl_IPersistStream_AddRef
,
904 IDirectMusicContainerImpl_IPersistStream_Release
,
905 IDirectMusicContainerImpl_IPersistStream_GetClassID
,
906 IDirectMusicContainerImpl_IPersistStream_IsDirty
,
907 IDirectMusicContainerImpl_IPersistStream_Load
,
908 IDirectMusicContainerImpl_IPersistStream_Save
,
909 IDirectMusicContainerImpl_IPersistStream_GetSizeMax
912 /* for ClassFactory */
913 HRESULT WINAPI
DMUSIC_CreateDirectMusicContainerImpl (LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) {
914 IDirectMusicContainerImpl
* obj
;
916 obj
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicContainerImpl
));
919 return E_OUTOFMEMORY
;
921 obj
->ContainerVtbl
= &DirectMusicContainer_Container_Vtbl
;
922 obj
->ObjectVtbl
= &DirectMusicContainer_Object_Vtbl
;
923 obj
->PersistStreamVtbl
= &DirectMusicContainer_PersistStream_Vtbl
;
924 obj
->dwRef
= 0; /* will be inited by QueryInterface */
925 obj
->pContainedObjects
= HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
, sizeof(struct list
));
926 list_init (obj
->pContainedObjects
);
928 /* increase number of instances */
929 InterlockedIncrement (&dwDirectMusicContainer
);
931 return IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface ((LPDIRECTMUSICCONTAINER
)&obj
->ContainerVtbl
, lpcGUID
, ppobj
);