Better handling of User IDirectMusicTools.

This commit is contained in:
Raphael Junqueira 2004-05-20 01:15:30 +00:00 committed by Alexandre Julliard
parent 40dd9692d9
commit ca7ee47750
2 changed files with 101 additions and 87 deletions

View File

@ -165,6 +165,12 @@ typedef struct _DMUS_PRIVATE_SEGMENT_ITEM {
WCHAR wszName[DMUS_MAX_NAME]; WCHAR wszName[DMUS_MAX_NAME];
} DMUS_PRIVATE_SEGMENT_ITEM, *LPDMUS_PRIVATE_SEGMENT_ITEM; } DMUS_PRIVATE_SEGMENT_ITEM, *LPDMUS_PRIVATE_SEGMENT_ITEM;
typedef struct _DMUS_PRIVATE_GRAPH_TOOL {
struct list entry; /* for listing elements */
DWORD dwIndex;
IDirectMusicTool* pTool;
} DMUS_PRIVATE_GRAPH_TOOL, *LPDMUS_PRIVATE_GRAPH_TOOL;
typedef struct _DMUS_PRIVATE_TEMPO_PLAY_STATE { typedef struct _DMUS_PRIVATE_TEMPO_PLAY_STATE {
DWORD dummy; DWORD dummy;
} DMUS_PRIVATE_TEMPO_PLAY_STATE, *LPDMUS_PRIVATE_TEMPO_PLAY_STATE; } DMUS_PRIVATE_TEMPO_PLAY_STATE, *LPDMUS_PRIVATE_TEMPO_PLAY_STATE;
@ -385,9 +391,8 @@ struct IDirectMusicGraphImpl {
/* IDirectMusicGraphImpl fields */ /* IDirectMusicGraphImpl fields */
LPDMUS_OBJECTDESC pDesc; LPDMUS_OBJECTDESC pDesc;
IDirectMusicTool8Impl* pFirst; WORD num_tools;
IDirectMusicTool8Impl* pLast; struct list Tools;
WORD num_tools;
}; };
/* IUnknown: */ /* IUnknown: */
@ -478,8 +483,6 @@ struct IDirectMusicTool8Impl {
DWORD ref; DWORD ref;
/* IDirectMusicTool8Impl fields */ /* IDirectMusicTool8Impl fields */
IDirectMusicTool8Impl* pPrev;
IDirectMusicTool8Impl* pNext;
}; };
/* IUnknown: */ /* IUnknown: */

View File

