usp10/tests: Add a second set of glyph props that have changed in Windows 10.
[wine.git] / dlls / dmime / audiopath.c
blob04f0af03d07156fdc499da1ce9d4a742d5ea57fb
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"
21 #include "dmobject.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
24 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
26 struct IDirectMusicAudioPathImpl {
27 IDirectMusicAudioPath IDirectMusicAudioPath_iface;
28 struct dmobject dmobj;
29 LONG ref;
30 IDirectMusicPerformance8* pPerf;
31 IDirectMusicGraph* pToolGraph;
32 IDirectSoundBuffer* pDSBuffer;
33 IDirectSoundBuffer* pPrimary;
35 BOOL fActive;
38 static inline struct IDirectMusicAudioPathImpl *impl_from_IDirectMusicAudioPath(IDirectMusicAudioPath *iface)
40 return CONTAINING_RECORD(iface, struct IDirectMusicAudioPathImpl, IDirectMusicAudioPath_iface);
43 static inline struct IDirectMusicAudioPathImpl *impl_from_IDirectMusicObject(IDirectMusicObject *iface)
45 return CONTAINING_RECORD(iface, struct IDirectMusicAudioPathImpl, dmobj.IDirectMusicObject_iface);
48 static inline struct IDirectMusicAudioPathImpl *impl_from_IPersistStream(IPersistStream *iface)
50 return CONTAINING_RECORD(iface, struct IDirectMusicAudioPathImpl, dmobj.IPersistStream_iface);
53 void set_audiopath_perf_pointer(IDirectMusicAudioPath *iface, IDirectMusicPerformance8 *performance)
55 struct IDirectMusicAudioPathImpl *This = impl_from_IDirectMusicAudioPath(iface);
56 This->pPerf = performance;
59 void set_audiopath_dsound_buffer(IDirectMusicAudioPath *iface, IDirectSoundBuffer *buffer)
61 struct IDirectMusicAudioPathImpl *This = impl_from_IDirectMusicAudioPath(iface);
62 This->pDSBuffer = buffer;
65 void set_audiopath_primary_dsound_buffer(IDirectMusicAudioPath *iface, IDirectSoundBuffer *buffer)
67 struct IDirectMusicAudioPathImpl *This = impl_from_IDirectMusicAudioPath(iface);
68 This->pPrimary = buffer;
71 /*****************************************************************************
72 * IDirectMusicAudioPathImpl implementation
74 static HRESULT WINAPI IDirectMusicAudioPathImpl_QueryInterface (IDirectMusicAudioPath *iface, REFIID riid, void **ppobj)
76 struct IDirectMusicAudioPathImpl *This = impl_from_IDirectMusicAudioPath(iface);
78 TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
80 *ppobj = NULL;
82 if (IsEqualIID (riid, &IID_IDirectMusicAudioPath) || IsEqualIID (riid, &IID_IUnknown))
83 *ppobj = &This->IDirectMusicAudioPath_iface;
84 else if (IsEqualIID (riid, &IID_IDirectMusicObject))
85 *ppobj = &This->dmobj.IDirectMusicObject_iface;
86 else if (IsEqualIID (riid, &IID_IPersistStream))
87 *ppobj = &This->dmobj.IPersistStream_iface;
89 if (*ppobj) {
90 IUnknown_AddRef((IUnknown*)*ppobj);
91 return S_OK;
94 WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
95 return E_NOINTERFACE;
98 static ULONG WINAPI IDirectMusicAudioPathImpl_AddRef (IDirectMusicAudioPath *iface)
100 struct IDirectMusicAudioPathImpl *This = impl_from_IDirectMusicAudioPath(iface);
101 ULONG ref = InterlockedIncrement(&This->ref);
103 TRACE("(%p): AddRef from %d\n", This, ref - 1);
105 DMIME_LockModule();
106 return ref;
109 static ULONG WINAPI IDirectMusicAudioPathImpl_Release (IDirectMusicAudioPath *iface)
111 struct IDirectMusicAudioPathImpl *This = impl_from_IDirectMusicAudioPath(iface);
112 ULONG ref = InterlockedDecrement(&This->ref);
114 TRACE("(%p): ReleaseRef to %d\n", This, ref);
116 if (ref == 0) {
117 if (This->pDSBuffer)
118 IDirectSoundBuffer8_Release(This->pDSBuffer);
119 This->pPerf = NULL;
120 HeapFree(GetProcessHeap(), 0, This);
123 DMIME_UnlockModule();
124 return ref;
127 static HRESULT WINAPI IDirectMusicAudioPathImpl_GetObjectInPath (IDirectMusicAudioPath *iface, DWORD dwPChannel, DWORD dwStage, DWORD dwBuffer,
128 REFGUID guidObject, WORD dwIndex, REFGUID iidInterface, void** ppObject)
130 struct IDirectMusicAudioPathImpl *This = impl_from_IDirectMusicAudioPath(iface);
131 HRESULT hr;
133 FIXME("(%p, %d, %d, %d, %s, %d, %s, %p): stub\n", This, dwPChannel, dwStage, dwBuffer, debugstr_dmguid(guidObject),
134 dwIndex, debugstr_dmguid(iidInterface), ppObject);
136 switch (dwStage) {
137 case DMUS_PATH_BUFFER:
138 if (This->pDSBuffer)
140 if (IsEqualIID (iidInterface, &IID_IDirectSoundBuffer8)) {
141 IDirectSoundBuffer8_QueryInterface (This->pDSBuffer, &IID_IDirectSoundBuffer8, ppObject);
142 TRACE("returning %p\n",*ppObject);
143 return S_OK;
144 } else if (IsEqualIID (iidInterface, &IID_IDirectSound3DBuffer)) {
145 IDirectSoundBuffer8_QueryInterface (This->pDSBuffer, &IID_IDirectSound3DBuffer, ppObject);
146 TRACE("returning %p\n",*ppObject);
147 return S_OK;
148 } else {
149 FIXME("Bad iid\n");
152 break;
154 case DMUS_PATH_PRIMARY_BUFFER: {
155 if (IsEqualIID (iidInterface, &IID_IDirectSound3DListener)) {
156 IDirectSoundBuffer8_QueryInterface (This->pPrimary, &IID_IDirectSound3DListener, ppObject);
157 return S_OK;
158 } else {
159 FIXME("bad iid...\n");
162 break;
164 case DMUS_PATH_AUDIOPATH_GRAPH:
166 if (IsEqualIID (iidInterface, &IID_IDirectMusicGraph)) {
167 if (NULL == This->pToolGraph) {
168 IDirectMusicGraphImpl* pGraph;
169 hr = create_dmgraph(&IID_IDirectMusicGraph, (void**)&pGraph);
170 if (FAILED(hr))
171 return hr;
172 This->pToolGraph = (IDirectMusicGraph*) pGraph;
174 *ppObject = This->pToolGraph;
175 IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH) *ppObject);
176 return S_OK;
179 break;
181 case DMUS_PATH_AUDIOPATH_TOOL:
183 /* TODO */
185 break;
187 case DMUS_PATH_PERFORMANCE:
189 /* TODO check wanted GUID */
190 *ppObject = This->pPerf;
191 IUnknown_AddRef((LPUNKNOWN) *ppObject);
192 return S_OK;
194 break;
196 case DMUS_PATH_PERFORMANCE_GRAPH:
198 IDirectMusicGraph* pPerfoGraph = NULL;
199 IDirectMusicPerformance8_GetGraph(This->pPerf, &pPerfoGraph);
200 if (NULL == pPerfoGraph) {
201 IDirectMusicGraphImpl* pGraph = NULL;
202 hr = create_dmgraph(&IID_IDirectMusicGraph, (void**)&pGraph);
203 if (FAILED(hr))
204 return hr;
205 IDirectMusicPerformance8_SetGraph(This->pPerf, (IDirectMusicGraph*) pGraph);
206 /* we need release as SetGraph do an AddRef */
207 IDirectMusicGraph_Release((LPDIRECTMUSICGRAPH) pGraph);
208 pPerfoGraph = (LPDIRECTMUSICGRAPH) pGraph;
210 *ppObject = pPerfoGraph;
211 return S_OK;
213 break;
215 case DMUS_PATH_PERFORMANCE_TOOL:
216 default:
217 break;
220 *ppObject = NULL;
221 return E_INVALIDARG;
224 static HRESULT WINAPI IDirectMusicAudioPathImpl_Activate (IDirectMusicAudioPath *iface, BOOL fActivate)
226 struct IDirectMusicAudioPathImpl *This = impl_from_IDirectMusicAudioPath(iface);
227 FIXME("(%p, %d): stub\n", This, fActivate);
228 if (!fActivate) {
229 if (!This->fActive) return S_OK;
230 This->fActive = FALSE;
231 } else {
232 if (This->fActive) return S_OK;
233 This->fActive = TRUE;
234 if (NULL != This->pDSBuffer) {
235 IDirectSoundBuffer_Stop(This->pDSBuffer);
238 return S_OK;
241 static HRESULT WINAPI IDirectMusicAudioPathImpl_SetVolume (IDirectMusicAudioPath *iface, LONG lVolume, DWORD dwDuration)
243 struct IDirectMusicAudioPathImpl *This = impl_from_IDirectMusicAudioPath(iface);
244 FIXME("(%p, %i, %d): stub\n", This, lVolume, dwDuration);
245 return S_OK;
248 static HRESULT WINAPI IDirectMusicAudioPathImpl_ConvertPChannel (IDirectMusicAudioPath *iface, DWORD dwPChannelIn, DWORD* pdwPChannelOut)
250 struct IDirectMusicAudioPathImpl *This = impl_from_IDirectMusicAudioPath(iface);
251 FIXME("(%p, %d, %p): stub\n", This, dwPChannelIn, pdwPChannelOut);
252 return S_OK;
255 static const IDirectMusicAudioPathVtbl DirectMusicAudioPathVtbl = {
256 IDirectMusicAudioPathImpl_QueryInterface,
257 IDirectMusicAudioPathImpl_AddRef,
258 IDirectMusicAudioPathImpl_Release,
259 IDirectMusicAudioPathImpl_GetObjectInPath,
260 IDirectMusicAudioPathImpl_Activate,
261 IDirectMusicAudioPathImpl_SetVolume,
262 IDirectMusicAudioPathImpl_ConvertPChannel
265 /* IDirectMusicObject */
266 static HRESULT WINAPI DirectMusicObject_ParseDescriptor(IDirectMusicObject *iface, IStream *pStream, DMUS_OBJECTDESC *pDesc)
268 struct IDirectMusicAudioPathImpl *This = impl_from_IDirectMusicObject(iface);
269 DMUS_PRIVATE_CHUNK Chunk;
270 DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
271 LARGE_INTEGER liMove; /* used when skipping chunks */
273 TRACE("(%p, %p, %p)\n", This, pStream, pDesc);
275 /* FIXME: should this be determined from stream? */
276 pDesc->dwValidData |= DMUS_OBJ_CLASS;
277 pDesc->guidClass = This->dmobj.desc.guidClass;
279 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
280 TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
281 switch (Chunk.fccID) {
282 case FOURCC_RIFF: {
283 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
284 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
285 StreamSize = Chunk.dwSize - sizeof(FOURCC);
286 StreamCount = 0;
287 if (Chunk.fccID == DMUS_FOURCC_AUDIOPATH_FORM) {
288 TRACE_(dmfile)(": audio path form\n");
289 do {
290 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
291 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
292 TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
293 switch (Chunk.fccID) {
294 case DMUS_FOURCC_GUID_CHUNK: {
295 TRACE_(dmfile)(": GUID chunk\n");
296 pDesc->dwValidData |= DMUS_OBJ_OBJECT;
297 IStream_Read (pStream, &pDesc->guidObject, Chunk.dwSize, NULL);
298 break;
300 case DMUS_FOURCC_VERSION_CHUNK: {
301 TRACE_(dmfile)(": version chunk\n");
302 pDesc->dwValidData |= DMUS_OBJ_VERSION;
303 IStream_Read (pStream, &pDesc->vVersion, Chunk.dwSize, NULL);
304 break;
306 case DMUS_FOURCC_CATEGORY_CHUNK: {
307 TRACE_(dmfile)(": category chunk\n");
308 pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
309 IStream_Read (pStream, pDesc->wszCategory, Chunk.dwSize, NULL);
310 break;
312 case FOURCC_LIST: {
313 IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
314 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
315 ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
316 ListCount[0] = 0;
317 switch (Chunk.fccID) {
318 /* evil M$ UNFO list, which can (!?) contain INFO elements */
319 case DMUS_FOURCC_UNFO_LIST: {
320 TRACE_(dmfile)(": UNFO list\n");
321 do {
322 IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
323 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
324 TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
325 switch (Chunk.fccID) {
326 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
327 (though strings seem to be valid unicode) */
328 case mmioFOURCC('I','N','A','M'):
329 case DMUS_FOURCC_UNAM_CHUNK: {
330 TRACE_(dmfile)(": name chunk\n");
331 pDesc->dwValidData |= DMUS_OBJ_NAME;
332 IStream_Read (pStream, pDesc->wszName, Chunk.dwSize, NULL);
333 break;
335 case mmioFOURCC('I','A','R','T'):
336 case DMUS_FOURCC_UART_CHUNK: {
337 TRACE_(dmfile)(": artist chunk (ignored)\n");
338 liMove.QuadPart = Chunk.dwSize;
339 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
340 break;
342 case mmioFOURCC('I','C','O','P'):
343 case DMUS_FOURCC_UCOP_CHUNK: {
344 TRACE_(dmfile)(": copyright chunk (ignored)\n");
345 liMove.QuadPart = Chunk.dwSize;
346 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
347 break;
349 case mmioFOURCC('I','S','B','J'):
350 case DMUS_FOURCC_USBJ_CHUNK: {
351 TRACE_(dmfile)(": subject chunk (ignored)\n");
352 liMove.QuadPart = Chunk.dwSize;
353 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
354 break;
356 case mmioFOURCC('I','C','M','T'):
357 case DMUS_FOURCC_UCMT_CHUNK: {
358 TRACE_(dmfile)(": comment chunk (ignored)\n");
359 liMove.QuadPart = Chunk.dwSize;
360 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
361 break;
363 default: {
364 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
365 liMove.QuadPart = Chunk.dwSize;
366 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
367 break;
370 TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
371 } while (ListCount[0] < ListSize[0]);
372 break;
374 default: {
375 TRACE_(dmfile)(": unknown (skipping)\n");
376 liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
377 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
378 break;
381 break;
383 default: {
384 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
385 liMove.QuadPart = Chunk.dwSize;
386 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
387 break;
390 TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
391 } while (StreamCount < StreamSize);
392 } else {
393 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
394 liMove.QuadPart = StreamSize;
395 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
396 return E_FAIL;
399 TRACE_(dmfile)(": reading finished\n");
400 break;
402 default: {
403 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
404 liMove.QuadPart = Chunk.dwSize;
405 IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
406 return DMUS_E_INVALIDFILE;
410 TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC (pDesc));
412 return S_OK;
415 static const IDirectMusicObjectVtbl dmobject_vtbl = {
416 dmobj_IDirectMusicObject_QueryInterface,
417 dmobj_IDirectMusicObject_AddRef,
418 dmobj_IDirectMusicObject_Release,
419 dmobj_IDirectMusicObject_GetDescriptor,
420 dmobj_IDirectMusicObject_SetDescriptor,
421 DirectMusicObject_ParseDescriptor
424 /* IPersistStream */
425 static HRESULT WINAPI PersistStream_Load(IPersistStream *iface, IStream *pStm)
427 struct IDirectMusicAudioPathImpl *This = impl_from_IPersistStream(iface);
429 FOURCC chunkID;
430 DWORD chunkSize, StreamSize, StreamCount, ListSize[3], ListCount[3];
431 LARGE_INTEGER liMove; /* used when skipping chunks */
433 FIXME("(%p, %p): Loading not implemented yet\n", This, pStm);
434 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
435 IStream_Read (pStm, &chunkSize, sizeof(DWORD), NULL);
436 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (chunkID), chunkSize);
437 switch (chunkID) {
438 case FOURCC_RIFF: {
439 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
440 TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunkID));
441 StreamSize = chunkSize - sizeof(FOURCC);
442 StreamCount = 0;
443 switch (chunkID) {
444 case DMUS_FOURCC_AUDIOPATH_FORM: {
445 TRACE_(dmfile)(": audio path form\n");
446 do {
447 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
448 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
449 StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
450 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (chunkID), chunkSize);
451 switch (chunkID) {
452 case DMUS_FOURCC_GUID_CHUNK: {
453 TRACE_(dmfile)(": GUID chunk\n");
454 This->dmobj.desc.dwValidData |= DMUS_OBJ_OBJECT;
455 IStream_Read (pStm, &This->dmobj.desc.guidObject, chunkSize, NULL);
456 break;
458 case DMUS_FOURCC_VERSION_CHUNK: {
459 TRACE_(dmfile)(": version chunk\n");
460 This->dmobj.desc.dwValidData |= DMUS_OBJ_VERSION;
461 IStream_Read (pStm, &This->dmobj.desc.vVersion, chunkSize, NULL);
462 break;
464 case DMUS_FOURCC_CATEGORY_CHUNK: {
465 TRACE_(dmfile)(": category chunk\n");
466 This->dmobj.desc.dwValidData |= DMUS_OBJ_CATEGORY;
467 IStream_Read (pStm, This->dmobj.desc.wszCategory, chunkSize, NULL);
468 break;
470 case FOURCC_LIST: {
471 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
472 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
473 ListSize[0] = chunkSize - sizeof(FOURCC);
474 ListCount[0] = 0;
475 switch (chunkID) {
476 case DMUS_FOURCC_UNFO_LIST: {
477 TRACE_(dmfile)(": UNFO list\n");
478 do {
479 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
480 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
481 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
482 TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (chunkID), chunkSize);
483 switch (chunkID) {
484 /* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
485 (though strings seem to be valid unicode) */
486 case mmioFOURCC('I','N','A','M'):
487 case DMUS_FOURCC_UNAM_CHUNK: {
488 TRACE_(dmfile)(": name chunk\n");
489 This->dmobj.desc.dwValidData |= DMUS_OBJ_NAME;
490 IStream_Read (pStm, This->dmobj.desc.wszName, chunkSize, NULL);
491 break;
493 case mmioFOURCC('I','A','R','T'):
494 case DMUS_FOURCC_UART_CHUNK: {
495 TRACE_(dmfile)(": artist chunk (ignored)\n");
496 liMove.QuadPart = chunkSize;
497 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
498 break;
500 case mmioFOURCC('I','C','O','P'):
501 case DMUS_FOURCC_UCOP_CHUNK: {
502 TRACE_(dmfile)(": copyright chunk (ignored)\n");
503 liMove.QuadPart = chunkSize;
504 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
505 break;
507 case mmioFOURCC('I','S','B','J'):
508 case DMUS_FOURCC_USBJ_CHUNK: {
509 TRACE_(dmfile)(": subject chunk (ignored)\n");
510 liMove.QuadPart = chunkSize;
511 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
512 break;
514 case mmioFOURCC('I','C','M','T'):
515 case DMUS_FOURCC_UCMT_CHUNK: {
516 TRACE_(dmfile)(": comment chunk (ignored)\n");
517 liMove.QuadPart = chunkSize;
518 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
519 break;
521 default: {
522 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
523 liMove.QuadPart = chunkSize;
524 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
525 break;
528 TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
529 } while (ListCount[0] < ListSize[0]);
530 break;
532 default: {
533 TRACE_(dmfile)(": unknown (skipping)\n");
534 liMove.QuadPart = chunkSize - sizeof(FOURCC);
535 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
536 break;
539 break;
541 default: {
542 TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
543 liMove.QuadPart = chunkSize;
544 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
545 break;
548 TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
549 } while (StreamCount < StreamSize);
550 break;
552 default: {
553 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
554 liMove.QuadPart = StreamSize;
555 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
556 return E_FAIL;
559 TRACE_(dmfile)(": reading finished\n");
560 break;
562 default: {
563 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
564 liMove.QuadPart = chunkSize;
565 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
566 return E_FAIL;
570 return S_OK;
573 static const IPersistStreamVtbl persiststream_vtbl = {
574 dmobj_IPersistStream_QueryInterface,
575 dmobj_IPersistStream_AddRef,
576 dmobj_IPersistStream_Release,
577 dmobj_IPersistStream_GetClassID,
578 unimpl_IPersistStream_IsDirty,
579 PersistStream_Load,
580 unimpl_IPersistStream_Save,
581 unimpl_IPersistStream_GetSizeMax
584 /* for ClassFactory */
585 HRESULT WINAPI create_dmaudiopath(REFIID riid, void **ppobj)
587 IDirectMusicAudioPathImpl* obj;
588 HRESULT hr;
590 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicAudioPathImpl));
591 if (NULL == obj) {
592 *ppobj = NULL;
593 return E_OUTOFMEMORY;
595 obj->IDirectMusicAudioPath_iface.lpVtbl = &DirectMusicAudioPathVtbl;
596 obj->ref = 1;
597 dmobject_init(&obj->dmobj, &CLSID_DirectMusicAudioPathConfig,
598 (IUnknown *)&obj->IDirectMusicAudioPath_iface);
599 obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl;
600 obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
602 hr = IDirectMusicAudioPath_QueryInterface(&obj->IDirectMusicAudioPath_iface, riid, ppobj);
603 IDirectMusicAudioPath_Release(&obj->IDirectMusicAudioPath_iface);
604 return hr;