1 /* IDirectMusicAudioPath Implementation
3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "dmime_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
23 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
25 /*****************************************************************************
26 * IDirectMusicAudioPathImpl implementation
28 /* IDirectMusicAudioPath IUnknown part: */
29 static HRESULT WINAPI IDirectMusicAudioPathImpl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
30 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, UnknownVtbl, iface);
31 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
33 if (IsEqualIID (riid, &IID_IUnknown)) {
34 *ppobj = (LPVOID)&This->UnknownVtbl;
35 IUnknown_AddRef (iface);
37 } else if (IsEqualIID (riid, &IID_IDirectMusicAudioPath)) {
38 *ppobj = (LPVOID)&This->AudioPathVtbl;
39 IUnknown_AddRef (iface);
41 } else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
42 *ppobj = (LPVOID)&This->ObjectVtbl;
43 IUnknown_AddRef (iface);
45 } else if (IsEqualIID (riid, &IID_IPersistStream)) {
46 *ppobj = (LPVOID)&This->PersistStreamVtbl;
47 IUnknown_AddRef (iface);
51 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
55 static ULONG WINAPI IDirectMusicAudioPathImpl_IUnknown_AddRef (LPUNKNOWN iface) {
56 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, UnknownVtbl, iface);
57 ULONG ref = InterlockedIncrement(&This->ref);
59 TRACE("(%p): AddRef from %d\n", This, ref - 1);
66 static ULONG WINAPI IDirectMusicAudioPathImpl_IUnknown_Release (LPUNKNOWN iface) {
67 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, UnknownVtbl, iface);
68 ULONG ref = InterlockedDecrement(&This->ref);
69 TRACE("(%p): ReleaseRef to %d\n", This, ref);
72 if (This->pDSBuffer) {
73 IDirectSoundBuffer8_Release(This->pDSBuffer);
75 HeapFree(GetProcessHeap(), 0, This);
83 static const IUnknownVtbl DirectMusicAudioPath_Unknown_Vtbl = {
84 IDirectMusicAudioPathImpl_IUnknown_QueryInterface,
85 IDirectMusicAudioPathImpl_IUnknown_AddRef,
86 IDirectMusicAudioPathImpl_IUnknown_Release
89 /* IDirectMusicAudioPathImpl IDirectMusicAudioPath part: */
90 static HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicAudioPath_QueryInterface (LPDIRECTMUSICAUDIOPATH iface, REFIID riid, LPVOID *ppobj) {
91 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, AudioPathVtbl, iface);
92 return IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
95 static ULONG WINAPI IDirectMusicAudioPathImpl_IDirectMusicAudioPath_AddRef (LPDIRECTMUSICAUDIOPATH iface) {
96 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, AudioPathVtbl, iface);
97 return IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
100 static ULONG WINAPI IDirectMusicAudioPathImpl_IDirectMusicAudioPath_Release (LPDIRECTMUSICAUDIOPATH iface) {
101 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, AudioPathVtbl, iface);
102 return IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
105 static HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicAudioPath_GetObjectInPath (LPDIRECTMUSICAUDIOPATH iface, DWORD dwPChannel, DWORD dwStage, DWORD dwBuffer, REFGUID guidObject, WORD dwIndex, REFGUID iidInterface, void** ppObject) {
106 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, AudioPathVtbl, iface);
108 FIXME("(%p, %d, %d, %d, %s, %d, %s, %p): stub\n", This, dwPChannel, dwStage, dwBuffer, debugstr_dmguid(guidObject), dwIndex, debugstr_dmguid(iidInterface), ppObject);
111 case DMUS_PATH_BUFFER:
113 if (IsEqualIID (iidInterface, &IID_IDirectSoundBuffer8)) {
114 IDirectSoundBuffer8_QueryInterface (This->pDSBuffer, &IID_IDirectSoundBuffer8, ppObject);
115 TRACE("returning %p\n",*ppObject);
117 } else if (IsEqualIID (iidInterface, &IID_IDirectSound3DBuffer)) {
118 IDirectSoundBuffer8_QueryInterface (This->pDSBuffer, &IID_IDirectSound3DBuffer, ppObject);
119 TRACE("returning %p\n",*ppObject);
127 case DMUS_PATH_PRIMARY_BUFFER: {
128 if (IsEqualIID (iidInterface, &IID_IDirectSound3DListener)) {
129 IDirectSoundBuffer8_QueryInterface (This->pPrimary, &IID_IDirectSound3DListener, ppObject);
132 FIXME("bad iid...\n");
137 case DMUS_PATH_AUDIOPATH_GRAPH:
139 if (IsEqualIID (iidInterface, &IID_IDirectMusicGraph)) {
140 if (NULL == This->pToolGraph) {
141 IDirectMusicGraphImpl* pGraph;
142 DMUSIC_CreateDirectMusicGraphImpl (&IID_IDirectMusicGraph, (LPVOID*)&pGraph, NULL);
143 This->pToolGraph = (IDirectMusicGraph*) pGraph;
145 *ppObject = (LPDIRECTMUSICGRAPH) This->pToolGraph;
146 IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH) *ppObject);
152 case DMUS_PATH_AUDIOPATH_TOOL:
158 case DMUS_PATH_PERFORMANCE:
160 /* TODO check wanted GUID */
161 *ppObject = (LPDIRECTMUSICPERFORMANCE8) This->pPerf;
162 IUnknown_AddRef((LPUNKNOWN) *ppObject);
167 case DMUS_PATH_PERFORMANCE_GRAPH:
169 IDirectMusicGraph* pPerfoGraph = NULL;
170 IDirectMusicPerformance8_GetGraph((LPDIRECTMUSICPERFORMANCE8) This->pPerf, &pPerfoGraph);
171 if (NULL == pPerfoGraph) {
172 IDirectMusicGraphImpl* pGraph = NULL;
173 DMUSIC_CreateDirectMusicGraphImpl (&IID_IDirectMusicGraph, (LPVOID*)&pGraph, NULL);
174 IDirectMusicPerformance8_SetGraph((LPDIRECTMUSICPERFORMANCE8) This->pPerf, (IDirectMusicGraph*) pGraph);
175 /* we need release as SetGraph do an AddRef */
176 IDirectMusicGraph_Release((LPDIRECTMUSICGRAPH) pGraph);
177 pPerfoGraph = (LPDIRECTMUSICGRAPH) pGraph;
179 *ppObject = (LPDIRECTMUSICGRAPH) pPerfoGraph;
184 case DMUS_PATH_PERFORMANCE_TOOL:
193 static HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicAudioPath_Activate (LPDIRECTMUSICAUDIOPATH iface, BOOL fActivate) {
194 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, AudioPathVtbl, iface);
195 FIXME("(%p, %d): stub\n", This, fActivate);
197 if (!This->fActive) return S_OK;
198 This->fActive = FALSE;
200 if (This->fActive) return S_OK;
201 This->fActive = TRUE;
202 if (NULL != This->pDSBuffer) {
203 IDirectSoundBuffer_Stop(This->pDSBuffer);
209 static HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicAudioPath_SetVolume (LPDIRECTMUSICAUDIOPATH iface, long lVolume, DWORD dwDuration) {
210 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, AudioPathVtbl, iface);
211 FIXME("(%p, %li, %d): stub\n", This, lVolume, dwDuration);
215 static HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicAudioPath_ConvertPChannel (LPDIRECTMUSICAUDIOPATH iface, DWORD dwPChannelIn, DWORD* pdwPChannelOut) {
216 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, AudioPathVtbl, iface);
217 FIXME("(%p, %d, %p): stub\n", This, dwPChannelIn, pdwPChannelOut);
221 static const IDirectMusicAudioPathVtbl DirectMusicAudioPath_AudioPath_Vtbl = {
222 IDirectMusicAudioPathImpl_IDirectMusicAudioPath_QueryInterface,
223 IDirectMusicAudioPathImpl_IDirectMusicAudioPath_AddRef,
224 IDirectMusicAudioPathImpl_IDirectMusicAudioPath_Release,
225 IDirectMusicAudioPathImpl_IDirectMusicAudioPath_GetObjectInPath,
226 IDirectMusicAudioPathImpl_IDirectMusicAudioPath_Activate,
227 IDirectMusicAudioPathImpl_IDirectMusicAudioPath_SetVolume,
228 IDirectMusicAudioPathImpl_IDirectMusicAudioPath_ConvertPChannel
231 /* IDirectMusicAudioPathImpl IDirectMusicObject part: */
232 static HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
233 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, ObjectVtbl, iface);
234 return IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
237 static ULONG WINAPI IDirectMusicAudioPathImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
238 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, ObjectVtbl, iface);
239 return IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
242 static ULONG WINAPI IDirectMusicAudioPathImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
243 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, ObjectVtbl, iface);
244 return IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
247 static HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
248 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, ObjectVtbl, iface);
249 TRACE("(%p, %p)\n", This, pDesc);
250 /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
251 memcpy (pDesc, This->pDesc, This->pDesc->dwSize);
255 static HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
256 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, ObjectVtbl, iface);
257 TRACE("(%p, %p): setting descriptor:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC (pDesc));
259 /* According to MSDN, we should copy only given values, not whole struct */
260 if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
261 memcpy (&This->pDesc->guidObject, &pDesc->guidObject, sizeof (pDesc->guidObject));
262 if (pDesc->dwValidData & DMUS_OBJ_CLASS)
263 memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
264 if (pDesc->dwValidData & DMUS_OBJ_NAME)
265 lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
266 if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
267 lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
268 if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
269 lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
270 if (pDesc->dwValidData & DMUS_OBJ_VERSION)
271 memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
272 if (pDesc->dwValidData & DMUS_OBJ_DATE)
273 memcpy (&This->pDesc->ftDate, &pDesc->ftDate, sizeof (pDesc->ftDate));
274 if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
275 memcpy (&This->pDesc->llMemLength, &pDesc->llMemLength, sizeof (pDesc->llMemLength));
276 memcpy (This->pDesc->pbMemData, pDesc->pbMemData, sizeof (pDesc->pbMemData));
278 if (pDesc->dwValidData & DMUS_OBJ_STREAM) {
279 /* according to MSDN, we copy the stream */
280 IStream_Clone (pDesc->pStream, &This->pDesc->pStream);
284 This->pDesc->dwValidData |= pDesc->dwValidData;
289 static HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) {
290 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, ObjectVtbl, iface);
291 DMUS_PRIVATE_CHUNK Chunk;
292 DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
293 LARGE_INTEGER liMove; /* used when skipping chunks */
295 TRACE("(%p, %p, %p)\n", This, pStream, pDesc);
297 /* FIXME: should this be determined from stream? */
298 pDesc->dwValidData |= DMUS_OBJ_CLASS;
299 memcpy (&pDesc->guidClass, &CLSID_DirectMusicAudioPath, sizeof(CLSID));
301 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
302 TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
303 switch (Chunk.fccID) {
305 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
306 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
307 StreamSize = Chunk.dwSize - sizeof(FOURCC);
309 if (Chunk.fccID == DMUS_FOURCC_AUDIOPATH_FORM) {
310 TRACE_(dmfile)(": audio path form\n");
312 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
313 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
314 TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
315 switch (Chunk.fccID) {
316 case DMUS_FOURCC_GUID_CHUNK: {
317 TRACE_(dmfile)(": GUID chunk\n");
318 pDesc->dwValidData |= DMUS_OBJ_OBJECT;
319 IStream_Read (pStream, &pDesc->guidObject, Chunk.dwSize, NULL);
322 case DMUS_FOURCC_VERSION_CHUNK: {
323 TRACE_(dmfile)(": version chunk\n");
324 pDesc->dwValidData |= DMUS_OBJ_VERSION;
325 IStream_Read (pStream, &pDesc->vVersion, Chunk.dwSize, NULL);
328 case DMUS_FOURCC_CATEGORY_CHUNK: {
329 TRACE_(dmfile)(": category chunk\n");
330 pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
331 IStream_Read (pStream, pDesc->wszCategory, Chunk.dwSize, NULL);
335 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
336 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
337 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
339 switch (Chunk.fccID) {
340 /* evil M$ UNFO list, which can (!?) contain INFO elements */
341 case DMUS_FOURCC_UNFO_LIST: {
342 TRACE_(dmfile)(": UNFO list\n");
344 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
345 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
346 TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
347 switch (Chunk.fccID) {
348 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
349 (though strings seem to be valid unicode) */
350 case mmioFOURCC('I','N','A','M'):
351 case DMUS_FOURCC_UNAM_CHUNK: {
352 TRACE_(dmfile)(": name chunk\n");
353 pDesc->dwValidData |= DMUS_OBJ_NAME;
354 IStream_Read (pStream, pDesc->wszName, Chunk.dwSize, NULL);
357 case mmioFOURCC('I','A','R','T'):
358 case DMUS_FOURCC_UART_CHUNK: {
359 TRACE_(dmfile)(": artist chunk (ignored)\n");
360 liMove.QuadPart = Chunk.dwSize;
361 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
364 case mmioFOURCC('I','C','O','P'):
365 case DMUS_FOURCC_UCOP_CHUNK: {
366 TRACE_(dmfile)(": copyright chunk (ignored)\n");
367 liMove.QuadPart = Chunk.dwSize;
368 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
371 case mmioFOURCC('I','S','B','J'):
372 case DMUS_FOURCC_USBJ_CHUNK: {
373 TRACE_(dmfile)(": subject chunk (ignored)\n");
374 liMove.QuadPart = Chunk.dwSize;
375 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
378 case mmioFOURCC('I','C','M','T'):
379 case DMUS_FOURCC_UCMT_CHUNK: {
380 TRACE_(dmfile)(": comment chunk (ignored)\n");
381 liMove.QuadPart = Chunk.dwSize;
382 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
386 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
387 liMove.QuadPart = Chunk.dwSize;
388 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
392 TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
393 } while (ListCount[0] < ListSize[0]);
397 TRACE_(dmfile)(": unknown (skipping)\n");
398 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
399 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
406 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
407 liMove.QuadPart = Chunk.dwSize;
408 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
412 TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
413 } while (StreamCount < StreamSize);
415 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
416 liMove.QuadPart = StreamSize;
417 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
421 TRACE_(dmfile)(": reading finished\n");
425 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
426 liMove.QuadPart = Chunk.dwSize;
427 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
428 return DMUS_E_INVALIDFILE;
432 TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC (pDesc));
437 static const IDirectMusicObjectVtbl DirectMusicAudioPath_Object_Vtbl = {
438 IDirectMusicAudioPathImpl_IDirectMusicObject_QueryInterface,
439 IDirectMusicAudioPathImpl_IDirectMusicObject_AddRef,
440 IDirectMusicAudioPathImpl_IDirectMusicObject_Release,
441 IDirectMusicAudioPathImpl_IDirectMusicObject_GetDescriptor,
442 IDirectMusicAudioPathImpl_IDirectMusicObject_SetDescriptor,
443 IDirectMusicAudioPathImpl_IDirectMusicObject_ParseDescriptor
446 /* IDirectMusicAudioPathImpl IPersistStream part: */
447 static HRESULT WINAPI IDirectMusicAudioPathImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
448 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, PersistStreamVtbl, iface);
449 return IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
452 static ULONG WINAPI IDirectMusicAudioPathImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
453 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, PersistStreamVtbl, iface);
454 return IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
457 static ULONG WINAPI IDirectMusicAudioPathImpl_IPersistStream_Release (LPPERSISTSTREAM iface) {
458 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, PersistStreamVtbl, iface);
459 return IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
462 static HRESULT WINAPI IDirectMusicAudioPathImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
466 static HRESULT WINAPI IDirectMusicAudioPathImpl_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
470 static HRESULT WINAPI IDirectMusicAudioPathImpl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
471 ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, PersistStreamVtbl, iface);
474 DWORD chunkSize, StreamSize, StreamCount, ListSize[3], ListCount[3];
475 LARGE_INTEGER liMove; /* used when skipping chunks */
477 FIXME("(%p, %p): Loading not implemented yet\n", This, pStm);
478 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
479 IStream_Read (pStm, &chunkSize, sizeof(DWORD), NULL);
480 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (chunkID), chunkSize);
483 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
484 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunkID));
485 StreamSize = chunkSize - sizeof(FOURCC);
488 case DMUS_FOURCC_AUDIOPATH_FORM: {
489 TRACE_(dmfile)(": audio path form\n");
491 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
492 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
493 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
494 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (chunkID), chunkSize);
496 case DMUS_FOURCC_GUID_CHUNK: {
497 TRACE_(dmfile)(": GUID chunk\n");
498 This->pDesc->dwValidData |= DMUS_OBJ_OBJECT;
499 IStream_Read (pStm, &This->pDesc->guidObject, chunkSize, NULL);
502 case DMUS_FOURCC_VERSION_CHUNK: {
503 TRACE_(dmfile)(": version chunk\n");
504 This->pDesc->dwValidData |= DMUS_OBJ_VERSION;
505 IStream_Read (pStm, &This->pDesc->vVersion, chunkSize, NULL);
508 case DMUS_FOURCC_CATEGORY_CHUNK: {
509 TRACE_(dmfile)(": category chunk\n");
510 This->pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
511 IStream_Read (pStm, This->pDesc->wszCategory, chunkSize, NULL);
515 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
516 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
517 ListSize[0] = chunkSize - sizeof(FOURCC);
520 case DMUS_FOURCC_UNFO_LIST: {
521 TRACE_(dmfile)(": UNFO list\n");
523 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
524 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
525 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
526 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (chunkID), chunkSize);
528 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
529 (though strings seem to be valid unicode) */
530 case mmioFOURCC('I','N','A','M'):
531 case DMUS_FOURCC_UNAM_CHUNK: {
532 TRACE_(dmfile)(": name chunk\n");
533 This->pDesc->dwValidData |= DMUS_OBJ_NAME;
534 IStream_Read (pStm, This->pDesc->wszName, chunkSize, NULL);
537 case mmioFOURCC('I','A','R','T'):
538 case DMUS_FOURCC_UART_CHUNK: {
539 TRACE_(dmfile)(": artist chunk (ignored)\n");
540 liMove.QuadPart = chunkSize;
541 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
544 case mmioFOURCC('I','C','O','P'):
545 case DMUS_FOURCC_UCOP_CHUNK: {
546 TRACE_(dmfile)(": copyright chunk (ignored)\n");
547 liMove.QuadPart = chunkSize;
548 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
551 case mmioFOURCC('I','S','B','J'):
552 case DMUS_FOURCC_USBJ_CHUNK: {
553 TRACE_(dmfile)(": subject chunk (ignored)\n");
554 liMove.QuadPart = chunkSize;
555 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
558 case mmioFOURCC('I','C','M','T'):
559 case DMUS_FOURCC_UCMT_CHUNK: {
560 TRACE_(dmfile)(": comment chunk (ignored)\n");
561 liMove.QuadPart = chunkSize;
562 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
566 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
567 liMove.QuadPart = chunkSize;
568 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
572 TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
573 } while (ListCount[0] < ListSize[0]);
577 TRACE_(dmfile)(": unknown (skipping)\n");
578 liMove.QuadPart = chunkSize - sizeof(FOURCC);
579 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
586 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
587 liMove.QuadPart = chunkSize;
588 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
592 TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
593 } while (StreamCount < StreamSize);
597 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
598 liMove.QuadPart = StreamSize;
599 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
603 TRACE_(dmfile)(": reading finished\n");
607 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
608 liMove.QuadPart = chunkSize;
609 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
617 static HRESULT WINAPI IDirectMusicAudioPathImpl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
621 static HRESULT WINAPI IDirectMusicAudioPathImpl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
625 static const IPersistStreamVtbl DirectMusicAudioPath_PersistStream_Vtbl = {
626 IDirectMusicAudioPathImpl_IPersistStream_QueryInterface,
627 IDirectMusicAudioPathImpl_IPersistStream_AddRef,
628 IDirectMusicAudioPathImpl_IPersistStream_Release,
629 IDirectMusicAudioPathImpl_IPersistStream_GetClassID,
630 IDirectMusicAudioPathImpl_IPersistStream_IsDirty,
631 IDirectMusicAudioPathImpl_IPersistStream_Load,
632 IDirectMusicAudioPathImpl_IPersistStream_Save,
633 IDirectMusicAudioPathImpl_IPersistStream_GetSizeMax
636 /* for ClassFactory */
637 HRESULT WINAPI DMUSIC_CreateDirectMusicAudioPathImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
638 IDirectMusicAudioPathImpl* obj;
640 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicAudioPathImpl));
643 return E_OUTOFMEMORY;
645 obj->UnknownVtbl = &DirectMusicAudioPath_Unknown_Vtbl;
646 obj->AudioPathVtbl = &DirectMusicAudioPath_AudioPath_Vtbl;
647 obj->ObjectVtbl = &DirectMusicAudioPath_Object_Vtbl;
648 obj->PersistStreamVtbl = &DirectMusicAudioPath_PersistStream_Vtbl;
649 obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
650 DM_STRUCT_INIT(obj->pDesc);
651 obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
652 memcpy (&obj->pDesc->guidClass, &CLSID_DirectMusicAudioPath, sizeof (CLSID));
653 obj->ref = 0; /* will be inited by QueryInterface */
655 return IDirectMusicAudioPathImpl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);