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

- handle StyleRefs list on DMStyleTracks

- handle PartRefs list on DMStyles - begin of Parts list support on DMStyles (for now only some array checks) - fix IDirectMusicStyle::QueryInterface
parent 974c94f6
......@@ -104,14 +104,30 @@ typedef struct _DMUS_PRIVATE_STYLE_BAND {
IDirectMusicBand* pBand;
} DMUS_PRIVATE_STYLE_BAND, *LPDMUS_PRIVATE_STYLE_BAND;
typedef struct _DMUS_PRIVATE_STYLE_MOTIF {
typedef struct _DMUS_PRIVATE_STYLE_PARTREF_ITEM {
struct list entry; /* for listing elements */
DMUS_OBJECTDESC desc;
DMUS_IO_PARTREF part_ref;
} DMUS_PRIVATE_STYLE_PARTREF_ITEM, *LPDMUS_PRIVATE_STYLE_PARTREF_ITEM;
typedef struct _DMUS_PRIVATE_STYLE_MOTIF {
struct list entry; /* for listing elements */
DWORD dwRythm;
DMUS_IO_PATTERN pattern;
DMUS_OBJECTDESC desc;
/** optional for motifs */
DMUS_IO_MOTIFSETTINGS settings;
IDirectMusicBand* pBand;
struct list Items;
} DMUS_PRIVATE_STYLE_MOTIF, *LPDMUS_PRIVATE_STYLE_MOTIF;
typedef struct _DMUS_PRIVATE_STYLE_ITEM {
struct list entry; /* for listing elements */
DWORD dwTimeStamp;
IDirectMusicStyle8* pObject;
} DMUS_PRIVATE_STYLE_ITEM, *LPDMUS_PRIVATE_STYLE_ITEM;
extern HRESULT WINAPI DMUSIC_CreateDirectMusicAuditionTrack (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DMUSIC_CreateDirectMusicChordTrack (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
extern HRESULT WINAPI DMUSIC_CreateDirectMusicCommandTrack (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
......@@ -486,6 +502,8 @@ struct IDirectMusicStyleTrack {
/* IDirectMusicStyleTrack fields */
LPDMUS_OBJECTDESC pDesc;
struct list Items;
};
/* IUnknown: */
......
......@@ -39,6 +39,10 @@ HRESULT WINAPI IDirectMusicStyle8Impl_IUnknown_QueryInterface (LPUNKNOWN iface,
*ppobj = (LPVOID)&This->StyleVtbl;
IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef ((LPDIRECTMUSICSTYLE8)&This->StyleVtbl);
return S_OK;
} else if (IsEqualIID (riid, &IID_IDirectMusicStyle8)) {
*ppobj = (LPVOID)&This->StyleVtbl;
IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef ((LPDIRECTMUSICSTYLE8)&This->StyleVtbl);
return S_OK;
} else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
*ppobj = (LPVOID)&This->ObjectVtbl;
IDirectMusicStyle8Impl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT)&This->ObjectVtbl);
......@@ -463,7 +467,8 @@ static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePartRefList (LPPERSIST
DWORD ListSize[3], ListCount[3];
LARGE_INTEGER liMove; /* used when skipping chunks */
DMUS_OBJECTDESC desc;
LPDMUS_PRIVATE_STYLE_PARTREF_ITEM pNewItem = NULL;
if (pChunk->fccID != DMUS_FOURCC_PARTREF_LIST) {
ERR_(dmfile)(": %s chunk should be a PARTREF list\n", debugstr_fourcc (pChunk->fccID));
......@@ -479,9 +484,16 @@ static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePartRefList (LPPERSIST
TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
case DMUS_FOURCC_PARTREF_CHUNK: {
TRACE_(dmfile)(": PartRef chunk (skipping for now)\n");
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
TRACE_(dmfile)(": PartRef chunk\n");
pNewItem = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_PARTREF_ITEM));
if (NULL == pNewItem) {
ERR(": no more memory\n");
return E_OUTOFMEMORY;
}
hr = IStream_Read (pStm, &pNewItem->part_ref, sizeof(DMUS_IO_PARTREF), NULL);
/*TRACE_(dmfile)(" - sizeof %lu\n", sizeof(DMUS_IO_PARTREF));*/
list_add_tail (&pNewMotif->Items, &pNewItem->entry);
DM_STRUCT_INIT(&pNewItem->desc);
break;
}
case FOURCC_LIST: {
......@@ -497,7 +509,7 @@ static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePartRefList (LPPERSIST
ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &desc);
hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &pNewItem->desc);
if (FAILED(hr)) return hr;
if (hr == S_FALSE) {
......@@ -545,6 +557,8 @@ static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePartList (LPPERSISTSTR
LARGE_INTEGER liMove; /* used when skipping chunks */
DMUS_OBJECTDESC desc;
DWORD dwSize = 0;
DWORD cnt = 0;
if (pChunk->fccID != DMUS_FOURCC_PART_LIST) {
ERR_(dmfile)(": %s chunk should be a PART list\n", debugstr_fourcc (pChunk->fccID));
......@@ -560,20 +574,40 @@ static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePartList (LPPERSISTSTR
TRACE_(dmfile)(": %s chunk (size = %ld)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
switch (Chunk.fccID) {
case DMUS_FOURCC_PART_CHUNK: {
TRACE_(dmfile)(": Part chunk (skipping for now)\n");
TRACE_(dmfile)(": Part chunk (skipping for now) (sizeof %u)\n", sizeof(DMUS_IO_STYLEPART));
liMove.QuadPart = Chunk.dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
case DMUS_FOURCC_NOTE_CHUNK: {
TRACE_(dmfile)(": Note chunk (skipping for now)\n");
liMove.QuadPart = Chunk.dwSize;
TRACE_(dmfile)(": Note chunk (skipping for now) (sizeof %u)\n", sizeof(DMUS_IO_STYLENOTE));
IStream_Read (pStm, &dwSize, sizeof(DWORD), NULL);
cnt = (Chunk.dwSize - sizeof(DWORD));
TRACE_(dmfile)(" - dwSize: %lu\n", dwSize);
TRACE_(dmfile)(" - cnt: %lu (%lu / %lu)\n", cnt / dwSize, (Chunk.dwSize - sizeof(DWORD)), dwSize);
if (cnt % dwSize != 0) {
ERR("Invalid Array Size");
return E_FAIL;
}
cnt /= dwSize;
/** skip for now */
liMove.QuadPart = cnt * dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
case DMUS_FOURCC_CURVE_CHUNK: {
TRACE_(dmfile)(": Curve chunk (skipping for now)\n");
liMove.QuadPart = Chunk.dwSize;
TRACE_(dmfile)(": Curve chunk (skipping for now) (sizeof %u)\n", sizeof(DMUS_IO_STYLECURVE));
IStream_Read (pStm, &dwSize, sizeof(DWORD), NULL);
cnt = (Chunk.dwSize - sizeof(DWORD));
TRACE_(dmfile)(" - dwSize: %lu\n", dwSize);
TRACE_(dmfile)(" - cnt: %lu (%lu / %lu)\n", cnt / dwSize, (Chunk.dwSize - sizeof(DWORD)), dwSize);
if (cnt % dwSize != 0) {
ERR("Invalid Array Size");
return E_FAIL;
}
cnt /= dwSize;
/** skip for now */
liMove.QuadPart = cnt * dwSize;
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
break;
}
......@@ -655,12 +689,10 @@ static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (LPPERSIST
DWORD ListSize[3], ListCount[3];
LARGE_INTEGER liMove; /* used when skipping chunks */
DWORD dwRythm;
DMUS_OBJECTDESC desc;
IDirectMusicBand* pBand = NULL;
LPDMUS_PRIVATE_STYLE_MOTIF pNewMotif = NULL;
dwRythm = 0;
DM_STRUCT_INIT(&desc);
if (pChunk->fccID != DMUS_FOURCC_PATTERN_LIST) {
......@@ -690,14 +722,14 @@ static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (LPPERSIST
/** TODO trace pattern */
/** reset all datas, as a new pattern begin */
dwRythm = 0;
DM_STRUCT_INIT(&pNewMotif->desc);
list_init (&pNewMotif->Items);
break;
}
case DMUS_FOURCC_RHYTHM_CHUNK: {
TRACE_(dmfile)(": Rythm chunk\n");
IStream_Read (pStm, &dwRythm, sizeof(DWORD), NULL);
TRACE_(dmfile)(" - dwRythm: %lu\n", dwRythm);
IStream_Read (pStm, &pNewMotif->dwRythm, sizeof(DWORD), NULL);
TRACE_(dmfile)(" - dwRythm: %lu\n", pNewMotif->dwRythm);
/** TODO understand why some Chunks have size > 4 */
liMove.QuadPart = Chunk.dwSize - sizeof(DWORD);
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
......
......@@ -242,15 +242,17 @@ HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_IsDirty (LPPERSISTSTREAM if
}
static HRESULT IDirectMusicStyleTrack_IPersistStream_ParseStyleRef (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
/*ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);*/
ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface);
DMUS_PRIVATE_CHUNK Chunk;
DWORD ListSize[3], ListCount[3];
LARGE_INTEGER liMove; /* used when skipping chunks */
HRESULT hr;
DWORD dwTimeStamp;
IDirectMusicObject* pObject = NULL;
LPDMUS_PRIVATE_STYLE_ITEM pNewItem = NULL;
if (pChunk->fccID != DMUS_FOURCC_STYLE_REF_LIST) {
ERR_(dmfile)(": %s chunk should be a SEGMENT list\n", debugstr_fourcc (pChunk->fccID));
ERR_(dmfile)(": %s chunk should be a STYLE list\n", debugstr_fourcc (pChunk->fccID));
return E_FAIL;
}
......@@ -264,8 +266,14 @@ static HRESULT IDirectMusicStyleTrack_IPersistStream_ParseStyleRef (LPPERSISTSTR
switch (Chunk.fccID) {
case DMUS_FOURCC_TIME_STAMP_CHUNK: {
TRACE_(dmfile)(": Time Stamp chunck \n");
IStream_Read (pStm, &dwTimeStamp, sizeof(DWORD), NULL);
TRACE_(dmfile)(" - dwTimeStamp: %lu\n", dwTimeStamp);
pNewItem = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_ITEM));
if (NULL == pNewItem) {
ERR(": no more memory\n");
return E_OUTOFMEMORY;
}
IStream_Read (pStm, &pNewItem->dwTimeStamp, sizeof(DWORD), NULL);
TRACE_(dmfile)(" - dwTimeStamp: %lu\n", pNewItem->dwTimeStamp);
list_add_tail (&This->Items, &pNewItem->entry);
break;
}
case FOURCC_LIST: {
......@@ -279,8 +287,18 @@ static HRESULT IDirectMusicStyleTrack_IPersistStream_ParseStyleRef (LPPERSISTSTR
*/
case DMUS_FOURCC_REF_LIST: {
FIXME_(dmfile)(": DMRF (DM References) list, not yet handled\n");
liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
hr = IDirectMusicUtils_IPersistStream_ParseReference (iface, &Chunk, pStm, &pObject);
if (FAILED(hr)) {
ERR(": could not load Reference\n");
return hr;
}
hr = IDirectMusicObject_QueryInterface(pObject, &IID_IDirectMusicStyle8, (LPVOID*)&pNewItem->pObject);
if (FAILED(hr)) {
ERR(": Reference not a IDirectMusicStyle, exiting\n");
exit(-1);
return hr;
}
IDirectMusicObject_Release(pObject);
break;
}
default: {
......@@ -443,6 +461,7 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicStyleTrack (LPCGUID lpcGUID, LPVOID *ppob
track->pDesc->dwValidData |= DMUS_OBJ_CLASS;
memcpy (&track->pDesc->guidClass, &CLSID_DirectMusicStyleTrack, sizeof (CLSID));
track->ref = 0; /* will be inited by QueryInterface */
list_init (&track->Items);
return IDirectMusicStyleTrack_IUnknown_QueryInterface ((LPUNKNOWN)&track->UnknownVtbl, lpcGUID, ppobj);
}
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