@ -98,82 +98,92 @@ HRESULT WINAPI IDirectMusicGraphImpl_IDirectMusicGraph_StampPMsg (LPDIRECTMUSICG
} }
HRESULT WINAPI IDirectMusicGraphImpl_IDirectMusicGraph_InsertTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool, DWORD* pdwPChannels, DWORD cPChannels, LONG lIndex) { HRESULT WINAPI IDirectMusicGraphImpl_IDirectMusicGraph_InsertTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool, DWORD* pdwPChannels, DWORD cPChannels, LONG lIndex) {
int i; ICOM_THIS_MULTI(IDirectMusicGraphImpl, GraphVtbl, iface);
IDirectMusicTool8Impl* p;
IDirectMusicTool8Impl* toAdd = (IDirectMusicTool8Impl*) pTool;
ICOM_THIS_MULTI(IDirectMusicGraphImpl, GraphVtbl, iface);
FIXME("(%p, %p, %p, %ld, %li): use of pdwPChannels\n", This, pTool, pdwPChannels, cPChannels, lIndex); HRESULT hr;
struct list* pEntry = NULL;
struct list* pPrevEntry = NULL;
LPDMUS_PRIVATE_GRAPH_TOOL pIt = NULL;
LPDMUS_PRIVATE_GRAPH_TOOL pNewTool = NULL;
if (0 == This->num_tools) {
This->pFirst = This->pLast = toAdd; FIXME("(%p, %p, %p, %ld, %li): use of pdwPChannels\n", This, pTool, pdwPChannels, cPChannels, lIndex);
toAdd->pPrev = toAdd->pNext = NULL;
} else if (lIndex == 0 || lIndex <= -This->num_tools) { if (NULL == pTool) {
This->pFirst->pPrev = toAdd; return E_POINTER;
toAdd->pNext = This->pFirst; }
toAdd->pPrev = NULL;
This->pFirst = toAdd; if (0 > lIndex) {
} else if (lIndex < 0) { lIndex = This->num_tools + lIndex;
p = This->pLast; }
for (i = 0; i < -lIndex; ++i) {
p = p->pPrev; pPrevEntry = &This->Tools;
} LIST_FOR_EACH (pEntry, &This->Tools) {
toAdd->pNext = p->pNext; pIt = LIST_ENTRY(pEntry, DMUS_PRIVATE_GRAPH_TOOL, entry);
if (p->pNext) p->pNext->pPrev = toAdd; if (pIt->dwIndex == lIndex) {
p->pNext = toAdd; return DMUS_E_ALREADY_EXISTS;
toAdd->pPrev = p; }
} else if (lIndex >= This->num_tools) { if (pIt->dwIndex > lIndex) {
This->pLast->pNext = toAdd; break ;
toAdd->pPrev = This->pLast; }
toAdd->pNext = NULL; pPrevEntry = pEntry;
This->pLast = toAdd; }
} else if (lIndex > 0) {
p = This->pFirst; ++This->num_tools;
for (i = 0; i < lIndex; ++i) { pNewTool = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_GRAPH_TOOL));
p = p->pNext; pNewTool->pTool = pTool;
} pNewTool->dwIndex = lIndex;
toAdd->pPrev = p->pPrev; IDirectMusicTool8_AddRef(pTool);
if (p->pPrev) p->pPrev->pNext = toAdd; hr = IDirectMusicTool8_Init(pTool, iface);
p->pPrev = toAdd; list_add_tail (pPrevEntry->next, &pNewTool->entry);
toAdd->pNext = p;
} #if 0
++This->num_tools; DWORD dwNum = 0;
return DS_OK; hr = IDirectMusicTool8_GetMediaTypes(pTool, &dwNum);
#endif
return DS_OK;
} }
HRESULT WINAPI IDirectMusicGraphImpl_IDirectMusicGraph_GetTool (LPDIRECTMUSICGRAPH iface, DWORD dwIndex, IDirectMusicTool** ppTool) { HRESULT WINAPI IDirectMusicGraphImpl_IDirectMusicGraph_GetTool (LPDIRECTMUSICGRAPH iface, DWORD dwIndex, IDirectMusicTool** ppTool) {
int i; ICOM_THIS_MULTI(IDirectMusicGraphImpl, GraphVtbl, iface);
IDirectMusicTool8Impl* p = NULL; struct list* pEntry = NULL;
ICOM_THIS_MULTI(IDirectMusicGraphImpl, GraphVtbl, iface); LPDMUS_PRIVATE_GRAPH_TOOL pIt = NULL;
FIXME("(%p, %ld, %p): stub\n", This, dwIndex, ppTool); FIXME("(%p, %ld, %p): stub\n", This, dwIndex, ppTool);
p = This->pFirst; LIST_FOR_EACH (pEntry, &This->Tools) {
for (i = 0; i < dwIndex && i < This->num_tools; ++i) { pIt = LIST_ENTRY(pEntry, DMUS_PRIVATE_GRAPH_TOOL, entry);
p = p->pNext; if (pIt->dwIndex == dwIndex) {
} *ppTool = pIt->pTool;
*ppTool = (IDirectMusicTool*) p; if (NULL != *ppTool) {
if (NULL != *ppTool) { IDirectMusicTool8Impl_AddRef((LPDIRECTMUSICTOOL8) *ppTool);
IDirectMusicTool8Impl_AddRef((LPDIRECTMUSICTOOL8) *ppTool); }
} return S_OK;
return S_OK; }
if (pIt->dwIndex > dwIndex) {
break ;
}
}
return DMUS_E_NOT_FOUND;
} }
HRESULT WINAPI IDirectMusicGraphImpl_IDirectMusicGraph_RemoveTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool) { HRESULT WINAPI IDirectMusicGraphImpl_IDirectMusicGraph_RemoveTool (LPDIRECTMUSICGRAPH iface, IDirectMusicTool* pTool) {
ICOM_THIS_MULTI(IDirectMusicGraphImpl, GraphVtbl, iface); ICOM_THIS_MULTI(IDirectMusicGraphImpl, GraphVtbl, iface);
FIXME("(%p, %p): stub\n", This, pTool); FIXME("(%p, %p): stub\n", This, pTool);
return S_OK; return S_OK;
} }
ICOM_VTABLE(IDirectMusicGraph) DirectMusicGraph_Graph_Vtbl = { ICOM_VTABLE(IDirectMusicGraph) DirectMusicGraph_Graph_Vtbl = {
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectMusicGraphImpl_IDirectMusicGraph_QueryInterface, IDirectMusicGraphImpl_IDirectMusicGraph_QueryInterface,
IDirectMusicGraphImpl_IDirectMusicGraph_AddRef, IDirectMusicGraphImpl_IDirectMusicGraph_AddRef,
IDirectMusicGraphImpl_IDirectMusicGraph_Release, IDirectMusicGraphImpl_IDirectMusicGraph_Release,
IDirectMusicGraphImpl_IDirectMusicGraph_StampPMsg, IDirectMusicGraphImpl_IDirectMusicGraph_StampPMsg,
IDirectMusicGraphImpl_IDirectMusicGraph_InsertTool, IDirectMusicGraphImpl_IDirectMusicGraph_InsertTool,
IDirectMusicGraphImpl_IDirectMusicGraph_GetTool, IDirectMusicGraphImpl_IDirectMusicGraph_GetTool,
IDirectMusicGraphImpl_IDirectMusicGraph_RemoveTool IDirectMusicGraphImpl_IDirectMusicGraph_RemoveTool
}; };
@ -586,22 +596,23 @@ ICOM_VTABLE(IPersistStream) DirectMusicGraph_PersistStream_Vtbl = {
/* for ClassFactory */ /* for ClassFactory */
HRESULT WINAPI DMUSIC_CreateDirectMusicGraphImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) { HRESULT WINAPI DMUSIC_CreateDirectMusicGraphImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
IDirectMusicGraphImpl* obj; IDirectMusicGraphImpl* obj;
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicGraphImpl)); obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicGraphImpl));
if (NULL == obj) { if (NULL == obj) {
*ppobj = (LPVOID) NULL; *ppobj = (LPVOID) NULL;
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
obj->UnknownVtbl = &DirectMusicGraph_Unknown_Vtbl; obj->UnknownVtbl = &DirectMusicGraph_Unknown_Vtbl;
obj->GraphVtbl = &DirectMusicGraph_Graph_Vtbl; obj->GraphVtbl = &DirectMusicGraph_Graph_Vtbl;
obj->ObjectVtbl = &DirectMusicGraph_Object_Vtbl; obj->ObjectVtbl = &DirectMusicGraph_Object_Vtbl;
obj->PersistStreamVtbl = &DirectMusicGraph_PersistStream_Vtbl; obj->PersistStreamVtbl = &DirectMusicGraph_PersistStream_Vtbl;
obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC)); obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
DM_STRUCT_INIT(obj->pDesc); DM_STRUCT_INIT(obj->pDesc);
obj->pDesc->dwValidData |= DMUS_OBJ_CLASS; obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
memcpy (&obj->pDesc->guidClass, &CLSID_DirectMusicGraph, sizeof (CLSID)); memcpy (&obj->pDesc->guidClass, &CLSID_DirectMusicGraph, sizeof (CLSID));
obj->ref = 0; /* will be inited by QueryInterface */ obj->ref = 0; /* will be inited by QueryInterface */
list_init (&obj->Tools);
return IDirectMusicGraphImpl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);
return IDirectMusicGraphImpl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);
} }