tempotrack.c 16.8 KB
Newer Older
1 2
/* IDirectMusicTempoTrack Implementation
 *
3
 * Copyright (C) 2003-2004 Rok Mandeljc
4
 * Copyright (C) 2004 Raphael Junqueira
5
 *
6 7 8 9
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
10 11 12
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
15
 *
16 17 18
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 20 21 22 23 24 25 26 27 28 29
 */

#include "dmime_private.h"

WINE_DEFAULT_DEBUG_CHANNEL(dmime);
WINE_DECLARE_DEBUG_CHANNEL(dmfile);

/*****************************************************************************
 * IDirectMusicTempoTrack implementation
 */
/* IDirectMusicTempoTrack IUnknown part: */
30
static HRESULT WINAPI IDirectMusicTempoTrack_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
31 32 33 34
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, UnknownVtbl, iface);
  TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
  
  if (IsEqualIID (riid, &IID_IUnknown)) {
35
    *ppobj = &This->UnknownVtbl;
36
    IUnknown_AddRef (iface);
37 38 39 40
    return S_OK;
  } else if (IsEqualIID (riid, &IID_IDirectMusicTrack)
	     || IsEqualIID (riid, &IID_IDirectMusicTrack8)) {
    *ppobj = (LPDIRECTMUSICTRACK8)&This->TrackVtbl;
41
    IUnknown_AddRef (iface);
42 43
    return S_OK;
  } else if (IsEqualIID (riid, &IID_IPersistStream)) {
44
    *ppobj = &This->PersistStreamVtbl;
45
    IUnknown_AddRef (iface);
46 47 48 49 50
    return S_OK;
  }
  
  WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
  return E_NOINTERFACE;
51 52
}

53
static ULONG WINAPI IDirectMusicTempoTrack_IUnknown_AddRef (LPUNKNOWN iface) {
54
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, UnknownVtbl, iface);
55 56
  ULONG ref = InterlockedIncrement(&This->ref);

57
  TRACE("(%p): AddRef from %d\n", This, ref - 1);
58

59 60
  DMIME_LockModule();

61
  return ref;
62 63
}

Mike McCormack's avatar
Mike McCormack committed
64
static 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 %d\n", This, ref);
68
  
69 70 71
  if (ref == 0) {
    HeapFree(GetProcessHeap(), 0, This);
  }
72 73 74

  DMIME_UnlockModule();
  
75
  return ref;
76 77
}

78
static const IUnknownVtbl DirectMusicTempoTrack_Unknown_Vtbl = {
79 80 81
  IDirectMusicTempoTrack_IUnknown_QueryInterface,
  IDirectMusicTempoTrack_IUnknown_AddRef,
  IDirectMusicTempoTrack_IUnknown_Release
82
};
83

84
/* IDirectMusicTempoTrack IDirectMusicTrack8 part: */
85
static HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_QueryInterface (LPDIRECTMUSICTRACK8 iface, REFIID riid, LPVOID *ppobj) {
86
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
87
  return IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
88
}
89

90
static ULONG WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_AddRef (LPDIRECTMUSICTRACK8 iface) {
91
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
92
  return IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
93 94
}

Mike McCormack's avatar
Mike McCormack committed
95
static ULONG WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_Release (LPDIRECTMUSICTRACK8 iface) {
96
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
97
  return IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
98 99
}

Mike McCormack's avatar
Mike McCormack committed
100
static HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_Init (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegment* pSegment)
101
{
102 103 104
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
  TRACE("(%p, %p): nothing to do here\n", This, pSegment);
  return S_OK;
105
}
106

Mike McCormack's avatar
Mike McCormack committed
107
static 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 112

  LPDMUS_PRIVATE_TEMPO_PLAY_STATE pState = NULL;

113
  FIXME("(%p, %p, %p, %p, %d, %d): semi-stub\n", This, pSegmentState, pPerformance, ppStateData, dwVirtualTrack8ID, dwFlags);
114 115 116 117 118 119

  pState = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_TEMPO_PLAY_STATE));
  if (NULL == pState) {
    ERR(": no more memory\n");
    return E_OUTOFMEMORY;
  }
120
  /** TODO real fill useful data */
121 122
  pState->dummy = 0;
  *ppStateData = pState;
123
  return S_OK;
124 125
}

