msvcrt: Add scheduler_resource_allocation_error class implementation.
[wine.git] / dlls / dmime / segtriggertrack.c
blobd1b208a6d04a8f8f1b394f05b80c1ef4d0d63b28
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
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License 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"
22 #include "dmobject.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
25 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
27 /*****************************************************************************
28 * IDirectMusicSegTriggerTrack implementation
30 typedef struct IDirectMusicSegTriggerTrack {
31 IDirectMusicTrack8 IDirectMusicTrack8_iface;
32 struct dmobject dmobj;/* IPersistStream only */
33 LONG ref;
34 struct list Items;
35 } IDirectMusicSegTriggerTrack;
37 /* IDirectMusicSegTriggerTrack IDirectMusicTrack8 part: */
38 static inline IDirectMusicSegTriggerTrack *impl_from_IDirectMusicTrack8(IDirectMusicTrack8 *iface)
40 return CONTAINING_RECORD(iface, IDirectMusicSegTriggerTrack, IDirectMusicTrack8_iface);
43 static HRESULT WINAPI IDirectMusicTrack8Impl_QueryInterface(IDirectMusicTrack8 *iface, REFIID riid,
44 void **ret_iface)
46 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
48 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
50 *ret_iface = NULL;
52 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicTrack) ||
53 IsEqualIID(riid, &IID_IDirectMusicTrack8))
54 *ret_iface = iface;
55 else if (IsEqualIID(riid, &IID_IPersistStream))
56 *ret_iface = &This->dmobj.IPersistStream_iface;
57 else {
58 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
59 return E_NOINTERFACE;
62 IUnknown_AddRef((IUnknown*)*ret_iface);
63 return S_OK;
66 static ULONG WINAPI IDirectMusicTrack8Impl_AddRef(IDirectMusicTrack8 *iface)
68 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
69 LONG ref = InterlockedIncrement(&This->ref);
71 TRACE("(%p) ref=%d\n", This, ref);
73 return ref;
76 static ULONG WINAPI IDirectMusicTrack8Impl_Release(IDirectMusicTrack8 *iface)
78 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
79 LONG ref = InterlockedDecrement(&This->ref);
81 TRACE("(%p) ref=%d\n", This, ref);
83 if (!ref) {
84 HeapFree(GetProcessHeap(), 0, This);
85 DMIME_UnlockModule();
88 return ref;
91 static HRESULT WINAPI IDirectMusicTrack8Impl_Init(IDirectMusicTrack8 *iface,
92 IDirectMusicSegment *pSegment)
94 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
95 FIXME("(%p, %p): stub\n", This, pSegment);
96 return S_OK;
99 static HRESULT WINAPI IDirectMusicTrack8Impl_InitPlay(IDirectMusicTrack8 *iface,
100 IDirectMusicSegmentState *pSegmentState, IDirectMusicPerformance *pPerformance,
101 void **ppStateData, DWORD dwVirtualTrack8ID, DWORD dwFlags)
103 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
104 FIXME("(%p, %p, %p, %p, %d, %d): stub\n", This, pSegmentState, pPerformance, ppStateData, dwVirtualTrack8ID, dwFlags);
105 return S_OK;
108 static HRESULT WINAPI IDirectMusicTrack8Impl_EndPlay(IDirectMusicTrack8 *iface, void *pStateData)
110 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
111 FIXME("(%p, %p): stub\n", This, pStateData);
112 return S_OK;
115 static HRESULT WINAPI IDirectMusicTrack8Impl_Play(IDirectMusicTrack8 *iface, void *pStateData,
116 MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD dwFlags,
117 IDirectMusicPerformance *pPerf, IDirectMusicSegmentState *pSegSt, DWORD dwVirtualID)
119 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
120 FIXME("(%p, %p, %d, %d, %d, %d, %p, %p, %d): stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
121 return S_OK;
124 static HRESULT WINAPI IDirectMusicTrack8Impl_GetParam(IDirectMusicTrack8 *iface, REFGUID rguidType,
125 MUSIC_TIME mtTime, MUSIC_TIME *pmtNext, void *pParam)
127 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
128 FIXME("(%p, %s, %d, %p, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pmtNext, pParam);
129 return S_OK;
132 static HRESULT WINAPI IDirectMusicTrack8Impl_SetParam(IDirectMusicTrack8 *iface, REFGUID rguidType,
133 MUSIC_TIME mtTime, void *pParam)
135 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
136 FIXME("(%p, %s, %d, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pParam);
137 return S_OK;
140 static HRESULT WINAPI IDirectMusicTrack8Impl_IsParamSupported(IDirectMusicTrack8 *iface,
141 REFGUID rguidType)
143 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
145 TRACE("(%p, %s)\n", This, debugstr_dmguid(rguidType));
146 /* didn't find any params */
147 TRACE("param unsupported\n");
148 return DMUS_E_TYPE_UNSUPPORTED;
151 static HRESULT WINAPI IDirectMusicTrack8Impl_AddNotificationType(IDirectMusicTrack8 *iface,
152 REFGUID notiftype)
154 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
156 TRACE("(%p, %s): method not implemented\n", This, debugstr_dmguid(notiftype));
157 return E_NOTIMPL;
160 static HRESULT WINAPI IDirectMusicTrack8Impl_RemoveNotificationType(IDirectMusicTrack8 *iface,
161 REFGUID notiftype)
163 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
165 TRACE("(%p, %s): method not implemented\n", This, debugstr_dmguid(notiftype));
166 return E_NOTIMPL;
169 static HRESULT WINAPI IDirectMusicTrack8Impl_Clone(IDirectMusicTrack8 *iface, MUSIC_TIME mtStart,
170 MUSIC_TIME mtEnd, IDirectMusicTrack **ppTrack)
172 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
173 FIXME("(%p, %d, %d, %p): stub\n", This, mtStart, mtEnd, ppTrack);
174 return S_OK;
177 static HRESULT WINAPI IDirectMusicTrack8Impl_PlayEx(IDirectMusicTrack8 *iface, void *pStateData,
178 REFERENCE_TIME rtStart, REFERENCE_TIME rtEnd, REFERENCE_TIME rtOffset, DWORD dwFlags,
179 IDirectMusicPerformance *pPerf, IDirectMusicSegmentState *pSegSt, DWORD dwVirtualID)
181 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
182 FIXME("(%p, %p, 0x%s, 0x%s, 0x%s, %d, %p, %p, %d): stub\n", This, pStateData, wine_dbgstr_longlong(rtStart),
183 wine_dbgstr_longlong(rtEnd), wine_dbgstr_longlong(rtOffset), dwFlags, pPerf, pSegSt, dwVirtualID);
184 return S_OK;
187 static HRESULT WINAPI IDirectMusicTrack8Impl_GetParamEx(IDirectMusicTrack8 *iface,
188 REFGUID rguidType, REFERENCE_TIME rtTime, REFERENCE_TIME *prtNext, void *pParam,
189 void *pStateData, DWORD dwFlags)
191 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
192 FIXME("(%p, %s, 0x%s, %p, %p, %p, %d): stub\n", This, debugstr_dmguid(rguidType),
193 wine_dbgstr_longlong(rtTime), prtNext, pParam, pStateData, dwFlags);
194 return S_OK;
197 static HRESULT WINAPI IDirectMusicTrack8Impl_SetParamEx(IDirectMusicTrack8 *iface,
198 REFGUID rguidType, REFERENCE_TIME rtTime, void *pParam, void *pStateData, DWORD dwFlags)
200 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
201 FIXME("(%p, %s, 0x%s, %p, %p, %d): stub\n", This, debugstr_dmguid(rguidType),
202 wine_dbgstr_longlong(rtTime), pParam, pStateData, dwFlags);
203 return S_OK;
206 static HRESULT WINAPI IDirectMusicTrack8Impl_Compose(IDirectMusicTrack8 *iface, IUnknown *context,
207 DWORD trackgroup, IDirectMusicTrack **track)
209 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
211 TRACE("(%p, %p, %d, %p): method not implemented\n", This, context, trackgroup, track);
212 return E_NOTIMPL;
215 static HRESULT WINAPI IDirectMusicTrack8Impl_Join(IDirectMusicTrack8 *iface,
216 IDirectMusicTrack *newtrack, MUSIC_TIME join, IUnknown *context, DWORD trackgroup,
217 IDirectMusicTrack **resulttrack)
219 IDirectMusicSegTriggerTrack *This = impl_from_IDirectMusicTrack8(iface);
220 TRACE("(%p, %p, %d, %p, %d, %p): method not implemented\n", This, newtrack, join, context,
221 trackgroup, resulttrack);
222 return E_NOTIMPL;
225 static const IDirectMusicTrack8Vtbl dmtrack8_vtbl = {
226 IDirectMusicTrack8Impl_QueryInterface,
227 IDirectMusicTrack8Impl_AddRef,
228 IDirectMusicTrack8Impl_Release,
229 IDirectMusicTrack8Impl_Init,
230 IDirectMusicTrack8Impl_InitPlay,
231 IDirectMusicTrack8Impl_EndPlay,
232 IDirectMusicTrack8Impl_Play,
233 IDirectMusicTrack8Impl_GetParam,
234 IDirectMusicTrack8Impl_SetParam,
235 IDirectMusicTrack8Impl_IsParamSupported,
236 IDirectMusicTrack8Impl_AddNotificationType,
237 IDirectMusicTrack8Impl_RemoveNotificationType,
238 IDirectMusicTrack8Impl_Clone,
239 IDirectMusicTrack8Impl_PlayEx,
240 IDirectMusicTrack8Impl_GetParamEx,
241 IDirectMusicTrack8Impl_SetParamEx,
242 IDirectMusicTrack8Impl_Compose,
243 IDirectMusicTrack8Impl_Join
246 static HRESULT parse_segment(IDirectMusicSegTriggerTrack *This, DMUS_PRIVATE_CHUNK *pChunk,
247 IStream *pStm)
249 DMUS_PRIVATE_CHUNK Chunk;
250 DWORD ListSize[3], ListCount[3];
251 LARGE_INTEGER liMove; /* used when skipping chunks */
252 HRESULT hr;
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));
259 return E_FAIL;
262 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
263 ListCount[0] = 0;
265 do {
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 = %d)", 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 (!pNewItem)
275 return E_OUTOFMEMORY;
277 IStream_Read (pStm, &pNewItem->header, sizeof(DMUS_IO_SEGMENT_ITEM_HEADER), NULL);
278 TRACE_(dmfile)(" - lTimePhysical: %u\n", pNewItem->header.lTimeLogical);
279 TRACE_(dmfile)(" - lTimePhysical: %u\n", pNewItem->header.lTimePhysical);
280 TRACE_(dmfile)(" - dwPlayFlags: 0x%08x\n", pNewItem->header.dwPlayFlags);
281 TRACE_(dmfile)(" - dwFlags: 0x%08x\n", pNewItem->header.dwFlags);
282 list_add_tail (&This->Items, &pNewItem->entry);
283 break;
285 case DMUS_FOURCC_SEGMENTITEMNAME_CHUNK: {
286 TRACE_(dmfile)(": segment item name chunk\n");
287 if (!pNewItem) {
288 ERR(": pNewItem not allocated, bad chunk order?\n");
289 return E_FAIL;
291 IStream_Read (pStm, pNewItem->wszName, Chunk.dwSize, NULL);
292 TRACE_(dmfile)(" - name: %s\n", debugstr_w(pNewItem->wszName));
293 break;
295 case FOURCC_LIST: {
296 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
297 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
298 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
299 ListCount[1] = 0;
300 switch (Chunk.fccID) {
301 case DMUS_FOURCC_REF_LIST: {
302 FIXME_(dmfile)(": DMRF (DM References) list\n");
303 hr = IDirectMusicUtils_IPersistStream_ParseReference(&This->dmobj.IPersistStream_iface,
304 &Chunk, pStm, &pObject);
305 if (FAILED(hr)) {
306 ERR(": could not load Reference\n");
307 return hr;
309 if (!pNewItem) {
310 ERR(": pNewItem not allocated, bad chunk order?\n");
311 return E_FAIL;
313 pNewItem->pObject = pObject;
314 break;
316 default: {
317 TRACE_(dmfile)(": unknown (skipping)\n");
318 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
319 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
320 break;
323 break;
325 default: {
326 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
327 liMove.QuadPart = Chunk.dwSize;
328 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
329 break;
332 TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
333 } while (ListCount[0] < ListSize[0]);
335 return S_OK;
338 static HRESULT parse_segments_list(IDirectMusicSegTriggerTrack *This, DMUS_PRIVATE_CHUNK *pChunk,
339 IStream *pStm)
341 HRESULT hr = E_FAIL;
342 DMUS_PRIVATE_CHUNK Chunk;
343 DWORD ListSize[3], ListCount[3];
344 LARGE_INTEGER liMove; /* used when skipping chunks */
346 if (pChunk->fccID != DMUS_FOURCC_SEGMENTS_LIST) {
347 ERR_(dmfile)(": %s chunk should be a SEGMENTS list\n", debugstr_fourcc (pChunk->fccID));
348 return E_FAIL;
351 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
352 ListCount[0] = 0;
354 do {
355 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
356 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
357 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
358 switch (Chunk.fccID) {
359 case FOURCC_LIST: {
360 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
361 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
362 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
363 ListCount[1] = 0;
364 switch (Chunk.fccID) {
365 case DMUS_FOURCC_SEGMENT_LIST: {
366 TRACE_(dmfile)(": SEGMENT list\n");
367 hr = parse_segment(This, &Chunk, pStm);
368 if (FAILED(hr)) return hr;
369 break;
371 default: {
372 TRACE_(dmfile)(": unknown (skipping)\n");
373 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
374 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
375 break;
378 break;
380 default: {
381 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
382 liMove.QuadPart = Chunk.dwSize;
383 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
384 break;
387 TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
388 } while (ListCount[0] < ListSize[0]);
390 return S_OK;
393 static HRESULT parse_seqtrack_list(IDirectMusicSegTriggerTrack *This, DMUS_PRIVATE_CHUNK *pChunk,
394 IStream *pStm)
396 HRESULT hr = E_FAIL;
397 DMUS_PRIVATE_CHUNK Chunk;
398 DWORD ListSize[3], ListCount[3];
399 LARGE_INTEGER liMove; /* used when skipping chunks */
401 if (pChunk->fccID != DMUS_FOURCC_SEGTRACK_LIST) {
402 ERR_(dmfile)(": %s chunk should be a SEGTRACK list\n", debugstr_fourcc (pChunk->fccID));
403 return E_FAIL;
406 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
407 ListCount[0] = 0;
409 do {
410 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
411 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
412 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
413 switch (Chunk.fccID) {
414 case DMUS_FOURCC_SEGTRACK_CHUNK: {
415 TRACE_(dmfile)(": segment trigger track chunk\n");
416 liMove.QuadPart = Chunk.dwSize;
417 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
418 break;
420 case FOURCC_LIST: {
421 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
422 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
423 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
424 ListCount[1] = 0;
425 switch (Chunk.fccID) {
426 case DMUS_FOURCC_SEGMENTS_LIST: {
427 TRACE_(dmfile)(": SEGMENTS list\n");
428 hr = parse_segments_list(This, &Chunk, pStm);
429 if (FAILED(hr)) return hr;
430 break;
432 default: {
433 TRACE_(dmfile)(": unknown (skipping)\n");
434 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
435 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
436 break;
439 break;
441 default: {
442 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
443 liMove.QuadPart = Chunk.dwSize;
444 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
445 break;
448 TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
449 } while (ListCount[0] < ListSize[0]);
451 return S_OK;
454 static inline IDirectMusicSegTriggerTrack *impl_from_IPersistStream(IPersistStream *iface)
456 return CONTAINING_RECORD(iface, IDirectMusicSegTriggerTrack, dmobj.IPersistStream_iface);
459 static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pStm)
461 IDirectMusicSegTriggerTrack *This = impl_from_IPersistStream(iface);
462 DMUS_PRIVATE_CHUNK Chunk;
463 LARGE_INTEGER liMove;
464 HRESULT hr;
466 TRACE("(%p, %p): Loading\n", This, pStm);
468 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
469 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
470 switch (Chunk.fccID) {
471 case FOURCC_LIST: {
472 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
473 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
474 switch (Chunk.fccID) {
475 case DMUS_FOURCC_SEGTRACK_LIST: {
476 TRACE_(dmfile)(": segment trigger track list\n");
477 hr = parse_seqtrack_list(This, &Chunk, pStm);
478 if (FAILED(hr)) return hr;
479 break;
481 default: {
482 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
483 liMove.QuadPart = Chunk.dwSize;
484 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
485 return E_FAIL;
488 TRACE_(dmfile)(": reading finished\n");
489 break;
491 default: {
492 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
493 liMove.QuadPart = Chunk.dwSize;
494 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
495 return E_FAIL;
499 return S_OK;
502 static const IPersistStreamVtbl persiststream_vtbl = {
503 dmobj_IPersistStream_QueryInterface,
504 dmobj_IPersistStream_AddRef,
505 dmobj_IPersistStream_Release,
506 dmobj_IPersistStream_GetClassID,
507 unimpl_IPersistStream_IsDirty,
508 IPersistStreamImpl_Load,
509 unimpl_IPersistStream_Save,
510 unimpl_IPersistStream_GetSizeMax
513 /* for ClassFactory */
514 HRESULT WINAPI create_dmsegtriggertrack(REFIID lpcGUID, void **ppobj)
516 IDirectMusicSegTriggerTrack *track;
517 HRESULT hr;
519 track = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track));
520 if (!track) {
521 *ppobj = NULL;
522 return E_OUTOFMEMORY;
524 track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl;
525 track->ref = 1;
526 dmobject_init(&track->dmobj, &CLSID_DirectMusicSegTriggerTrack,
527 (IUnknown *)&track->IDirectMusicTrack8_iface);
528 track->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
529 list_init(&track->Items);
531 DMIME_LockModule();
532 hr = IDirectMusicTrack8_QueryInterface(&track->IDirectMusicTrack8_iface, lpcGUID, ppobj);
533 IDirectMusicTrack8_Release(&track->IDirectMusicTrack8_iface);
535 return hr;