Implementation stub for QueueUserWorkItem.
[wine] / dlls / dmime / tempotrack.c
1 /* IDirectMusicTempoTrack Implementation
2  *
3  * Copyright (C) 2003-2004 Rok Mandeljc
4  * Copyright (C) 2004 Raphael Junqueira
5  *
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.
10  *
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.
15  *
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 #include "dmime_private.h"
22
23 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
24 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
25
26 /*****************************************************************************
27  * IDirectMusicTempoTrack implementation
28  */
29 /* IDirectMusicTempoTrack IUnknown part: */
30 HRESULT WINAPI IDirectMusicTempoTrack_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
31   ICOM_THIS_MULTI(IDirectMusicTempoTrack, UnknownVtbl, iface);
32   TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
33   
34   if (IsEqualIID (riid, &IID_IUnknown)) {
35     *ppobj = (LPUNKNOWN)&This->UnknownVtbl;
36     IDirectMusicTempoTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
37     return S_OK;
38   } else if (IsEqualIID (riid, &IID_IDirectMusicTrack)
39              || IsEqualIID (riid, &IID_IDirectMusicTrack8)) {
40     *ppobj = (LPDIRECTMUSICTRACK8)&This->TrackVtbl;
41     IDirectMusicTempoTrack_IDirectMusicTrack_AddRef ((LPDIRECTMUSICTRACK8)&This->TrackVtbl);
42     return S_OK;
43   } else if (IsEqualIID (riid, &IID_IPersistStream)) {
44     *ppobj = (LPPERSISTSTREAM)&This->PersistStreamVtbl;
45     IDirectMusicTempoTrack_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
46     return S_OK;
47   }
48   
49   WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
50   return E_NOINTERFACE;
51 }
52
53 ULONG WINAPI IDirectMusicTempoTrack_IUnknown_AddRef (LPUNKNOWN iface) {
54   ICOM_THIS_MULTI(IDirectMusicTempoTrack, UnknownVtbl, iface);
55   ULONG ref = InterlockedIncrement(&This->ref);
56
57   TRACE("(%p): AddRef from %ld\n", This, ref - 1);
58
59   DMIME_LockModule();
60
61   return ref;
62 }
63
64 ULONG WINAPI IDirectMusicTempoTrack_IUnknown_Release (LPUNKNOWN iface) {
65   ICOM_THIS_MULTI(IDirectMusicTempoTrack, UnknownVtbl, iface);
66   ULONG ref = InterlockedDecrement(&This->ref);
67   TRACE("(%p): ReleaseRef to %ld\n", This, ref);
68   
69   if (ref == 0) {
70     HeapFree(GetProcessHeap(), 0, This);
71   }
72
73   DMIME_UnlockModule();
74   
75   return ref;
76 }
77
78 IUnknownVtbl DirectMusicTempoTrack_Unknown_Vtbl = {
79   IDirectMusicTempoTrack_IUnknown_QueryInterface,
80   IDirectMusicTempoTrack_IUnknown_AddRef,
81   IDirectMusicTempoTrack_IUnknown_Release
82 };
83
84 /* IDirectMusicTempoTrack IDirectMusicTrack8 part: */
85 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_QueryInterface (LPDIRECTMUSICTRACK8 iface, REFIID riid, LPVOID *ppobj) {
86   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
87   return IDirectMusicTempoTrack_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
88 }
89
90 ULONG WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_AddRef (LPDIRECTMUSICTRACK8 iface) {
91   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
92   return IDirectMusicTempoTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
93 }
94
95 ULONG WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_Release (LPDIRECTMUSICTRACK8 iface) {
96   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
97   return IDirectMusicTempoTrack_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
98 }
99
100 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_Init (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegment* pSegment)
101 {
102   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
103   TRACE("(%p, %p): nothing to do here\n", This, pSegment);
104   return S_OK;
105 }
106
107 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_InitPlay (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegmentState* pSegmentState, IDirectMusicPerformance* pPerformance, void** ppStateData, DWORD dwVirtualTrack8ID, DWORD dwFlags)
108 {
109   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
110
111   LPDMUS_PRIVATE_TEMPO_PLAY_STATE pState = NULL;
112
113   FIXME("(%p, %p, %p, %p, %ld, %ld): semi-stub\n", This, pSegmentState, pPerformance, ppStateData, dwVirtualTrack8ID, dwFlags);
114
115   pState = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_TEMPO_PLAY_STATE));
116   if (NULL == pState) {
117     ERR(": no more memory\n");
118     return E_OUTOFMEMORY;
119   }
120   /** TODO real fill usefull datas */
121   pState->dummy = 0;
122   *ppStateData = pState;
123   return S_OK;
124 }
125
126 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_EndPlay (LPDIRECTMUSICTRACK8 iface, void* pStateData)
127 {
128   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
129
130   LPDMUS_PRIVATE_TEMPO_PLAY_STATE pState = pStateData;
131
132   FIXME("(%p, %p): semi-stub\n", This, pStateData);
133
134   if (NULL == pStateData) {
135     return E_POINTER;
136   }
137   /** TODO real clean up */
138   HeapFree(GetProcessHeap(), 0, pState);
139   return S_OK;
140 }
141
142 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_Play (LPDIRECTMUSICTRACK8 iface, void* pStateData, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID)
143 {
144   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
145   FIXME("(%p, %p, %ld, %ld, %ld, %ld, %p, %p, %ld): stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
146   /** should use IDirectMusicPerformance_SendPMsg here */
147   return S_OK;
148 }
149
150 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_GetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) {
151   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
152
153   HRESULT hr = S_OK;
154   struct list* pEntry = NULL;
155   LPDMUS_PRIVATE_TEMPO_ITEM pIt = NULL;
156   DMUS_TEMPO_PARAM* prm = pParam;
157
158   FIXME("(%p, %s, %ld, %p, %p): almost stub\n", This, debugstr_dmguid(rguidType), mtTime, pmtNext, pParam);
159
160   if (NULL == pParam) {
161     return E_POINTER;
162   }
163
164   hr = IDirectMusicTempoTrack_IDirectMusicTrack_IsParamSupported (iface, rguidType);
165   if (FAILED(hr)) {
166     return hr;
167   }
168   if (FALSE == This->enabled) {
169     return DMUS_E_TYPE_DISABLED;
170   }
171
172   if (NULL != pmtNext) *pmtNext = 0;
173   prm->mtTime = 0;
174   prm->dblTempo = 0.123456;
175
176   LIST_FOR_EACH (pEntry, &This->Items) {
177     pIt = LIST_ENTRY(pEntry, DMUS_PRIVATE_TEMPO_ITEM, entry);
178     /*TRACE(" - %p -> 0x%lx,%p\n", pIt, pIt->item.lTime, pIt->item.dblTempo);*/
179     if (pIt->item.lTime <= mtTime) {
180       MUSIC_TIME ofs = pIt->item.lTime - mtTime;
181       if (ofs > prm->mtTime) {
182         prm->mtTime = ofs;
183         prm->dblTempo = pIt->item.dblTempo;
184       } 
185       if (NULL != pmtNext && pIt->item.lTime > mtTime) {
186         if (pIt->item.lTime < *pmtNext) {
187           *pmtNext = pIt->item.lTime;
188         }
189       }
190     }
191   }
192   
193   if (0.123456 == prm->dblTempo) {
194     return DMUS_E_NOT_FOUND;
195   }
196   return S_OK;
197 }
198
199 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_SetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, void* pParam) {
200         ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
201         FIXME("(%p, %s, %ld, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pParam);
202         return S_OK;
203 }
204
205 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_IsParamSupported (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType) {
206   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
207
208   TRACE("(%p, %s): ", This, debugstr_dmguid(rguidType));
209   if (IsEqualGUID (rguidType, &GUID_DisableTempo)
210       || IsEqualGUID (rguidType, &GUID_EnableTempo)
211       || IsEqualGUID (rguidType, &GUID_TempoParam)) {
212     TRACE("param supported\n");
213     return S_OK;
214   }
215   if (FALSE == This->enabled) {
216     return DMUS_E_TYPE_DISABLED;
217   }
218   TRACE("param unsupported\n");
219   return DMUS_E_TYPE_UNSUPPORTED;
220 }
221
222 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_AddNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType) {
223   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
224   FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
225   return S_OK;
226 }
227
228 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_RemoveNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType) {
229   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
230   FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
231   return S_OK;
232 }
233
234 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_Clone (LPDIRECTMUSICTRACK8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, IDirectMusicTrack** ppTrack) {
235   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
236   FIXME("(%p, %ld, %ld, %p): stub\n", This, mtStart, mtEnd, ppTrack);
237   return S_OK;
238 }
239
240 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_PlayEx (LPDIRECTMUSICTRACK8 iface, void* pStateData, REFERENCE_TIME rtStart, REFERENCE_TIME rtEnd, REFERENCE_TIME rtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID) {
241   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
242   FIXME("(%p, %p, %lli, %lli, %lli, %ld, %p, %p, %ld): stub\n", This, pStateData, rtStart, rtEnd, rtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
243   return S_OK;
244 }
245
246 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_GetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, REFERENCE_TIME* prtNext, void* pParam, void* pStateData, DWORD dwFlags) {
247   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
248   FIXME("(%p, %s, %lli, %p, %p, %p, %ld): stub\n", This, debugstr_dmguid(rguidType), rtTime, prtNext, pParam, pStateData, dwFlags);
249   return S_OK;
250 }
251
252 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_SetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, void* pParam, void* pStateData, DWORD dwFlags) {
253   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
254   FIXME("(%p, %s, %lli, %p, %p, %ld): stub\n", This, debugstr_dmguid(rguidType), rtTime, pParam, pStateData, dwFlags);
255   return S_OK;
256 }
257
258 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_Compose (LPDIRECTMUSICTRACK8 iface, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack) {
259   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
260   FIXME("(%p, %p, %ld, %p): stub\n", This, pContext, dwTrackGroup, ppResultTrack);
261   return S_OK;
262 }
263
264 HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_Join (LPDIRECTMUSICTRACK8 iface, IDirectMusicTrack* pNewTrack, MUSIC_TIME mtJoin, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack) {
265   ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
266   FIXME("(%p, %p, %ld, %p, %ld, %p): stub\n", This, pNewTrack, mtJoin, pContext, dwTrackGroup, ppResultTrack);
267   return S_OK;
268 }
269
270 IDirectMusicTrack8Vtbl DirectMusicTempoTrack_Track_Vtbl = {
271   IDirectMusicTempoTrack_IDirectMusicTrack_QueryInterface,
272   IDirectMusicTempoTrack_IDirectMusicTrack_AddRef,
273   IDirectMusicTempoTrack_IDirectMusicTrack_Release,
274   IDirectMusicTempoTrack_IDirectMusicTrack_Init,
275   IDirectMusicTempoTrack_IDirectMusicTrack_InitPlay,
276   IDirectMusicTempoTrack_IDirectMusicTrack_EndPlay,
277   IDirectMusicTempoTrack_IDirectMusicTrack_Play,
278   IDirectMusicTempoTrack_IDirectMusicTrack_GetParam,
279   IDirectMusicTempoTrack_IDirectMusicTrack_SetParam,
280   IDirectMusicTempoTrack_IDirectMusicTrack_IsParamSupported,
281   IDirectMusicTempoTrack_IDirectMusicTrack_AddNotificationType,
282   IDirectMusicTempoTrack_IDirectMusicTrack_RemoveNotificationType,
283   IDirectMusicTempoTrack_IDirectMusicTrack_Clone,
284   IDirectMusicTempoTrack_IDirectMusicTrack_PlayEx,
285   IDirectMusicTempoTrack_IDirectMusicTrack_GetParamEx,
286   IDirectMusicTempoTrack_IDirectMusicTrack_SetParamEx,
287   IDirectMusicTempoTrack_IDirectMusicTrack_Compose,
288   IDirectMusicTempoTrack_IDirectMusicTrack_Join
289 };
290
291 /* IDirectMusicTempoTrack IPersistStream part: */
292 HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
293   ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
294   return IDirectMusicTempoTrack_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
295 }
296
297 ULONG WINAPI IDirectMusicTempoTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
298   ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
299   return IDirectMusicTempoTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
300 }
301
302 ULONG WINAPI IDirectMusicTempoTrack_IPersistStream_Release (LPPERSISTSTREAM iface) {
303   ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
304   return IDirectMusicTempoTrack_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
305 }
306
307 HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
308   ICOM_THIS_MULTI(IDirectMusicSegment8Impl, PersistStreamVtbl, iface);
309   TRACE("(%p, %p)\n", This, pClassID);
310   memcpy(pClassID, &CLSID_DirectMusicTempoTrack, sizeof(CLSID));
311   return S_OK;
312 }
313
314 HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
315   ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
316   FIXME("(%p): stub, always S_FALSE\n", This);
317   return S_FALSE;
318 }
319
320 HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
321   ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
322   DMUS_PRIVATE_CHUNK Chunk;
323   DWORD StreamSize, StreamCount;
324   LARGE_INTEGER liMove;
325   DMUS_IO_TEMPO_ITEM item;
326   LPDMUS_PRIVATE_TEMPO_ITEM pNewItem = NULL;
327   DWORD nItem = 0;
328   FIXME("(%p, %p): Loading not fully implemented yet\n", This, pStm);
329   
330 #if 1
331   IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
332   TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
333   switch (Chunk.fccID) {        
334   case DMUS_FOURCC_TEMPO_TRACK: {
335     TRACE_(dmfile)(": Tempo track\n");
336 #if 1
337     IStream_Read (pStm, &StreamSize, sizeof(DWORD), NULL);
338     StreamSize -= sizeof(DWORD);
339     StreamCount = 0;
340     TRACE_(dmfile)(" - sizeof(DMUS_IO_TEMPO_ITEM): %lu (chunkSize = %lu)\n", StreamSize, Chunk.dwSize - sizeof(DWORD));
341     do {
342       IStream_Read (pStm, &item, sizeof(item), NULL);
343       ++nItem;
344       TRACE_(dmfile)("DMUS_IO_TEMPO_ITEM #%ld\n", nItem);
345       TRACE_(dmfile)(" - lTime = %lu\n", item.lTime);
346       TRACE_(dmfile)(" - dblTempo = %g\n", item.dblTempo);
347       pNewItem = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_TEMPO_ITEM));
348       if (NULL == pNewItem) {
349         ERR(": no more memory\n");
350         return  E_OUTOFMEMORY;
351       }
352       memcpy(&pNewItem->item, &item, sizeof(DMUS_IO_TEMPO_ITEM));
353       list_add_tail (&This->Items, &pNewItem->entry);
354       pNewItem = NULL;
355       StreamCount += sizeof(item);
356       TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount, StreamSize);
357     } while (StreamCount < StreamSize); 
358 #else    
359     liMove.QuadPart = Chunk.dwSize;
360     IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
361 #endif
362     break;
363   }
364   default: {
365     TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
366     liMove.QuadPart = Chunk.dwSize;
367     IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
368     return E_FAIL;
369   }
370   }
371 #endif
372
373   return S_OK;
374 }
375
376 HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
377   ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
378   FIXME("(%p): Saving not implemented yet\n", This);
379   return E_NOTIMPL;
380 }
381
382 HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
383   ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
384   FIXME("(%p, %p): stub\n", This, pcbSize);
385   return E_NOTIMPL;
386 }
387
388 IPersistStreamVtbl DirectMusicTempoTrack_PersistStream_Vtbl = {
389   IDirectMusicTempoTrack_IPersistStream_QueryInterface,
390   IDirectMusicTempoTrack_IPersistStream_AddRef,
391   IDirectMusicTempoTrack_IPersistStream_Release,
392   IDirectMusicTempoTrack_IPersistStream_GetClassID,
393   IDirectMusicTempoTrack_IPersistStream_IsDirty,
394   IDirectMusicTempoTrack_IPersistStream_Load,
395   IDirectMusicTempoTrack_IPersistStream_Save,
396   IDirectMusicTempoTrack_IPersistStream_GetSizeMax
397 };
398
399 /* for ClassFactory */
400 HRESULT WINAPI DMUSIC_CreateDirectMusicTempoTrack (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
401   IDirectMusicTempoTrack* track;
402         
403   track = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicTempoTrack));
404   if (NULL == track) {
405     *ppobj = NULL;
406     return E_OUTOFMEMORY;
407   }
408   track->UnknownVtbl = &DirectMusicTempoTrack_Unknown_Vtbl;
409   track->TrackVtbl = &DirectMusicTempoTrack_Track_Vtbl;
410   track->PersistStreamVtbl = &DirectMusicTempoTrack_PersistStream_Vtbl;
411   track->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
412   DM_STRUCT_INIT(track->pDesc);
413   track->pDesc->dwValidData |= DMUS_OBJ_CLASS;
414   memcpy (&track->pDesc->guidClass, &CLSID_DirectMusicTempoTrack, sizeof (CLSID));
415   track->ref = 0; /* will be inited by QueryInterface */
416   track->enabled = TRUE;
417   list_init (&track->Items);
418
419   return IDirectMusicTempoTrack_IUnknown_QueryInterface ((LPUNKNOWN)&track->UnknownVtbl, lpcGUID, ppobj);
420 }