1 /* IDirectMusicSegment8 Implementation
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 "dmime_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmime
);
23 WINE_DECLARE_DEBUG_CHANNEL(dmfile
);
25 /*****************************************************************************
26 * IDirectMusicSegmentImpl implementation
28 /* IDirectMusicSegment IUnknown part: */
29 HRESULT WINAPI
IDirectMusicSegment8Impl_IUnknown_QueryInterface (LPUNKNOWN iface
, REFIID riid
, LPVOID
*ppobj
) {
30 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, UnknownVtbl
, iface
);
31 TRACE("(%p, %s, %p)\n", This
, debugstr_dmguid(riid
), ppobj
);
33 if (IsEqualIID (riid
, &IID_IUnknown
)) {
34 *ppobj
= (LPVOID
)&This
->UnknownVtbl
;
35 IDirectMusicSegment8Impl_IUnknown_AddRef ((LPUNKNOWN
)&This
->UnknownVtbl
);
37 } else if (IsEqualIID (riid
, &IID_IDirectMusicSegment
)
38 || IsEqualIID (riid
, &IID_IDirectMusicSegment2
)
39 || IsEqualIID (riid
, &IID_IDirectMusicSegment8
)) {
40 *ppobj
= (LPVOID
)&This
->SegmentVtbl
;
41 IDirectMusicSegment8Impl_IDirectMusicSegment8_AddRef ((LPDIRECTMUSICSEGMENT8
)&This
->SegmentVtbl
);
43 } else if (IsEqualIID (riid
, &IID_IDirectMusicObject
)) {
44 *ppobj
= (LPVOID
)&This
->ObjectVtbl
;
45 IDirectMusicSegment8Impl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT
)&This
->ObjectVtbl
);
47 } else if (IsEqualIID (riid
, &IID_IPersistStream
)) {
48 *ppobj
= (LPVOID
)&This
->PersistStreamVtbl
;
49 IDirectMusicSegment8Impl_IPersistStream_AddRef ((LPPERSISTSTREAM
)&This
->PersistStreamVtbl
);
53 WARN("(%p, %s, %p): not found\n", This
, debugstr_dmguid(riid
), ppobj
);
57 ULONG WINAPI
IDirectMusicSegment8Impl_IUnknown_AddRef (LPUNKNOWN iface
) {
58 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, UnknownVtbl
, iface
);
59 TRACE("(%p): AddRef from %ld\n", This
, This
->ref
);
63 ULONG WINAPI
IDirectMusicSegment8Impl_IUnknown_Release (LPUNKNOWN iface
) {
64 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, UnknownVtbl
, iface
);
65 ULONG ref
= --This
->ref
;
66 TRACE("(%p): ReleaseRef to %ld\n", This
, This
->ref
);
68 HeapFree(GetProcessHeap(), 0, This
);
73 ICOM_VTABLE(IUnknown
) DirectMusicSegment8_Unknown_Vtbl
= {
74 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
75 IDirectMusicSegment8Impl_IUnknown_QueryInterface
,
76 IDirectMusicSegment8Impl_IUnknown_AddRef
,
77 IDirectMusicSegment8Impl_IUnknown_Release
80 /* IDirectMusicSegmentImpl IDirectMusicSegment part: */
81 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_QueryInterface (LPDIRECTMUSICSEGMENT8 iface
, REFIID riid
, LPVOID
*ppobj
) {
82 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
83 return IDirectMusicSegment8Impl_IUnknown_QueryInterface ((LPUNKNOWN
)&This
->UnknownVtbl
, riid
, ppobj
);
86 ULONG WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_AddRef (LPDIRECTMUSICSEGMENT8 iface
) {
87 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
88 return IDirectMusicSegment8Impl_IUnknown_AddRef ((LPUNKNOWN
)&This
->UnknownVtbl
);
91 ULONG WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_Release (LPDIRECTMUSICSEGMENT8 iface
) {
92 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
93 return IDirectMusicSegment8Impl_IUnknown_Release ((LPUNKNOWN
)&This
->UnknownVtbl
);
96 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetLength (LPDIRECTMUSICSEGMENT8 iface
, MUSIC_TIME
* pmtLength
) {
97 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
98 FIXME("(%p, %p): stub\n", This
, pmtLength
);
102 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetLength (LPDIRECTMUSICSEGMENT8 iface
, MUSIC_TIME mtLength
) {
103 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
104 FIXME("(%p, %ld): stub\n", This
, mtLength
);
108 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetRepeats (LPDIRECTMUSICSEGMENT8 iface
, DWORD
* pdwRepeats
) {
109 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
110 FIXME("(%p, %p): stub\n", This
, pdwRepeats
);
114 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetRepeats (LPDIRECTMUSICSEGMENT8 iface
, DWORD dwRepeats
) {
115 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
116 FIXME("(%p, %ld): stub\n", This
, dwRepeats
);
120 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetDefaultResolution (LPDIRECTMUSICSEGMENT8 iface
, DWORD
* pdwResolution
) {
121 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
122 FIXME("(%p, %p): stub\n", This
, pdwResolution
);
126 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetDefaultResolution (LPDIRECTMUSICSEGMENT8 iface
, DWORD dwResolution
) {
127 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
128 FIXME("(%p, %ld): stub\n", This
, dwResolution
);
132 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetTrack (LPDIRECTMUSICSEGMENT8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, IDirectMusicTrack
** ppTrack
) {
133 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
134 FIXME("(%p, %s, %ld, %ld, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwGroupBits
, dwIndex
, ppTrack
);
138 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetTrackGroup (LPDIRECTMUSICSEGMENT8 iface
, IDirectMusicTrack
* pTrack
, DWORD
* pdwGroupBits
) {
139 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
140 FIXME("(%p, %p, %p): stub\n", This
, pTrack
, pdwGroupBits
);
144 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_InsertTrack (LPDIRECTMUSICSEGMENT8 iface
, IDirectMusicTrack
* pTrack
, DWORD dwGroupBits
) {
145 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
146 FIXME("(%p, %p, %ld): stub\n", This
, pTrack
, dwGroupBits
);
150 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_RemoveTrack (LPDIRECTMUSICSEGMENT8 iface
, IDirectMusicTrack
* pTrack
) {
151 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
152 FIXME("(%p, %p): stub\n", This
, pTrack
);
156 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_InitPlay (LPDIRECTMUSICSEGMENT8 iface
, IDirectMusicSegmentState
** ppSegState
, IDirectMusicPerformance
* pPerformance
, DWORD dwFlags
) {
157 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
158 FIXME("(%p, %p, %p, %ld): stub\n", This
, ppSegState
, pPerformance
, dwFlags
);
162 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetGraph (LPDIRECTMUSICSEGMENT8 iface
, IDirectMusicGraph
** ppGraph
) {
163 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
164 FIXME("(%p, %p): stub\n", This
, ppGraph
);
168 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetGraph (LPDIRECTMUSICSEGMENT8 iface
, IDirectMusicGraph
* pGraph
) {
169 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
170 FIXME("(%p, %p): stub\n", This
, pGraph
);
174 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_AddNotificationType (LPDIRECTMUSICSEGMENT8 iface
, REFGUID rguidNotificationType
) {
175 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
176 FIXME("(%p, %s): stub\n", This
, debugstr_dmguid(rguidNotificationType
));
180 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_RemoveNotificationType (LPDIRECTMUSICSEGMENT8 iface
, REFGUID rguidNotificationType
) {
181 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
182 FIXME("(%p, %s): stub\n", This
, debugstr_dmguid(rguidNotificationType
));
186 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetParam (LPDIRECTMUSICSEGMENT8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, MUSIC_TIME
* pmtNext
, void* pParam
) {
187 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
188 FIXME("(%p, %s, %ld, %ld, %ld, %p, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pmtNext
, pParam
);
192 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetParam (LPDIRECTMUSICSEGMENT8 iface
, REFGUID rguidType
, DWORD dwGroupBits
, DWORD dwIndex
, MUSIC_TIME mtTime
, void* pParam
) {
193 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
194 FIXME("(%p, %s, %ld, %ld, %ld, %p): stub\n", This
, debugstr_dmguid(rguidType
), dwGroupBits
, dwIndex
, mtTime
, pParam
);
198 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_Clone (LPDIRECTMUSICSEGMENT8 iface
, MUSIC_TIME mtStart
, MUSIC_TIME mtEnd
, IDirectMusicSegment
** ppSegment
) {
199 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
200 FIXME("(%p, %ld, %ld, %p): stub\n", This
, mtStart
, mtEnd
, ppSegment
);
204 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetStartPoint (LPDIRECTMUSICSEGMENT8 iface
, MUSIC_TIME mtStart
) {
205 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
206 FIXME("(%p, %ld): stub\n", This
, mtStart
);
210 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetStartPoint (LPDIRECTMUSICSEGMENT8 iface
, MUSIC_TIME
* pmtStart
) {
211 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
212 FIXME("(%p, %p): stub\n", This
, pmtStart
);
216 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetLoopPoints (LPDIRECTMUSICSEGMENT8 iface
, MUSIC_TIME mtStart
, MUSIC_TIME mtEnd
) {
217 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
218 FIXME("(%p, %ld, %ld): stub\n", This
, mtStart
, mtEnd
);
222 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetLoopPoints (LPDIRECTMUSICSEGMENT8 iface
, MUSIC_TIME
* pmtStart
, MUSIC_TIME
* pmtEnd
) {
223 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
224 FIXME("(%p, %p, %p): stub\n", This
, pmtStart
, pmtEnd
);
228 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetPChannelsUsed (LPDIRECTMUSICSEGMENT8 iface
, DWORD dwNumPChannels
, DWORD
* paPChannels
) {
229 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
230 FIXME("(%p, %ld, %p): stub\n", This
, dwNumPChannels
, paPChannels
);
234 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_SetTrackConfig (LPDIRECTMUSICSEGMENT8 iface
, REFGUID rguidTrackClassID
, DWORD dwGroupBits
, DWORD dwIndex
, DWORD dwFlagsOn
, DWORD dwFlagsOff
) {
235 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
236 FIXME("(%p, %s, %ld, %ld, %ld, %ld): stub\n", This
, debugstr_dmguid(rguidTrackClassID
), dwGroupBits
, dwIndex
, dwFlagsOn
, dwFlagsOff
);
240 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_GetAudioPathConfig (LPDIRECTMUSICSEGMENT8 iface
, IUnknown
** ppAudioPathConfig
){
241 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
242 FIXME("(%p, %p): stub\n", This
, ppAudioPathConfig
);
246 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_Compose (LPDIRECTMUSICSEGMENT8 iface
, MUSIC_TIME mtTime
, IDirectMusicSegment
* pFromSegment
, IDirectMusicSegment
* pToSegment
, IDirectMusicSegment
** ppComposedSegment
) {
247 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
248 FIXME("(%p, %ld, %p, %p, %p): stub\n", This
, mtTime
, pFromSegment
, pToSegment
, ppComposedSegment
);
252 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_Download (LPDIRECTMUSICSEGMENT8 iface
, IUnknown
*pAudioPath
) {
253 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
254 FIXME("(%p, %p): stub\n", This
, pAudioPath
);
258 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicSegment8_Unload (LPDIRECTMUSICSEGMENT8 iface
, IUnknown
*pAudioPath
) {
259 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, SegmentVtbl
, iface
);
260 FIXME("(%p, %p): stub\n", This
, pAudioPath
);
264 ICOM_VTABLE(IDirectMusicSegment8
) DirectMusicSegment8_Segment_Vtbl
= {
265 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
266 IDirectMusicSegment8Impl_IDirectMusicSegment8_QueryInterface
,
267 IDirectMusicSegment8Impl_IDirectMusicSegment8_AddRef
,
268 IDirectMusicSegment8Impl_IDirectMusicSegment8_Release
,
269 IDirectMusicSegment8Impl_IDirectMusicSegment8_GetLength
,
270 IDirectMusicSegment8Impl_IDirectMusicSegment8_SetLength
,
271 IDirectMusicSegment8Impl_IDirectMusicSegment8_GetRepeats
,
272 IDirectMusicSegment8Impl_IDirectMusicSegment8_SetRepeats
,
273 IDirectMusicSegment8Impl_IDirectMusicSegment8_GetDefaultResolution
,
274 IDirectMusicSegment8Impl_IDirectMusicSegment8_SetDefaultResolution
,
275 IDirectMusicSegment8Impl_IDirectMusicSegment8_GetTrack
,
276 IDirectMusicSegment8Impl_IDirectMusicSegment8_GetTrackGroup
,
277 IDirectMusicSegment8Impl_IDirectMusicSegment8_InsertTrack
,
278 IDirectMusicSegment8Impl_IDirectMusicSegment8_RemoveTrack
,
279 IDirectMusicSegment8Impl_IDirectMusicSegment8_InitPlay
,
280 IDirectMusicSegment8Impl_IDirectMusicSegment8_GetGraph
,
281 IDirectMusicSegment8Impl_IDirectMusicSegment8_SetGraph
,
282 IDirectMusicSegment8Impl_IDirectMusicSegment8_AddNotificationType
,
283 IDirectMusicSegment8Impl_IDirectMusicSegment8_RemoveNotificationType
,
284 IDirectMusicSegment8Impl_IDirectMusicSegment8_GetParam
,
285 IDirectMusicSegment8Impl_IDirectMusicSegment8_SetParam
,
286 IDirectMusicSegment8Impl_IDirectMusicSegment8_Clone
,
287 IDirectMusicSegment8Impl_IDirectMusicSegment8_SetStartPoint
,
288 IDirectMusicSegment8Impl_IDirectMusicSegment8_GetStartPoint
,
289 IDirectMusicSegment8Impl_IDirectMusicSegment8_SetLoopPoints
,
290 IDirectMusicSegment8Impl_IDirectMusicSegment8_GetLoopPoints
,
291 IDirectMusicSegment8Impl_IDirectMusicSegment8_SetPChannelsUsed
,
292 IDirectMusicSegment8Impl_IDirectMusicSegment8_SetTrackConfig
,
293 IDirectMusicSegment8Impl_IDirectMusicSegment8_GetAudioPathConfig
,
294 IDirectMusicSegment8Impl_IDirectMusicSegment8_Compose
,
295 IDirectMusicSegment8Impl_IDirectMusicSegment8_Download
,
296 IDirectMusicSegment8Impl_IDirectMusicSegment8_Unload
299 /* IDirectMusicSegment8Impl IDirectMusicObject part: */
300 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface
, REFIID riid
, LPVOID
*ppobj
) {
301 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, ObjectVtbl
, iface
);
302 return IDirectMusicSegment8Impl_IUnknown_QueryInterface ((LPUNKNOWN
)&This
->UnknownVtbl
, riid
, ppobj
);
305 ULONG WINAPI
IDirectMusicSegment8Impl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface
) {
306 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, ObjectVtbl
, iface
);
307 return IDirectMusicSegment8Impl_IUnknown_AddRef ((LPUNKNOWN
)&This
->UnknownVtbl
);
310 ULONG WINAPI
IDirectMusicSegment8Impl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface
) {
311 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, ObjectVtbl
, iface
);
312 return IDirectMusicSegment8Impl_IUnknown_Release ((LPUNKNOWN
)&This
->UnknownVtbl
);
315 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface
, LPDMUS_OBJECTDESC pDesc
) {
316 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, ObjectVtbl
, iface
);
317 TRACE("(%p, %p)\n", This
, pDesc
);
318 /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
319 memcpy (pDesc
, This
->pDesc
, This
->pDesc
->dwSize
);
323 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface
, LPDMUS_OBJECTDESC pDesc
) {
324 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, ObjectVtbl
, iface
);
325 TRACE("(%p, %p): setting descriptor:\n%s\n", This
, pDesc
, debugstr_DMUS_OBJECTDESC (pDesc
));
327 /* According to MSDN, we should copy only given values, not whole struct */
328 if (pDesc
->dwValidData
& DMUS_OBJ_OBJECT
)
329 memcpy (&This
->pDesc
->guidObject
, &pDesc
->guidObject
, sizeof (pDesc
->guidObject
));
330 if (pDesc
->dwValidData
& DMUS_OBJ_CLASS
)
331 memcpy (&This
->pDesc
->guidClass
, &pDesc
->guidClass
, sizeof (pDesc
->guidClass
));
332 if (pDesc
->dwValidData
& DMUS_OBJ_NAME
)
333 strncpyW (This
->pDesc
->wszName
, pDesc
->wszName
, DMUS_MAX_NAME
);
334 if (pDesc
->dwValidData
& DMUS_OBJ_CATEGORY
)
335 strncpyW (This
->pDesc
->wszCategory
, pDesc
->wszCategory
, DMUS_MAX_CATEGORY
);
336 if (pDesc
->dwValidData
& DMUS_OBJ_FILENAME
)
337 strncpyW (This
->pDesc
->wszFileName
, pDesc
->wszFileName
, DMUS_MAX_FILENAME
);
338 if (pDesc
->dwValidData
& DMUS_OBJ_VERSION
)
339 memcpy (&This
->pDesc
->vVersion
, &pDesc
->vVersion
, sizeof (pDesc
->vVersion
));
340 if (pDesc
->dwValidData
& DMUS_OBJ_DATE
)
341 memcpy (&This
->pDesc
->ftDate
, &pDesc
->ftDate
, sizeof (pDesc
->ftDate
));
342 if (pDesc
->dwValidData
& DMUS_OBJ_MEMORY
) {
343 memcpy (&This
->pDesc
->llMemLength
, &pDesc
->llMemLength
, sizeof (pDesc
->llMemLength
));
344 memcpy (This
->pDesc
->pbMemData
, pDesc
->pbMemData
, sizeof (pDesc
->pbMemData
));
346 if (pDesc
->dwValidData
& DMUS_OBJ_STREAM
) {
347 /* according to MSDN, we copy the stream */
348 IStream_Clone (pDesc
->pStream
, &This
->pDesc
->pStream
);
352 This
->pDesc
->dwValidData
|= pDesc
->dwValidData
;
357 HRESULT WINAPI
IDirectMusicSegment8Impl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface
, LPSTREAM pStream
, LPDMUS_OBJECTDESC pDesc
) {
358 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, ObjectVtbl
, iface
);
359 DMUS_PRIVATE_CHUNK Chunk
;
360 DWORD StreamSize
, StreamCount
, ListSize
[1], ListCount
[1];
361 LARGE_INTEGER liMove
; /* used when skipping chunks */
363 TRACE("(%p,%p, %p)\n", This
, pStream
, pDesc
);
365 /* FIXME: should this be determined from stream? */
366 pDesc
->dwValidData
|= DMUS_OBJ_CLASS
;
367 memcpy (&pDesc
->guidClass
, &CLSID_DirectMusicSegment
, sizeof(CLSID
));
369 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
370 TRACE_(dmfile
)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
371 switch (Chunk
.fccID
) {
373 IStream_Read (pStream
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
374 TRACE_(dmfile
)(": RIFF chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
375 StreamSize
= Chunk
.dwSize
- sizeof(FOURCC
);
377 if (Chunk
.fccID
== DMUS_FOURCC_SEGMENT_FORM
) {
378 TRACE_(dmfile
)(": segment form\n");
380 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
381 StreamCount
+= sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
382 TRACE_(dmfile
)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
383 switch (Chunk
.fccID
) {
384 case DMUS_FOURCC_GUID_CHUNK
: {
385 TRACE_(dmfile
)(": GUID chunk\n");
386 pDesc
->dwValidData
|= DMUS_OBJ_OBJECT
;
387 IStream_Read (pStream
, &pDesc
->guidObject
, Chunk
.dwSize
, NULL
);
390 case DMUS_FOURCC_VERSION_CHUNK
: {
391 TRACE_(dmfile
)(": version chunk\n");
392 pDesc
->dwValidData
|= DMUS_OBJ_VERSION
;
393 IStream_Read (pStream
, &pDesc
->vVersion
, Chunk
.dwSize
, NULL
);
396 case DMUS_FOURCC_CATEGORY_CHUNK
: {
397 TRACE_(dmfile
)(": category chunk\n");
398 pDesc
->dwValidData
|= DMUS_OBJ_CATEGORY
;
399 IStream_Read (pStream
, pDesc
->wszCategory
, Chunk
.dwSize
, NULL
);
403 IStream_Read (pStream
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
404 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
405 ListSize
[0] = Chunk
.dwSize
- sizeof(FOURCC
);
407 switch (Chunk
.fccID
) {
408 /* evil M$ UNFO list, which can (!?) contain INFO elements */
409 case DMUS_FOURCC_UNFO_LIST
: {
410 TRACE_(dmfile
)(": UNFO list\n");
412 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
413 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
414 TRACE_(dmfile
)(": %s chunk (size = 0x%04lx)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
415 switch (Chunk
.fccID
) {
416 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
417 (though strings seem to be valid unicode) */
418 case mmioFOURCC('I','N','A','M'):
419 case DMUS_FOURCC_UNAM_CHUNK
: {
420 TRACE_(dmfile
)(": name chunk\n");
421 pDesc
->dwValidData
|= DMUS_OBJ_NAME
;
422 IStream_Read (pStream
, pDesc
->wszName
, Chunk
.dwSize
, NULL
);
425 case mmioFOURCC('I','A','R','T'):
426 case DMUS_FOURCC_UART_CHUNK
: {
427 TRACE_(dmfile
)(": artist chunk (ignored)\n");
428 liMove
.QuadPart
= Chunk
.dwSize
;
429 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
432 case mmioFOURCC('I','C','O','P'):
433 case DMUS_FOURCC_UCOP_CHUNK
: {
434 TRACE_(dmfile
)(": copyright chunk (ignored)\n");
435 liMove
.QuadPart
= Chunk
.dwSize
;
436 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
439 case mmioFOURCC('I','S','B','J'):
440 case DMUS_FOURCC_USBJ_CHUNK
: {
441 TRACE_(dmfile
)(": subject chunk (ignored)\n");
442 liMove
.QuadPart
= Chunk
.dwSize
;
443 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
446 case mmioFOURCC('I','C','M','T'):
447 case DMUS_FOURCC_UCMT_CHUNK
: {
448 TRACE_(dmfile
)(": comment chunk (ignored)\n");
449 liMove
.QuadPart
= Chunk
.dwSize
;
450 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
454 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
455 liMove
.QuadPart
= Chunk
.dwSize
;
456 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
460 TRACE_(dmfile
)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount
[0], ListSize
[0]);
461 } while (ListCount
[0] < ListSize
[0]);
464 case DMUS_FOURCC_TRACK_LIST
: {
465 TRACE_(dmfile
)(": TRACK list\n");
467 IStream_Read (pStream
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
468 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
469 TRACE_(dmfile
)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
470 switch (Chunk
.fccID
) {
472 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
473 liMove
.QuadPart
= Chunk
.dwSize
;
474 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
478 TRACE_(dmfile
)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount
[0], ListSize
[0]);
479 } while (ListCount
[0] < ListSize
[0]);
483 TRACE_(dmfile
)(": unknown (skipping)\n");
484 liMove
.QuadPart
= Chunk
.dwSize
- sizeof(FOURCC
);
485 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
492 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
493 liMove
.QuadPart
= Chunk
.dwSize
;
494 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
498 TRACE_(dmfile
)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount
, StreamSize
);
499 } while (StreamCount
< StreamSize
);
501 } else if (Chunk
.fccID
== mmioFOURCC('W','A','V','E')) {
502 TRACE_(dmfile
)(": wave form (loading not yet implemented)\n");
503 liMove
.QuadPart
= StreamSize
;
504 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
506 TRACE_(dmfile
)(": unexpected chunk (loading failed)\n");
507 liMove
.QuadPart
= StreamSize
;
508 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
512 TRACE_(dmfile
)(": reading finished\n");
516 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
517 liMove
.QuadPart
= Chunk
.dwSize
;
518 IStream_Seek (pStream
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
519 return DMUS_E_INVALIDFILE
;
523 TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC (pDesc
));
528 ICOM_VTABLE(IDirectMusicObject
) DirectMusicSegment8_Object_Vtbl
= {
529 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
530 IDirectMusicSegment8Impl_IDirectMusicObject_QueryInterface
,
531 IDirectMusicSegment8Impl_IDirectMusicObject_AddRef
,
532 IDirectMusicSegment8Impl_IDirectMusicObject_Release
,
533 IDirectMusicSegment8Impl_IDirectMusicObject_GetDescriptor
,
534 IDirectMusicSegment8Impl_IDirectMusicObject_SetDescriptor
,
535 IDirectMusicSegment8Impl_IDirectMusicObject_ParseDescriptor
538 /* IDirectMusicSegment8Impl IPersistStream part: */
539 HRESULT WINAPI
IDirectMusicSegment8Impl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface
, REFIID riid
, LPVOID
*ppobj
) {
540 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, PersistStreamVtbl
, iface
);
541 return IDirectMusicSegment8Impl_IUnknown_QueryInterface ((LPUNKNOWN
)&This
->UnknownVtbl
, riid
, ppobj
);
544 ULONG WINAPI
IDirectMusicSegment8Impl_IPersistStream_AddRef (LPPERSISTSTREAM iface
) {
545 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, PersistStreamVtbl
, iface
);
546 return IDirectMusicSegment8Impl_IUnknown_AddRef ((LPUNKNOWN
)&This
->UnknownVtbl
);
549 ULONG WINAPI
IDirectMusicSegment8Impl_IPersistStream_Release (LPPERSISTSTREAM iface
) {
550 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, PersistStreamVtbl
, iface
);
551 return IDirectMusicSegment8Impl_IUnknown_Release ((LPUNKNOWN
)&This
->UnknownVtbl
);
554 HRESULT WINAPI
IDirectMusicSegment8Impl_IPersistStream_GetClassID (LPPERSISTSTREAM iface
, CLSID
* pClassID
) {
555 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, PersistStreamVtbl
, iface
);
556 TRACE("(%p, %p)\n", This
, pClassID
);
557 memcpy(pClassID
, &CLSID_DirectMusicContainer
, sizeof(CLSID
));
561 HRESULT WINAPI
IDirectMusicSegment8Impl_IPersistStream_IsDirty (LPPERSISTSTREAM iface
) {
562 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, PersistStreamVtbl
, iface
);
563 FIXME("(%p): stub, always S_FALSE\n", This
);
568 static HRESULT
IDirectMusicImpl_IPersistStream_ParseDescGeneric (DMUS_PRIVATE_CHUNK
* pChunk
, IStream
* pStm
, LPDMUS_OBJECTDESC pDesc
) {
570 switch (pChunk
->fccID
) {
571 case DMUS_FOURCC_GUID_CHUNK
: {
572 TRACE_(dmfile
)(": GUID chunk\n");
573 pDesc
->dwValidData
|= DMUS_OBJ_OBJECT
;
574 IStream_Read (pStm
, &pDesc
->guidObject
, pChunk
->dwSize
, NULL
);
577 case DMUS_FOURCC_VERSION_CHUNK
: {
578 TRACE_(dmfile
)(": version chunk\n");
579 pDesc
->dwValidData
|= DMUS_OBJ_VERSION
;
580 IStream_Read (pStm
, &pDesc
->vVersion
, pChunk
->dwSize
, NULL
);
583 case DMUS_FOURCC_CATEGORY_CHUNK
: {
584 TRACE_(dmfile
)(": category chunk\n");
585 pDesc
->dwValidData
|= DMUS_OBJ_CATEGORY
;
586 IStream_Read (pStm
, pDesc
->wszCategory
, pChunk
->dwSize
, NULL
);
597 static HRESULT
IDirectMusicImpl_IPersistStream_ParseUNFOGeneric (DMUS_PRIVATE_CHUNK
* pChunk
, IStream
* pStm
, LPDMUS_OBJECTDESC pDesc
) {
599 LARGE_INTEGER liMove
; /* used when skipping chunks */
602 * don't ask me why, but M$ puts INFO elements in UNFO list sometimes
603 * (though strings seem to be valid unicode)
605 switch (pChunk
->fccID
) {
607 case mmioFOURCC('I','N','A','M'):
608 case DMUS_FOURCC_UNAM_CHUNK: {
609 TRACE_(dmfile)(": name chunk\n");
610 pDesc->dwValidData |= DMUS_OBJ_NAME;
611 IStream_Read (pStream, pDesc->wszName, Chunk.dwSize, NULL);
615 case mmioFOURCC('I','A','R','T'):
616 case DMUS_FOURCC_UART_CHUNK
: {
617 TRACE_(dmfile
)(": artist chunk (ignored)\n");
618 liMove
.QuadPart
= pChunk
->dwSize
;
619 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
622 case mmioFOURCC('I','C','O','P'):
623 case DMUS_FOURCC_UCOP_CHUNK
: {
624 TRACE_(dmfile
)(": copyright chunk (ignored)\n");
625 liMove
.QuadPart
= pChunk
->dwSize
;
626 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
629 case mmioFOURCC('I','S','B','J'):
630 case DMUS_FOURCC_USBJ_CHUNK
: {
631 TRACE_(dmfile
)(": subject chunk (ignored)\n");
632 liMove
.QuadPart
= pChunk
->dwSize
;
633 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
636 case mmioFOURCC('I','C','M','T'):
637 case DMUS_FOURCC_UCMT_CHUNK
: {
638 TRACE_(dmfile
)(": comment chunk (ignored)\n");
639 liMove
.QuadPart
= pChunk
->dwSize
;
640 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
651 static HRESULT
IDirectMusicSegment8Impl_IPersistStream_LoadTrack (LPPERSISTSTREAM iface
, IStream
* pClonedStream
, IDirectMusicTrack
** ppTrack
,
652 DMUS_IO_TRACK_HEADER
* pTrack_hdr
) {
655 IPersistStream
* pPersistStream
= NULL
;
657 hr
= CoCreateInstance (&pTrack_hdr
->guidClassID
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDirectMusicTrack
, (LPVOID
*) ppTrack
);
659 ERR(": could not create object\n");
662 /* acquire PersistStream interface */
663 hr
= IDirectMusicTrack_QueryInterface (*ppTrack
, &IID_IPersistStream
, (LPVOID
*) &pPersistStream
);
665 ERR(": could not acquire IPersistStream\n");
669 hr
= IPersistStream_Load (pPersistStream
, pClonedStream
);
671 ERR(": failed to load object\n");
675 /* release all loading-related stuff */
676 IPersistStream_Release (pPersistStream
);
681 static HRESULT
IDirectMusicSegment8Impl_IPersistStream_ParseTrackForm (LPPERSISTSTREAM iface
, DMUS_PRIVATE_CHUNK
* pChunk
, IStream
* pStm
, IDirectMusicSegment8Impl
* This
) {
684 DMUS_PRIVATE_CHUNK Chunk
;
685 DWORD StreamSize
, StreamCount
, ListSize
[3], ListCount
[3];
686 LARGE_INTEGER liMove
; /* used when skipping chunks */
688 DMUS_IO_TRACK_HEADER track_hdr
;
689 DMUS_IO_TRACK_EXTRAS_HEADER track_xhdr
;
690 IDirectMusicTrack
* pTrack
= NULL
;
692 if (pChunk
->fccID
!= DMUS_FOURCC_TRACK_FORM
) {
693 ERR_(dmfile
)(": %s chunk should be a TRACK form\n", debugstr_fourcc (pChunk
->fccID
));
697 StreamSize
= pChunk
->dwSize
- sizeof(FOURCC
);
701 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
702 StreamCount
+= sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
703 TRACE_(dmfile
)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
705 switch (Chunk
.fccID
) {
706 case DMUS_FOURCC_TRACK_CHUNK
: {
707 TRACE_(dmfile
)(": track chunck\n");
708 IStream_Read (pStm
, &track_hdr
, sizeof(DMUS_IO_TRACK_HEADER
), NULL
);
709 TRACE_(dmfile
)("class: %s\n", debugstr_guid (&track_hdr
.guidClassID
));
710 TRACE_(dmfile
)("dwGroup: %ld\n", track_hdr
.dwGroup
);
711 TRACE_(dmfile
)("ckid: %s\n", debugstr_fourcc (track_hdr
.ckid
));
712 TRACE_(dmfile
)("fccType: %s\n", debugstr_fourcc (track_hdr
.fccType
));
715 case DMUS_FOURCC_TRACK_EXTRAS_CHUNK
: {
716 TRACE_(dmfile
)(": track extras chunck\n");
717 IStream_Read (pStm
, &track_xhdr
, sizeof(DMUS_IO_TRACK_EXTRAS_HEADER
), NULL
);
721 case DMUS_FOURCC_COMMANDTRACK_CHUNK
: {
722 TRACE_(dmfile
)(": COMMANDTRACK track\n");
723 liMove
.QuadPart
= Chunk
.dwSize
;
724 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
729 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
730 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
731 ListSize
[0] = Chunk
.dwSize
- sizeof(FOURCC
);
733 if (Chunk
.fccID
== track_hdr
.fccType
&& 0 == track_hdr
.ckid
) {
734 LPSTREAM pClonedStream
= NULL
;
736 TRACE_(dmfile
)(": TRACK list\n");
738 IStream_Clone (pStm
, &pClonedStream
);
741 liMove
.QuadPart
-= (sizeof(FOURCC
) + sizeof(DWORD
));
742 IStream_Seek (pClonedStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
744 hr
= IDirectMusicSegment8Impl_IPersistStream_LoadTrack (iface
, pClonedStream
, &pTrack
, &track_hdr
);
746 ERR(": could not load track\n");
750 IStream_Release (pClonedStream
);
752 hr
= IDirectMusicSegment8Impl_IDirectMusicSegment8_InsertTrack ((LPDIRECTMUSICSEGMENT8
)This
->SegmentVtbl
, pTrack
, track_hdr
.dwGroup
); /* at dsPosition */
754 ERR(": could not insert track\n");
757 IDirectMusicTrack_Release(pTrack
); pTrack
= NULL
; /* now we can release at as it inserted */
759 liMove
.QuadPart
= Chunk
.dwSize
;
760 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
763 TRACE_(dmfile
)(": unknown (skipping)\n");
764 liMove
.QuadPart
= Chunk
.dwSize
;
765 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
771 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
772 FIXME_(dmfile
)(": LIST chunk of type %s (behavior to check)", debugstr_fourcc(Chunk
.fccID
));
773 ListSize
[0] = Chunk
.dwSize
- sizeof(FOURCC
);
775 if (Chunk
.fccID
== track_hdr
.fccType
&& 0 == track_hdr
.ckid
) {
776 TRACE_(dmfile
)(": TRACK RIFF\n");
778 hr = IDirectMusicSegment8Impl_IPersistStream_LoadTrack (iface, pStm, &pTrack, &track_hdr);
779 if (FAILED(hr)) return hr;
781 liMove
.QuadPart
= Chunk
.dwSize
;
782 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
785 TRACE_(dmfile
)(": unknown (skipping)\n");
786 liMove
.QuadPart
= Chunk
.dwSize
;
787 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
793 if (0 == track_hdr
.fccType
&& Chunk
.fccID
== track_hdr
.ckid
) {
794 LPSTREAM pClonedStream
= NULL
;
796 TRACE_(dmfile
)(": TRACK solo\n");
798 IStream_Clone (pStm
, &pClonedStream
);
801 liMove
.QuadPart
-= (sizeof(FOURCC
) + sizeof(DWORD
));
802 IStream_Seek (pClonedStream
, liMove
, STREAM_SEEK_CUR
, NULL
);
804 hr
= IDirectMusicSegment8Impl_IPersistStream_LoadTrack (iface
, pClonedStream
, &pTrack
, &track_hdr
);
806 ERR(": could not load track\n");
810 IStream_Release (pClonedStream
);
812 hr
= IDirectMusicSegment8Impl_IDirectMusicSegment8_InsertTrack ((LPDIRECTMUSICSEGMENT8
)This
->SegmentVtbl
, pTrack
, track_hdr
.dwGroup
); /* at dsPosition */
814 ERR(": could not insert track\n");
817 IDirectMusicTrack_Release(pTrack
); pTrack
= NULL
; /* now we can release at as it inserted */
819 liMove
.QuadPart
= Chunk
.dwSize
;
820 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
825 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
826 liMove
.QuadPart
= Chunk
.dwSize
;
827 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
831 TRACE_(dmfile
)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount
, StreamSize
);
832 } while (StreamCount
< StreamSize
);
837 static HRESULT
IDirectMusicSegment8Impl_IPersistStream_ParseTrackList (LPPERSISTSTREAM iface
, DMUS_PRIVATE_CHUNK
* pChunk
, IStream
* pStm
, IDirectMusicSegment8Impl
* This
) {
840 DMUS_PRIVATE_CHUNK Chunk
;
841 DWORD StreamSize
, StreamCount
, ListSize
[3], ListCount
[3];
842 LARGE_INTEGER liMove
; /* used when skipping chunks */
844 if (pChunk
->fccID
!= DMUS_FOURCC_TRACK_LIST
) {
845 ERR_(dmfile
)(": %s chunk should be a TRACK list\n", debugstr_fourcc (pChunk
->fccID
));
849 ListSize
[0] = Chunk
.dwSize
- sizeof(FOURCC
);
853 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
854 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
855 TRACE_(dmfile
)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
856 switch (Chunk
.fccID
) {
858 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
859 TRACE_(dmfile
)(": RIFF chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
860 StreamSize
= Chunk
.dwSize
- sizeof(FOURCC
);
862 switch (Chunk
.fccID
) {
863 case DMUS_FOURCC_TRACK_FORM
: {
864 TRACE_(dmfile
)(": TRACK form\n");
865 hr
= IDirectMusicSegment8Impl_IPersistStream_ParseTrackForm (iface
, &Chunk
, pStm
, This
);
866 if (FAILED(hr
)) return hr
;
870 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
871 liMove
.QuadPart
= StreamSize
;
872 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
879 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
880 liMove
.QuadPart
= Chunk
.dwSize
;
881 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
885 TRACE_(dmfile
)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount
[0], ListSize
[0]);
886 } while (ListCount
[0] < ListSize
[0]);
891 static HRESULT
IDirectMusicSegment8Impl_IPersistStream_ParseSegmentForm (LPPERSISTSTREAM iface
, DMUS_PRIVATE_CHUNK
* pChunk
, IStream
* pStm
, IDirectMusicSegment8Impl
* This
) {
894 DMUS_PRIVATE_CHUNK Chunk
;
895 DWORD StreamSize
, StreamCount
, ListSize
[3], ListCount
[3];
896 LARGE_INTEGER liMove
; /* used when skipping chunks */
898 if (pChunk
->fccID
!= DMUS_FOURCC_SEGMENT_FORM
) {
899 ERR_(dmfile
)(": %s chunk should be a segment form\n", debugstr_fourcc (pChunk
->fccID
));
903 StreamSize
= pChunk
->dwSize
- sizeof(FOURCC
);
907 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
908 StreamCount
+= sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
909 TRACE_(dmfile
)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
911 hr
= IDirectMusicImpl_IPersistStream_ParseDescGeneric(&Chunk
, pStm
, This
->pDesc
);
912 if (FAILED(hr
)) return hr
;
915 switch (Chunk
.fccID
) {
916 case DMUS_FOURCC_SEGMENT_CHUNK
: {
917 FIXME_(dmfile
)(": segment chunk\n");
918 liMove
.QuadPart
= Chunk
.dwSize
;
919 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
923 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
924 TRACE_(dmfile
)(": LIST chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
925 ListSize
[0] = Chunk
.dwSize
- sizeof(FOURCC
);
927 switch (Chunk
.fccID
) {
928 case DMUS_FOURCC_UNFO_LIST
: {
929 TRACE_(dmfile
)(": UNFO list\n");
931 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
932 ListCount
[0] += sizeof(FOURCC
) + sizeof(DWORD
) + Chunk
.dwSize
;
933 TRACE_(dmfile
)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
935 hr
= IDirectMusicImpl_IPersistStream_ParseUNFOGeneric(&Chunk
, pStm
, This
->pDesc
);
936 if (FAILED(hr
)) return hr
;
939 switch (Chunk
.fccID
) {
941 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
942 liMove
.QuadPart
= Chunk
.dwSize
;
943 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
949 TRACE_(dmfile
)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount
[0], ListSize
[0]);
950 } while (ListCount
[0] < ListSize
[0]);
953 case DMUS_FOURCC_TRACK_LIST
: {
954 TRACE_(dmfile
)(": TRACK list\n");
955 hr
= IDirectMusicSegment8Impl_IPersistStream_ParseTrackList (iface
, &Chunk
, pStm
, This
);
956 if (FAILED(hr
)) return hr
;
960 TRACE_(dmfile
)(": unknown (skipping)\n");
961 liMove
.QuadPart
= Chunk
.dwSize
- sizeof(FOURCC
);
962 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
969 TRACE_(dmfile
)(": unknown chunk (irrevelant & skipping)\n");
970 liMove
.QuadPart
= Chunk
.dwSize
;
971 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
);
976 TRACE_(dmfile
)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount
, StreamSize
);
977 } while (StreamCount
< StreamSize
);
982 HRESULT WINAPI
IDirectMusicSegment8Impl_IPersistStream_Load (LPPERSISTSTREAM iface
, IStream
* pStm
) {
983 ICOM_THIS_MULTI(IDirectMusicSegment8Impl
, PersistStreamVtbl
, iface
);
986 DMUS_PRIVATE_CHUNK Chunk
;
987 DWORD StreamSize
, StreamCount
;
988 /*DWORD ListSize[3], ListCount[3];*/
989 LARGE_INTEGER liMove
; /* used when skipping chunks */
992 FIXME("(%p, %p): Loading not implemented yet\n", This
, pStm
);
993 IStream_Read (pStm
, &Chunk
, sizeof(FOURCC
)+sizeof(DWORD
), NULL
);
994 TRACE_(dmfile
)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk
.fccID
), Chunk
.dwSize
);
995 switch (Chunk
.fccID
) {
997 IStream_Read (pStm
, &Chunk
.fccID
, sizeof(FOURCC
), NULL
);
998 TRACE_(dmfile
)(": RIFF chunk of type %s", debugstr_fourcc(Chunk
.fccID
));
999 StreamSize
= Chunk
.dwSize
- sizeof(FOURCC
);
1001 switch (Chunk
.fccID
) {
1002 case DMUS_FOURCC_SEGMENT_FORM
: {
1003 TRACE_(dmfile
)(": segment form\n");
1004 hr
= IDirectMusicSegment8Impl_IPersistStream_ParseSegmentForm (iface
, &Chunk
, pStm
, This
);
1005 if (FAILED(hr
)) return hr
;
1008 case mmioFOURCC('W','A','V','E'): {
1009 FIXME_(dmfile
)(": WAVE form (loading not yet implemented)\n");
1010 liMove
.QuadPart
= StreamSize
;
1011 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
1015 TRACE_(dmfile
)(": unexpected chunk (loading failed)\n");
1016 liMove
.QuadPart
= StreamSize
;
1017 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
1021 TRACE_(dmfile
)(": reading finished\n");
1025 TRACE_(dmfile
)(": unexpected chunk; loading failed)\n");
1026 liMove
.QuadPart
= Chunk
.dwSize
;
1027 IStream_Seek (pStm
, liMove
, STREAM_SEEK_CUR
, NULL
); /* skip the rest of the chunk */
1035 HRESULT WINAPI
IDirectMusicSegment8Impl_IPersistStream_Save (LPPERSISTSTREAM iface
, IStream
* pStm
, BOOL fClearDirty
) {
1039 HRESULT WINAPI
IDirectMusicSegment8Impl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface
, ULARGE_INTEGER
* pcbSize
) {
1043 ICOM_VTABLE(IPersistStream
) DirectMusicSegment8_PersistStream_Vtbl
= {
1044 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1045 IDirectMusicSegment8Impl_IPersistStream_QueryInterface
,
1046 IDirectMusicSegment8Impl_IPersistStream_AddRef
,
1047 IDirectMusicSegment8Impl_IPersistStream_Release
,
1048 IDirectMusicSegment8Impl_IPersistStream_GetClassID
,
1049 IDirectMusicSegment8Impl_IPersistStream_IsDirty
,
1050 IDirectMusicSegment8Impl_IPersistStream_Load
,
1051 IDirectMusicSegment8Impl_IPersistStream_Save
,
1052 IDirectMusicSegment8Impl_IPersistStream_GetSizeMax
1055 /* for ClassFactory */
1056 HRESULT WINAPI
DMUSIC_CreateDirectMusicSegmentImpl (LPCGUID lpcGUID
, LPVOID
* ppobj
, LPUNKNOWN pUnkOuter
) {
1057 IDirectMusicSegment8Impl
* obj
;
1059 obj
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectMusicSegment8Impl
));
1061 *ppobj
= (LPVOID
) NULL
;
1062 return E_OUTOFMEMORY
;
1064 obj
->UnknownVtbl
= &DirectMusicSegment8_Unknown_Vtbl
;
1065 obj
->SegmentVtbl
= &DirectMusicSegment8_Segment_Vtbl
;
1066 obj
->ObjectVtbl
= &DirectMusicSegment8_Object_Vtbl
;
1067 obj
->PersistStreamVtbl
= &DirectMusicSegment8_PersistStream_Vtbl
;
1068 obj
->pDesc
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(DMUS_OBJECTDESC
));
1069 DM_STRUCT_INIT(obj
->pDesc
);
1070 obj
->pDesc
->dwValidData
|= DMUS_OBJ_CLASS
;
1071 memcpy (&obj
->pDesc
->guidClass
, &CLSID_DirectMusicSegment
, sizeof (CLSID
));
1072 obj
->ref
= 0; /* will be inited by QueryInterface */
1074 return IDirectMusicSegment8Impl_IUnknown_QueryInterface ((LPUNKNOWN
)&obj
->UnknownVtbl
, lpcGUID
, ppobj
);