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
;
148 *pDesc
= pContainedObject
->Desc
;
155 TRACE(": not found\n");
159 static const IDirectMusicContainerVtbl DirectMusicContainer_Container_Vtbl
= {
160 IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface
,
161 IDirectMusicContainerImpl_IDirectMusicContainer_AddRef
,
162 IDirectMusicContainerImpl_IDirectMusicContainer_Release
,
163 IDirectMusicContainerImpl_IDirectMusicContainer_EnumObject
166 /* IDirectMusicObject part: */
167 static HRESULT WINAPI
IDirectMusicContainerImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface
, REFIID riid
, LPVOID
*ppobj
) {
168 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ObjectVtbl
, iface
);
169 return IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface ((LPDIRECTMUSICCONTAINER
)&This
->ContainerVtbl
, riid
, ppobj
);
172 static ULONG WINAPI
IDirectMusicContainerImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface
) {
173 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ObjectVtbl
, iface
);
174 return IDirectMusicContainerImpl_IDirectMusicContainer_AddRef ((LPDIRECTMUSICCONTAINER
)&This
->ContainerVtbl
);
177 static ULONG WINAPI
IDirectMusicContainerImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface
) {
178 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ObjectVtbl
, iface
);
179 return IDirectMusicContainerImpl_IDirectMusicContainer_Release ((LPDIRECTMUSICCONTAINER
)&This
->ContainerVtbl
);
182 static HRESULT WINAPI
IDirectMusicContainerImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface
, LPDMUS_OBJECTDESC pDesc
) {
183 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ObjectVtbl
, iface
);
184 TRACE("(%p, %p):\n", This
, pDesc
);
186 /* check if we can write to whole pDesc */
187 if (IsBadReadPtr (pDesc
, sizeof(DWORD
))) {
188 ERR(": pDesc->dwSize bad read pointer\n");
191 if (pDesc
->dwSize
!= sizeof(DMUS_OBJECTDESC
)) {
192 ERR(": invalid pDesc->dwSize\n");
195 if (IsBadWritePtr (pDesc
, sizeof(DMUS_OBJECTDESC
))) {
196 ERR(": pDesc bad write pointer\n");
200 DM_STRUCT_INIT(pDesc
);
206 static HRESULT WINAPI
IDirectMusicContainerImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface
, LPDMUS_OBJECTDESC pDesc
) {
207 DWORD dwNewFlags
= 0;
208 DWORD dwFlagDifference
;
209 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ObjectVtbl
, iface
);
210 TRACE("(%p, %p):\n", This
, pDesc
);
212 /* check if we can read whole pDesc */
213 if (IsBadReadPtr (pDesc
, sizeof(DWORD
))) {
214 ERR(": pDesc->dwSize bad read pointer\n");
217 if (pDesc
->dwSize
!= sizeof(DMUS_OBJECTDESC
)) {
218 ERR(": invalid pDesc->dwSize\n");
221 if (IsBadReadPtr (pDesc
, sizeof(DMUS_OBJECTDESC
))) {
222 ERR(": pDesc bad read pointer\n");
226 if (pDesc
->dwValidData
& DMUS_OBJ_OBJECT
) {
227 This
->Desc
.guidObject
= pDesc
->guidObject
;
228 dwNewFlags
|= DMUS_OBJ_OBJECT
;
230 if (pDesc
->dwValidData
& DMUS_OBJ_NAME
) {
231 lstrcpynW (This
->Desc
.wszName
, pDesc
->wszName
, DMUS_MAX_NAME
);
232 dwNewFlags
|= DMUS_OBJ_NAME
;
234 if (pDesc
->dwValidData
& DMUS_OBJ_CATEGORY
) {
235 lstrcpynW (This
->Desc
.wszCategory
, pDesc
->wszCategory
, DMUS_MAX_CATEGORY
);
236 dwNewFlags
|= DMUS_OBJ_CATEGORY
;
238 if (pDesc
->dwValidData
& (DMUS_OBJ_FILENAME
| DMUS_OBJ_FULLPATH
)) {
239 lstrcpynW (This
->Desc
.wszFileName
, pDesc
->wszFileName
, DMUS_MAX_FILENAME
);
240 dwNewFlags
|= (pDesc
->dwValidData
& (DMUS_OBJ_FILENAME
| DMUS_OBJ_FULLPATH
));
242 if (pDesc
->dwValidData
& DMUS_OBJ_VERSION
) {
243 This
->Desc
.vVersion
.dwVersionLS
= pDesc
->vVersion
.dwVersionLS
;
244 This
->Desc
.vVersion
.dwVersionMS
= pDesc
->vVersion
.dwVersionMS
;
245 dwNewFlags
|= DMUS_OBJ_VERSION
;
247 if (pDesc
->dwValidData
& DMUS_OBJ_DATE
) {
248 This
->Desc
.ftDate
.dwHighDateTime
= pDesc
->ftDate
.dwHighDateTime
;
249 This
->Desc
.ftDate
.dwLowDateTime
= pDesc
->ftDate
.dwLowDateTime
;
250 dwNewFlags
|= DMUS_OBJ_DATE
;
253 This
->Desc
.dwValidData
|= dwNewFlags
;
255 dwFlagDifference
= pDesc
->dwValidData
- dwNewFlags
;
256 if (dwFlagDifference
) {
257 pDesc
->dwValidData
&= ~dwFlagDifference
; /* and with bitwise complement */
262 static HRESULT WINAPI
IDirectMusicContainerImpl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface
, LPSTREAM pStream
, LPDMUS_OBJECTDESC pDesc
) {
263 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, ObjectVtbl
, iface
);
265 DWORD StreamSize
, StreamCount
, ListSize
[1], ListCount
[1];
266 LARGE_INTEGER liMove
; /* used when skipping chunks */
268 TRACE("(%p, %p, %p)\n", This
, pStream
, pDesc
);
270 /* check whether arguments are OK */
271 if (IsBadReadPtr (pStream
, sizeof(LPVOID
))) {
272 ERR(": pStream bad read pointer\n");
275 /* check whether pDesc is OK */
276 if (IsBadReadPtr (pDesc
, sizeof(DWORD
))) {
277 ERR(": pDesc->dwSize bad read pointer\n");
280 if (pDesc
->dwSize
!= sizeof(DMUS_OBJECTDESC
)) {
281 ERR(": invalid pDesc->dwSize\n");
284 if (IsBadWritePtr (pDesc
, sizeof(DMUS_OBJECTDESC
))) {
285 ERR(": pDesc bad write pointer\n");
289 DM_STRUCT_INIT(pDesc
);
292 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
293 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
294 switch (Chunk
.fccID
) {
296 IStream_Read (pStream
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
297 TRACE_(dmfile
)(": RIFF chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
298 StreamSize
= Chunk
.dwSize
- sizeof(FOURCC
);
300 if (Chunk
.fccID
== DMUS_FOURCC_CONTAINER_FORM
) {
301 TRACE_(dmfile
)(": container form\n");
303 pDesc
->dwValidData
|= DMUS_OBJ_CLASS
;
304 pDesc
->guidClass
= CLSID_DirectMusicContainer
;
306 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
307 StreamCount
+= sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
308 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
309 switch (Chunk
.fccID
) {
310 case DMUS_FOURCC_GUID_CHUNK
: {
311 TRACE_(dmfile
)(": GUID chunk\n");
312 pDesc
->dwValidData
|= DMUS_OBJ_OBJECT
;
313 IStream_Read (pStream
, &pDesc
->guidObject
, Chunk
.dwSize
, NULL
);
314 TRACE_(dmdump
)(": GUID: %s\n", debugstr_guid(&pDesc
->guidObject
));
317 case DMUS_FOURCC_VERSION_CHUNK
: {
318 TRACE_(dmfile
)(": version chunk\n");
319 pDesc
->dwValidData
|= DMUS_OBJ_VERSION
;
320 IStream_Read (pStream
, &pDesc
->vVersion
, Chunk
.dwSize
, NULL
);
321 TRACE_(dmdump
)(": version: %s\n", debugstr_dmversion(&pDesc
->vVersion
));
324 case DMUS_FOURCC_DATE_CHUNK
: {
325 TRACE_(dmfile
)(": date chunk\n");
326 IStream_Read (pStream
, &pDesc
->ftDate
, Chunk
.dwSize
, NULL
);
327 pDesc
->dwValidData
|= DMUS_OBJ_DATE
;
328 TRACE_(dmdump
)(": date: %s\n", debugstr_filetime(&pDesc
->ftDate
));
331 case DMUS_FOURCC_CATEGORY_CHUNK
: {
332 TRACE_(dmfile
)(": category chunk\n");
333 /* if it happens that string is too long,
334 read what we can and skip the rest*/
335 if (Chunk
.dwSize
> DMUS_MAX_CATEGORY_SIZE
) {
336 IStream_Read (pStream
, pDesc
->wszCategory
, DMUS_MAX_CATEGORY_SIZE
, NULL
);
337 liMove
.QuadPart
= Chunk
.dwSize
- DMUS_MAX_CATEGORY_SIZE
;
338 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
340 IStream_Read (pStream
, pDesc
->wszCategory
, Chunk
.dwSize
, NULL
);
342 pDesc
->dwValidData
|= DMUS_OBJ_CATEGORY
;
343 TRACE_(dmdump
)(": category: %s\n", debugstr_w(pDesc
->wszCategory
));
347 IStream_Read (pStream
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
348 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
349 ListSize
[0] = Chunk
.dwSize
- sizeof(FOURCC
);
351 switch (Chunk
.fccID
) {
352 /* evil M$ UNFO list, which can (!?) contain INFO elements */
353 case DMUS_FOURCC_UNFO_LIST
: {
354 TRACE_(dmfile
)(": UNFO list\n");
356 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
357 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
358 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
359 switch (Chunk
.fccID
) {
360 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
361 (though strings seem to be valid unicode) */
362 case mmioFOURCC('I','N','A','M'):
363 case DMUS_FOURCC_UNAM_CHUNK
: {
364 TRACE_(dmfile
)(": name chunk\n");
365 /* if it happens that string is too long,
366 read what we can and skip the rest*/
367 if (Chunk
.dwSize
> DMUS_MAX_NAME_SIZE
) {
368 IStream_Read (pStream
, pDesc
->wszName
, DMUS_MAX_NAME_SIZE
, NULL
);
369 liMove
.QuadPart
= Chunk
.dwSize
- DMUS_MAX_NAME_SIZE
;
370 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
372 IStream_Read (pStream
, pDesc
->wszName
, Chunk
.dwSize
, NULL
);
374 pDesc
->dwValidData
|= DMUS_OBJ_NAME
;
375 TRACE_(dmdump
)(": name: %s\n", debugstr_w(pDesc
->wszName
));
379 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
380 liMove
.QuadPart
= Chunk
.dwSize
;
381 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
385 TRACE_(dmfile
)(": ListCount[0] = 0x%08X < ListSize[0] = 0x%08X\n", ListCount
[0], ListSize
[0]);
386 } while (ListCount
[0] < ListSize
[0]);
390 TRACE_(dmfile
)(": unknown (skipping)\n");
391 liMove
.QuadPart
= Chunk
.dwSize
- sizeof(FOURCC
);
392 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
399 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
400 liMove
.QuadPart
= Chunk
.dwSize
;
401 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
405 TRACE_(dmfile
)(": StreamCount[0] = 0x%08X < StreamSize[0] = 0x%08X\n", StreamCount
, StreamSize
);
406 } while (StreamCount
< StreamSize
);
408 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
409 liMove
.QuadPart
= StreamSize
;
410 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
414 TRACE_(dmfile
)(": reading finished\n");
418 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
419 liMove
.QuadPart
= Chunk
.dwSize
;
420 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
421 return DMUS_E_INVALIDFILE
;
425 TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC(pDesc
));
429 static const IDirectMusicObjectVtbl DirectMusicContainer_Object_Vtbl
= {
430 IDirectMusicContainerImpl_IDirectMusicObject_QueryInterface
,
431 IDirectMusicContainerImpl_IDirectMusicObject_AddRef
,
432 IDirectMusicContainerImpl_IDirectMusicObject_Release
,
433 IDirectMusicContainerImpl_IDirectMusicObject_GetDescriptor
,
434 IDirectMusicContainerImpl_IDirectMusicObject_SetDescriptor
,
435 IDirectMusicContainerImpl_IDirectMusicObject_ParseDescriptor
438 /* IPersistStream part: */
439 static HRESULT WINAPI
IDirectMusicContainerImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface
, REFIID riid
, LPVOID
*ppobj
) {
440 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, PersistStreamVtbl
, iface
);
441 return IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface ((LPDIRECTMUSICCONTAINER
)&This
->ContainerVtbl
, riid
, ppobj
);
444 static ULONG WINAPI
IDirectMusicContainerImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface
) {
445 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, PersistStreamVtbl
, iface
);
446 return IDirectMusicContainerImpl_IDirectMusicContainer_AddRef ((LPDIRECTMUSICCONTAINER
)&This
->ContainerVtbl
);
449 static ULONG WINAPI
IDirectMusicContainerImpl_IPersistStream_Release (LPPERSISTSTREAM iface
) {
450 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, PersistStreamVtbl
, iface
);
451 return IDirectMusicContainerImpl_IDirectMusicContainer_Release ((LPDIRECTMUSICCONTAINER
)&This
->ContainerVtbl
);
454 static HRESULT WINAPI
IDirectMusicContainerImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface
, CLSID
* pClassID
) {
455 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, PersistStreamVtbl
, iface
);
457 TRACE("(%p, %p)\n", This
, pClassID
);
458 if (IsBadWritePtr (pClassID
, sizeof(CLSID
))) {
459 ERR(": pClassID bad write pointer\n");
463 *pClassID
= CLSID_DirectMusicContainer
;
467 static HRESULT WINAPI
IDirectMusicContainerImpl_IPersistStream_IsDirty (LPPERSISTSTREAM iface
) {
468 /* FIXME: is implemented (somehow) */
472 static HRESULT WINAPI
IDirectMusicContainerImpl_IPersistStream_Load (LPPERSISTSTREAM iface
, IStream
* pStm
) {
473 ICOM_THIS_MULTI(IDirectMusicContainerImpl
, PersistStreamVtbl
, iface
);
475 DWORD StreamSize
, StreamCount
, ListSize
[3], ListCount
[3];
476 LARGE_INTEGER liMove
; /* used when skipping chunks */
477 ULARGE_INTEGER uliPos
; /* needed when dealing with RIFF chunks */
478 LPDIRECTMUSICGETLOADER pGetLoader
;
479 LPDIRECTMUSICLOADER pLoader
;
480 HRESULT result
= S_OK
;
482 TRACE("(%p, %p):\n", This
, pStm
);
484 /* check whether pStm is valid read pointer */
485 if (IsBadReadPtr (pStm
, sizeof(LPVOID
))) {
486 ERR(": pStm bad read pointer\n");
489 /* if stream is already set, this means the container is already loaded */
491 TRACE(": stream is already set, which means container is already loaded\n");
492 return DMUS_E_ALREADY_LOADED
;
495 /* get loader since it will be needed later */
496 if (FAILED(IStream_QueryInterface (pStm
, &IID_IDirectMusicGetLoader
, (LPVOID
*)&pGetLoader
))) {
497 ERR(": stream not supported\n");
498 return DMUS_E_UNSUPPORTED_STREAM
;
500 IDirectMusicGetLoader_GetLoader (pGetLoader
, &pLoader
);
501 IDirectMusicGetLoader_Release (pGetLoader
);
503 This
->pStream
= pStm
;
504 IStream_AddRef (pStm
); /* add count for later references */
506 /* start with load */
507 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
508 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
509 switch (Chunk
.fccID
) {
511 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
512 TRACE_(dmfile
)(": RIFF chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
513 StreamSize
= Chunk
.dwSize
- sizeof(FOURCC
);
515 switch (Chunk
.fccID
) {
516 case DMUS_FOURCC_CONTAINER_FORM
: {
517 TRACE_(dmfile
)(": container form\n");
518 This
->Desc
.guidClass
= CLSID_DirectMusicContainer
;
519 This
->Desc
.dwValidData
|= DMUS_OBJ_CLASS
;
521 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
522 StreamCount
+= sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
523 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
524 switch (Chunk
.fccID
) {
525 case DMUS_FOURCC_CONTAINER_CHUNK
: {
526 TRACE_(dmfile
)(": container header chunk\n");
527 IStream_Read (pStm
, &This
->Header
, Chunk
.dwSize
, NULL
);
528 TRACE_(dmdump
)(": container header chunk:\n%s\n", debugstr_DMUS_IO_CONTAINER_HEADER(&This
->Header
));
531 case DMUS_FOURCC_GUID_CHUNK
: {
532 TRACE_(dmfile
)(": GUID chunk\n");
533 IStream_Read (pStm
, &This
->Desc
.guidObject
, Chunk
.dwSize
, NULL
);
534 This
->Desc
.dwValidData
|= DMUS_OBJ_OBJECT
;
535 TRACE_(dmdump
)(": GUID: %s\n", debugstr_guid(&This
->Desc
.guidObject
));
538 case DMUS_FOURCC_VERSION_CHUNK
: {
539 TRACE_(dmfile
)(": version chunk\n");
540 IStream_Read (pStm
, &This
->Desc
.vVersion
, Chunk
.dwSize
, NULL
);
541 This
->Desc
.dwValidData
|= DMUS_OBJ_VERSION
;
542 TRACE_(dmdump
)(": version: %s\n", debugstr_dmversion(&This
->Desc
.vVersion
));
545 case DMUS_FOURCC_DATE_CHUNK
: {
546 TRACE_(dmfile
)(": date chunk\n");
547 IStream_Read (pStm
, &This
->Desc
.ftDate
, Chunk
.dwSize
, NULL
);
548 This
->Desc
.dwValidData
|= DMUS_OBJ_DATE
;
549 TRACE_(dmdump
)(": date: %s\n", debugstr_filetime(&This
->Desc
.ftDate
));
552 case DMUS_FOURCC_CATEGORY_CHUNK
: {
553 TRACE_(dmfile
)(": category chunk\n");
554 /* if it happens that string is too long,
555 read what we can and skip the rest*/
556 if (Chunk
.dwSize
> DMUS_MAX_CATEGORY_SIZE
) {
557 IStream_Read (pStm
, This
->Desc
.wszCategory
, DMUS_MAX_CATEGORY_SIZE
, NULL
);
558 liMove
.QuadPart
= Chunk
.dwSize
- DMUS_MAX_CATEGORY_SIZE
;
559 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
561 IStream_Read (pStm
, This
->Desc
.wszCategory
, Chunk
.dwSize
, NULL
);
563 This
->Desc
.dwValidData
|= DMUS_OBJ_CATEGORY
;
564 TRACE_(dmdump
)(": category: %s\n", debugstr_w(This
->Desc
.wszCategory
));
568 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
569 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
570 ListSize
[0] = Chunk
.dwSize
- sizeof(FOURCC
);
572 switch (Chunk
.fccID
) {
573 case DMUS_FOURCC_UNFO_LIST
: {
574 TRACE_(dmfile
)(": UNFO list\n");
576 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
577 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
578 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
579 switch (Chunk
.fccID
) {
580 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
581 (though strings seem to be valid unicode) */
582 case mmioFOURCC('I','N','A','M'):
583 case DMUS_FOURCC_UNAM_CHUNK
: {
584 TRACE_(dmfile
)(": name chunk\n");
585 /* if it happens that string is too long,
586 read what we can and skip the rest*/
587 if (Chunk
.dwSize
> DMUS_MAX_NAME_SIZE
) {
588 IStream_Read (pStm
, This
->Desc
.wszName
, DMUS_MAX_NAME_SIZE
, NULL
);
589 liMove
.QuadPart
= Chunk
.dwSize
- DMUS_MAX_NAME_SIZE
;
590 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
592 IStream_Read (pStm
, This
->Desc
.wszName
, Chunk
.dwSize
, NULL
);
594 This
->Desc
.dwValidData
|= DMUS_OBJ_NAME
;
595 TRACE_(dmdump
)(": name: %s\n", debugstr_w(This
->Desc
.wszName
));
599 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
600 liMove
.QuadPart
= Chunk
.dwSize
;
601 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
605 TRACE_(dmfile
)(": ListCount[0] = 0x%08X < ListSize[0] = 0x%08X\n", ListCount
[0], ListSize
[0]);
606 } while (ListCount
[0] < ListSize
[0]);
609 case DMUS_FOURCC_CONTAINED_OBJECTS_LIST
: {
610 TRACE_(dmfile
)(": contained objects list\n");
612 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
613 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
614 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
615 switch (Chunk
.fccID
) {
617 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
618 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
619 ListSize
[1] = Chunk
.dwSize
- sizeof(FOURCC
);
621 switch (Chunk
.fccID
) {
622 case DMUS_FOURCC_CONTAINED_OBJECT_LIST
: {
623 LPWINE_CONTAINER_ENTRY pNewEntry
;
624 TRACE_(dmfile
)(": contained object list\n");
625 pNewEntry
= HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
, sizeof(WINE_CONTAINER_ENTRY
));
626 DM_STRUCT_INIT(&pNewEntry
->Desc
);
628 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
629 ListCount
[1] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
630 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
631 switch (Chunk
.fccID
) {
632 case DMUS_FOURCC_CONTAINED_ALIAS_CHUNK
: {
633 TRACE_(dmfile
)(": alias chunk\n");
634 pNewEntry
->wszAlias
= HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
, Chunk
.dwSize
);
635 IStream_Read (pStm
, pNewEntry
->wszAlias
, Chunk
.dwSize
, NULL
);
636 TRACE_(dmdump
)(": alias: %s\n", debugstr_w(pNewEntry
->wszAlias
));
639 case DMUS_FOURCC_CONTAINED_OBJECT_CHUNK
: {
640 DMUS_IO_CONTAINED_OBJECT_HEADER tmpObjectHeader
;
641 TRACE_(dmfile
)(": contained object header chunk\n");
642 IStream_Read (pStm
, &tmpObjectHeader
, Chunk
.dwSize
, NULL
);
643 TRACE_(dmdump
)(": contained object header:\n%s\n", debugstr_DMUS_IO_CONTAINED_OBJECT_HEADER(&tmpObjectHeader
));
645 pNewEntry
->Desc
.dwValidData
|= DMUS_OBJ_CLASS
;
646 pNewEntry
->Desc
.guidClass
= tmpObjectHeader
.guidClassID
;
648 pNewEntry
->dwFlags
= tmpObjectHeader
.dwFlags
;
651 /* now read data... it may be safe to read everything after object header chunk,
652 but I'm not comfortable with MSDN's "the header is *normally* followed by ..." */
654 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
655 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
656 ListSize
[2] = Chunk
.dwSize
- sizeof(FOURCC
);
658 switch (Chunk
.fccID
) {
659 case DMUS_FOURCC_REF_LIST
: {
660 TRACE_(dmfile
)(": reference list\n");
661 pNewEntry
->bIsRIFF
= 0;
663 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
664 ListCount
[2] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
665 TRACE_(dmfile
)(": %s chunk (size = 0x%08X)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
666 switch (Chunk
.fccID
) {
667 case DMUS_FOURCC_REF_CHUNK
: {
668 DMUS_IO_REFERENCE tmpReferenceHeader
; /* temporary structure */
669 TRACE_(dmfile
)(": reference header chunk\n");
670 memset (&tmpReferenceHeader
, 0, sizeof(DMUS_IO_REFERENCE
));
671 IStream_Read (pStm
, &tmpReferenceHeader
, Chunk
.dwSize
, NULL
);
672 /* copy retrieved data to DMUS_OBJECTDESC */
673 if (!IsEqualCLSID (&pNewEntry
->Desc
.guidClass
, &tmpReferenceHeader
.guidClassID
)) ERR(": object header declares different CLSID than reference header?\n");
674 /* it shouldn't be necessary to copy guidClass, since it was set in contained object header already...
675 yet if they happen to be different, I'd rather stick to this one */
676 pNewEntry
->Desc
.guidClass
= tmpReferenceHeader
.guidClassID
;
677 pNewEntry
->Desc
.dwValidData
|= tmpReferenceHeader
.dwValidData
;
680 case DMUS_FOURCC_GUID_CHUNK
: {
681 TRACE_(dmfile
)(": guid chunk\n");
682 /* no need to set flags since they were copied from reference header */
683 IStream_Read (pStm
, &pNewEntry
->Desc
.guidObject
, Chunk
.dwSize
, NULL
);
686 case DMUS_FOURCC_DATE_CHUNK
: {
687 TRACE_(dmfile
)(": file date chunk\n");
688 /* no need to set flags since they were copied from reference header */
689 IStream_Read (pStm
, &pNewEntry
->Desc
.ftDate
, Chunk
.dwSize
, NULL
);
692 case DMUS_FOURCC_NAME_CHUNK
: {
693 TRACE_(dmfile
)(": name chunk\n");
694 /* no need to set flags since they were copied from reference header */
695 IStream_Read (pStm
, pNewEntry
->Desc
.wszName
, Chunk
.dwSize
, NULL
);
698 case DMUS_FOURCC_FILE_CHUNK
: {
699 TRACE_(dmfile
)(": file name chunk\n");
700 /* no need to set flags since they were copied from reference header */
701 IStream_Read (pStm
, pNewEntry
->Desc
.wszFileName
, Chunk
.dwSize
, NULL
);
704 case DMUS_FOURCC_CATEGORY_CHUNK
: {
705 TRACE_(dmfile
)(": category chunk\n");
706 /* no need to set flags since they were copied from reference header */
707 IStream_Read (pStm
, pNewEntry
->Desc
.wszCategory
, Chunk
.dwSize
, NULL
);
710 case DMUS_FOURCC_VERSION_CHUNK
: {
711 TRACE_(dmfile
)(": version chunk\n");
712 /* no need to set flags since they were copied from reference header */
713 IStream_Read (pStm
, &pNewEntry
->Desc
.vVersion
, Chunk
.dwSize
, NULL
);
717 TRACE_(dmfile
)(": unknown chunk (skipping)\n");
718 liMove
.QuadPart
= Chunk
.dwSize
;
719 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip this chunk */
723 TRACE_(dmfile
)(": ListCount[2] = 0x%08X < ListSize[2] = 0x%08X\n", ListCount
[2], ListSize
[2]);
724 } while (ListCount
[2] < ListSize
[2]);
728 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
736 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
737 TRACE_(dmfile
)(": RIFF chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
738 if (IS_VALID_DMFORM (Chunk
.fccID
)) {
739 TRACE_(dmfile
)(": valid DMUSIC form\n");
740 pNewEntry
->bIsRIFF
= 1;
741 /* we'll have to skip whole RIFF chunk after SetObject is called */
743 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, &uliPos
);
744 uliPos
.QuadPart
+= (Chunk
.dwSize
- sizeof(FOURCC
)); /* set uliPos at the end of RIFF chunk */
745 /* move at the beginning of RIFF chunk */
747 liMove
.QuadPart
-= (sizeof(FOURCC
)+sizeof(DWORD
)+sizeof(FOURCC
));
748 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
749 /* put pointer to stream in descriptor */
750 pNewEntry
->Desc
.dwValidData
|= DMUS_OBJ_STREAM
;
751 pNewEntry
->Desc
.pStream
= pStm
; /* we don't have to worry about cloning, since SetObject will perform it */
752 /* wait till we get on the end of object list */
754 TRACE_(dmfile
)(": invalid DMUSIC form (skipping)\n");
755 liMove
.QuadPart
= Chunk
.dwSize
- sizeof(FOURCC
);
756 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
757 /* FIXME: should we return E_FAIL? */
762 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
763 liMove
.QuadPart
= Chunk
.dwSize
;
764 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
768 TRACE_(dmfile
)(": ListCount[1] = 0x%08X < ListSize[1] = 0x%08X\n", ListCount
[1], ListSize
[1]);
769 } while (ListCount
[1] < ListSize
[1]);
770 /* SetObject: this will fill descriptor with additional info and add alias in loader's cache */
771 IDirectMusicLoader_SetObject (pLoader
, &pNewEntry
->Desc
);
772 /* now that SetObject collected appropriate info into descriptor we can live happily ever after;
773 or not, since we have to clean evidence of loading through stream... *sigh*
774 and we have to skip rest of the chunk, if we loaded through RIFF */
775 if (pNewEntry
->bIsRIFF
) {
776 liMove
.QuadPart
= uliPos
.QuadPart
;
777 IStream_Seek (pStm
, liMove
, STREAM_SEEK_SET
, NULL
);
778 pNewEntry
->Desc
.dwValidData
&= ~DMUS_OBJ_STREAM
; /* clear flag (and with bitwise complement) */
779 pNewEntry
->Desc
.pStream
= NULL
;
781 /* add entry to list of objects */
782 list_add_tail (This
->pContainedObjects
, &pNewEntry
->entry
);
786 TRACE_(dmfile
)(": unknown (skipping)\n");
787 liMove
.QuadPart
= Chunk
.dwSize
- sizeof(FOURCC
);
788 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
795 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
796 liMove
.QuadPart
= Chunk
.dwSize
;
797 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
801 TRACE_(dmfile
)(": ListCount[0] = 0x%08X < ListSize[0] = 0x%08X\n", ListCount
[0], ListSize
[0]);
802 } while (ListCount
[0] < ListSize
[0]);
806 TRACE_(dmfile
)(": unknown (skipping)\n");
807 liMove
.QuadPart
= Chunk
.dwSize
- sizeof(FOURCC
);
808 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
815 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
816 liMove
.QuadPart
= Chunk
.dwSize
;
817 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
821 TRACE_(dmfile
)(": StreamCount[0] = 0x%08X < StreamSize[0] = 0x%08X\n", StreamCount
, StreamSize
);
822 } while (StreamCount
< StreamSize
);
826 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
827 liMove
.QuadPart
= StreamSize
;
828 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
832 TRACE_(dmfile
)(": reading finished\n");
833 This
->Desc
.dwValidData
|= DMUS_OBJ_LOADED
;
837 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
838 liMove
.QuadPart
= Chunk
.dwSize
;
839 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
844 /* now, if DMUS_CONTAINER_NOLOADS is not set, we are supposed to load contained objects;
845 so when we call GetObject later, they'll already be in cache */
846 if (!(This
->Header
.dwFlags
& DMUS_CONTAINER_NOLOADS
)) {
848 LPWINE_CONTAINER_ENTRY pContainedObject
;
850 TRACE(": DMUS_CONTAINER_NOLOADS not set... load all objects\n");
852 LIST_FOR_EACH (pEntry
, This
->pContainedObjects
) {
853 IDirectMusicObject
* pObject
;
854 pContainedObject
= LIST_ENTRY (pEntry
, WINE_CONTAINER_ENTRY
, entry
);
855 /* get object from loader and then release it */
856 if (SUCCEEDED(IDirectMusicLoader_GetObject (pLoader
, &pContainedObject
->Desc
, &IID_IDirectMusicObject
, (LPVOID
*)&pObject
))) {
857 pContainedObject
->pObject
= pObject
; /* for final release */
858 IDirectMusicObject_Release (pObject
); /* we don't really need this one */
860 WARN(": failed to load contained object\n");
861 result
= DMUS_S_PARTIALLOAD
;
866 IDirectMusicLoader_Release (pLoader
); /* release loader */
869 /* DEBUG: dumps whole container object tree: */
870 if (TRACE_ON(dmloader
)) {
872 LPWINE_CONTAINER_ENTRY tmpEntry
;
873 struct list
*listEntry
;
875 TRACE("*** IDirectMusicContainer (%p) ***\n", This
->ContainerVtbl
);
876 TRACE(" - Objects:\n");
877 LIST_FOR_EACH (listEntry
, This
->pContainedObjects
) {
878 tmpEntry
= LIST_ENTRY( listEntry
, WINE_CONTAINER_ENTRY
, entry
);
879 TRACE(" - Object[%i]:\n", r
);
880 TRACE(" - wszAlias: %s\n", debugstr_w(tmpEntry
->wszAlias
));
881 TRACE(" - Object descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC(&tmpEntry
->Desc
));
890 static HRESULT WINAPI
IDirectMusicContainerImpl_IPersistStream_Save (LPPERSISTSTREAM iface
, IStream
* pStm
, BOOL fClearDirty
) {
891 ERR(": should not be needed\n");
895 static HRESULT WINAPI
IDirectMusicContainerImpl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface
, ULARGE_INTEGER
* pcbSize
) {
896 ERR(": should not be needed\n");
900 static const IPersistStreamVtbl DirectMusicContainer_PersistStream_Vtbl
= {
901 IDirectMusicContainerImpl_IPersistStream_QueryInterface
,
902 IDirectMusicContainerImpl_IPersistStream_AddRef
,
903 IDirectMusicContainerImpl_IPersistStream_Release
,
904 IDirectMusicContainerImpl_IPersistStream_GetClassID
,
905 IDirectMusicContainerImpl_IPersistStream_IsDirty
,
906 IDirectMusicContainerImpl_IPersistStream_Load
,
907 IDirectMusicContainerImpl_IPersistStream_Save
,
908 IDirectMusicContainerImpl_IPersistStream_GetSizeMax
911 /* for ClassFactory */
912 HRESULT WINAPI
DMUSIC_CreateDirectMusicContainerImpl (LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) {
913 IDirectMusicContainerImpl
* obj
;
915 obj
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicContainerImpl
));
918 return E_OUTOFMEMORY
;
920 obj
->ContainerVtbl
= &DirectMusicContainer_Container_Vtbl
;
921 obj
->ObjectVtbl
= &DirectMusicContainer_Object_Vtbl
;
922 obj
->PersistStreamVtbl
= &DirectMusicContainer_PersistStream_Vtbl
;
923 obj
->dwRef
= 0; /* will be inited by QueryInterface */
924 obj
->pContainedObjects
= HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
, sizeof(struct list
));
925 list_init (obj
->pContainedObjects
);
927 /* increase number of instances */
928 InterlockedIncrement (&dwDirectMusicContainer
);
930 return IDirectMusicContainerImpl_IDirectMusicContainer_QueryInterface ((LPDIRECTMUSICCONTAINER
)&obj
->ContainerVtbl
, lpcGUID
, ppobj
);