Mike McCormack's avatar
Mike McCormack committed
126
static HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_EndPlay (LPDIRECTMUSICTRACK8 iface, void* pStateData)
127
{
128
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
129 130 131 132 133 134 135 136 137 138

  LPDMUS_PRIVATE_TEMPO_PLAY_STATE pState = pStateData;

  FIXME("(%p, %p): semi-stub\n", This, pStateData);

  if (NULL == pStateData) {
    return E_POINTER;
  }
  /** TODO real clean up */
  HeapFree(GetProcessHeap(), 0, pState);
139
  return S_OK;
140 141
}

Mike McCormack's avatar
Mike McCormack committed
142
static 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, %d, %d, %d, %d, %p, %p, %d): stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
146
  /** should use IDirectMusicPerformance_SendPMsg here */
147
  return S_OK;
148 149
}

Mike McCormack's avatar
Mike McCormack committed
150
static HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_GetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) {
151 152 153 154 155 156 157
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);

  HRESULT hr = S_OK;
  struct list* pEntry = NULL;
  LPDMUS_PRIVATE_TEMPO_ITEM pIt = NULL;
  DMUS_TEMPO_PARAM* prm = pParam;

158
  FIXME("(%p, %s, %d, %p, %p): almost stub\n", This, debugstr_dmguid(rguidType), mtTime, pmtNext, pParam);
159 160 161 162 163

  if (NULL == pParam) {
    return E_POINTER;
  }

164
  hr = IDirectMusicTrack_IsParamSupported (iface, rguidType);
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
  if (FAILED(hr)) {
    return hr;
  }
  if (FALSE == This->enabled) {
    return DMUS_E_TYPE_DISABLED;
  }

  if (NULL != pmtNext) *pmtNext = 0;
  prm->mtTime = 0;
  prm->dblTempo = 0.123456;

  LIST_FOR_EACH (pEntry, &This->Items) {
    pIt = LIST_ENTRY(pEntry, DMUS_PRIVATE_TEMPO_ITEM, entry);
    /*TRACE(" - %p -> 0x%lx,%p\n", pIt, pIt->item.lTime, pIt->item.dblTempo);*/
    if (pIt->item.lTime <= mtTime) {
      MUSIC_TIME ofs = pIt->item.lTime - mtTime;
      if (ofs > prm->mtTime) {
	prm->mtTime = ofs;
	prm->dblTempo = pIt->item.dblTempo;
      }	
      if (NULL != pmtNext && pIt->item.lTime > mtTime) {
	if (pIt->item.lTime < *pmtNext) {
	  *pmtNext = pIt->item.lTime;
	}
      }
    }
  }
  
  if (0.123456 == prm->dblTempo) {
    return DMUS_E_NOT_FOUND;
  }
  return S_OK;
197 198
}

Mike McCormack's avatar
Mike McCormack committed
199
static 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, %d, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pParam);
202 203 204
	return S_OK;
}

205
static HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_IsParamSupported (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType) {
206 207
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);

208
  TRACE("(%p, %s)\n", This, debugstr_dmguid(rguidType));
209 210 211 212 213 214 215 216 217 218 219
  if (IsEqualGUID (rguidType, &GUID_DisableTempo)
      || IsEqualGUID (rguidType, &GUID_EnableTempo)
      || IsEqualGUID (rguidType, &GUID_TempoParam)) {
    TRACE("param supported\n");
    return S_OK;
  }
  if (FALSE == This->enabled) {
    return DMUS_E_TYPE_DISABLED;
  }
  TRACE("param unsupported\n");
  return DMUS_E_TYPE_UNSUPPORTED;
220 221
}

Mike McCormack's avatar
Mike McCormack committed
222
static HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_AddNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType) {
223 224 225
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
  FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
  return S_OK;
226 227
}

Mike McCormack's avatar
Mike McCormack committed
228
static HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_RemoveNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType) {
229 230 231
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
  FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
  return S_OK;
232 233
}

Mike McCormack's avatar
Mike McCormack committed
234
static 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, %d, %d, %p): stub\n", This, mtStart, mtEnd, ppTrack);
237
  return S_OK;
238 239
}

Mike McCormack's avatar
Mike McCormack committed
240
static 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, 0x%s, 0x%s, 0x%s, %d, %p, %p, %d): stub\n", This, pStateData, wine_dbgstr_longlong(rtStart),
243
      wine_dbgstr_longlong(rtEnd), wine_dbgstr_longlong(rtOffset), dwFlags, pPerf, pSegSt, dwVirtualID);
244
  return S_OK;
245 246
}

