chordtrack.c 18.1 KB
Newer Older
1 2
/* IDirectMusicChordTrack Implementation
 *
3
 * Copyright (C) 2003-2004 Rok Mandeljc
4
 * Copyright (C) 2003-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
 */

#include "dmstyle_private.h"

WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
WINE_DECLARE_DEBUG_CHANNEL(dmfile);

26 27 28 29
static ULONG WINAPI IDirectMusicChordTrack_IUnknown_AddRef (LPUNKNOWN iface);
static ULONG WINAPI IDirectMusicChordTrack_IDirectMusicTrack_AddRef (LPDIRECTMUSICTRACK8 iface);
static ULONG WINAPI IDirectMusicChordTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface);

30 31 32 33
/*****************************************************************************
 * IDirectMusicChordTrack implementation
 */
/* IDirectMusicChordTrack IUnknown part: */
34
static HRESULT WINAPI IDirectMusicChordTrack_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
35
	ICOM_THIS_MULTI(IDirectMusicChordTrack, UnknownVtbl, iface);
36
	TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
37

38
	if (IsEqualIID (riid, &IID_IUnknown)) {
39
		*ppobj = &This->UnknownVtbl;
40 41 42 43 44 45
		IDirectMusicChordTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
		return S_OK;
	} else if (IsEqualIID (riid, &IID_IDirectMusicTrack)
	  || IsEqualIID (riid, &IID_IDirectMusicTrack8)) {
		*ppobj = (LPDIRECTMUSICTRACK8)&This->TrackVtbl;
		IDirectMusicChordTrack_IDirectMusicTrack_AddRef ((LPDIRECTMUSICTRACK8)&This->TrackVtbl);
46 47
		return S_OK;
	} else if (IsEqualIID (riid, &IID_IPersistStream)) {
48
		*ppobj = &This->PersistStreamVtbl;
49
		IDirectMusicChordTrack_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
50 51
		return S_OK;
	}
52
	
53
	WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
54 55 56
	return E_NOINTERFACE;
}

57
static ULONG WINAPI IDirectMusicChordTrack_IUnknown_AddRef (LPUNKNOWN iface) {
58
	ICOM_THIS_MULTI(IDirectMusicChordTrack, UnknownVtbl, iface);
59 60
        ULONG ref = InterlockedIncrement(&This->ref);

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

63 64
	DMSTYLE_LockModule();

65
	return ref;
66 67
}

68
static ULONG WINAPI IDirectMusicChordTrack_IUnknown_Release (LPUNKNOWN iface) {
69
	ICOM_THIS_MULTI(IDirectMusicChordTrack, UnknownVtbl, iface);
70 71
	ULONG ref = InterlockedDecrement(&This->ref);

72
	TRACE("(%p): ReleaseRef to %d\n", This, ref);
73

74 75 76
	if (ref == 0) {
		HeapFree(GetProcessHeap(), 0, This);
	}
77 78 79

	DMSTYLE_UnlockModule();

80 81 82
	return ref;
}

83
static const IUnknownVtbl DirectMusicChordTrack_Unknown_Vtbl = {
84 85 86
  IDirectMusicChordTrack_IUnknown_QueryInterface,
  IDirectMusicChordTrack_IUnknown_AddRef,
  IDirectMusicChordTrack_IUnknown_Release
87
};
88

89
/* IDirectMusicChordTrack IDirectMusicTrack8 part: */
90
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_QueryInterface (LPDIRECTMUSICTRACK8 iface, REFIID riid, LPVOID *ppobj) {
91 92
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
  return IDirectMusicChordTrack_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
93
}
94

95
static ULONG WINAPI IDirectMusicChordTrack_IDirectMusicTrack_AddRef (LPDIRECTMUSICTRACK8 iface) {
96 97
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
  return IDirectMusicChordTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
98 99
}

100
static ULONG WINAPI IDirectMusicChordTrack_IDirectMusicTrack_Release (LPDIRECTMUSICTRACK8 iface) {
101 102
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
  return IDirectMusicChordTrack_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
103 104
}

105
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_Init (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegment* pSegment) {
106 107 108
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
  FIXME("(%p, %p): stub\n", This, pSegment);
  return S_OK;
109
}
110

111
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_InitPlay (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegmentState* pSegmentState, IDirectMusicPerformance* pPerformance, void** ppStateData, DWORD dwVirtualTrack8ID, DWORD dwFlags)
112
{
113
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
114
  FIXME("(%p, %p, %p, %p, %d, %d): stub\n", This, pSegmentState, pPerformance, ppStateData, dwVirtualTrack8ID, dwFlags);
115
  return S_OK;
116 117
}

118
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_EndPlay (LPDIRECTMUSICTRACK8 iface, void* pStateData)
119
{
120 121 122
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
  FIXME("(%p, %p): stub\n", This, pStateData);
  return S_OK;
123 124
}

125
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_Play (LPDIRECTMUSICTRACK8 iface, void* pStateData, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, MUSIC_TIME mtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID)
126
{
127
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
128
  FIXME("(%p, %p, %d, %d, %d, %d, %p, %p, %d): stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
129
  return S_OK;
130 131
}

132
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_GetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) {
133
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
134
  FIXME("(%p, %s, %d, %p, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pmtNext, pParam);
135
  return S_OK;
136 137
}

138
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_SetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, void* pParam) {
139
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
140
  FIXME("(%p, %s, %d, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pParam);
141
  return S_OK;
142 143
}

144
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_IsParamSupported (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType) {
145 146
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
  
147
  TRACE("(%p, %s)\n", This, debugstr_dmguid(rguidType));
148 149 150 151 152 153 154 155
  if (IsEqualGUID (rguidType, &GUID_BandParam)
      || IsEqualGUID (rguidType, &GUID_ChordParam)
      || IsEqualGUID (rguidType, &GUID_RhythmParam)) {
    TRACE("param supported\n");
    return S_OK;
  }
  TRACE("param unsupported\n");
  return DMUS_E_TYPE_UNSUPPORTED;
156 157
}

158
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_AddNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType) {
159 160 161
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
  FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
  return S_OK;
162 163
}

164
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_RemoveNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType) {
165 166 167
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
  FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
  return S_OK;
168 169
}

170
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_Clone (LPDIRECTMUSICTRACK8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, IDirectMusicTrack** ppTrack) {
171
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
172
  FIXME("(%p, %d, %d, %p): stub\n", This, mtStart, mtEnd, ppTrack);
173
  return S_OK;
174 175
}

176
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_PlayEx (LPDIRECTMUSICTRACK8 iface, void* pStateData, REFERENCE_TIME rtStart, REFERENCE_TIME rtEnd, REFERENCE_TIME rtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID) {
177
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
178
  FIXME("(%p, %p, 0x%s, 0x%s, 0x%s, %d, %p, %p, %d): stub\n", This, pStateData, wine_dbgstr_longlong(rtStart),
179
      wine_dbgstr_longlong(rtEnd), wine_dbgstr_longlong(rtOffset), dwFlags, pPerf, pSegSt, dwVirtualID);
180
  return S_OK;
181 182
}

183
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_GetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, REFERENCE_TIME* prtNext, void* pParam, void* pStateData, DWORD dwFlags) {
184
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
185
  FIXME("(%p, %s, 0x%s, %p, %p, %p, %d): stub\n", This, debugstr_dmguid(rguidType),
186
      wine_dbgstr_longlong(rtTime), prtNext, pParam, pStateData, dwFlags);
187
  return S_OK;
188 189
}

190
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_SetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, void* pParam, void* pStateData, DWORD dwFlags) {
191
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
192
  FIXME("(%p, %s, 0x%s, %p, %p, %d): stub\n", This, debugstr_dmguid(rguidType),
193
      wine_dbgstr_longlong(rtTime), pParam, pStateData, dwFlags);
194
  return S_OK;
195 196
}

197
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_Compose (LPDIRECTMUSICTRACK8 iface, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack) {
198
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
199
  FIXME("(%p, %p, %d, %p): stub\n", This, pContext, dwTrackGroup, ppResultTrack);
200
  return S_OK;
201 202
}

203
static HRESULT WINAPI IDirectMusicChordTrack_IDirectMusicTrack_Join (LPDIRECTMUSICTRACK8 iface, IDirectMusicTrack* pNewTrack, MUSIC_TIME mtJoin, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack) {
204
  ICOM_THIS_MULTI(IDirectMusicChordTrack, TrackVtbl, iface);
205
  FIXME("(%p, %p, %d, %p, %d, %p): stub\n", This, pNewTrack, mtJoin, pContext, dwTrackGroup, ppResultTrack);
206
  return S_OK;
207 208
}

209
static const IDirectMusicTrack8Vtbl DirectMusicChordTrack_Track_Vtbl = {
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
  IDirectMusicChordTrack_IDirectMusicTrack_QueryInterface,
  IDirectMusicChordTrack_IDirectMusicTrack_AddRef,
  IDirectMusicChordTrack_IDirectMusicTrack_Release,
  IDirectMusicChordTrack_IDirectMusicTrack_Init,
  IDirectMusicChordTrack_IDirectMusicTrack_InitPlay,
  IDirectMusicChordTrack_IDirectMusicTrack_EndPlay,
  IDirectMusicChordTrack_IDirectMusicTrack_Play,
  IDirectMusicChordTrack_IDirectMusicTrack_GetParam,
  IDirectMusicChordTrack_IDirectMusicTrack_SetParam,
  IDirectMusicChordTrack_IDirectMusicTrack_IsParamSupported,
  IDirectMusicChordTrack_IDirectMusicTrack_AddNotificationType,
  IDirectMusicChordTrack_IDirectMusicTrack_RemoveNotificationType,
  IDirectMusicChordTrack_IDirectMusicTrack_Clone,
  IDirectMusicChordTrack_IDirectMusicTrack_PlayEx,
  IDirectMusicChordTrack_IDirectMusicTrack_GetParamEx,
  IDirectMusicChordTrack_IDirectMusicTrack_SetParamEx,
  IDirectMusicChordTrack_IDirectMusicTrack_Compose,
  IDirectMusicChordTrack_IDirectMusicTrack_Join
228 229
};

230
/* IDirectMusicChordTrack IPersistStream part: */
231
static HRESULT WINAPI IDirectMusicChordTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
232 233
  ICOM_THIS_MULTI(IDirectMusicChordTrack, PersistStreamVtbl, iface);
  return IDirectMusicChordTrack_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
234 235
}

236
static ULONG WINAPI IDirectMusicChordTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
237 238
  ICOM_THIS_MULTI(IDirectMusicChordTrack, PersistStreamVtbl, iface);
  return IDirectMusicChordTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
239 240
}

241
static ULONG WINAPI IDirectMusicChordTrack_IPersistStream_Release (LPPERSISTSTREAM iface) {
242 243
  ICOM_THIS_MULTI(IDirectMusicChordTrack, PersistStreamVtbl, iface);
  return IDirectMusicChordTrack_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
244 245
}

246
static HRESULT WINAPI IDirectMusicChordTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
247 248
  ICOM_THIS_MULTI(IDirectMusicChordTrack, PersistStreamVtbl, iface);
  TRACE("(%p, %p)\n", This, pClassID);
249
  *pClassID = CLSID_DirectMusicChordTrack;
250
  return S_OK;
251 252
}

253
static HRESULT WINAPI IDirectMusicChordTrack_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
254 255 256 257 258
  ICOM_THIS_MULTI(IDirectMusicChordTrack, PersistStreamVtbl, iface);
  FIXME("(%p): stub, always S_FALSE\n", This);
  return S_FALSE;
}

259
static HRESULT IDirectMusicChordTrack_IPersistStream_ParseChordTrackList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
260

261
  ICOM_THIS_MULTI(IDirectMusicChordTrack, PersistStreamVtbl, iface);
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
  DMUS_PRIVATE_CHUNK Chunk;
  DWORD ListSize[3], ListCount[3];
  LARGE_INTEGER liMove; /* used when skipping chunks */

  if (pChunk->fccID != DMUS_FOURCC_CHORDTRACK_LIST) {
    ERR_(dmfile)(": %s chunk should be a CHORDTRACK list\n", debugstr_fourcc (pChunk->fccID));
    return E_FAIL;
  }  

  ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
  ListCount[0] = 0;

  do {
    IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
    ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
277
    TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
278 279
    switch (Chunk.fccID) { 
    case DMUS_FOURCC_CHORDTRACKHEADER_CHUNK: {
Raphael Junqueira's avatar
Raphael Junqueira committed
280
      TRACE_(dmfile)(": Chord track header chunk\n");
281
      IStream_Read (pStm, &This->dwScale, sizeof(DWORD), NULL);
282
      TRACE_(dmfile)(" - dwScale: %d\n", This->dwScale);
283 284 285 286 287 288 289 290 291
      break;
    }
    case DMUS_FOURCC_CHORDTRACKBODY_CHUNK: {
      DWORD sz;
      DWORD it;
      DWORD num;
      DMUS_IO_CHORD body;
      DMUS_IO_SUBCHORD subchords;

Raphael Junqueira's avatar
Raphael Junqueira committed
292
      TRACE_(dmfile)(": Chord track body chunk\n");
293 294

      IStream_Read (pStm, &sz, sizeof(DWORD), NULL);
295
      TRACE_(dmfile)(" - sizeof(DMUS_IO_CHORD): %d\n", sz);
296 297 298
      if (sz != sizeof(DMUS_IO_CHORD)) return E_FAIL;
      IStream_Read (pStm, &body, sizeof(DMUS_IO_CHORD), NULL);
      TRACE_(dmfile)(" - wszName: %s\n", debugstr_w(body.wszName));
299
      TRACE_(dmfile)(" - mtTime: %u\n", body.mtTime);
300 301 302 303 304
      TRACE_(dmfile)(" - wMeasure: %u\n", body.wMeasure);
      TRACE_(dmfile)(" - bBeat:  %u\n", body.bBeat);
      TRACE_(dmfile)(" - bFlags: 0x%02x\n", body.bFlags);
      
      IStream_Read (pStm, &num, sizeof(DWORD), NULL);
305
      TRACE_(dmfile)(" - # DMUS_IO_SUBCHORDS: %d\n", num);
306
      IStream_Read (pStm, &sz, sizeof(DWORD), NULL);
307
      TRACE_(dmfile)(" - sizeof(DMUS_IO_SUBCHORDS): %d\n", sz);
308 309 310 311
      if (sz != sizeof(DMUS_IO_SUBCHORD)) return E_FAIL;

      for (it = 0; it < num; ++it) {
	IStream_Read (pStm, &subchords, sizeof(DMUS_IO_SUBCHORD), NULL);
312 313 314 315 316
	TRACE_(dmfile)("DMUS_IO_SUBCHORD #%d\n", it+1);
	TRACE_(dmfile)(" - dwChordPattern: %u\n", subchords.dwChordPattern);
	TRACE_(dmfile)(" - dwScalePattern: %u\n", subchords.dwScalePattern);
	TRACE_(dmfile)(" - dwInversionPoints: %u\n", subchords.dwInversionPoints);
	TRACE_(dmfile)(" - dwLevels: %u\n", subchords.dwLevels);
317 318 319 320 321 322
	TRACE_(dmfile)(" - bChordRoot:  %u\n", subchords.bChordRoot);
	TRACE_(dmfile)(" - bScaleRoot: %u\n", subchords.bScaleRoot);
      }
      break;
    }
    default: {
323
      TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
324 325 326 327 328
      liMove.QuadPart = Chunk.dwSize;
      IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
      break;		
    }
    }
329
    TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
330 331 332
  } while (ListCount[0] < ListSize[0]);

  return S_OK;
