1 /* IDirectMusicSegTriggerTrack Implementation
3 * Copyright (C) 2003-2004 Rok Mandeljc
4 * Copyright (C) 2003-2004 Raphael Junqueira
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Library General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "dmime_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
24 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
26 /*****************************************************************************
27 * IDirectMusicSegTriggerTrack implementation
29 /* IDirectMusicSegTriggerTrack IUnknown part: */
30 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
31 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, UnknownVtbl, iface);
32 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
34 if (IsEqualIID (riid, &IID_IUnknown)) {
35 *ppobj = (LPUNKNOWN)&This->UnknownVtbl;
36 IUnknown_AddRef (iface);
38 } else if (IsEqualIID (riid, &IID_IDirectMusicTrack)
39 || IsEqualIID (riid, &IID_IDirectMusicTrack8)) {
40 *ppobj = (LPDIRECTMUSICTRACK8)&This->TrackVtbl;
41 IUnknown_AddRef (iface);
43 } else if (IsEqualIID (riid, &IID_IPersistStream)) {
44 *ppobj = (LPPERSISTSTREAM)&This->PersistStreamVtbl;
45 IUnknown_AddRef (iface);
49 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
53 static ULONG WINAPI IDirectMusicSegTriggerTrack_IUnknown_AddRef (LPUNKNOWN iface) {
54 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, UnknownVtbl, iface);
55 ULONG ref = InterlockedIncrement(&This->ref);
57 TRACE("(%p): AddRef from %ld\n", This, ref - 1);
64 static ULONG WINAPI IDirectMusicSegTriggerTrack_IUnknown_Release (LPUNKNOWN iface) {
65 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, UnknownVtbl, iface);
66 ULONG ref = InterlockedDecrement(&This->ref);
67 TRACE("(%p): ReleaseRef to %ld\n", This, ref);
70 HeapFree(GetProcessHeap(), 0, This);
78 static const IUnknownVtbl DirectMusicSegTriggerTrack_Unknown_Vtbl = {
79 IDirectMusicSegTriggerTrack_IUnknown_QueryInterface,
80 IDirectMusicSegTriggerTrack_IUnknown_AddRef,
81 IDirectMusicSegTriggerTrack_IUnknown_Release
84 /* IDirectMusicSegTriggerTrack IDirectMusicTrack8 part: */
85 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_QueryInterface (LPDIRECTMUSICTRACK8 iface, REFIID riid, LPVOID *ppobj) {
86 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
87 return IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
90 static ULONG WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_AddRef (LPDIRECTMUSICTRACK8 iface) {
91 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
92 return IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
95 static ULONG WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_Release (LPDIRECTMUSICTRACK8 iface) {
96 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
97 return IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
100 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_Init (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegment* pSegment)
102 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
103 FIXME("(%p, %p): stub\n", This, pSegment);
107 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_InitPlay (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegmentState* pSegmentState, IDirectMusicPerformance* pPerformance, void** ppStateData, DWORD dwVirtualTrack8ID, DWORD dwFlags)
109 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
110 FIXME("(%p, %p, %p, %p, %ld, %ld): stub\n", This, pSegmentState, pPerformance, ppStateData, dwVirtualTrack8ID, dwFlags);
114 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_EndPlay (LPDIRECTMUSICTRACK8 iface, void* pStateData)
116 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
117 FIXME("(%p, %p): stub\n", This, pStateData);
121 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_Play (LPDIRECTMUSICTRACK8 iface, void* pStateData, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID)
123 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
124 FIXME("(%p, %p, %ld, %ld, %ld, %ld, %p, %p, %ld): stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
128 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_GetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) {
129 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
130 FIXME("(%p, %s, %ld, %p, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pmtNext, pParam);
134 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_SetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, void* pParam) {
135 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
136 FIXME("(%p, %s, %ld, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pParam);
140 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_IsParamSupported (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType) {
141 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
143 TRACE("(%p, %s): ", This, debugstr_dmguid(rguidType));
144 /* didn't find any params */
145 TRACE("param unsupported\n");
146 return DMUS_E_TYPE_UNSUPPORTED;
149 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_AddNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType) {
150 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
151 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
155 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_RemoveNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType) {
156 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
157 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
161 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_Clone (LPDIRECTMUSICTRACK8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, IDirectMusicTrack** ppTrack) {
162 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
163 FIXME("(%p, %ld, %ld, %p): stub\n", This, mtStart, mtEnd, ppTrack);
167 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_PlayEx (LPDIRECTMUSICTRACK8 iface, void* pStateData, REFERENCE_TIME rtStart, REFERENCE_TIME rtEnd, REFERENCE_TIME rtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID) {
168 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
169 FIXME("(%p, %p, %lli, %lli, %lli, %ld, %p, %p, %ld): stub\n", This, pStateData, rtStart, rtEnd, rtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
173 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_GetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, REFERENCE_TIME* prtNext, void* pParam, void* pStateData, DWORD dwFlags) {
174 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
175 FIXME("(%p, %s, %lli, %p, %p, %p, %ld): stub\n", This, debugstr_dmguid(rguidType), rtTime, prtNext, pParam, pStateData, dwFlags);
179 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_SetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, void* pParam, void* pStateData, DWORD dwFlags) {
180 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
181 FIXME("(%p, %s, %lli, %p, %p, %ld): stub\n", This, debugstr_dmguid(rguidType), rtTime, pParam, pStateData, dwFlags);
185 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_Compose (LPDIRECTMUSICTRACK8 iface, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack) {
186 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
187 FIXME("(%p, %p, %ld, %p): stub\n", This, pContext, dwTrackGroup, ppResultTrack);
191 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IDirectMusicTrack_Join (LPDIRECTMUSICTRACK8 iface, IDirectMusicTrack* pNewTrack, MUSIC_TIME mtJoin, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack) {
192 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, TrackVtbl, iface);
193 FIXME("(%p, %p, %ld, %p, %ld, %p): stub\n", This, pNewTrack, mtJoin, pContext, dwTrackGroup, ppResultTrack);
197 static const IDirectMusicTrack8Vtbl DirectMusicSegTriggerTrack_Track_Vtbl = {
198 IDirectMusicSegTriggerTrack_IDirectMusicTrack_QueryInterface,
199 IDirectMusicSegTriggerTrack_IDirectMusicTrack_AddRef,
200 IDirectMusicSegTriggerTrack_IDirectMusicTrack_Release,
201 IDirectMusicSegTriggerTrack_IDirectMusicTrack_Init,
202 IDirectMusicSegTriggerTrack_IDirectMusicTrack_InitPlay,
203 IDirectMusicSegTriggerTrack_IDirectMusicTrack_EndPlay,
204 IDirectMusicSegTriggerTrack_IDirectMusicTrack_Play,
205 IDirectMusicSegTriggerTrack_IDirectMusicTrack_GetParam,
206 IDirectMusicSegTriggerTrack_IDirectMusicTrack_SetParam,
207 IDirectMusicSegTriggerTrack_IDirectMusicTrack_IsParamSupported,
208 IDirectMusicSegTriggerTrack_IDirectMusicTrack_AddNotificationType,
209 IDirectMusicSegTriggerTrack_IDirectMusicTrack_RemoveNotificationType,
210 IDirectMusicSegTriggerTrack_IDirectMusicTrack_Clone,
211 IDirectMusicSegTriggerTrack_IDirectMusicTrack_PlayEx,
212 IDirectMusicSegTriggerTrack_IDirectMusicTrack_GetParamEx,
213 IDirectMusicSegTriggerTrack_IDirectMusicTrack_SetParamEx,
214 IDirectMusicSegTriggerTrack_IDirectMusicTrack_Compose,
215 IDirectMusicSegTriggerTrack_IDirectMusicTrack_Join
218 /* IDirectMusicSegTriggerTrack IPersistStream part: */
219 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
220 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);
221 return IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
224 static ULONG WINAPI IDirectMusicSegTriggerTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
225 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);
226 return IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
229 static ULONG WINAPI IDirectMusicSegTriggerTrack_IPersistStream_Release (LPPERSISTSTREAM iface) {
230 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);
231 return IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
234 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
235 ICOM_THIS_MULTI(IDirectMusicSegment8Impl, PersistStreamVtbl, iface);
236 TRACE("(%p, %p)\n", This, pClassID);
237 memcpy(pClassID, &CLSID_DirectMusicSegTriggerTrack, sizeof(CLSID));
241 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
242 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);
243 FIXME("(%p): stub, always S_FALSE\n", This);
247 static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegment (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
248 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);
249 DMUS_PRIVATE_CHUNK Chunk;
250 DWORD ListSize[3], ListCount[3];
251 LARGE_INTEGER liMove; /* used when skipping chunks */
254 IDirectMusicObject* pObject = NULL;
255 LPDMUS_PRIVATE_SEGMENT_ITEM pNewItem = NULL;
257 if (pChunk->fccID != DMUS_FOURCC_SEGMENT_LIST) {
258 ERR_(dmfile)(": %s chunk should be a SEGMENT list\n", debugstr_fourcc (pChunk->fccID));
262 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
266 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
267 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
268 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
269 switch (Chunk.fccID) {
270 case DMUS_FOURCC_SEGMENTITEM_CHUNK: {
271 TRACE_(dmfile)(": segment item chunk\n");
272 /** alloc new item entry */
273 pNewItem = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_SEGMENT_ITEM));
274 if (NULL == pNewItem) {
275 ERR(": no more memory\n");
276 return E_OUTOFMEMORY;
278 IStream_Read (pStm, &pNewItem->header, sizeof(DMUS_IO_SEGMENT_ITEM_HEADER), NULL);
279 TRACE_(dmfile)(" - lTimePhysical: %lu\n", pNewItem->header.lTimeLogical);
280 TRACE_(dmfile)(" - lTimePhysical: %lu\n", pNewItem->header.lTimePhysical);
281 TRACE_(dmfile)(" - dwPlayFlags: 0x%08lx\n", pNewItem->header.dwPlayFlags);
282 TRACE_(dmfile)(" - dwFlags: 0x%08lx\n", pNewItem->header.dwFlags);
283 list_add_tail (&This->Items, &pNewItem->entry);
286 case DMUS_FOURCC_SEGMENTITEMNAME_CHUNK: {
287 TRACE_(dmfile)(": segment item name chunk\n");
288 IStream_Read (pStm, pNewItem->wszName, Chunk.dwSize, NULL);
289 TRACE_(dmfile)(" - name: %s\n", debugstr_w(pNewItem->wszName));
293 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
294 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
295 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
297 switch (Chunk.fccID) {
298 case DMUS_FOURCC_REF_LIST: {
299 FIXME_(dmfile)(": DMRF (DM References) list\n");
300 hr = IDirectMusicUtils_IPersistStream_ParseReference (iface, &Chunk, pStm, &pObject);
302 ERR(": could not load Reference\n");
305 pNewItem->pObject = pObject;
309 TRACE_(dmfile)(": unknown (skipping)\n");
310 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
311 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
318 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
319 liMove.QuadPart = Chunk.dwSize;
320 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
324 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
325 } while (ListCount[0] < ListSize[0]);
330 static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegmentsList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
331 /*ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);*/
333 DMUS_PRIVATE_CHUNK Chunk;
334 DWORD ListSize[3], ListCount[3];
335 LARGE_INTEGER liMove; /* used when skipping chunks */
337 if (pChunk->fccID != DMUS_FOURCC_SEGMENTS_LIST) {
338 ERR_(dmfile)(": %s chunk should be a SEGMENTS list\n", debugstr_fourcc (pChunk->fccID));
342 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
346 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
347 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
348 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
349 switch (Chunk.fccID) {
351 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
352 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
353 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
355 switch (Chunk.fccID) {
356 case DMUS_FOURCC_SEGMENT_LIST: {
357 TRACE_(dmfile)(": SEGMENT list\n");
358 hr = IDirectMusicSegTriggerTrack_IPersistStream_ParseSegment (iface, &Chunk, pStm);
359 if (FAILED(hr)) return hr;
363 TRACE_(dmfile)(": unknown (skipping)\n");
364 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
365 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
372 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
373 liMove.QuadPart = Chunk.dwSize;
374 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
378 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
379 } while (ListCount[0] < ListSize[0]);
384 static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegTrackList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
385 /*ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);*/
387 DMUS_PRIVATE_CHUNK Chunk;
388 DWORD ListSize[3], ListCount[3];
389 LARGE_INTEGER liMove; /* used when skipping chunks */
391 if (pChunk->fccID != DMUS_FOURCC_SEGTRACK_LIST) {
392 ERR_(dmfile)(": %s chunk should be a SEGTRACK list\n", debugstr_fourcc (pChunk->fccID));
396 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
400 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
401 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
402 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
403 switch (Chunk.fccID) {
404 case DMUS_FOURCC_SEGTRACK_CHUNK: {
405 TRACE_(dmfile)(": segment trigger track chunk\n");
406 liMove.QuadPart = Chunk.dwSize;
407 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
411 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
412 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
413 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
415 switch (Chunk.fccID) {
416 case DMUS_FOURCC_SEGMENTS_LIST: {
417 TRACE_(dmfile)(": SEGMENTS list\n");
418 hr = IDirectMusicSegTriggerTrack_IPersistStream_ParseSegmentsList (iface, &Chunk, pStm);
419 if (FAILED(hr)) return hr;
423 TRACE_(dmfile)(": unknown (skipping)\n");
424 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
425 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
432 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
433 liMove.QuadPart = Chunk.dwSize;
434 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
438 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
439 } while (ListCount[0] < ListSize[0]);
444 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
445 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);
447 DMUS_PRIVATE_CHUNK Chunk;
448 LARGE_INTEGER liMove;
451 TRACE("(%p, %p): Loading\n", This, pStm);
454 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
455 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
456 switch (Chunk.fccID) {
458 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
459 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
460 switch (Chunk.fccID) {
461 case DMUS_FOURCC_SEGTRACK_LIST: {
462 TRACE_(dmfile)(": segment trigger track list\n");
463 hr = IDirectMusicSegTriggerTrack_IPersistStream_ParseSegTrackList (iface, &Chunk, pStm);
464 if (FAILED(hr)) return hr;
468 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
469 liMove.QuadPart = Chunk.dwSize;
470 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
474 TRACE_(dmfile)(": reading finished\n");
478 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
479 liMove.QuadPart = Chunk.dwSize;
480 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
489 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
490 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);
491 FIXME("(%p): Saving not implemented yet\n", This);
495 static HRESULT WINAPI IDirectMusicSegTriggerTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
496 ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);
497 FIXME("(%p, %p): stub\n", This, pcbSize);
501 static const IPersistStreamVtbl DirectMusicSegTriggerTrack_PersistStream_Vtbl = {
502 IDirectMusicSegTriggerTrack_IPersistStream_QueryInterface,
503 IDirectMusicSegTriggerTrack_IPersistStream_AddRef,
504 IDirectMusicSegTriggerTrack_IPersistStream_Release,
505 IDirectMusicSegTriggerTrack_IPersistStream_GetClassID,
506 IDirectMusicSegTriggerTrack_IPersistStream_IsDirty,
507 IDirectMusicSegTriggerTrack_IPersistStream_Load,
508 IDirectMusicSegTriggerTrack_IPersistStream_Save,
509 IDirectMusicSegTriggerTrack_IPersistStream_GetSizeMax
512 /* for ClassFactory */
513 HRESULT WINAPI DMUSIC_CreateDirectMusicSegTriggerTrack (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
514 IDirectMusicSegTriggerTrack* track;
516 track = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSegTriggerTrack));
519 return E_OUTOFMEMORY;
521 track->UnknownVtbl = &DirectMusicSegTriggerTrack_Unknown_Vtbl;
522 track->TrackVtbl = &DirectMusicSegTriggerTrack_Track_Vtbl;
523 track->PersistStreamVtbl = &DirectMusicSegTriggerTrack_PersistStream_Vtbl;
524 track->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
525 DM_STRUCT_INIT(track->pDesc);
526 track->pDesc->dwValidData |= DMUS_OBJ_CLASS;
527 memcpy (&track->pDesc->guidClass, &CLSID_DirectMusicSegTriggerTrack, sizeof (CLSID));
528 track->ref = 0; /* will be inited by QueryInterface */
529 list_init (&track->Items);
531 return IDirectMusicSegTriggerTrack_IUnknown_QueryInterface ((LPUNKNOWN)&track->UnknownVtbl, lpcGUID, ppobj);