Removed non-standard header includes.
[wine/multimedia.git] / dlls / dmime / segment.c
blob7e8be4e8701a44a7cea6bf1d8d28f39e14986562
1 /* IDirectMusicSegment8 Implementation
3 * Copyright (C) 2003 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 "windef.h"
21 #include "winbase.h"
22 #include "winuser.h"
23 #include "wingdi.h"
24 #include "wine/debug.h"
26 #include "dmime_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(dmime);
29 WINE_DECLARE_DEBUG_CHANNEL(dmfile);
31 /*****************************************************************************
32 * IDirectMusicSegment8Impl implementation
34 /* IDirectMusicSegment8 IUnknown part: */
35 HRESULT WINAPI IDirectMusicSegment8Impl_QueryInterface (LPDIRECTMUSICSEGMENT8 iface, REFIID riid, LPVOID *ppobj)
37 ICOM_THIS(IDirectMusicSegment8Impl,iface);
39 if (IsEqualIID (riid, &IID_IUnknown) ||
40 IsEqualIID (riid, &IID_IDirectMusicSegment) ||
41 IsEqualIID (riid, &IID_IDirectMusicSegment8)) {
42 IDirectMusicSegment8Impl_AddRef(iface);
43 *ppobj = This;
44 return S_OK;
47 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
48 return E_NOINTERFACE;
51 ULONG WINAPI IDirectMusicSegment8Impl_AddRef (LPDIRECTMUSICSEGMENT8 iface)
53 ICOM_THIS(IDirectMusicSegment8Impl,iface);
54 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
55 return ++(This->ref);
58 ULONG WINAPI IDirectMusicSegment8Impl_Release (LPDIRECTMUSICSEGMENT8 iface)
60 ICOM_THIS(IDirectMusicSegment8Impl,iface);
61 ULONG ref = --This->ref;
62 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
63 if (ref == 0) {
64 HeapFree(GetProcessHeap(), 0, This);
66 return ref;
69 /* IDirectMusicSegment8 IDirectMusicSegment part: */
70 HRESULT WINAPI IDirectMusicSegment8Impl_GetLength (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME* pmtLength)
72 ICOM_THIS(IDirectMusicSegment8Impl,iface);
74 TRACE("(%p, %p)\n", This, pmtLength);
75 *pmtLength = This->segHeader.mtLength;
77 return S_OK;
80 HRESULT WINAPI IDirectMusicSegment8Impl_SetLength (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtLength)
82 ICOM_THIS(IDirectMusicSegment8Impl,iface);
84 TRACE("(%p, %ld)\n", This, mtLength);
85 This->segHeader.mtLength = mtLength;
87 return S_OK;
90 HRESULT WINAPI IDirectMusicSegment8Impl_GetRepeats (LPDIRECTMUSICSEGMENT8 iface, DWORD* pdwRepeats)
92 ICOM_THIS(IDirectMusicSegment8Impl,iface);
94 TRACE("(%p, %p)\n", This, pdwRepeats);
95 *pdwRepeats = This->segHeader.dwRepeats;
97 return S_OK;
100 HRESULT WINAPI IDirectMusicSegment8Impl_SetRepeats (LPDIRECTMUSICSEGMENT8 iface, DWORD dwRepeats)
102 ICOM_THIS(IDirectMusicSegment8Impl,iface);
104 TRACE("(%p, %ld)\n", This, dwRepeats);
105 This->segHeader.dwRepeats = dwRepeats;
107 return S_OK;
110 HRESULT WINAPI IDirectMusicSegment8Impl_GetDefaultResolution (LPDIRECTMUSICSEGMENT8 iface, DWORD* pdwResolution)
112 ICOM_THIS(IDirectMusicSegment8Impl,iface);
114 TRACE("(%p, %p)\n", This, pdwResolution);
115 *pdwResolution = This->segHeader.dwResolution;
117 return S_OK;
120 HRESULT WINAPI IDirectMusicSegment8Impl_SetDefaultResolution (LPDIRECTMUSICSEGMENT8 iface, DWORD dwResolution)
122 ICOM_THIS(IDirectMusicSegment8Impl,iface);
124 TRACE("(%p, %ld)\n", This, dwResolution);
125 This->segHeader.dwResolution = dwResolution;
127 return S_OK;
130 HRESULT WINAPI IDirectMusicSegment8Impl_GetTrack (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, IDirectMusicTrack** ppTrack)
132 ICOM_THIS(IDirectMusicSegment8Impl,iface);
134 FIXME("(%p, %s, %ld, %ld, %p): stub\n", This, debugstr_guid(rguidType), dwGroupBits, dwIndex, ppTrack);
136 return S_OK;
139 HRESULT WINAPI IDirectMusicSegment8Impl_GetTrackGroup (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicTrack* pTrack, DWORD* pdwGroupBits)
141 ICOM_THIS(IDirectMusicSegment8Impl,iface);
143 FIXME("(%p, %p, %p): stub\n", This, pTrack, pdwGroupBits);
145 return S_OK;
148 HRESULT WINAPI IDirectMusicSegment8Impl_InsertTrack (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicTrack* pTrack, DWORD dwGroupBits)
150 ICOM_THIS(IDirectMusicSegment8Impl,iface);
152 FIXME("(%p, %p, %ld): stub\n", This, pTrack, dwGroupBits);
154 return S_OK;
157 HRESULT WINAPI IDirectMusicSegment8Impl_RemoveTrack (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicTrack* pTrack)
159 ICOM_THIS(IDirectMusicSegment8Impl,iface);
161 FIXME("(%p, %p): stub\n", This, pTrack);
163 return S_OK;
166 HRESULT WINAPI IDirectMusicSegment8Impl_InitPlay (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicSegmentState** ppSegState, IDirectMusicPerformance* pPerformance, DWORD dwFlags)
168 ICOM_THIS(IDirectMusicSegment8Impl,iface);
170 FIXME("(%p, %p, %p, %ld): stub\n", This, ppSegState, pPerformance, dwFlags);
172 return S_OK;
175 HRESULT WINAPI IDirectMusicSegment8Impl_GetGraph (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicGraph** ppGraph)
177 ICOM_THIS(IDirectMusicSegment8Impl,iface);
179 FIXME("(%p, %p): stub\n", This, ppGraph);
181 return S_OK;
184 HRESULT WINAPI IDirectMusicSegment8Impl_SetGraph (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicGraph* pGraph)
186 ICOM_THIS(IDirectMusicSegment8Impl,iface);
188 FIXME("(%p, %p): stub\n", This, pGraph);
190 return S_OK;
193 HRESULT WINAPI IDirectMusicSegment8Impl_AddNotificationType (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidNotificationType)
195 ICOM_THIS(IDirectMusicSegment8Impl,iface);
197 FIXME("(%p, %s): stub\n", This, debugstr_guid(rguidNotificationType));
199 return S_OK;
202 HRESULT WINAPI IDirectMusicSegment8Impl_RemoveNotificationType (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidNotificationType)
204 ICOM_THIS(IDirectMusicSegment8Impl,iface);
206 FIXME("(%p, %s): stub\n", This, debugstr_guid(rguidNotificationType));
208 return S_OK;
211 HRESULT WINAPI IDirectMusicSegment8Impl_GetParam (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, MUSIC_TIME* pmtNext, void* pParam)
213 ICOM_THIS(IDirectMusicSegment8Impl,iface);
215 FIXME("(%p, %s, %ld, %ld, %ld, %p, %p): stub\n", This, debugstr_guid(rguidType), dwGroupBits, dwIndex, mtTime, pmtNext, pParam);
217 return S_OK;
220 HRESULT WINAPI IDirectMusicSegment8Impl_SetParam (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, MUSIC_TIME mtTime, void* pParam)
222 ICOM_THIS(IDirectMusicSegment8Impl,iface);
224 FIXME("(%p, %s, %ld, %ld, %ld, %p): stub\n", This, debugstr_guid(rguidType), dwGroupBits, dwIndex, mtTime, pParam);
226 return S_OK;
229 HRESULT WINAPI IDirectMusicSegment8Impl_Clone (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd, IDirectMusicSegment** ppSegment)
231 ICOM_THIS(IDirectMusicSegment8Impl,iface);
233 FIXME("(%p, %ld, %ld, %p): stub\n", This, mtStart, mtEnd, ppSegment);
235 return S_OK;
238 HRESULT WINAPI IDirectMusicSegment8Impl_SetStartPoint (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtStart)
240 ICOM_THIS(IDirectMusicSegment8Impl,iface);
242 TRACE("(%p, %ld): stub\n", This, mtStart);
243 This->segHeader.mtPlayStart = mtStart;
245 return S_OK;
248 HRESULT WINAPI IDirectMusicSegment8Impl_GetStartPoint (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME* pmtStart)
250 ICOM_THIS(IDirectMusicSegment8Impl,iface);
252 TRACE("(%p, %p): stub\n", This, pmtStart);
253 *pmtStart = This->segHeader.mtPlayStart;
255 return S_OK;
258 HRESULT WINAPI IDirectMusicSegment8Impl_SetLoopPoints (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd)
260 ICOM_THIS(IDirectMusicSegment8Impl,iface);
262 TRACE("(%p, %ld, %ld): stub\n", This, mtStart, mtEnd);
263 This->segHeader.mtLoopStart = mtStart;
264 This->segHeader.mtLoopEnd = mtEnd;
266 return S_OK;
269 HRESULT WINAPI IDirectMusicSegment8Impl_GetLoopPoints (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME* pmtStart, MUSIC_TIME* pmtEnd)
271 ICOM_THIS(IDirectMusicSegment8Impl,iface);
273 TRACE("(%p, %p, %p): stub\n", This, pmtStart, pmtEnd);
274 *pmtStart = This->segHeader.mtLoopStart;
275 *pmtEnd = This->segHeader.mtLoopEnd;
277 return S_OK;
280 HRESULT WINAPI IDirectMusicSegment8Impl_SetPChannelsUsed (LPDIRECTMUSICSEGMENT8 iface, DWORD dwNumPChannels, DWORD* paPChannels)
282 ICOM_THIS(IDirectMusicSegment8Impl,iface);
284 FIXME("(%p, %ld, %p): stub\n", This, dwNumPChannels, paPChannels);
286 return S_OK;
289 /* IDirectMusicSegment8 IDirectMusicSegment8 part: */
290 HRESULT WINAPI IDirectMusicSegment8Impl_SetTrackConfig (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidTrackClassID, DWORD dwGroupBits, DWORD dwIndex, DWORD dwFlagsOn, DWORD dwFlagsOff)
292 ICOM_THIS(IDirectMusicSegment8Impl,iface);
294 FIXME("(%p, %s, %ld, %ld, %ld, %ld): stub\n", This, debugstr_guid(rguidTrackClassID), dwGroupBits, dwIndex, dwFlagsOn, dwFlagsOff);
296 return S_OK;
299 HRESULT WINAPI IDirectMusicSegment8Impl_GetAudioPathConfig (LPDIRECTMUSICSEGMENT8 iface, IUnknown** ppAudioPathConfig)
301 ICOM_THIS(IDirectMusicSegment8Impl,iface);
303 FIXME("(%p, %p): stub\n", This, ppAudioPathConfig);
305 return S_OK;
308 HRESULT WINAPI IDirectMusicSegment8Impl_Compose (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtTime, IDirectMusicSegment* pFromSegment, IDirectMusicSegment* pToSegment, IDirectMusicSegment** ppComposedSegment)
310 ICOM_THIS(IDirectMusicSegment8Impl,iface);
312 FIXME("(%p, %ld, %p, %p, %p): stub\n", This, mtTime, pFromSegment, pToSegment, ppComposedSegment);
314 return S_OK;
317 HRESULT WINAPI IDirectMusicSegment8Impl_Download (LPDIRECTMUSICSEGMENT8 iface, IUnknown *pAudioPath)
319 ICOM_THIS(IDirectMusicSegment8Impl,iface);
321 FIXME("(%p, %p): stub\n", This, pAudioPath);
323 return S_OK;
326 HRESULT WINAPI IDirectMusicSegment8Impl_Unload (LPDIRECTMUSICSEGMENT8 iface, IUnknown *pAudioPath)
328 ICOM_THIS(IDirectMusicSegment8Impl,iface);
330 FIXME("(%p, %p): stub\n", This, pAudioPath);
332 return S_OK;
335 ICOM_VTABLE(IDirectMusicSegment8) DirectMusicSegment8_Vtbl =
337 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
338 IDirectMusicSegment8Impl_QueryInterface,
339 IDirectMusicSegment8Impl_AddRef,
340 IDirectMusicSegment8Impl_Release,
341 IDirectMusicSegment8Impl_GetLength,
342 IDirectMusicSegment8Impl_SetLength,
343 IDirectMusicSegment8Impl_GetRepeats,
344 IDirectMusicSegment8Impl_SetRepeats,
345 IDirectMusicSegment8Impl_GetDefaultResolution,
346 IDirectMusicSegment8Impl_SetDefaultResolution,
347 IDirectMusicSegment8Impl_GetTrack,
348 IDirectMusicSegment8Impl_GetTrackGroup,
349 IDirectMusicSegment8Impl_InsertTrack,
350 IDirectMusicSegment8Impl_RemoveTrack,
351 IDirectMusicSegment8Impl_InitPlay,
352 IDirectMusicSegment8Impl_GetGraph,
353 IDirectMusicSegment8Impl_SetGraph,
354 IDirectMusicSegment8Impl_AddNotificationType,
355 IDirectMusicSegment8Impl_RemoveNotificationType,
356 IDirectMusicSegment8Impl_GetParam,
357 IDirectMusicSegment8Impl_SetParam,
358 IDirectMusicSegment8Impl_Clone,
359 IDirectMusicSegment8Impl_SetStartPoint,
360 IDirectMusicSegment8Impl_GetStartPoint,
361 IDirectMusicSegment8Impl_SetLoopPoints,
362 IDirectMusicSegment8Impl_GetLoopPoints,
363 IDirectMusicSegment8Impl_SetPChannelsUsed,
364 IDirectMusicSegment8Impl_SetTrackConfig,
365 IDirectMusicSegment8Impl_GetAudioPathConfig,
366 IDirectMusicSegment8Impl_Compose,
367 IDirectMusicSegment8Impl_Download,
368 IDirectMusicSegment8Impl_Unload
371 /* for ClassFactory */
372 HRESULT WINAPI DMUSIC_CreateDirectMusicSegment (LPCGUID lpcGUID, LPDIRECTMUSICSEGMENT8 *ppDMSeg, LPUNKNOWN pUnkOuter)
374 IDirectMusicSegment8Impl *segment;
376 TRACE("(%p,%p,%p)\n", lpcGUID, ppDMSeg, pUnkOuter);
377 if (IsEqualIID (lpcGUID, &IID_IDirectMusicSegment)
378 || IsEqualIID (lpcGUID, &IID_IDirectMusicSegment2)
379 || IsEqualIID (lpcGUID, &IID_IDirectMusicSegment8)) {
380 segment = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSegment8Impl));
381 if (NULL == segment) {
382 *ppDMSeg = (LPDIRECTMUSICSEGMENT8) NULL;
383 return E_OUTOFMEMORY;
385 segment->lpVtbl = &DirectMusicSegment8_Vtbl;
386 segment->ref = 1;
387 *ppDMSeg = (LPDIRECTMUSICSEGMENT8) segment;
388 return S_OK;
391 WARN("No interface found\n");
392 return E_NOINTERFACE;
396 /*****************************************************************************
397 * IDirectMusicSegmentObject implementation
399 /* IDirectMusicSegmentObject IUnknown part: */
400 HRESULT WINAPI IDirectMusicSegmentObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj)
402 ICOM_THIS(IDirectMusicSegmentObject,iface);
404 if (IsEqualGUID(riid, &IID_IUnknown)
405 || IsEqualGUID(riid, &IID_IDirectMusicObject)) {
406 IDirectMusicSegmentObject_AddRef(iface);
407 *ppobj = This;
408 return S_OK;
409 } else if (IsEqualGUID (riid, &IID_IPersistStream)) {
410 IDirectMusicSegmentObjectStream_AddRef ((LPPERSISTSTREAM)This->pStream);
411 *ppobj = This->pStream;
412 return S_OK;
413 } else if (IsEqualGUID (riid, &IID_IDirectMusicSegment)
414 || IsEqualGUID (riid, &IID_IDirectMusicSegment8)) {
415 IDirectMusicSegment8Impl_AddRef ((LPDIRECTMUSICSEGMENT8)This->pSegment);
416 *ppobj = This->pSegment;
417 return S_OK;
419 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
420 return E_NOINTERFACE;
423 ULONG WINAPI IDirectMusicSegmentObject_AddRef (LPDIRECTMUSICOBJECT iface)
425 ICOM_THIS(IDirectMusicSegmentObject,iface);
426 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
427 return ++(This->ref);
430 ULONG WINAPI IDirectMusicSegmentObject_Release (LPDIRECTMUSICOBJECT iface)
432 ICOM_THIS(IDirectMusicSegmentObject,iface);
433 ULONG ref = --This->ref;
434 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
435 if (ref == 0)
437 HeapFree(GetProcessHeap(), 0, This);
439 return ref;
442 /* IDirectMusicSegmentObject IDirectMusicObject part: */
443 HRESULT WINAPI IDirectMusicSegmentObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
445 ICOM_THIS(IDirectMusicSegmentObject,iface);
447 TRACE("(%p, %p)\n", This, pDesc);
448 pDesc = This->pDesc;
450 return S_OK;
453 HRESULT WINAPI IDirectMusicSegmentObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
455 ICOM_THIS(IDirectMusicSegmentObject,iface);
457 TRACE("(%p, %p)\n", This, pDesc);
458 This->pDesc = pDesc;
460 return S_OK;
463 HRESULT WINAPI IDirectMusicSegmentObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc)
465 ICOM_THIS(IDirectMusicSegmentObject,iface);
467 FIXME("(%p, %p, %p): stub\n", This, pStream, pDesc);
469 return S_OK;
472 ICOM_VTABLE(IDirectMusicObject) DirectMusicSegmentObject_Vtbl =
474 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
475 IDirectMusicSegmentObject_QueryInterface,
476 IDirectMusicSegmentObject_AddRef,
477 IDirectMusicSegmentObject_Release,
478 IDirectMusicSegmentObject_GetDescriptor,
479 IDirectMusicSegmentObject_SetDescriptor,
480 IDirectMusicSegmentObject_ParseDescriptor
483 /* for ClassFactory */
484 HRESULT WINAPI DMUSIC_CreateDirectMusicSegmentObject (LPCGUID lpcGUID, LPDIRECTMUSICOBJECT* ppObject, LPUNKNOWN pUnkOuter)
486 IDirectMusicSegmentObject *obj;
488 TRACE("(%p,%p,%p)\n", lpcGUID, ppObject, pUnkOuter);
489 if (IsEqualGUID (lpcGUID, &IID_IDirectMusicObject)) {
490 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSegmentObject));
491 if (NULL == obj) {
492 *ppObject = (LPDIRECTMUSICOBJECT) NULL;
493 return E_OUTOFMEMORY;
495 obj->lpVtbl = &DirectMusicSegmentObject_Vtbl;
496 obj->ref = 1;
497 /* prepare IPersistStream */
498 obj->pStream = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicSegmentObjectStream));
499 obj->pStream->lpVtbl = &DirectMusicSegmentObjectStream_Vtbl;
500 obj->pStream->ref = 1;
501 obj->pStream->pParentObject = obj;
502 /* prepare IDirectMusicSegment8 */
503 DMUSIC_CreateDirectMusicSegment (&IID_IDirectMusicSegment8, (LPDIRECTMUSICSEGMENT8*)&obj->pSegment, NULL);
504 obj->pSegment->pObject = obj;
505 *ppObject = (LPDIRECTMUSICOBJECT) obj;
506 return S_OK;
508 WARN("No interface found\n");
510 return E_NOINTERFACE;
513 /*****************************************************************************
514 * IDirectMusicSegmentObjectStream implementation
516 /* IDirectMusicSegmentObjectStream IUnknown part: */
517 HRESULT WINAPI IDirectMusicSegmentObjectStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj)
519 ICOM_THIS(IDirectMusicSegmentObjectStream,iface);
521 if (IsEqualGUID(riid, &IID_IUnknown)
522 || IsEqualGUID(riid, &IID_IPersistStream)) {
523 IDirectMusicSegmentObjectStream_AddRef (iface);
524 *ppobj = This;
525 return S_OK;
527 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
528 return E_NOINTERFACE;
531 ULONG WINAPI IDirectMusicSegmentObjectStream_AddRef (LPPERSISTSTREAM iface)
533 ICOM_THIS(IDirectMusicSegmentObjectStream,iface);
534 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
535 return ++(This->ref);
538 ULONG WINAPI IDirectMusicSegmentObjectStream_Release (LPPERSISTSTREAM iface)
540 ICOM_THIS(IDirectMusicSegmentObjectStream,iface);
541 ULONG ref = --This->ref;
542 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
543 if (ref == 0)
545 HeapFree(GetProcessHeap(), 0, This);
547 return ref;
550 /* IDirectMusicSegmentObjectStream IPersist part: */
551 HRESULT WINAPI IDirectMusicSegmentObjectStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID)
553 return E_NOTIMPL;
556 /* IDirectMusicSegmentObjectStream IPersistStream part: */
557 HRESULT WINAPI IDirectMusicSegmentObjectStream_IsDirty (LPPERSISTSTREAM iface)
559 return E_NOTIMPL;
562 HRESULT WINAPI IDirectMusicSegmentObjectStream_Load (LPPERSISTSTREAM iface, IStream* pStm)
564 ICOM_THIS(IDirectMusicSegmentObjectStream,iface);
565 FOURCC chunkID;
566 DWORD chunkSize, StreamSize, StreamCount, ListSize[10], ListCount[10];
567 LARGE_INTEGER liMove; /* used when skipping chunks */
568 IDirectMusicSegment8Impl* pSegment = This->pParentObject->pSegment; /* that's where we load data */
569 DMUS_IO_TRACK_HEADER tempHeader;
570 DMUS_IO_TRACK_EXTRAS_HEADER tempXHeader;
572 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
573 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
574 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
575 switch (chunkID)
577 case FOURCC_RIFF: {
578 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
579 TRACE_(dmfile)(": RIFF chunk containing %s", debugstr_fourcc (chunkID));
580 StreamSize = chunkSize - sizeof(FOURCC);
581 StreamCount = 0;
582 switch (chunkID)
584 case DMUS_FOURCC_SEGMENT_FORM: {
585 TRACE_(dmfile)(": segment form\n");
586 do {
587 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
588 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
589 StreamCount += sizeof (FOURCC) + sizeof (DWORD) + chunkSize;
590 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
591 switch (chunkID) {
592 case DMUS_FOURCC_SEGMENT_CHUNK: {
593 TRACE_(dmfile)(": segment header chunk\n");
594 IStream_Read (pStm, &pSegment->segHeader, chunkSize, NULL);
595 break;
597 case DMUS_FOURCC_GUID_CHUNK: {
598 TRACE_(dmfile)(": GUID chunk\n");
599 IStream_Read (pStm, &pSegment->vVersion, chunkSize, NULL);
600 break;
602 case DMUS_FOURCC_VERSION_CHUNK: {
603 TRACE_(dmfile)(": version chunk\n");
604 IStream_Read (pStm, &pSegment->guidID, chunkSize, NULL);
605 break;
607 case FOURCC_LIST: {
608 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
609 TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
610 ListSize[0] = chunkSize - sizeof(FOURCC);
611 ListCount[0] = 0;
612 switch (chunkID) {
613 case DMUS_FOURCC_UNFO_LIST: {
614 TRACE_(dmfile)(": UNFO list\n");
615 do {
616 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
617 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
618 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
619 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
620 switch (chunkID) {
621 case DMUS_FOURCC_UNAM_CHUNK: {
622 TRACE_(dmfile)(": name chunk\n");
623 pSegment->wszName = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
624 IStream_Read (pStm, pSegment->wszName, chunkSize, NULL);
625 break;
627 case DMUS_FOURCC_UART_CHUNK: {
628 TRACE_(dmfile)(": artist chunk\n");
629 pSegment->wszArtist = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
630 IStream_Read (pStm, pSegment->wszArtist, chunkSize, NULL);
631 break;
633 case DMUS_FOURCC_UCOP_CHUNK: {
634 TRACE_(dmfile)(": copyright chunk\n");
635 pSegment->wszCopyright = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
636 IStream_Read (pStm, pSegment->wszCopyright, chunkSize, NULL);
637 break;
639 case DMUS_FOURCC_USBJ_CHUNK: {
640 TRACE_(dmfile)(": subject chunk\n");
641 pSegment->wszSubject = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
642 IStream_Read (pStm, pSegment->wszSubject, chunkSize, NULL);
643 break;
645 case DMUS_FOURCC_UCMT_CHUNK: {
646 TRACE_(dmfile)(": comment chunk\n");
647 pSegment->wszComment = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, chunkSize);
648 IStream_Read (pStm, pSegment->wszComment, chunkSize, NULL);
649 break;
651 default: {
652 TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
653 liMove.QuadPart = chunkSize;
654 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
655 break;
658 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
659 } while (ListCount[0] < ListSize[0]);
660 break;
662 case DMUS_FOURCC_TRACK_LIST: {
663 TRACE_(dmfile)(": track list\n");
664 do {
665 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
666 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
667 ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
668 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
669 switch (chunkID)
671 case FOURCC_RIFF: {
672 TRACE_(dmfile)(": RIFF chunk");
673 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
674 switch (chunkID)
676 case DMUS_FOURCC_TRACK_FORM: {
677 TRACE_(dmfile)(": containing %s: track form\n", debugstr_fourcc(chunkID));
678 ListSize[1] = chunkSize - sizeof(FOURCC);
679 ListCount[1] = 0;
680 do {
681 IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
682 IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
683 ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
684 TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (chunkID), chunkSize);
685 switch (chunkID) {
686 case DMUS_FOURCC_TRACK_CHUNK: {
687 TRACE_(dmfile)(": track header chunk\n");
688 IStream_Read (pStm, &tempHeader, chunkSize, NULL);
689 break;
691 case DMUS_FOURCC_TRACK_EXTRAS_CHUNK: {
692 TRACE_(dmfile)(": track extra header chunk\n");
693 IStream_Read (pStm, &tempXHeader, chunkSize, NULL);
694 break;
696 /* add other stuff (look at note below) */
697 default: {
698 TRACE_(dmfile)(": unknown chunk (skipping)\n");
699 liMove.QuadPart = chunkSize;
700 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
701 break;
704 TRACE_(dmfile)(": ListCount[1] = %ld < ListSize[1] = %ld\n", ListCount[1], ListSize[1]);
705 } while (ListCount[1] < ListSize[1]);
706 FIXME(": loading tracks not supported yet\n");
707 /* sigh... now comes track creation... currently I have some problems with implementing
708 this one because my test are contradicting:
709 - tracks are not loaded by loader (at least my dxdiag test with native dmime doesn't show it)
710 therefore i guess they're created with CoCreateInstance with CLSID specified in header and
711 IID_IDirectMusicTrack(8). Tracks are then probably passed to IDirectMusicSegment_Insert
712 (not quite sure, but behaviour complies with the one described in MSDN (about calling IDirectMusicTrack_Init)
713 - but on the other hand, track's stream implementation gets only <data> chunk (look in MSDN for more info)
714 (tested with native dmime and builtin dmband and dmstyle) => this means that all info about track (header, extra header
715 UNFO, GUID and version are read by segment's stream... now, how the hell is all this info set on track?!
716 => I believe successful approach would be to create structure like this:
717 _DMUSIC_PRIVATE_TRACK_ENTRY {
718 DMUS_IO_TRACK_HEADER trkHeader;
719 DMUS_IO_TRACK_EXTRAS_HEADER trkXHeader;
720 WCHAR* name, ...;
721 GUID guidID;
722 DMUS_VERSION vVersion;
724 IDirectMusicTrack* pTrack;
725 } DMUSIC_PRIVATE_TRACK_ENTRY;
726 and then load all stuff into it
727 => anyway, I'll try to implement it when I find some time again, but this note is here for anyone that wants to give it a try :)
729 break;
731 default: {
732 TRACE_(dmfile)(": unknown chunk (only DMTK expected; skipping)\n");
733 liMove.QuadPart = chunkSize - sizeof(FOURCC);
734 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
735 break;
738 break;
740 default: {
741 TRACE_(dmfile)("(unexpected) non-RIFF chunk (skipping, but expect errors)\n");
742 liMove.QuadPart = chunkSize;
743 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
744 break;
747 TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
748 } while (ListCount[0] < ListSize[0]);
749 break;
751 default: {
752 TRACE_(dmfile)(": unknown (skipping)\n");
753 liMove.QuadPart = chunkSize - sizeof(FOURCC);
754 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
755 break;
758 break;
760 default: {
761 TRACE_(dmfile)(": unknown chunk (skipping)\n");
762 liMove.QuadPart = chunkSize;
763 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
764 break;
767 TRACE_(dmfile)(": StreamCount = %ld < StreamSize = %ld\n", StreamCount, StreamSize);
768 } while (StreamCount < StreamSize);
769 break;
771 default: {
772 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
773 liMove.QuadPart = StreamSize;
774 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
775 return E_FAIL;
778 TRACE_(dmfile)(": reading finished\n");
779 break;
781 default: {
782 TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
783 liMove.QuadPart = chunkSize;
784 IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
785 return E_FAIL;
789 return S_OK;
792 HRESULT WINAPI IDirectMusicSegmentObjectStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty)
794 return E_NOTIMPL;
797 HRESULT WINAPI IDirectMusicSegmentObjectStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize)
799 return E_NOTIMPL;
802 ICOM_VTABLE(IPersistStream) DirectMusicSegmentObjectStream_Vtbl =
804 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
805 IDirectMusicSegmentObjectStream_QueryInterface,
806 IDirectMusicSegmentObjectStream_AddRef,
807 IDirectMusicSegmentObjectStream_Release,
808 IDirectMusicSegmentObjectStream_GetClassID,
809 IDirectMusicSegmentObjectStream_IsDirty,
810 IDirectMusicSegmentObjectStream_Load,
811 IDirectMusicSegmentObjectStream_Save,
812 IDirectMusicSegmentObjectStream_GetSizeMax