Mike McCormack's avatar
Mike McCormack committed
247
static HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_GetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, REFERENCE_TIME* prtNext, void* pParam, void* pStateData, DWORD dwFlags) {
248
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
249
  FIXME("(%p, %s, 0x%s, %p, %p, %p, %d): stub\n", This, debugstr_dmguid(rguidType),
250
      wine_dbgstr_longlong(rtTime), prtNext, pParam, pStateData, dwFlags);
251
  return S_OK;
252 253
}

Mike McCormack's avatar
Mike McCormack committed
254
static HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_SetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, void* pParam, void* pStateData, DWORD dwFlags) {
255
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
256
  FIXME("(%p, %s, 0x%s, %p, %p, %d): stub\n", This, debugstr_dmguid(rguidType),
257
      wine_dbgstr_longlong(rtTime), pParam, pStateData, dwFlags);
258
  return S_OK;
259 260
}

Mike McCormack's avatar
Mike McCormack committed
261
static HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_Compose (LPDIRECTMUSICTRACK8 iface, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack) {
262
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
263
  FIXME("(%p, %p, %d, %p): stub\n", This, pContext, dwTrackGroup, ppResultTrack);
264
  return S_OK;
265 266
}

Mike McCormack's avatar
Mike McCormack committed
267
static HRESULT WINAPI IDirectMusicTempoTrack_IDirectMusicTrack_Join (LPDIRECTMUSICTRACK8 iface, IDirectMusicTrack* pNewTrack, MUSIC_TIME mtJoin, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack) {
268
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, TrackVtbl, iface);
269
  FIXME("(%p, %p, %d, %p, %d, %p): stub\n", This, pNewTrack, mtJoin, pContext, dwTrackGroup, ppResultTrack);
270
  return S_OK;
271 272
}

273
static const IDirectMusicTrack8Vtbl DirectMusicTempoTrack_Track_Vtbl = {
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
  IDirectMusicTempoTrack_IDirectMusicTrack_QueryInterface,
  IDirectMusicTempoTrack_IDirectMusicTrack_AddRef,
  IDirectMusicTempoTrack_IDirectMusicTrack_Release,
  IDirectMusicTempoTrack_IDirectMusicTrack_Init,
  IDirectMusicTempoTrack_IDirectMusicTrack_InitPlay,
  IDirectMusicTempoTrack_IDirectMusicTrack_EndPlay,
  IDirectMusicTempoTrack_IDirectMusicTrack_Play,
  IDirectMusicTempoTrack_IDirectMusicTrack_GetParam,
  IDirectMusicTempoTrack_IDirectMusicTrack_SetParam,
  IDirectMusicTempoTrack_IDirectMusicTrack_IsParamSupported,
  IDirectMusicTempoTrack_IDirectMusicTrack_AddNotificationType,
  IDirectMusicTempoTrack_IDirectMusicTrack_RemoveNotificationType,
  IDirectMusicTempoTrack_IDirectMusicTrack_Clone,
  IDirectMusicTempoTrack_IDirectMusicTrack_PlayEx,
  IDirectMusicTempoTrack_IDirectMusicTrack_GetParamEx,
  IDirectMusicTempoTrack_IDirectMusicTrack_SetParamEx,
  IDirectMusicTempoTrack_IDirectMusicTrack_Compose,
  IDirectMusicTempoTrack_IDirectMusicTrack_Join
292 293
};

294
/* IDirectMusicTempoTrack IPersistStream part: */
295
static HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
296
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
297
  return IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
298 299
}

300
static ULONG WINAPI IDirectMusicTempoTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
301
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
302
  return IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
303 304
}

Mike McCormack's avatar
Mike McCormack committed
305
static ULONG WINAPI IDirectMusicTempoTrack_IPersistStream_Release (LPPERSISTSTREAM iface) {
306
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
307
  return IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
308 309
}

Mike McCormack's avatar
Mike McCormack committed
310
static HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
311
  ICOM_THIS_MULTI(IDirectMusicSegment8Impl, PersistStreamVtbl, iface);
312
  TRACE("(%p, %p)\n", This, pClassID);
313
  *pClassID = CLSID_DirectMusicTempoTrack;
314
  return S_OK;
315 316
}

Mike McCormack's avatar
Mike McCormack committed
317
static HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
318 319 320
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
  FIXME("(%p): stub, always S_FALSE\n", This);
  return S_FALSE;
321 322
}