333 334
}

335
static HRESULT WINAPI IDirectMusicChordTrack_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
336 337 338 339 340 341
  ICOM_THIS_MULTI(IDirectMusicChordTrack, PersistStreamVtbl, iface);
 
  DMUS_PRIVATE_CHUNK Chunk;
  LARGE_INTEGER liMove;
  HRESULT hr;
 
Raphael Junqueira's avatar
Raphael Junqueira committed
342
  TRACE("(%p, %p): Loading\n", This, pStm);
343 344

  IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
345
  TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
346 347 348
  switch (Chunk.fccID) {	
  case FOURCC_LIST: {
    IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
349
    TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
350 351 352
    switch (Chunk.fccID) { 
    case DMUS_FOURCC_CHORDTRACK_LIST: {
      TRACE_(dmfile)(": Chord track list\n");
353
      hr = IDirectMusicChordTrack_IPersistStream_ParseChordTrackList (iface, &Chunk, pStm);
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
      if (FAILED(hr)) return hr;
      break;    
    }
    default: {
      TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
      liMove.QuadPart = Chunk.dwSize;
      IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
      return E_FAIL;
    }
    }
    TRACE_(dmfile)(": reading finished\n");
    break;
  }
  default: {
    TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
    liMove.QuadPart = Chunk.dwSize;
    IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
    return E_FAIL;
  }
373
  }
374 375

  return S_OK;
376 377
}

378
static HRESULT WINAPI IDirectMusicChordTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
379 380 381
  ICOM_THIS_MULTI(IDirectMusicChordTrack, PersistStreamVtbl, iface);
  FIXME("(%p): Saving not implemented yet\n", This);
  return E_NOTIMPL;
382 383
}

384
static HRESULT WINAPI IDirectMusicChordTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
385 386 387
  ICOM_THIS_MULTI(IDirectMusicChordTrack, PersistStreamVtbl, iface);
  FIXME("(%p, %p): stub\n", This, pcbSize);
  return E_NOTIMPL;
388 389
}

390
static const IPersistStreamVtbl DirectMusicChordTrack_PersistStream_Vtbl = {
391 392 393 394 395 396 397 398
  IDirectMusicChordTrack_IPersistStream_QueryInterface,
  IDirectMusicChordTrack_IPersistStream_AddRef,
  IDirectMusicChordTrack_IPersistStream_Release,
  IDirectMusicChordTrack_IPersistStream_GetClassID,
  IDirectMusicChordTrack_IPersistStream_IsDirty,
  IDirectMusicChordTrack_IPersistStream_Load,
  IDirectMusicChordTrack_IPersistStream_Save,
  IDirectMusicChordTrack_IPersistStream_GetSizeMax
399
};
400 401 402

/* for ClassFactory */
HRESULT WINAPI DMUSIC_CreateDirectMusicChordTrack (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
403 404 405 406
  IDirectMusicChordTrack* track;
  
  track = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicChordTrack));
  if (NULL == track) {
407
    *ppobj = NULL;
408 409 410 411 412 413 414 415
    return E_OUTOFMEMORY;
  }
  track->UnknownVtbl = &DirectMusicChordTrack_Unknown_Vtbl;
  track->TrackVtbl = &DirectMusicChordTrack_Track_Vtbl;
  track->PersistStreamVtbl = &DirectMusicChordTrack_PersistStream_Vtbl;
  track->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
  DM_STRUCT_INIT(track->pDesc);
  track->pDesc->dwValidData |= DMUS_OBJ_CLASS;
416
  track->pDesc->guidClass = CLSID_DirectMusicChordTrack;
417
  track->ref = 0; /* will be inited by QueryInterface */
418

419
  return IDirectMusicChordTrack_IUnknown_QueryInterface ((LPUNKNOWN)&track->UnknownVtbl, lpcGUID, ppobj);
420
}