dmime: No need to allocate description separately for IDirectMusicGraph.

This commit is contained in:
Nikolay Sivov 2015-04-27 00:53:47 +03:00 committed by Alexandre Julliard
parent 494c674028
commit b508c85c66
1 changed files with 24 additions and 26 deletions

View File

@ -29,7 +29,7 @@ struct IDirectMusicGraphImpl {
LONG ref; LONG ref;
/* IDirectMusicGraphImpl fields */ /* IDirectMusicGraphImpl fields */
LPDMUS_OBJECTDESC pDesc; DMUS_OBJECTDESC desc;
WORD num_tools; WORD num_tools;
struct list Tools; struct list Tools;
}; };
@ -218,8 +218,7 @@ static HRESULT WINAPI DirectMusicObject_GetDescriptor(IDirectMusicObject *iface,
{ {
IDirectMusicGraphImpl *This = impl_from_IDirectMusicObject(iface); IDirectMusicGraphImpl *This = impl_from_IDirectMusicObject(iface);
TRACE("(%p, %p)\n", This, desc); TRACE("(%p, %p)\n", This, desc);
/* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */ *desc = This->desc;
memcpy(desc, This->pDesc, This->pDesc->dwSize);
return S_OK; return S_OK;
} }
@ -231,31 +230,31 @@ static HRESULT WINAPI DirectMusicObject_SetDescriptor(IDirectMusicObject *iface,
/* According to MSDN, we should copy only given values, not whole struct */ /* According to MSDN, we should copy only given values, not whole struct */
if (pDesc->dwValidData & DMUS_OBJ_OBJECT) if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
This->pDesc->guidObject = pDesc->guidObject; This->desc.guidObject = pDesc->guidObject;
if (pDesc->dwValidData & DMUS_OBJ_CLASS) if (pDesc->dwValidData & DMUS_OBJ_CLASS)
This->pDesc->guidClass = pDesc->guidClass; This->desc.guidClass = pDesc->guidClass;
if (pDesc->dwValidData & DMUS_OBJ_NAME) if (pDesc->dwValidData & DMUS_OBJ_NAME)
lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME); lstrcpynW (This->desc.wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY) if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY); lstrcpynW (This->desc.wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME) if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME); lstrcpynW (This->desc.wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
if (pDesc->dwValidData & DMUS_OBJ_VERSION) if (pDesc->dwValidData & DMUS_OBJ_VERSION)
This->pDesc->vVersion = pDesc->vVersion; This->desc.vVersion = pDesc->vVersion;
if (pDesc->dwValidData & DMUS_OBJ_DATE) if (pDesc->dwValidData & DMUS_OBJ_DATE)
This->pDesc->ftDate = pDesc->ftDate; This->desc.ftDate = pDesc->ftDate;
if (pDesc->dwValidData & DMUS_OBJ_MEMORY) if (pDesc->dwValidData & DMUS_OBJ_MEMORY)
{ {
This->pDesc->llMemLength = pDesc->llMemLength; This->desc.llMemLength = pDesc->llMemLength;
memcpy(This->pDesc->pbMemData, pDesc->pbMemData, pDesc->llMemLength); memcpy(This->desc.pbMemData, pDesc->pbMemData, pDesc->llMemLength);
} }
/* according to MSDN, we copy the stream */ /* according to MSDN, we copy the stream */
if (pDesc->dwValidData & DMUS_OBJ_STREAM) if (pDesc->dwValidData & DMUS_OBJ_STREAM)
IStream_Clone(pDesc->pStream, &This->pDesc->pStream); IStream_Clone(pDesc->pStream, &This->desc.pStream);
/* add new flags */ /* add new flags */
This->pDesc->dwValidData |= pDesc->dwValidData; This->desc.dwValidData |= pDesc->dwValidData;
return S_OK; return S_OK;
} }
@ -479,20 +478,20 @@ static HRESULT WINAPI PersistStream_Load(IPersistStream *iface, IStream* pStm)
switch (chunkID) { switch (chunkID) {
case DMUS_FOURCC_GUID_CHUNK: { case DMUS_FOURCC_GUID_CHUNK: {
TRACE_(dmfile)(": GUID chunk\n"); TRACE_(dmfile)(": GUID chunk\n");
This->pDesc->dwValidData |= DMUS_OBJ_OBJECT; This->desc.dwValidData |= DMUS_OBJ_OBJECT;
IStream_Read (pStm, &This->pDesc->guidObject, chunkSize, NULL); IStream_Read (pStm, &This->desc.guidObject, chunkSize, NULL);
break; break;
} }
case DMUS_FOURCC_VERSION_CHUNK: { case DMUS_FOURCC_VERSION_CHUNK: {
TRACE_(dmfile)(": version chunk\n"); TRACE_(dmfile)(": version chunk\n");
This->pDesc->dwValidData |= DMUS_OBJ_VERSION; This->desc.dwValidData |= DMUS_OBJ_VERSION;
IStream_Read (pStm, &This->pDesc->vVersion, chunkSize, NULL); IStream_Read (pStm, &This->desc.vVersion, chunkSize, NULL);
break; break;
} }
case DMUS_FOURCC_CATEGORY_CHUNK: { case DMUS_FOURCC_CATEGORY_CHUNK: {
TRACE_(dmfile)(": category chunk\n"); TRACE_(dmfile)(": category chunk\n");
This->pDesc->dwValidData |= DMUS_OBJ_CATEGORY; This->desc.dwValidData |= DMUS_OBJ_CATEGORY;
IStream_Read (pStm, This->pDesc->wszCategory, chunkSize, NULL); IStream_Read (pStm, This->desc.wszCategory, chunkSize, NULL);
break; break;
} }
case FOURCC_LIST: { case FOURCC_LIST: {
@ -514,8 +513,8 @@ static HRESULT WINAPI PersistStream_Load(IPersistStream *iface, IStream* pStm)
case mmioFOURCC('I','N','A','M'): case mmioFOURCC('I','N','A','M'):
case DMUS_FOURCC_UNAM_CHUNK: { case DMUS_FOURCC_UNAM_CHUNK: {
TRACE_(dmfile)(": name chunk\n"); TRACE_(dmfile)(": name chunk\n");
This->pDesc->dwValidData |= DMUS_OBJ_NAME; This->desc.dwValidData |= DMUS_OBJ_NAME;
IStream_Read (pStm, This->pDesc->wszName, chunkSize, NULL); IStream_Read (pStm, This->desc.wszName, chunkSize, NULL);
break; break;
} }
case mmioFOURCC('I','A','R','T'): case mmioFOURCC('I','A','R','T'):
@ -639,10 +638,9 @@ HRESULT WINAPI create_dmgraph(REFIID riid, void **ret_iface)
obj->IDirectMusicGraph_iface.lpVtbl = &DirectMusicGraphVtbl; obj->IDirectMusicGraph_iface.lpVtbl = &DirectMusicGraphVtbl;
obj->IDirectMusicObject_iface.lpVtbl = &DirectMusicObjectVtbl; obj->IDirectMusicObject_iface.lpVtbl = &DirectMusicObjectVtbl;
obj->IPersistStream_iface.lpVtbl = &PersistStreamVtbl; obj->IPersistStream_iface.lpVtbl = &PersistStreamVtbl;
obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC)); DM_STRUCT_INIT(&obj->desc);
DM_STRUCT_INIT(obj->pDesc); obj->desc.dwValidData |= DMUS_OBJ_CLASS;
obj->pDesc->dwValidData |= DMUS_OBJ_CLASS; obj->desc.guidClass = CLSID_DirectMusicGraph;
obj->pDesc->guidClass = CLSID_DirectMusicGraph;
obj->ref = 1; obj->ref = 1;
list_init(&obj->Tools); list_init(&obj->Tools);