Commit ee51a0c0 authored by Raphael Junqueira's avatar Raphael Junqueira Committed by Alexandre Julliard

- Many IDirectMusicSegment fixes (loading).

- AudioPath crash fix (don't use DSound APIs if buffer is null). - Move generic functions to dmime_main.c for future reuse (from segment.c). - IDirectMusicTempoTrack loading (many tempo case must be handled). - IDirectMusicSegTriggerTrack loading implementation (now DMRF/DirectMusic References loading should be done).
parent fd98f1c8
......@@ -191,8 +191,10 @@ HRESULT WINAPI IDirectMusicAudioPathImpl_IDirectMusicAudioPath_Activate (LPDIREC
} else {
if (This->fActive) return S_OK;
This->fActive = TRUE;
if (NULL != This->pDSBuffer) {
IDirectSoundBuffer_Stop(This->pDSBuffer);
}
}
return S_OK;
}
......
......@@ -20,6 +20,7 @@
#include "dmime_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmime);
WINE_DECLARE_DEBUG_CHANNEL(dmfile);
typedef struct {
/* IUnknown fields */
......@@ -1155,3 +1156,105 @@ const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc) {
*/
return "X";
}
HRESULT IDirectMusicImpl_IPersistStream_ParseDescGeneric (DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, LPDMUS_OBJECTDESC pDesc) {
switch (pChunk->fccID) {
case DMUS_FOURCC_GUID_CHUNK: {
TRACE_(dmfile)(": GUID chunk\n");
pDesc->dwValidData |= DMUS_OBJ_OBJECT;
IStream_Read (pStm, &pDesc->guidObject, pChunk->dwSize, NULL);
break;
}
case DMUS_FOURCC_DATE_CHUNK: {
TRACE_(dmfile)(": file date chunk\n");
pDesc->dwValidData |= DMUS_OBJ_DATE;
IStream_Read (pStm, &pDesc->ftDate, pChunk->dwSize, NULL);
break;
}
case DMUS_FOURCC_NAME_CHUNK: {
TRACE_(dmfile)(": name chunk\n");
pDesc->dwValidData |= DMUS_OBJ_NAME;
IStream_Read (pStm, &pDesc->wszName, pChunk->dwSize, NULL);
break;
}
case DMUS_FOURCC_FILE_CHUNK: {
TRACE_(dmfile)(": file name chunk\n");
pDesc->dwValidData |= DMUS_OBJ_FILENAME;
IStream_Read (pStm, &pDesc->wszFileName, pChunk->dwSize, NULL);
break;
}
case DMUS_FOURCC_VERSION_CHUNK: {
TRACE_(dmfile)(": version chunk\n");
pDesc->dwValidData |= DMUS_OBJ_VERSION;
IStream_Read (pStm, &pDesc->vVersion, pChunk->dwSize, NULL);
break;
}
case DMUS_FOURCC_CATEGORY_CHUNK: {
TRACE_(dmfile)(": category chunk\n");
pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
IStream_Read (pStm, pDesc->wszCategory, pChunk->dwSize, NULL);
break;
}
default:
/* not handled */
return S_FALSE;
}
return S_OK;
}
HRESULT IDirectMusicImpl_IPersistStream_ParseUNFOGeneric (DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, LPDMUS_OBJECTDESC pDesc) {
LARGE_INTEGER liMove; /* used when skipping chunks */
/**
* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
* (though strings seem to be valid unicode)
*/
switch (pChunk->fccID) {
case mmioFOURCC('I','N','A','M'):
case DMUS_FOURCC_UNAM_CHUNK: {
TRACE_(dmfile)(": name chunk\n");
pDesc->dwValidData |= DMUS_OBJ_NAME;
IStream_Read (pStm, pDesc->wszName, pChunk->dwSize, NULL);
break;
}
case mmioFOURCC('I','A','R','T'):
case DMUS_FOURCC_UART_CHUNK: {
TRACE_(dmfile)(": artist chunk (ignored)\n");
liMove.QuadPart = pChunk->dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
case mmioFOURCC('I','C','O','P'):
case DMUS_FOURCC_UCOP_CHUNK: {
TRACE_(dmfile)(": copyright chunk (ignored)\n");
liMove.QuadPart = pChunk->dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
case mmioFOURCC('I','S','B','J'):
case DMUS_FOURCC_USBJ_CHUNK: {
TRACE_(dmfile)(": subject chunk (ignored)\n");
liMove.QuadPart = pChunk->dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
case mmioFOURCC('I','C','M','T'):
case DMUS_FOURCC_UCMT_CHUNK: {
TRACE_(dmfile)(": comment chunk (ignored)\n");
liMove.QuadPart = pChunk->dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
default:
/* not handled */
return S_FALSE;
}
return S_OK;
}
......@@ -960,4 +960,7 @@ extern const char *debugstr_DMUS_OBJ_FLAGS (DWORD flagmask);
/* dump whole DMUS_OBJECTDESC struct */
extern const char *debugstr_DMUS_OBJECTDESC (LPDMUS_OBJECTDESC pDesc);
HRESULT IDirectMusicImpl_IPersistStream_ParseDescGeneric (DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, LPDMUS_OBJECTDESC pDesc);
HRESULT IDirectMusicImpl_IPersistStream_ParseUNFOGeneric (DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, LPDMUS_OBJECTDESC pDesc);
#endif /* __WINE_DMIME_PRIVATE_H */
......@@ -626,90 +626,6 @@ HRESULT WINAPI IDirectMusicSegment8Impl_IPersistStream_IsDirty (LPPERSISTSTREAM
return S_FALSE;
}
static HRESULT IDirectMusicImpl_IPersistStream_ParseDescGeneric (DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, LPDMUS_OBJECTDESC pDesc) {
switch (pChunk->fccID) {
case DMUS_FOURCC_GUID_CHUNK: {
TRACE_(dmfile)(": GUID chunk\n");
pDesc->dwValidData |= DMUS_OBJ_OBJECT;
IStream_Read (pStm, &pDesc->guidObject, pChunk->dwSize, NULL);
break;
}
case DMUS_FOURCC_VERSION_CHUNK: {
TRACE_(dmfile)(": version chunk\n");
pDesc->dwValidData |= DMUS_OBJ_VERSION;
IStream_Read (pStm, &pDesc->vVersion, pChunk->dwSize, NULL);
break;
}
case DMUS_FOURCC_CATEGORY_CHUNK: {
TRACE_(dmfile)(": category chunk\n");
pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
IStream_Read (pStm, pDesc->wszCategory, pChunk->dwSize, NULL);
break;
}
default:
/* not handled */
return S_FALSE;
}
return S_OK;
}
static HRESULT IDirectMusicImpl_IPersistStream_ParseUNFOGeneric (DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, LPDMUS_OBJECTDESC pDesc) {
LARGE_INTEGER liMove; /* used when skipping chunks */
/**
* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
* (though strings seem to be valid unicode)
*/
switch (pChunk->fccID) {
/*
case mmioFOURCC('I','N','A','M'):
case DMUS_FOURCC_UNAM_CHUNK: {
TRACE_(dmfile)(": name chunk\n");
pDesc->dwValidData |= DMUS_OBJ_NAME;
IStream_Read (pStream, pDesc->wszName, Chunk.dwSize, NULL);
break;
}
*/
case mmioFOURCC('I','A','R','T'):
case DMUS_FOURCC_UART_CHUNK: {
TRACE_(dmfile)(": artist chunk (ignored)\n");
liMove.QuadPart = pChunk->dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
case mmioFOURCC('I','C','O','P'):
case DMUS_FOURCC_UCOP_CHUNK: {
TRACE_(dmfile)(": copyright chunk (ignored)\n");
liMove.QuadPart = pChunk->dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
case mmioFOURCC('I','S','B','J'):
case DMUS_FOURCC_USBJ_CHUNK: {
TRACE_(dmfile)(": subject chunk (ignored)\n");
liMove.QuadPart = pChunk->dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
case mmioFOURCC('I','C','M','T'):
case DMUS_FOURCC_UCMT_CHUNK: {
TRACE_(dmfile)(": comment chunk (ignored)\n");
liMove.QuadPart = pChunk->dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
default:
/* not handled */
return S_FALSE;
}
return S_OK;
}
static HRESULT IDirectMusicSegment8Impl_IPersistStream_LoadTrack (LPPERSISTSTREAM iface, IStream* pClonedStream, IDirectMusicTrack** ppTrack,
DMUS_IO_TRACK_HEADER* pTrack_hdr) {
......@@ -800,7 +716,7 @@ static HRESULT IDirectMusicSegment8Impl_IPersistStream_ParseTrackForm (LPPERSIST
IStream_Clone (pStm, &pClonedStream);
liMove.QuadPart = 0;
liMove.QuadPart -= (sizeof(FOURCC) + sizeof(DWORD));
liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD));
IStream_Seek (pClonedStream, liMove, STREAM_SEEK_CUR, NULL);
hr = IDirectMusicSegment8Impl_IPersistStream_LoadTrack (iface, pClonedStream, &pTrack, &track_hdr);
......@@ -809,18 +725,41 @@ static HRESULT IDirectMusicSegment8Impl_IPersistStream_ParseTrackForm (LPPERSIST
return hr;
}
IStream_Release (pClonedStream);
hr = IDirectMusicSegment8Impl_IDirectMusicSegment8_InsertTrack ((LPDIRECTMUSICSEGMENT8)This->SegmentVtbl, pTrack, track_hdr.dwGroup); /* at dsPosition */
if (FAILED(hr)) {
ERR(": could not insert track\n");
return hr;
}
IDirectMusicTrack_Release(pTrack); pTrack = NULL; /* now we can release at as it inserted */
IStream_Release (pClonedStream);
#if 0
#else
/*
do {
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
default: {
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
}
TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
} while (ListCount[0] < ListSize[0]);
*/
#endif
liMove.QuadPart = ListSize[0];
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
/*
*/
} else {
TRACE_(dmfile)(": unknown (skipping)\n");
liMove.QuadPart = Chunk.dwSize;
......@@ -831,21 +770,43 @@ static HRESULT IDirectMusicSegment8Impl_IPersistStream_ParseTrackForm (LPPERSIST
case FOURCC_RIFF: {
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
FIXME_(dmfile)(": LIST chunk of type %s (behavior to check)", debugstr_fourcc(Chunk.fccID));
FIXME_(dmfile)(": RIFF chunk of type %s (behavior to check)\n", debugstr_fourcc(Chunk.fccID));
ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
ListCount[0] = 0;
if (Chunk.fccID == track_hdr.fccType && 0 == track_hdr.ckid) {
LPSTREAM pClonedStream = NULL;
TRACE_(dmfile)(": TRACK RIFF\n");
/*
hr = IDirectMusicSegment8Impl_IPersistStream_LoadTrack (iface, pStm, &pTrack, &track_hdr);
if (FAILED(hr)) return hr;
*/
liMove.QuadPart = Chunk.dwSize;
IStream_Clone (pStm, &pClonedStream);
liMove.QuadPart = 0;
liMove.QuadPart -= (sizeof(FOURCC) + sizeof(DWORD));
IStream_Seek (pClonedStream, liMove, STREAM_SEEK_CUR, NULL);
hr = IDirectMusicSegment8Impl_IPersistStream_LoadTrack (iface, pClonedStream, &pTrack, &track_hdr);
if (FAILED(hr)) {
ERR(": could not load track\n");
return hr;
}
IStream_Release (pClonedStream);
hr = IDirectMusicSegment8Impl_IDirectMusicSegment8_InsertTrack ((LPDIRECTMUSICSEGMENT8)This->SegmentVtbl, pTrack, track_hdr.dwGroup); /* at dsPosition */
if (FAILED(hr)) {
ERR(": could not insert track\n");
return hr;
}
IDirectMusicTrack_Release(pTrack); pTrack = NULL; /* now we can release at as it inserted */
/** now safe move the cursor */
liMove.QuadPart = ListSize[0];
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
} else {
TRACE_(dmfile)(": unknown (skipping)\n");
liMove.QuadPart = Chunk.dwSize;
TRACE_(dmfile)(": unknown RIFF fmt (skipping)\n");
liMove.QuadPart = ListSize[0];
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
}
break;
......@@ -908,7 +869,7 @@ static HRESULT IDirectMusicSegment8Impl_IPersistStream_ParseTrackList (LPPERSIST
return E_FAIL;
}
ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
ListCount[0] = 0;
do {
......@@ -976,8 +937,9 @@ static HRESULT IDirectMusicSegment8Impl_IPersistStream_ParseSegmentForm (LPPERSI
if (hr == S_FALSE) {
switch (Chunk.fccID) {
case DMUS_FOURCC_SEGMENT_CHUNK: {
DWORD checkSz = 0;
DWORD checkSz = sizeof(FOURCC);
FIXME_(dmfile)(": segment chunk\n");
#if 1
/** DX 7 */
IStream_Read (pStm, &This->header.dwRepeats, sizeof(This->header.dwRepeats), NULL);
checkSz += sizeof(This->header.dwRepeats);
......@@ -991,6 +953,12 @@ static HRESULT IDirectMusicSegment8Impl_IPersistStream_ParseSegmentForm (LPPERSI
checkSz += sizeof(This->header.mtLoopEnd);
IStream_Read (pStm, &This->header.dwResolution, sizeof(This->header.dwResolution), NULL);
checkSz += sizeof(This->header.dwResolution);
TRACE_(dmfile)("dwRepeats: %lu\n", This->header.dwRepeats);
TRACE_(dmfile)("mtLength: %lu\n", This->header.mtLength);
TRACE_(dmfile)("mtPlayStart: %lu\n", This->header.mtPlayStart);
TRACE_(dmfile)("mtLoopStart: %lu\n", This->header.mtLoopStart);
TRACE_(dmfile)("mtLoopEnd: %lu\n", This->header.mtLoopEnd);
TRACE_(dmfile)("dwResolution: %lu\n", This->header.dwResolution);
/** DX 8 */
if (Chunk.dwSize > checkSz) {
IStream_Read (pStm, &This->header.rtLength, sizeof(This->header.rtLength), NULL);
......@@ -1007,7 +975,8 @@ static HRESULT IDirectMusicSegment8Impl_IPersistStream_ParseSegmentForm (LPPERSI
IStream_Read (pStm, &This->header.rtPlayStart, sizeof(This->header.rtPlayStart), NULL);
checkSz += sizeof(This->header.rtPlayStart);
}
liMove.QuadPart = Chunk.dwSize - checkSz;
#endif
liMove.QuadPart = Chunk.dwSize - checkSz + sizeof(FOURCC);
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
......@@ -1081,7 +1050,7 @@ HRESULT WINAPI IDirectMusicSegment8Impl_IPersistStream_Load (LPPERSISTSTREAM ifa
LARGE_INTEGER liMove; /* used when skipping chunks */
FIXME("(%p, %p): Loading not implemented yet\n", This, pStm);
FIXME("(%p, %p): Loading not fully implemented yet\n", This, pStm);
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
......
......@@ -224,15 +224,241 @@ ULONG WINAPI IDirectMusicSegTriggerTrack_IPersistStream_Release (LPPERSISTSTREAM
}
HRESULT WINAPI IDirectMusicSegTriggerTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
ICOM_THIS_MULTI(IDirectMusicSegment8Impl, PersistStreamVtbl, iface);
FIXME("(%p, %p): stub\n", This, pClassID);
return E_NOTIMPL;
}
HRESULT WINAPI IDirectMusicSegTriggerTrack_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
return E_NOTIMPL;
ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);
FIXME("(%p): stub, always S_FALSE\n", This);
return S_FALSE;
}
static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegment (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, IDirectMusicSegTriggerTrack* This) {
DMUS_PRIVATE_CHUNK Chunk;
DWORD ListSize[3], ListCount[3];
LARGE_INTEGER liMove; /* used when skipping chunks */
if (pChunk->fccID != DMUS_FOURCC_SEGMENT_LIST) {
ERR_(dmfile)(": %s chunk should be a SEGMENT list\n", debugstr_fourcc (pChunk->fccID));
return E_FAIL;
}
ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
ListCount[0] = 0;
do {
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
case DMUS_FOURCC_SEGMENTITEM_CHUNK: {
TRACE_(dmfile)(": segment item chunk\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
case DMUS_FOURCC_SEGMENTITEMNAME_CHUNK: {
TRACE_(dmfile)(": segment item name chunk\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
case FOURCC_LIST: {
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
ListCount[1] = 0;
switch (Chunk.fccID) {
/**
* should be a DMRF (DirectMusic Reference) list @TODO
*/
default: {
TRACE_(dmfile)(": unknown (skipping)\n");
liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
}
break;
}
default: {
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
}
TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
} while (ListCount[0] < ListSize[0]);
return S_OK;
}
static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegmentsList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, IDirectMusicSegTriggerTrack* This) {
HRESULT hr = E_FAIL;
DMUS_PRIVATE_CHUNK Chunk;
DWORD ListSize[3], ListCount[3];
LARGE_INTEGER liMove; /* used when skipping chunks */
if (pChunk->fccID != DMUS_FOURCC_SEGMENTS_LIST) {
ERR_(dmfile)(": %s chunk should be a SEGMENTS list\n", debugstr_fourcc (pChunk->fccID));
return E_FAIL;
}
ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
ListCount[0] = 0;
do {
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
case FOURCC_LIST: {
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
ListCount[1] = 0;
switch (Chunk.fccID) {
case DMUS_FOURCC_SEGMENT_LIST: {
TRACE_(dmfile)(": SEGMENT list\n");
hr = IDirectMusicSegTriggerTrack_IPersistStream_ParseSegment (iface, &Chunk, pStm, This);
if (FAILED(hr)) return hr;
break;
}
default: {
TRACE_(dmfile)(": unknown (skipping)\n");
liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
}
break;
}
default: {
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
}
TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
} while (ListCount[0] < ListSize[0]);
return S_OK;
}
static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegTrackList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, IDirectMusicSegTriggerTrack* This) {
HRESULT hr = E_FAIL;
DMUS_PRIVATE_CHUNK Chunk;
DWORD ListSize[3], ListCount[3];
LARGE_INTEGER liMove; /* used when skipping chunks */
if (pChunk->fccID != DMUS_FOURCC_SEGTRACK_LIST) {
ERR_(dmfile)(": %s chunk should be a TRACK list\n", debugstr_fourcc (pChunk->fccID));
return E_FAIL;
}
ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
ListCount[0] = 0;
do {
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
case DMUS_FOURCC_SEGTRACK_CHUNK: {
FIXME_(dmfile)(": segment trigger track chunk\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
case FOURCC_LIST: {
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
ListCount[1] = 0;
switch (Chunk.fccID) {
case DMUS_FOURCC_SEGMENTS_LIST: {
TRACE_(dmfile)(": SEGMENTS list\n");
hr = IDirectMusicSegTriggerTrack_IPersistStream_ParseSegmentsList (iface, &Chunk, pStm, This);
if (FAILED(hr)) return hr;
break;
}
default: {
TRACE_(dmfile)(": unknown (skipping)\n");
liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
}
break;
}
default: {
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
}
TRACE_(dmfile)(": ListCount[0] = %ld < ListSize[0] = %ld\n", ListCount[0], ListSize[0]);
} while (ListCount[0] < ListSize[0]);
return S_OK;
}
HRESULT WINAPI IDirectMusicSegTriggerTrack_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
FIXME(": Loading not implemented yet\n");
ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);
DMUS_PRIVATE_CHUNK Chunk;
LARGE_INTEGER liMove;
HRESULT hr;
FIXME("(%p, %p): Loading not fully implemented yet\n", This, pStm);
#if 1
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
case FOURCC_LIST: {
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
case DMUS_FOURCC_SEGTRACK_LIST: {
TRACE_(dmfile)(": segment trigger track list\n");
hr = IDirectMusicSegTriggerTrack_IPersistStream_ParseSegTrackList (iface, &Chunk, pStm, This);
if (FAILED(hr)) return hr;
/*
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
*/
break;
}
default: {
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
return E_FAIL;
}
}
TRACE_(dmfile)(": reading finished\n");
break;
}
default: {
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
return E_FAIL;
}
}
#endif
return S_OK;
}
......
......@@ -229,15 +229,61 @@ ULONG WINAPI IDirectMusicTempoTrack_IPersistStream_Release (LPPERSISTSTREAM ifac
}
HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
return E_NOTIMPL;
ICOM_THIS_MULTI(IDirectMusicSegment8Impl, PersistStreamVtbl, iface);
FIXME("(%p, %p): stub\n", This, pClassID);
return S_OK;
}
HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
return E_NOTIMPL;
ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
FIXME("(%p): stub, always S_FALSE\n", This);
return S_FALSE;
}
HRESULT WINAPI IDirectMusicTempoTrack_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
FIXME(": Loading not implemented yet\n");
ICOM_THIS_MULTI(IDirectMusicTempoTrack, PersistStreamVtbl, iface);
DMUS_PRIVATE_CHUNK Chunk;
DWORD StreamSize, StreamCount;
LARGE_INTEGER liMove;
DMUS_IO_TEMPO_ITEM item;
DWORD nItem = 0;
FIXME("(%p, %p): Loading not fully implemented yet\n", This, pStm);
#if 1
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
case DMUS_FOURCC_TEMPO_TRACK: {
TRACE_(dmfile)(": tempo track\n");
#if 1
IStream_Read (pStm, &StreamSize, sizeof(DWORD), NULL);
StreamSize -= sizeof(DWORD);
StreamCount = 0;
TRACE_(dmfile)(": items (size = %lu, chunkSize = %lu)\n", StreamSize, Chunk.dwSize - sizeof(DWORD));
do {
IStream_Read (pStm, &item, sizeof(item), NULL);
++nItem;
TRACE_(dmfile)("DMUS_IO_TEMPO_ITEM: item %ld\n", nItem);
TRACE_(dmfile)(" - lTime = %lu\n", item.lTime);
TRACE_(dmfile)(" - dblTempo = %g\n", item.dblTempo);
StreamCount += sizeof(item);
TRACE_(dmfile)(": StreamCount[0] = %ld < StreamSize[0] = %ld\n", StreamCount, StreamSize);
} while (StreamCount < StreamSize);
#else
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
#endif
break;
}
default: {
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
return E_FAIL;
}
}
#endif
return S_OK;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment