From c77788b59f613b55a11f0669766623367a1d26dd Mon Sep 17 00:00:00 2001 From: Raphael Junqueira Date: Mon, 10 May 2004 19:56:17 +0000 Subject: [PATCH] - Release DSBuffer on AudioPath destruction. - Semi stub for AudioPath Activate. - IDirectMusicPerformance8::CreateAudioPath stub. - Most of the IDirectMusicSegment8_[Set,Get]* (using header). - Load of Streamer IDirectMusicSegment8 header. --- dlls/dmime/audiopath.c | 31 ++- dlls/dmime/dmime_main.c | 18 ++ dlls/dmime/dmime_private.h | 6 +- dlls/dmime/performance.c | 25 ++- dlls/dmime/segment.c | 216 ++++++++++++++------ dlls/dmscript/dmscript_private.h | 1 + dlls/dmscript/script.c | 336 ++++++++++++++++--------------- 7 files changed, 391 insertions(+), 242 deletions(-) diff --git a/dlls/dmime/audiopath.c b/dlls/dmime/audiopath.c index 6dccfb79fb0..ebe7ed1cadc 100644 --- a/dlls/dmime/audiopath.c +++ b/dlls/dmime/audiopath.c @@ -59,13 +59,16 @@ ULONG WINAPI IDirectMusicAudioPathImpl_IUnknown_AddRef (LPUNKNOWN iface) { } ULONG WINAPI IDirectMusicAudioPathImpl_IUnknown_Release (LPUNKNOWN iface) { - ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, UnknownVtbl, iface); - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { - HeapFree(GetProcessHeap(), 0, This); - } - return ref; + ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, UnknownVtbl, iface); + ULONG ref = --This->ref; + TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); + if (ref == 0) { + if (This->pDSBuffer) { + IDirectSoundBuffer8_Release(This->pDSBuffer); + } + HeapFree(GetProcessHeap(), 0, This); + } + return ref; } ICOM_VTABLE(IUnknown) DirectMusicAudioPath_Unknown_Vtbl = { @@ -180,9 +183,17 @@ HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicAudioPath_GetObjectInPath ( } HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicAudioPath_Activate (LPDIRECTMUSICAUDIOPATH iface, BOOL fActivate) { - ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, AudioPathVtbl, iface); - FIXME("(%p, %d): stub\n", This, fActivate); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicAudioPathImpl, AudioPathVtbl, iface); + FIXME("(%p, %d): stub\n", This, fActivate); + if (!fActivate) { + if (!This->fActive) return S_OK; + This->fActive = FALSE; + } else { + if (This->fActive) return S_OK; + This->fActive = TRUE; + IDirectSoundBuffer_Stop(This->pDSBuffer); + } + return S_OK; } HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicAudioPath_SetVolume (LPDIRECTMUSICAUDIOPATH iface, long lVolume, DWORD dwDuration) { diff --git a/dlls/dmime/dmime_main.c b/dlls/dmime/dmime_main.c index a3cc6d1b541..c6f18427ae7 100644 --- a/dlls/dmime/dmime_main.c +++ b/dlls/dmime/dmime_main.c @@ -1116,6 +1116,22 @@ const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask) { /* dump whole DMUS_OBJECTDESC struct */ const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) { + if (pDesc) { + TRACE("DMUS_OBJECTDESC (%p):\n", pDesc); + TRACE(" - dwSize = %ld\n", pDesc->dwSize); + TRACE(" - dwValidData = %s\n", debugstr_DMUS_OBJ_FLAGS (pDesc->dwValidData)); + if (pDesc->dwValidData & DMUS_OBJ_NAME) TRACE(" - wszName = %s\n", debugstr_w(pDesc->wszName)); + if (pDesc->dwValidData & DMUS_OBJ_CLASS) TRACE(" - guidClass = %s\n", debugstr_dmguid(&pDesc->guidClass)); + if (pDesc->dwValidData & DMUS_OBJ_OBJECT) TRACE(" - guidObject = %s\n", debugstr_guid(&pDesc->guidObject)); + if (pDesc->dwValidData & DMUS_OBJ_DATE) TRACE(" - ftDate = FIXME\n"); + if (pDesc->dwValidData & DMUS_OBJ_VERSION) TRACE(" - vVersion = %s\n", debugstr_dmversion(&pDesc->vVersion)); + if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) TRACE(" - wszCategory = %s\n", debugstr_w(pDesc->wszCategory)); + if (pDesc->dwValidData & DMUS_OBJ_FILENAME) TRACE(" - wszFileName = %s\n", debugstr_w(pDesc->wszFileName)); + if (pDesc->dwValidData & DMUS_OBJ_MEMORY) TRACE(" - llMemLength = %lli\n - pbMemData = %p\n", pDesc->llMemLength, pDesc->pbMemData); + if (pDesc->dwValidData & DMUS_OBJ_STREAM) TRACE(" - pStream = %p\n", pDesc->pStream); + } else { + TRACE("(NULL)\n"); + }/* if (pDesc) { char buffer[1024] = "", *ptr = &buffer[0]; @@ -1136,4 +1152,6 @@ const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) { } else { return wine_dbg_sprintf("(NULL)"); } + */ + return "X"; } diff --git a/dlls/dmime/dmime_private.h b/dlls/dmime/dmime_private.h index 1279de85bf5..cebeba1efba 100644 --- a/dlls/dmime/dmime_private.h +++ b/dlls/dmime/dmime_private.h @@ -264,7 +264,9 @@ struct IDirectMusicSegment8Impl { DWORD ref; /* IDirectMusicSegment8Impl fields */ - LPDMUS_OBJECTDESC pDesc; + LPDMUS_OBJECTDESC pDesc; + DMUS_IO_SEGMENT_HEADER header; + IDirectMusicGraph* pGraph; }; /* IUnknown: */ @@ -408,6 +410,8 @@ struct IDirectMusicAudioPathImpl { IDirectMusicGraph* pToolGraph; IDirectSoundBuffer* pDSBuffer; IDirectSoundBuffer* pPrimary; + + BOOL fActive; }; /* IUnknown: */ diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c index 84c6a486e51..6ac704602b1 100644 --- a/dlls/dmime/performance.c +++ b/dlls/dmime/performance.c @@ -418,6 +418,8 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_GetGraph (LPDIRECTMUSICPERFORMANCE8 if (NULL != This->pToolGraph) { *ppGraph = (LPDIRECTMUSICGRAPH) This->pToolGraph; IDirectMusicGraph_AddRef((LPDIRECTMUSICGRAPH) *ppGraph); + } else { + return E_FAIL; } return S_OK; } @@ -702,6 +704,7 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_InitAudio (LPDIRECTMUSICPERFORMANCE8 * TODO, how can i fill the struct * as seen at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directX/htm/dmusaudioparams.asp */ + memset(&This->pParams, 0, sizeof(DMUS_AUDIOPARAMS)); This->pParams.dwSize = sizeof(DMUS_AUDIOPARAMS); This->pParams.fInitNow = FALSE; This->pParams.dwValidData = DMUS_AUDIOPARAMS_FEATURES | DMUS_AUDIOPARAMS_VOICES | DMUS_AUDIOPARAMS_SAMPLERATE | DMUS_AUDIOPARAMS_DEFAULTSYNTH; @@ -736,9 +739,25 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_ClonePMsg (LPDIRECTMUSICPERFORMANCE8 } HRESULT WINAPI IDirectMusicPerformance8Impl_CreateAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IUnknown* pSourceConfig, BOOL fActivate, IDirectMusicAudioPath** ppNewPath) { + IDirectMusicAudioPathImpl *default_path; + IDirectMusicAudioPath *pPath; + ICOM_THIS(IDirectMusicPerformance8Impl,iface); FIXME("(%p, %p, %d, %p): stub\n", This, pSourceConfig, fActivate, ppNewPath); - return S_OK; + + if (NULL == ppNewPath) { + return E_POINTER; + } + + DMUSIC_CreateDirectMusicAudioPathImpl (&IID_IDirectMusicAudioPath, (LPVOID*)&pPath, NULL); + default_path = (IDirectMusicAudioPathImpl*)((char*)(pPath) - offsetof(IDirectMusicAudioPathImpl,AudioPathVtbl)); + default_path->pPerf = (IDirectMusicPerformance8*) This; + + /** TODO */ + + *ppNewPath = (LPDIRECTMUSICAUDIOPATH) pPath; + + return IDirectMusicAudioPathImpl_IDirectMusicAudioPath_Activate(*ppNewPath, fActivate); } /** @@ -765,6 +784,7 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath (LPDIRECTMUS default_path->pPerf = (IDirectMusicPerformance8*) This; /* Secondary buffer description */ + memset(&format, 0, sizeof(format)); format.wFormatTag = WAVE_FORMAT_PCM; format.nChannels = 1; format.nSamplesPerSec = 44000; @@ -773,6 +793,7 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath (LPDIRECTMUS format.wBitsPerSample = 16; format.cbSize = 0; + memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); desc.dwFlags = DSBCAPS_CTRLFX | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_GLOBALFOCUS; desc.dwBufferBytes = DSBSIZE_MIN; @@ -831,7 +852,7 @@ HRESULT WINAPI IDirectMusicPerformance8Impl_CreateStandardAudioPath (LPDIRECTMUS TRACE(" returning IDirectMusicPerformance interface at %p.\n", *ppNewPath); - return S_OK; + return IDirectMusicAudioPathImpl_IDirectMusicAudioPath_Activate(*ppNewPath, fActivate); } HRESULT WINAPI IDirectMusicPerformance8Impl_SetDefaultAudioPath (LPDIRECTMUSICPERFORMANCE8 iface, IDirectMusicAudioPath* pAudioPath) { diff --git a/dlls/dmime/segment.c b/dlls/dmime/segment.c index f9c20a5e0e4..e8e28bf0cac 100644 --- a/dlls/dmime/segment.c +++ b/dlls/dmime/segment.c @@ -71,104 +71,148 @@ ULONG WINAPI IDirectMusicSegment8Impl_IUnknown_Release (LPUNKNOWN iface) { } ICOM_VTABLE(IUnknown) DirectMusicSegment8_Unknown_Vtbl = { - ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE - IDirectMusicSegment8Impl_IUnknown_QueryInterface, - IDirectMusicSegment8Impl_IUnknown_AddRef, - IDirectMusicSegment8Impl_IUnknown_Release + ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE + IDirectMusicSegment8Impl_IUnknown_QueryInterface, + IDirectMusicSegment8Impl_IUnknown_AddRef, + IDirectMusicSegment8Impl_IUnknown_Release }; /* IDirectMusicSegmentImpl IDirectMusicSegment part: */ HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_QueryInterface (LPDIRECTMUSICSEGMENT8 iface, REFIID riid, LPVOID *ppobj) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - return IDirectMusicSegment8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj); + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + return IDirectMusicSegment8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj); } ULONG WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_AddRef (LPDIRECTMUSICSEGMENT8 iface) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - return IDirectMusicSegment8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl); + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + return IDirectMusicSegment8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl); } ULONG WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_Release (LPDIRECTMUSICSEGMENT8 iface) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - return IDirectMusicSegment8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl); + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + return IDirectMusicSegment8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl); } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetLength (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME* pmtLength) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %p): stub\n", This, pmtLength); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + TRACE("(%p, %p)\n", This, pmtLength); + if (NULL == pmtLength) { + return E_POINTER; + } + *pmtLength = This->header.mtLength; + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetLength (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtLength) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %ld): stub\n", This, mtLength); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + TRACE("(%p, %ld)\n", This, mtLength); + This->header.mtLength = mtLength; + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetRepeats (LPDIRECTMUSICSEGMENT8 iface, DWORD* pdwRepeats) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %p): stub\n", This, pdwRepeats); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + TRACE("(%p, %p)\n", This, pdwRepeats); + if (NULL == pdwRepeats) { + return E_POINTER; + } + *pdwRepeats = This->header.dwRepeats; + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetRepeats (LPDIRECTMUSICSEGMENT8 iface, DWORD dwRepeats) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %ld): stub\n", This, dwRepeats); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + TRACE("(%p, %ld)\n", This, dwRepeats); + This->header.dwRepeats = dwRepeats; + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetDefaultResolution (LPDIRECTMUSICSEGMENT8 iface, DWORD* pdwResolution) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %p): stub\n", This, pdwResolution); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + TRACE("(%p, %p)\n", This, pdwResolution); + if (NULL == pdwResolution) { + return E_POINTER; + } + *pdwResolution = This->header.dwResolution; + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetDefaultResolution (LPDIRECTMUSICSEGMENT8 iface, DWORD dwResolution) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %ld): stub\n", This, dwResolution); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + TRACE("(%p, %ld)\n", This, dwResolution); + This->header.dwResolution = dwResolution; + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetTrack (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidType, DWORD dwGroupBits, DWORD dwIndex, IDirectMusicTrack** ppTrack) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %s, %ld, %ld, %p): stub\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, ppTrack); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + FIXME("(%p, %s, %ld, %ld, %p): stub\n", This, debugstr_dmguid(rguidType), dwGroupBits, dwIndex, ppTrack); + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetTrackGroup (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicTrack* pTrack, DWORD* pdwGroupBits) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %p, %p): stub\n", This, pTrack, pdwGroupBits); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + FIXME("(%p, %p, %p): stub\n", This, pTrack, pdwGroupBits); + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_InsertTrack (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicTrack* pTrack, DWORD dwGroupBits) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %p, %ld): stub\n", This, pTrack, dwGroupBits); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + FIXME("(%p, %p, %ld): stub\n", This, pTrack, dwGroupBits); + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_RemoveTrack (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicTrack* pTrack) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %p): stub\n", This, pTrack); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + FIXME("(%p, %p): stub\n", This, pTrack); + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_InitPlay (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicSegmentState** ppSegState, IDirectMusicPerformance* pPerformance, DWORD dwFlags) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %p, %p, %ld): stub\n", This, ppSegState, pPerformance, dwFlags); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + HRESULT hr; + FIXME("(%p, %p, %p, %ld): semi-stub\n", This, ppSegState, pPerformance, dwFlags); + if (NULL == ppSegState) { + return E_POINTER; + } + hr = DMUSIC_CreateDirectMusicSegmentStateImpl(&IID_IDirectMusicSegmentState, (void**) ppSegState, NULL); + if (FAILED(hr)) { + return hr; + } + /* TODO: DMUS_SEGF_FLAGS */ + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetGraph (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicGraph** ppGraph) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %p): stub\n", This, ppGraph); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + FIXME("(%p, %p): semi-stub\n", This, ppGraph); + if (NULL == ppGraph) { + return E_POINTER; + } + if (NULL == This->pGraph) { + return DMUS_E_NOT_FOUND; + } + /** + * should return This, as seen in msdn + * http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/htm/idirectmusicsegment8getgraph.asp + * "...The segment object implements IDirectMusicGraph directly..." + */ + *ppGraph = This->pGraph; + IDirectMusicGraph_AddRef(This->pGraph); + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetGraph (LPDIRECTMUSICSEGMENT8 iface, IDirectMusicGraph* pGraph) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %p): stub\n", This, pGraph); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + FIXME("(%p, %p): to complete\n", This, pGraph); + if (NULL != This->pGraph) { + IDirectMusicGraph_Release(This->pGraph); + } + This->pGraph = pGraph; + if (NULL != This->pGraph) { + IDirectMusicGraph_AddRef(This->pGraph); + } + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_AddNotificationType (LPDIRECTMUSICSEGMENT8 iface, REFGUID rguidNotificationType) { @@ -202,27 +246,45 @@ HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_Clone (LPDIRECTMUSI } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetStartPoint (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtStart) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %ld): stub\n", This, mtStart); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + TRACE("(%p, %ld)\n", This, mtStart); + if (mtStart >= This->header.mtLength) { + return DMUS_E_OUT_OF_RANGE; + } + This->header.mtPlayStart = mtStart; + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetStartPoint (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME* pmtStart) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %p): stub\n", This, pmtStart); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + TRACE("(%p, %p)\n", This, pmtStart); + if (NULL == pmtStart) { + return E_POINTER; + } + *pmtStart = This->header.mtPlayStart; + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetLoopPoints (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME mtStart, MUSIC_TIME mtEnd) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %ld, %ld): stub\n", This, mtStart, mtEnd); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + TRACE("(%p, %ld, %ld)\n", This, mtStart, mtEnd); + if (mtStart >= This->header.mtLength || mtEnd > This->header.mtLength || mtStart > mtEnd) { + return DMUS_E_OUT_OF_RANGE; + } + This->header.mtLoopStart = mtStart; + This->header.mtLoopEnd = mtEnd; + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_GetLoopPoints (LPDIRECTMUSICSEGMENT8 iface, MUSIC_TIME* pmtStart, MUSIC_TIME* pmtEnd) { - ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); - FIXME("(%p, %p, %p): stub\n", This, pmtStart, pmtEnd); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicSegment8Impl, SegmentVtbl, iface); + TRACE("(%p, %p, %p)\n", This, pmtStart, pmtEnd); + if (NULL == pmtStart || NULL == pmtEnd) { + return E_POINTER; + } + *pmtStart = This->header.mtLoopStart; + *pmtEnd = This->header.mtLoopEnd; + return S_OK; } HRESULT WINAPI IDirectMusicSegment8Impl_IDirectMusicSegment8_SetPChannelsUsed (LPDIRECTMUSICSEGMENT8 iface, DWORD dwNumPChannels, DWORD* paPChannels) { @@ -914,8 +976,38 @@ static HRESULT IDirectMusicSegment8Impl_IPersistStream_ParseSegmentForm (LPPERSI if (hr == S_FALSE) { switch (Chunk.fccID) { case DMUS_FOURCC_SEGMENT_CHUNK: { + DWORD checkSz = 0; FIXME_(dmfile)(": segment chunk\n"); - liMove.QuadPart = Chunk.dwSize; + /** DX 7 */ + IStream_Read (pStm, &This->header.dwRepeats, sizeof(This->header.dwRepeats), NULL); + checkSz += sizeof(This->header.dwRepeats); + IStream_Read (pStm, &This->header.mtLength, sizeof(This->header.mtLength), NULL); + checkSz += sizeof(This->header.mtLength); + IStream_Read (pStm, &This->header.mtPlayStart, sizeof(This->header.mtPlayStart), NULL); + checkSz += sizeof(This->header.mtPlayStart); + IStream_Read (pStm, &This->header.mtLoopStart, sizeof(This->header.mtLoopStart), NULL); + checkSz += sizeof(This->header.mtLoopStart); + IStream_Read (pStm, &This->header.mtLoopEnd, sizeof(This->header.mtLoopEnd), NULL); + checkSz += sizeof(This->header.mtLoopEnd); + IStream_Read (pStm, &This->header.dwResolution, sizeof(This->header.dwResolution), NULL); + checkSz += sizeof(This->header.dwResolution); + /** DX 8 */ + if (Chunk.dwSize > checkSz) { + IStream_Read (pStm, &This->header.rtLength, sizeof(This->header.rtLength), NULL); + checkSz += sizeof(This->header.rtLength); + IStream_Read (pStm, &This->header.dwFlags, sizeof(This->header.dwFlags), NULL); + checkSz += sizeof(This->header.dwFlags); + } + /** DX 9 */ + if (Chunk.dwSize > checkSz) { + IStream_Read (pStm, &This->header.rtLoopStart, sizeof(This->header.rtLoopStart), NULL); + checkSz += sizeof(This->header.rtLoopStart); + IStream_Read (pStm, &This->header.rtLoopEnd, sizeof(This->header.rtLoopEnd), NULL); + checkSz += sizeof(This->header.rtLoopEnd); + IStream_Read (pStm, &This->header.rtPlayStart, sizeof(This->header.rtPlayStart), NULL); + checkSz += sizeof(This->header.rtPlayStart); + } + liMove.QuadPart = Chunk.dwSize - checkSz; IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); break; } diff --git a/dlls/dmscript/dmscript_private.h b/dlls/dmscript/dmscript_private.h index fc446ac005a..0e9b933fecf 100644 --- a/dlls/dmscript/dmscript_private.h +++ b/dlls/dmscript/dmscript_private.h @@ -77,6 +77,7 @@ struct IDirectMusicScriptImpl { DWORD ref; /* IDirectMusicScriptImpl fields */ + IDirectMusicPerformance* pPerformance; LPDMUS_OBJECTDESC pDesc; DMUS_IO_SCRIPT_HEADER* pHeader; DMUS_IO_VERSION* pVersion; diff --git a/dlls/dmscript/script.c b/dlls/dmscript/script.c index 39de1e982da..54524c62692 100644 --- a/dlls/dmscript/script.c +++ b/dlls/dmscript/script.c @@ -35,216 +35,218 @@ WINE_DECLARE_DEBUG_CHANNEL(dmfile); */ /* IDirectMusicScriptImpl IUnknown part: */ HRESULT WINAPI IDirectMusicScriptImpl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, UnknownVtbl, iface); - TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj); - - if (IsEqualIID (riid, &IID_IUnknown)) { - *ppobj = (LPVOID)&This->UnknownVtbl; - IDirectMusicScriptImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl); - return S_OK; - } else if (IsEqualIID (riid, &IID_IDirectMusicScript)) { - *ppobj = (LPVOID)&This->ScriptVtbl; - IDirectMusicScriptImpl_IDirectMusicScript_AddRef ((LPDIRECTMUSICSCRIPT)&This->ScriptVtbl); - return S_OK; - } else if (IsEqualIID (riid, &IID_IDirectMusicObject)) { - *ppobj = (LPVOID)&This->ObjectVtbl; - IDirectMusicScriptImpl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT)&This->ObjectVtbl); - return S_OK; - } else if (IsEqualIID (riid, &IID_IPersistStream)) { - *ppobj = (LPVOID)&This->PersistStreamVtbl; - IDirectMusicScriptImpl_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl); - return S_OK; - } - - WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj); - return E_NOINTERFACE; + ICOM_THIS_MULTI(IDirectMusicScriptImpl, UnknownVtbl, iface); + TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj); + + if (IsEqualIID (riid, &IID_IUnknown)) { + *ppobj = (LPVOID)&This->UnknownVtbl; + IDirectMusicScriptImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl); + return S_OK; + } else if (IsEqualIID (riid, &IID_IDirectMusicScript)) { + *ppobj = (LPVOID)&This->ScriptVtbl; + IDirectMusicScriptImpl_IDirectMusicScript_AddRef ((LPDIRECTMUSICSCRIPT)&This->ScriptVtbl); + return S_OK; + } else if (IsEqualIID (riid, &IID_IDirectMusicObject)) { + *ppobj = (LPVOID)&This->ObjectVtbl; + IDirectMusicScriptImpl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT)&This->ObjectVtbl); + return S_OK; + } else if (IsEqualIID (riid, &IID_IPersistStream)) { + *ppobj = (LPVOID)&This->PersistStreamVtbl; + IDirectMusicScriptImpl_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl); + return S_OK; + } + + WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj); + return E_NOINTERFACE; } ULONG WINAPI IDirectMusicScriptImpl_IUnknown_AddRef (LPUNKNOWN iface) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, UnknownVtbl, iface); - TRACE("(%p): AddRef from %ld\n", This, This->ref); - return ++(This->ref); + ICOM_THIS_MULTI(IDirectMusicScriptImpl, UnknownVtbl, iface); + TRACE("(%p): AddRef from %ld\n", This, This->ref); + return ++(This->ref); } ULONG WINAPI IDirectMusicScriptImpl_IUnknown_Release (LPUNKNOWN iface) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, UnknownVtbl, iface); - ULONG ref = --This->ref; - TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); - if (ref == 0) { - if (NULL != This->pHeader) HeapFree(GetProcessHeap(), 0, This->pHeader); - if (NULL != This->pVersion) HeapFree(GetProcessHeap(), 0, This->pVersion); - if (NULL != This->pwzLanguage) HeapFree(GetProcessHeap(), 0, This->pwzLanguage); - if (NULL != This->pwzSource) HeapFree(GetProcessHeap(), 0, This->pwzSource); - HeapFree(GetProcessHeap(), 0, This); - } - return ref; + ICOM_THIS_MULTI(IDirectMusicScriptImpl, UnknownVtbl, iface); + ULONG ref = --This->ref; + TRACE("(%p): ReleaseRef to %ld\n", This, This->ref); + if (ref == 0) { + if (NULL != This->pHeader) HeapFree(GetProcessHeap(), 0, This->pHeader); + if (NULL != This->pVersion) HeapFree(GetProcessHeap(), 0, This->pVersion); + if (NULL != This->pwzLanguage) HeapFree(GetProcessHeap(), 0, This->pwzLanguage); + if (NULL != This->pwzSource) HeapFree(GetProcessHeap(), 0, This->pwzSource); + HeapFree(GetProcessHeap(), 0, This); + } + return ref; } ICOM_VTABLE(IUnknown) DirectMusicScript_Unknown_Vtbl = { - ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE - IDirectMusicScriptImpl_IUnknown_QueryInterface, - IDirectMusicScriptImpl_IUnknown_AddRef, - IDirectMusicScriptImpl_IUnknown_Release + ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE + IDirectMusicScriptImpl_IUnknown_QueryInterface, + IDirectMusicScriptImpl_IUnknown_AddRef, + IDirectMusicScriptImpl_IUnknown_Release }; /* IDirectMusicScriptImpl IDirectMusicScript part: */ HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_QueryInterface (LPDIRECTMUSICSCRIPT iface, REFIID riid, LPVOID *ppobj) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); - return IDirectMusicScriptImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj); + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); + return IDirectMusicScriptImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj); } ULONG WINAPI IDirectMusicScriptImpl_IDirectMusicScript_AddRef (LPDIRECTMUSICSCRIPT iface) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); - return IDirectMusicScriptImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl); + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); + return IDirectMusicScriptImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl); } ULONG WINAPI IDirectMusicScriptImpl_IDirectMusicScript_Release (LPDIRECTMUSICSCRIPT iface) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); - return IDirectMusicScriptImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl); + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); + return IDirectMusicScriptImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl); } HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_Init (LPDIRECTMUSICSCRIPT iface, IDirectMusicPerformance* pPerformance, DMUS_SCRIPT_ERRORINFO* pErrorInfo) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); - FIXME("(%p, %p, %p): stub\n", This, pPerformance, pErrorInfo); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); + FIXME("(%p, %p, %p): stub\n", This, pPerformance, pErrorInfo); + This->pPerformance = pPerformance; + return S_OK; } HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_CallRoutine (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszRoutineName, DMUS_SCRIPT_ERRORINFO* pErrorInfo) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); - FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszRoutineName), pErrorInfo); - /*return E_NOTIMPL;*/ - return S_OK; + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); + FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszRoutineName), pErrorInfo); + /*return E_NOTIMPL;*/ + /*return S_OK;*/ + return E_FAIL; } HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_SetVariableVariant (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, VARIANT varValue, BOOL fSetRef, DMUS_SCRIPT_ERRORINFO* pErrorInfo) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); - FIXME("(%p, %p, FIXME, %d, %p): stub\n", This, pwszVariableName,/* varValue,*/ fSetRef, pErrorInfo); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); + FIXME("(%p, %s, FIXME, %d, %p): stub\n", This, debugstr_w(pwszVariableName),/* varValue,*/ fSetRef, pErrorInfo); + return S_OK; } HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_GetVariableVariant (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, VARIANT* pvarValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); - FIXME("(%p, %p, %p, %p): stub\n", This, pwszVariableName, pvarValue, pErrorInfo); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); + FIXME("(%p, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), pvarValue, pErrorInfo); + return S_OK; } HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_SetVariableNumber (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, LONG lValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); - FIXME("(%p, %p, %li, %p): stub\n", This, pwszVariableName, lValue, pErrorInfo); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); + FIXME("(%p, %s, %li, %p): stub\n", This, debugstr_w(pwszVariableName), lValue, pErrorInfo); + return S_OK; } HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_GetVariableNumber (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, LONG* plValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); - FIXME("(%p, %p, %p, %p): stub\n", This, pwszVariableName, plValue, pErrorInfo); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); + FIXME("(%p, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), plValue, pErrorInfo); + return S_OK; } HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_SetVariableObject (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, IUnknown* punkValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); - FIXME("(%p, %p, %p, %p): stub\n", This, pwszVariableName, punkValue, pErrorInfo); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); + FIXME("(%p, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), punkValue, pErrorInfo); + return S_OK; } HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_GetVariableObject (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, REFIID riid, LPVOID* ppv, DMUS_SCRIPT_ERRORINFO* pErrorInfo) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); - FIXME("(%p, %p, %s, %p, %p): stub\n", This, pwszVariableName, debugstr_dmguid(riid), ppv, pErrorInfo); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); + FIXME("(%p, %s, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), debugstr_dmguid(riid), ppv, pErrorInfo); + return S_OK; } HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_EnumRoutine (LPDIRECTMUSICSCRIPT iface, DWORD dwIndex, WCHAR* pwszName) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); - FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); + FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName); + return S_OK; } HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_EnumVariable (LPDIRECTMUSICSCRIPT iface, DWORD dwIndex, WCHAR* pwszName) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); - FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface); + FIXME("(%p, %ld, %p): stub\n", This, dwIndex, pwszName); + return S_OK; } ICOM_VTABLE(IDirectMusicScript) DirectMusicScript_Script_Vtbl = { - ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE - IDirectMusicScriptImpl_IDirectMusicScript_QueryInterface, - IDirectMusicScriptImpl_IDirectMusicScript_AddRef, - IDirectMusicScriptImpl_IDirectMusicScript_Release, - IDirectMusicScriptImpl_IDirectMusicScript_Init, - IDirectMusicScriptImpl_IDirectMusicScript_CallRoutine, - IDirectMusicScriptImpl_IDirectMusicScript_SetVariableVariant, - IDirectMusicScriptImpl_IDirectMusicScript_GetVariableVariant, - IDirectMusicScriptImpl_IDirectMusicScript_SetVariableNumber, - IDirectMusicScriptImpl_IDirectMusicScript_GetVariableNumber, - IDirectMusicScriptImpl_IDirectMusicScript_SetVariableObject, - IDirectMusicScriptImpl_IDirectMusicScript_GetVariableObject, - IDirectMusicScriptImpl_IDirectMusicScript_EnumRoutine, - IDirectMusicScriptImpl_IDirectMusicScript_EnumVariable + ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE + IDirectMusicScriptImpl_IDirectMusicScript_QueryInterface, + IDirectMusicScriptImpl_IDirectMusicScript_AddRef, + IDirectMusicScriptImpl_IDirectMusicScript_Release, + IDirectMusicScriptImpl_IDirectMusicScript_Init, + IDirectMusicScriptImpl_IDirectMusicScript_CallRoutine, + IDirectMusicScriptImpl_IDirectMusicScript_SetVariableVariant, + IDirectMusicScriptImpl_IDirectMusicScript_GetVariableVariant, + IDirectMusicScriptImpl_IDirectMusicScript_SetVariableNumber, + IDirectMusicScriptImpl_IDirectMusicScript_GetVariableNumber, + IDirectMusicScriptImpl_IDirectMusicScript_SetVariableObject, + IDirectMusicScriptImpl_IDirectMusicScript_GetVariableObject, + IDirectMusicScriptImpl_IDirectMusicScript_EnumRoutine, + IDirectMusicScriptImpl_IDirectMusicScript_EnumVariable }; /* IDirectMusicScriptImpl IDirectMusicObject part: */ HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface); - return IDirectMusicScriptImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj); + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface); + return IDirectMusicScriptImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj); } ULONG WINAPI IDirectMusicScriptImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface); - return IDirectMusicScriptImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl); + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface); + return IDirectMusicScriptImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl); } ULONG WINAPI IDirectMusicScriptImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface); - return IDirectMusicScriptImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl); + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface); + return IDirectMusicScriptImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl); } HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface); - TRACE("(%p, %p)\n", This, pDesc); - /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */ - memcpy (pDesc, This->pDesc, This->pDesc->dwSize); - return S_OK; + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface); + TRACE("(%p, %p)\n", This, pDesc); + /* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */ + memcpy (pDesc, This->pDesc, This->pDesc->dwSize); + return S_OK; } HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface); - TRACE("(%p, %p): setting descriptor:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC (pDesc)); + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface); + TRACE("(%p, %p): setting descriptor:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC (pDesc)); - /* According to MSDN, we should copy only given values, not whole struct */ - if (pDesc->dwValidData & DMUS_OBJ_OBJECT) - memcpy (&This->pDesc->guidObject, &pDesc->guidObject, sizeof (pDesc->guidObject)); - if (pDesc->dwValidData & DMUS_OBJ_CLASS) - memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass)); - if (pDesc->dwValidData & DMUS_OBJ_NAME) - strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME); - if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) - strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY); - if (pDesc->dwValidData & DMUS_OBJ_FILENAME) - strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME); - if (pDesc->dwValidData & DMUS_OBJ_VERSION) - memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion)); - if (pDesc->dwValidData & DMUS_OBJ_DATE) - memcpy (&This->pDesc->ftDate, &pDesc->ftDate, sizeof (pDesc->ftDate)); - if (pDesc->dwValidData & DMUS_OBJ_MEMORY) { - memcpy (&This->pDesc->llMemLength, &pDesc->llMemLength, sizeof (pDesc->llMemLength)); - memcpy (This->pDesc->pbMemData, pDesc->pbMemData, sizeof (pDesc->pbMemData)); - } - if (pDesc->dwValidData & DMUS_OBJ_STREAM) { - /* according to MSDN, we copy the stream */ - IStream_Clone (pDesc->pStream, &This->pDesc->pStream); - } - - /* add new flags */ - This->pDesc->dwValidData |= pDesc->dwValidData; - - return S_OK; + /* According to MSDN, we should copy only given values, not whole struct */ + if (pDesc->dwValidData & DMUS_OBJ_OBJECT) + memcpy (&This->pDesc->guidObject, &pDesc->guidObject, sizeof (pDesc->guidObject)); + if (pDesc->dwValidData & DMUS_OBJ_CLASS) + memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass)); + if (pDesc->dwValidData & DMUS_OBJ_NAME) + strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME); + if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) + strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY); + if (pDesc->dwValidData & DMUS_OBJ_FILENAME) + strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME); + if (pDesc->dwValidData & DMUS_OBJ_VERSION) + memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion)); + if (pDesc->dwValidData & DMUS_OBJ_DATE) + memcpy (&This->pDesc->ftDate, &pDesc->ftDate, sizeof (pDesc->ftDate)); + if (pDesc->dwValidData & DMUS_OBJ_MEMORY) { + memcpy (&This->pDesc->llMemLength, &pDesc->llMemLength, sizeof (pDesc->llMemLength)); + memcpy (This->pDesc->pbMemData, pDesc->pbMemData, sizeof (pDesc->pbMemData)); + } + if (pDesc->dwValidData & DMUS_OBJ_STREAM) { + /* according to MSDN, we copy the stream */ + IStream_Clone (pDesc->pStream, &This->pDesc->pStream); + } + + /* add new flags */ + This->pDesc->dwValidData |= pDesc->dwValidData; + + return S_OK; } HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) { - ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface); - DMUS_PRIVATE_CHUNK Chunk; - DWORD StreamSize, StreamCount, ListSize[1], ListCount[1]; - LARGE_INTEGER liMove; /* used when skipping chunks */ - + ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface); + DMUS_PRIVATE_CHUNK Chunk; + DWORD StreamSize, StreamCount, ListSize[1], ListCount[1]; + LARGE_INTEGER liMove; /* used when skipping chunks */ + TRACE("(%p, %p, %p)\n", This, pStream, pDesc); /* FIXME: should this be determined from stream? */ @@ -651,43 +653,43 @@ HRESULT WINAPI IDirectMusicScriptImpl_IPersistStream_Load (LPPERSISTSTREAM iface } HRESULT WINAPI IDirectMusicScriptImpl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) { - return E_NOTIMPL; + return E_NOTIMPL; } HRESULT WINAPI IDirectMusicScriptImpl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) { - return E_NOTIMPL; + return E_NOTIMPL; } ICOM_VTABLE(IPersistStream) DirectMusicScript_PersistStream_Vtbl = { - ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE - IDirectMusicScriptImpl_IPersistStream_QueryInterface, - IDirectMusicScriptImpl_IPersistStream_AddRef, - IDirectMusicScriptImpl_IPersistStream_Release, - IDirectMusicScriptImpl_IPersistStream_GetClassID, - IDirectMusicScriptImpl_IPersistStream_IsDirty, - IDirectMusicScriptImpl_IPersistStream_Load, - IDirectMusicScriptImpl_IPersistStream_Save, - IDirectMusicScriptImpl_IPersistStream_GetSizeMax + ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE + IDirectMusicScriptImpl_IPersistStream_QueryInterface, + IDirectMusicScriptImpl_IPersistStream_AddRef, + IDirectMusicScriptImpl_IPersistStream_Release, + IDirectMusicScriptImpl_IPersistStream_GetClassID, + IDirectMusicScriptImpl_IPersistStream_IsDirty, + IDirectMusicScriptImpl_IPersistStream_Load, + IDirectMusicScriptImpl_IPersistStream_Save, + IDirectMusicScriptImpl_IPersistStream_GetSizeMax }; /* for ClassFactory */ HRESULT WINAPI DMUSIC_CreateDirectMusicScriptImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) { - IDirectMusicScriptImpl* obj; - - obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicScriptImpl)); - if (NULL == obj) { - *ppobj = (LPVOID) NULL; - return E_OUTOFMEMORY; - } - obj->UnknownVtbl = &DirectMusicScript_Unknown_Vtbl; - obj->ScriptVtbl = &DirectMusicScript_Script_Vtbl; - obj->ObjectVtbl = &DirectMusicScript_Object_Vtbl; - obj->PersistStreamVtbl = &DirectMusicScript_PersistStream_Vtbl; - obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC)); - DM_STRUCT_INIT(obj->pDesc); - obj->pDesc->dwValidData |= DMUS_OBJ_CLASS; - memcpy (&obj->pDesc->guidClass, &CLSID_DirectMusicScript, sizeof (CLSID)); - obj->ref = 0; /* will be inited by QueryInterface */ - - return IDirectMusicScriptImpl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj); + IDirectMusicScriptImpl* obj; + + obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicScriptImpl)); + if (NULL == obj) { + *ppobj = (LPVOID) NULL; + return E_OUTOFMEMORY; + } + obj->UnknownVtbl = &DirectMusicScript_Unknown_Vtbl; + obj->ScriptVtbl = &DirectMusicScript_Script_Vtbl; + obj->ObjectVtbl = &DirectMusicScript_Object_Vtbl; + obj->PersistStreamVtbl = &DirectMusicScript_PersistStream_Vtbl; + obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC)); + DM_STRUCT_INIT(obj->pDesc); + obj->pDesc->dwValidData |= DMUS_OBJ_CLASS; + memcpy (&obj->pDesc->guidClass, &CLSID_DirectMusicScript, sizeof (CLSID)); + obj->ref = 0; /* will be inited by QueryInterface */ + + return IDirectMusicScriptImpl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj); }