Make SYSTEM_THREAD_INFORMATION.pszProcessName a UNICODE_STRING.
[wine/hacks.git] / dlls / dmstyle / styletrack.c
blob117fa957c5dfcb73e5c08701a8e4d8787c7ba33d
1 /* IDirectMusicStyleTrack Implementation
3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Library General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "dmstyle_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
23 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
25 /*****************************************************************************
26 * IDirectMusicStyleTrack implementation
28 /* IDirectMusicStyleTrack IUnknown part: */
29 HRESULT WINAPI IDirectMusicStyleTrack_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
30 ICOM_THIS_MULTI(IDirectMusicStyleTrack, UnknownVtbl, iface);
31 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
33 if (IsEqualIID (riid, &IID_IUnknown)) {
34 *ppobj = (LPUNKNOWN)&This->UnknownVtbl;
35 IDirectMusicStyleTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
36 return S_OK;
37 } else if (IsEqualIID (riid, &IID_IDirectMusicTrack)
38 || IsEqualIID (riid, &IID_IDirectMusicTrack8)) {
39 *ppobj = (LPDIRECTMUSICTRACK8)&This->TrackVtbl;
40 IDirectMusicStyleTrack_IDirectMusicTrack_AddRef ((LPDIRECTMUSICTRACK8)&This->TrackVtbl);
41 return S_OK;
42 } else if (IsEqualIID (riid, &IID_IPersistStream)) {
43 *ppobj = (LPPERSISTSTREAM)&This->PersistStreamVtbl;
44 IDirectMusicStyleTrack_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
45 return S_OK;
48 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
49 return E_NOINTERFACE;
52 ULONG WINAPI IDirectMusicStyleTrack_IUnknown_AddRef (LPUNKNOWN iface) {
53 ICOM_THIS_MULTI(IDirectMusicStyleTrack, UnknownVtbl, iface);
54 ULONG ref = InterlockedIncrement(&This->ref);
56 TRACE("(%p): AddRef from %ld\n", This, ref - 1);
58 DMSTYLE_LockModule();
60 return ref;
63 ULONG WINAPI IDirectMusicStyleTrack_IUnknown_Release (LPUNKNOWN iface) {
64 ICOM_THIS_MULTI(IDirectMusicStyleTrack, UnknownVtbl, iface);
65 ULONG ref = InterlockedDecrement(&This->ref);
67 TRACE("(%p): ReleaseRef to %ld\n", This, ref);
69 if (ref == 0) {
70 HeapFree(GetProcessHeap(), 0, This);
73 DMSTYLE_UnlockModule();
75 return ref;
78 static const IUnknownVtbl DirectMusicStyleTrack_Unknown_Vtbl = {
79 IDirectMusicStyleTrack_IUnknown_QueryInterface,
80 IDirectMusicStyleTrack_IUnknown_AddRef,
81 IDirectMusicStyleTrack_IUnknown_Release
84 /* IDirectMusicStyleTrack IDirectMusicTrack8 part: */
85 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_QueryInterface (LPDIRECTMUSICTRACK8 iface, REFIID riid, LPVOID *ppobj) {
86 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
87 return IDirectMusicStyleTrack_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
90 ULONG WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_AddRef (LPDIRECTMUSICTRACK8 iface) {
91 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
92 return IDirectMusicStyleTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
95 ULONG WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_Release (LPDIRECTMUSICTRACK8 iface) {
96 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
97 return IDirectMusicStyleTrack_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
100 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_Init (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegment* pSegment)
102 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
103 FIXME("(%p, %p): stub\n", This, pSegment);
104 return S_OK;
107 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_InitPlay (LPDIRECTMUSICTRACK8 iface, IDirectMusicSegmentState* pSegmentState, IDirectMusicPerformance* pPerformance, void** ppStateData, DWORD dwVirtualTrack8ID, DWORD dwFlags)
109 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
110 FIXME("(%p, %p, %p, %p, %ld, %ld): stub\n", This, pSegmentState, pPerformance, ppStateData, dwVirtualTrack8ID, dwFlags);
111 return S_OK;
114 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_EndPlay (LPDIRECTMUSICTRACK8 iface, void* pStateData)
116 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
117 FIXME("(%p, %p): stub\n", This, pStateData);
118 return S_OK;
121 HRESULT WINAPI IDirectMusicStyleTrack_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(IDirectMusicStyleTrack, TrackVtbl, iface);
124 FIXME("(%p, %p, %ld, %ld, %ld, %ld, %p, %p, %ld): stub\n", This, pStateData, mtStart, mtEnd, mtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
125 return S_OK;
128 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_GetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam) {
129 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
130 FIXME("(%p, %s, %ld, %p, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pmtNext, pParam);
131 return S_OK;
134 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_SetParam (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, MUSIC_TIME mtTime, void* pParam) {
135 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
136 FIXME("(%p, %s, %ld, %p): stub\n", This, debugstr_dmguid(rguidType), mtTime, pParam);
137 return S_OK;
140 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_IsParamSupported (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType) {
141 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
143 TRACE("(%p, %s): ", This, debugstr_dmguid(rguidType));
144 if (IsEqualGUID (rguidType, &GUID_DisableTimeSig)
145 || IsEqualGUID (rguidType, &GUID_EnableTimeSig)
146 || IsEqualGUID (rguidType, &GUID_IDirectMusicStyle)
147 || IsEqualGUID (rguidType, &GUID_SeedVariations)
148 || IsEqualGUID (rguidType, &GUID_TimeSignature)) {
149 TRACE("param supported\n");
150 return S_OK;
152 TRACE("param unsupported\n");
153 return DMUS_E_TYPE_UNSUPPORTED;
156 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_AddNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType) {
157 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
158 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
159 return S_OK;
162 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_RemoveNotificationType (LPDIRECTMUSICTRACK8 iface, REFGUID rguidNotificationType) {
163 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
164 FIXME("(%p, %s): stub\n", This, debugstr_dmguid(rguidNotificationType));
165 return S_OK;
168 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_Clone (LPDIRECTMUSICTRACK8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, IDirectMusicTrack** ppTrack) {
169 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
170 FIXME("(%p, %ld, %ld, %p): stub\n", This, mtStart, mtEnd, ppTrack);
171 return S_OK;
174 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_PlayEx (LPDIRECTMUSICTRACK8 iface, void* pStateData, REFERENCE_TIME rtStart, REFERENCE_TIME rtEnd, REFERENCE_TIME rtOffset, DWORD dwFlags, IDirectMusicPerformance* pPerf, IDirectMusicSegmentState* pSegSt, DWORD dwVirtualID) {
175 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
176 FIXME("(%p, %p, %lli, %lli, %lli, %ld, %p, %p, %ld): stub\n", This, pStateData, rtStart, rtEnd, rtOffset, dwFlags, pPerf, pSegSt, dwVirtualID);
177 return S_OK;
180 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_GetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, REFERENCE_TIME* prtNext, void* pParam, void* pStateData, DWORD dwFlags) {
181 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
182 FIXME("(%p, %s, %lli, %p, %p, %p, %ld): stub\n", This, debugstr_dmguid(rguidType), rtTime, prtNext, pParam, pStateData, dwFlags);
183 return S_OK;
186 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_SetParamEx (LPDIRECTMUSICTRACK8 iface, REFGUID rguidType, REFERENCE_TIME rtTime, void* pParam, void* pStateData, DWORD dwFlags) {
187 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
188 FIXME("(%p, %s, %lli, %p, %p, %ld): stub\n", This, debugstr_dmguid(rguidType), rtTime, pParam, pStateData, dwFlags);
189 return S_OK;
192 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_Compose (LPDIRECTMUSICTRACK8 iface, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack) {
193 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
194 FIXME("(%p, %p, %ld, %p): stub\n", This, pContext, dwTrackGroup, ppResultTrack);
195 return S_OK;
198 HRESULT WINAPI IDirectMusicStyleTrack_IDirectMusicTrack_Join (LPDIRECTMUSICTRACK8 iface, IDirectMusicTrack* pNewTrack, MUSIC_TIME mtJoin, IUnknown* pContext, DWORD dwTrackGroup, IDirectMusicTrack** ppResultTrack) {
199 ICOM_THIS_MULTI(IDirectMusicStyleTrack, TrackVtbl, iface);
200 FIXME("(%p, %p, %ld, %p, %ld, %p): stub\n", This, pNewTrack, mtJoin, pContext, dwTrackGroup, ppResultTrack);
201 return S_OK;
204 static const IDirectMusicTrack8Vtbl DirectMusicStyleTrack_Track_Vtbl = {
205 IDirectMusicStyleTrack_IDirectMusicTrack_QueryInterface,
206 IDirectMusicStyleTrack_IDirectMusicTrack_AddRef,
207 IDirectMusicStyleTrack_IDirectMusicTrack_Release,
208 IDirectMusicStyleTrack_IDirectMusicTrack_Init,
209 IDirectMusicStyleTrack_IDirectMusicTrack_InitPlay,
210 IDirectMusicStyleTrack_IDirectMusicTrack_EndPlay,
211 IDirectMusicStyleTrack_IDirectMusicTrack_Play,
212 IDirectMusicStyleTrack_IDirectMusicTrack_GetParam,
213 IDirectMusicStyleTrack_IDirectMusicTrack_SetParam,
214 IDirectMusicStyleTrack_IDirectMusicTrack_IsParamSupported,
215 IDirectMusicStyleTrack_IDirectMusicTrack_AddNotificationType,
216 IDirectMusicStyleTrack_IDirectMusicTrack_RemoveNotificationType,
217 IDirectMusicStyleTrack_IDirectMusicTrack_Clone,
218 IDirectMusicStyleTrack_IDirectMusicTrack_PlayEx,
219 IDirectMusicStyleTrack_IDirectMusicTrack_GetParamEx,
220 IDirectMusicStyleTrack_IDirectMusicTrack_SetParamEx,
221 IDirectMusicStyleTrack_IDirectMusicTrack_Compose,
222 IDirectMusicStyleTrack_IDirectMusicTrack_Join
225 /* IDirectMusicStyleTrack IPersistStream part: */
226 HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
227 ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
228 return IDirectMusicStyleTrack_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
231 ULONG WINAPI IDirectMusicStyleTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
232 ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
233 return IDirectMusicStyleTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
236 ULONG WINAPI IDirectMusicStyleTrack_IPersistStream_Release (LPPERSISTSTREAM iface) {
237 ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
238 return IDirectMusicStyleTrack_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
241 HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
242 ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
243 TRACE("(%p, %p)\n", This, pClassID);
244 memcpy(pClassID, &CLSID_DirectMusicStyleTrack, sizeof(CLSID));
245 return S_OK;
248 HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
249 ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
250 FIXME("(%p): stub, always S_FALSE\n", This);
251 return S_FALSE;
254 static HRESULT IDirectMusicStyleTrack_IPersistStream_ParseStyleRef (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
255 ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
256 DMUS_PRIVATE_CHUNK Chunk;
257 DWORD ListSize[3], ListCount[3];
258 LARGE_INTEGER liMove; /* used when skipping chunks */
259 HRESULT hr;
261 IDirectMusicObject* pObject = NULL;
262 LPDMUS_PRIVATE_STYLE_ITEM pNewItem = NULL;
264 if (pChunk->fccID != DMUS_FOURCC_STYLE_REF_LIST) {
265 ERR_(dmfile)(": %s chunk should be a STYLE list\n", debugstr_fourcc (pChunk->fccID));
266 return E_FAIL;
269 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
270 ListCount[0] = 0;
272 do {
273 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
274 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
275 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
276 switch (Chunk.fccID) {
277 case DMUS_FOURCC_TIME_STAMP_CHUNK: {
278 TRACE_(dmfile)(": Time Stamp chunck \n");
279 pNewItem = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_ITEM));
280 if (NULL == pNewItem) {
281 ERR(": no more memory\n");
282 return E_OUTOFMEMORY;
284 IStream_Read (pStm, &pNewItem->dwTimeStamp, sizeof(DWORD), NULL);
285 TRACE_(dmfile)(" - dwTimeStamp: %lu\n", pNewItem->dwTimeStamp);
286 list_add_tail (&This->Items, &pNewItem->entry);
287 break;
289 case FOURCC_LIST: {
290 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
291 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
292 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
293 ListCount[1] = 0;
294 switch (Chunk.fccID) {
296 * should be a DMRF (DirectMusic Reference) list @TODO
298 case DMUS_FOURCC_REF_LIST: {
299 FIXME_(dmfile)(": DMRF (DM References) list, not yet handled\n");
300 hr = IDirectMusicUtils_IPersistStream_ParseReference (iface, &Chunk, pStm, &pObject);
301 if (FAILED(hr)) {
302 ERR(": could not load Reference\n");
303 return hr;
305 hr = IDirectMusicObject_QueryInterface(pObject, &IID_IDirectMusicStyle8, (LPVOID*)&pNewItem->pObject);
306 if (FAILED(hr)) {
307 ERR(": Reference not an IDirectMusicStyle, exiting\n");
308 exit(-1);
309 return hr;
311 IDirectMusicObject_Release(pObject);
312 break;
314 default: {
315 TRACE_(dmfile)(": unknown (skipping)\n");
316 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
317 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
318 break;
321 break;
323 default: {
324 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
325 liMove.QuadPart = Chunk.dwSize;
326 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
327 break;
330 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
331 } while (ListCount[0] < ListSize[0]);
333 return S_OK;
336 static HRESULT IDirectMusicStyleTrack_IPersistStream_ParseStyleTrackList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
338 /*ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);*/
339 DMUS_PRIVATE_CHUNK Chunk;
340 DWORD ListSize[3], ListCount[3];
341 LARGE_INTEGER liMove; /* used when skipping chunks */
342 HRESULT hr;
344 if (pChunk->fccID != DMUS_FOURCC_STYLE_TRACK_LIST) {
345 ERR_(dmfile)(": %s chunk should be a STYLETRACK list\n", debugstr_fourcc (pChunk->fccID));
346 return E_FAIL;
349 ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
350 ListCount[0] = 0;
352 do {
353 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
354 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
355 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
356 switch (Chunk.fccID) {
357 case FOURCC_LIST: {
358 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
359 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
360 ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
361 ListCount[1] = 0;
362 switch (Chunk.fccID) {
363 case DMUS_FOURCC_STYLE_REF_LIST: {
364 TRACE_(dmfile)(": STYLE_REF list\n");
365 hr = IDirectMusicStyleTrack_IPersistStream_ParseStyleRef (iface, &Chunk, pStm);
366 if (FAILED(hr)) return hr;
367 break;
369 default: {
370 TRACE_(dmfile)(": unknown (skipping)\n");
371 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
372 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
373 break;
376 break;
378 default: {
379 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
380 liMove.QuadPart = Chunk.dwSize;
381 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
382 break;
385 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
386 } while (ListCount[0] < ListSize[0]);
388 return S_OK;
391 HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
392 ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
394 DMUS_PRIVATE_CHUNK Chunk;
395 LARGE_INTEGER liMove;
396 HRESULT hr;
398 FIXME("(%p, %p): Loading not fully implemented yet\n", This, pStm);
400 IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
401 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
402 switch (Chunk.fccID) {
403 case FOURCC_LIST: {
404 IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
405 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
406 switch (Chunk.fccID) {
407 case DMUS_FOURCC_STYLE_TRACK_LIST: {
408 TRACE_(dmfile)(": Chord track list\n");
409 hr = IDirectMusicStyleTrack_IPersistStream_ParseStyleTrackList (iface, &Chunk, pStm);
410 if (FAILED(hr)) return hr;
411 break;
413 default: {
414 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
415 liMove.QuadPart = Chunk.dwSize;
416 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
417 return E_FAIL;
420 TRACE_(dmfile)(": reading finished\n");
421 break;
423 default: {
424 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
425 liMove.QuadPart = Chunk.dwSize;
426 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
427 return E_FAIL;
431 return S_OK;
434 HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
435 ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
436 FIXME("(%p): Saving not implemented yet\n", This);
437 return E_NOTIMPL;
440 HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
441 ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
442 FIXME("(%p, %p): stub\n", This, pcbSize);
443 return E_NOTIMPL;
446 static const IPersistStreamVtbl DirectMusicStyleTrack_PersistStream_Vtbl = {
447 IDirectMusicStyleTrack_IPersistStream_QueryInterface,
448 IDirectMusicStyleTrack_IPersistStream_AddRef,
449 IDirectMusicStyleTrack_IPersistStream_Release,
450 IDirectMusicStyleTrack_IPersistStream_GetClassID,
451 IDirectMusicStyleTrack_IPersistStream_IsDirty,
452 IDirectMusicStyleTrack_IPersistStream_Load,
453 IDirectMusicStyleTrack_IPersistStream_Save,
454 IDirectMusicStyleTrack_IPersistStream_GetSizeMax
457 /* for ClassFactory */
458 HRESULT WINAPI DMUSIC_CreateDirectMusicStyleTrack (LPCGUID lpcGUID, LPVOID *ppobj, LPUNKNOWN pUnkOuter) {
459 IDirectMusicStyleTrack* track;
461 track = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicStyleTrack));
462 if (NULL == track) {
463 *ppobj = NULL;
464 return E_OUTOFMEMORY;
466 track->UnknownVtbl = &DirectMusicStyleTrack_Unknown_Vtbl;
467 track->TrackVtbl = &DirectMusicStyleTrack_Track_Vtbl;
468 track->PersistStreamVtbl = &DirectMusicStyleTrack_PersistStream_Vtbl;
469 track->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
470 DM_STRUCT_INIT(track->pDesc);
471 track->pDesc->dwValidData |= DMUS_OBJ_CLASS;
472 memcpy (&track->pDesc->guidClass, &CLSID_DirectMusicStyleTrack, sizeof (CLSID));
473 track->ref = 0; /* will be inited by QueryInterface */
474 list_init (&track->Items);
476 return IDirectMusicStyleTrack_IUnknown_QueryInterface ((LPUNKNOWN)&track->UnknownVtbl, lpcGUID, ppobj);