Mike McCormack's avatar
Mike McCormack committed
323
static HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
324 325 326 327 328
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
  DMUS_PRIVATE_CHUNK Chunk;
  DWORD StreamSize, StreamCount;
  LARGE_INTEGER liMove;
  DMUS_IO_TEMPO_ITEM item;
329
  LPDMUS_PRIVATE_TEMPO_ITEM pNewItem = NULL;
330 331 332 333 334
  DWORD nItem = 0;
  FIXME("(%p, %p): Loading not fully implemented yet\n", This, pStm);
  
#if 1
  IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
335
  TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
336 337
  switch (Chunk.fccID) {	
  case DMUS_FOURCC_TEMPO_TRACK: {
338
    TRACE_(dmfile)(": Tempo track\n");
339 340 341 342
#if 1
    IStream_Read (pStm, &StreamSize, sizeof(DWORD), NULL);
    StreamSize -= sizeof(DWORD);
    StreamCount = 0;
343
    TRACE_(dmfile)(" - sizeof(DMUS_IO_TEMPO_ITEM): %u (chunkSize = %u)\n", StreamSize, Chunk.dwSize);
344 345 346
    do {
      IStream_Read (pStm, &item, sizeof(item), NULL);
      ++nItem;
347
      TRACE_(dmfile)("DMUS_IO_TEMPO_ITEM #%d\n", nItem);
348
      TRACE_(dmfile)(" - lTime = %u\n", item.lTime);
349
      TRACE_(dmfile)(" - dblTempo = %g\n", item.dblTempo);
350 351 352 353 354
      pNewItem = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_TEMPO_ITEM));
      if (NULL == pNewItem) {
	ERR(": no more memory\n");
	return  E_OUTOFMEMORY;
      }
355
      pNewItem->item = item;
356 357
      list_add_tail (&This->Items, &pNewItem->entry);
      pNewItem = NULL;
358
      StreamCount += sizeof(item);
359
      TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
    } while (StreamCount < StreamSize); 
#else    
    liMove.QuadPart = Chunk.dwSize;
    IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
#endif
    break;
  }
  default: {
    TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
    liMove.QuadPart = Chunk.dwSize;
    IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
    return E_FAIL;
  }
  }
#endif

  return S_OK;
377 378
}

Mike McCormack's avatar
Mike McCormack committed
379
static HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
380 381 382
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
  FIXME("(%p): Saving not implemented yet\n", This);
  return E_NOTIMPL;
383 384
}

Mike McCormack's avatar
Mike McCormack committed
385
static HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
386 387 388
  ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
  FIXME("(%p, %p): stub\n", This, pcbSize);
  return E_NOTIMPL;
389 390
}

391
static const IPersistStreamVtbl DirectMusicTempoTrack_PersistStream_Vtbl = {
392 393 394 395 396 397 398 399
  IDirectMusicTempoTrack_IPersistStream_QueryInterface,
  IDirectMusicTempoTrack_IPersistStream_AddRef,
  IDirectMusicTempoTrack_IPersistStream_Release,
  IDirectMusicTempoTrack_IPersistStream_GetClassID,
  IDirectMusicTempoTrack_IPersistStream_IsDirty,
  IDirectMusicTempoTrack_IPersistStream_Load,
  IDirectMusicTempoTrack_IPersistStream_Save,
  IDirectMusicTempoTrack_IPersistStream_GetSizeMax
400
};
401 402 403

/* for ClassFactory */
HRESULT WINAPI DMUSIC_CreateDirectMusicTempoTrack (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
404
  IDirectMusicTempoTrack* track;
405
	
406 407
  track = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicTempoTrack));
  if (NULL == track) {
408
    *ppobj = NULL;
409 410 411 412 413 414 415 416
    return E_OUTOFMEMORY;
  }
  track->UnknownVtbl = &DirectMusicTempoTrack_Unknown_Vtbl;
  track->TrackVtbl = &DirectMusicTempoTrack_Track_Vtbl;
  track->PersistStreamVtbl = &DirectMusicTempoTrack_PersistStream_Vtbl;
  track->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
  DM_STRUCT_INIT(track->pDesc);
  track->pDesc->dwValidData |= DMUS_OBJ_CLASS;
417
  track->pDesc->guidClass = CLSID_DirectMusicTempoTrack;
418 419 420 421 422
  track->ref = 0; /* will be inited by QueryInterface */
  track->enabled = TRUE;
  list_init (&track->Items);

  return IDirectMusicTempoTrack_IUnknown_QueryInterface ((LPUNKNOWN)&track->UnknownVtbl, lpcGUID, ppobj);
423
}