2003-07-22 00:10:14 +02:00
|
|
|
/* IDirectMusicGraph
|
|
|
|
*
|
2004-01-20 01:21:40 +01:00
|
|
|
* Copyright (C) 2003-2004 Rok Mandeljc
|
2003-07-22 00:10:14 +02:00
|
|
|
*
|
2007-05-30 12:54:07 +02:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2003-07-22 00:10:14 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-05-30 12:54:07 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2003-07-22 00:10:14 +02:00
|
|
|
*
|
2007-05-30 12:54:07 +02:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-07-22 00:10:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dmime_private.h"
|
2015-06-15 01:22:26 +02:00
|
|
|
#include "dmobject.h"
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dmime);
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
struct IDirectMusicGraphImpl {
|
|
|
|
IDirectMusicGraph IDirectMusicGraph_iface;
|
2015-06-15 01:22:26 +02:00
|
|
|
struct dmobject dmobj;
|
2014-02-28 05:57:06 +01:00
|
|
|
LONG ref;
|
|
|
|
WORD num_tools;
|
|
|
|
struct list Tools;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline IDirectMusicGraphImpl *impl_from_IDirectMusicGraph(IDirectMusicGraph *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicGraphImpl, IDirectMusicGraph_iface);
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static inline IDirectMusicGraphImpl *impl_from_IPersistStream(IPersistStream *iface)
|
|
|
|
{
|
2015-06-15 01:22:26 +02:00
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicGraphImpl, dmobj.IPersistStream_iface);
|
2014-02-28 05:57:06 +01:00
|
|
|
}
|
2005-01-11 17:02:21 +01:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI DirectMusicGraph_QueryInterface(IDirectMusicGraph *iface, REFIID riid, void **ret_iface)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IDirectMusicGraph(iface);
|
2005-02-02 10:31:06 +01:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ret_iface);
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
*ret_iface = NULL;
|
2005-02-02 10:31:06 +01:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IDirectMusicGraph))
|
|
|
|
{
|
|
|
|
*ret_iface = &This->IDirectMusicGraph_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IDirectMusicObject))
|
2015-06-15 01:22:26 +02:00
|
|
|
*ret_iface = &This->dmobj.IDirectMusicObject_iface;
|
2014-02-28 05:57:06 +01:00
|
|
|
else if (IsEqualIID(riid, &IID_IPersistStream))
|
2015-06-15 01:22:26 +02:00
|
|
|
*ret_iface = &This->dmobj.IPersistStream_iface;
|
2014-02-28 05:57:06 +01:00
|
|
|
|
|
|
|
if (*ret_iface)
|
|
|
|
{
|
|
|
|
IDirectMusicGraph_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p, %s, %p): not found\n", This, debugstr_guid(riid), ret_iface);
|
|
|
|
return E_NOINTERFACE;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static ULONG WINAPI DirectMusicGraph_AddRef(IDirectMusicGraph *iface)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IDirectMusicGraph(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2022-02-08 23:14:49 +01:00
|
|
|
TRACE("(%p): %ld\n", This, ref);
|
2004-01-20 01:21:40 +01:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
DMIME_LockModule();
|
|
|
|
return ref;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static ULONG WINAPI DirectMusicGraph_Release(IDirectMusicGraph *iface)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IDirectMusicGraph(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2004-01-20 01:21:40 +01:00
|
|
|
|
2022-02-08 23:14:49 +01:00
|
|
|
TRACE("(%p): %ld\n", This, ref);
|
2014-02-28 05:57:06 +01:00
|
|
|
|
|
|
|
if (ref == 0)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
|
|
|
|
DMIME_UnlockModule();
|
|
|
|
return ref;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI DirectMusicGraph_StampPMsg(IDirectMusicGraph *iface, DMUS_PMSG *msg)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IDirectMusicGraph(iface);
|
|
|
|
FIXME("(%p, %p): stub\n", This, msg);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2004-05-20 03:15:30 +02:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI DirectMusicGraph_InsertTool(IDirectMusicGraph *iface, IDirectMusicTool* pTool, DWORD* pdwPChannels, DWORD cPChannels, LONG lIndex)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IDirectMusicGraph(iface);
|
|
|
|
struct list* pEntry = NULL;
|
|
|
|
struct list* pPrevEntry = NULL;
|
|
|
|
LPDMUS_PRIVATE_GRAPH_TOOL pIt = NULL;
|
|
|
|
LPDMUS_PRIVATE_GRAPH_TOOL pNewTool = NULL;
|
2004-05-20 03:15:30 +02:00
|
|
|
|
2022-02-08 23:14:49 +01:00
|
|
|
FIXME("(%p, %p, %p, %ld, %li): use of pdwPChannels\n", This, pTool, pdwPChannels, cPChannels, lIndex);
|
2004-05-20 03:15:30 +02:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
if (!pTool)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if (lIndex < 0)
|
|
|
|
lIndex = This->num_tools + lIndex;
|
|
|
|
|
|
|
|
pPrevEntry = &This->Tools;
|
|
|
|
LIST_FOR_EACH(pEntry, &This->Tools)
|
|
|
|
{
|
|
|
|
pIt = LIST_ENTRY(pEntry, DMUS_PRIVATE_GRAPH_TOOL, entry);
|
|
|
|
if (pIt->dwIndex == lIndex)
|
|
|
|
return DMUS_E_ALREADY_EXISTS;
|
|
|
|
|
|
|
|
if (pIt->dwIndex > lIndex)
|
|
|
|
break ;
|
|
|
|
pPrevEntry = pEntry;
|
2004-05-20 03:15:30 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
++This->num_tools;
|
|
|
|
pNewTool = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_GRAPH_TOOL));
|
|
|
|
pNewTool->pTool = pTool;
|
|
|
|
pNewTool->dwIndex = lIndex;
|
|
|
|
IDirectMusicTool8_AddRef(pTool);
|
|
|
|
IDirectMusicTool8_Init(pTool, iface);
|
|
|
|
list_add_tail (pPrevEntry->next, &pNewTool->entry);
|
2004-05-20 03:15:30 +02:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
DWORD dwNum = 0;
|
2008-04-15 22:33:30 +02:00
|
|
|
IDirectMusicTool8_GetMediaTypes(pTool, &dwNum);
|
2004-05-20 03:15:30 +02:00
|
|
|
#endif
|
2008-04-15 22:33:30 +02:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
return DS_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI DirectMusicGraph_GetTool(IDirectMusicGraph *iface, DWORD dwIndex, IDirectMusicTool** ppTool)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IDirectMusicGraph(iface);
|
|
|
|
struct list* pEntry = NULL;
|
|
|
|
LPDMUS_PRIVATE_GRAPH_TOOL pIt = NULL;
|
2020-03-16 06:33:43 +01:00
|
|
|
|
2022-02-08 23:14:49 +01:00
|
|
|
TRACE("(%p, %ld, %p)\n", This, dwIndex, ppTool);
|
2014-02-28 05:57:06 +01:00
|
|
|
|
|
|
|
LIST_FOR_EACH (pEntry, &This->Tools)
|
|
|
|
{
|
|
|
|
pIt = LIST_ENTRY(pEntry, DMUS_PRIVATE_GRAPH_TOOL, entry);
|
|
|
|
if (pIt->dwIndex == dwIndex)
|
|
|
|
{
|
|
|
|
*ppTool = pIt->pTool;
|
|
|
|
if (*ppTool)
|
|
|
|
IDirectMusicTool_AddRef(*ppTool);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if (pIt->dwIndex > dwIndex)
|
|
|
|
break ;
|
2004-05-20 03:15:30 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
return DMUS_E_NOT_FOUND;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI DirectMusicGraph_RemoveTool(IDirectMusicGraph *iface, IDirectMusicTool* pTool)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IDirectMusicGraph(iface);
|
|
|
|
FIXME("(%p, %p): stub\n", This, pTool);
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static const IDirectMusicGraphVtbl DirectMusicGraphVtbl =
|
|
|
|
{
|
|
|
|
DirectMusicGraph_QueryInterface,
|
|
|
|
DirectMusicGraph_AddRef,
|
|
|
|
DirectMusicGraph_Release,
|
|
|
|
DirectMusicGraph_StampPMsg,
|
|
|
|
DirectMusicGraph_InsertTool,
|
|
|
|
DirectMusicGraph_GetTool,
|
|
|
|
DirectMusicGraph_RemoveTool
|
2003-07-22 00:10:14 +02:00
|
|
|
};
|
|
|
|
|
2018-03-11 22:20:42 +01:00
|
|
|
static HRESULT WINAPI graph_IDirectMusicObject_ParseDescriptor(IDirectMusicObject *iface,
|
|
|
|
IStream *stream, DMUS_OBJECTDESC *desc)
|
2014-02-28 05:57:06 +01:00
|
|
|
{
|
2018-03-11 22:20:42 +01:00
|
|
|
struct chunk_entry riff = {0};
|
|
|
|
HRESULT hr;
|
2003-08-23 01:53:27 +02:00
|
|
|
|
2018-03-11 22:20:42 +01:00
|
|
|
TRACE("(%p, %p, %p)\n", iface, stream, desc);
|
2008-02-23 16:19:04 +01:00
|
|
|
|
2018-03-11 22:20:42 +01:00
|
|
|
if (!stream)
|
|
|
|
return E_POINTER;
|
|
|
|
if (!desc || desc->dwSize != sizeof(*desc))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if ((hr = stream_get_chunk(stream, &riff)) != S_OK)
|
|
|
|
return hr;
|
|
|
|
if (riff.id != FOURCC_RIFF || riff.type != DMUS_FOURCC_TOOLGRAPH_FORM) {
|
|
|
|
TRACE("loading failed: unexpected %s\n", debugstr_chunk(&riff));
|
|
|
|
stream_skip_chunk(stream, &riff);
|
|
|
|
return DMUS_E_CHUNKNOTFOUND;
|
|
|
|
}
|
2008-02-23 16:19:04 +01:00
|
|
|
|
2018-03-11 22:20:42 +01:00
|
|
|
hr = dmobj_parsedescriptor(stream, &riff, desc,
|
|
|
|
DMUS_OBJ_OBJECT|DMUS_OBJ_NAME|DMUS_OBJ_CATEGORY|DMUS_OBJ_VERSION);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
desc->guidClass = CLSID_DirectMusicGraph;
|
|
|
|
desc->dwValidData |= DMUS_OBJ_CLASS;
|
|
|
|
|
2019-09-30 20:35:59 +02:00
|
|
|
dump_DMUS_OBJECTDESC(desc);
|
2018-03-11 22:20:42 +01:00
|
|
|
return S_OK;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2015-06-15 01:22:26 +02:00
|
|
|
static const IDirectMusicObjectVtbl dmobject_vtbl = {
|
|
|
|
dmobj_IDirectMusicObject_QueryInterface,
|
|
|
|
dmobj_IDirectMusicObject_AddRef,
|
|
|
|
dmobj_IDirectMusicObject_Release,
|
|
|
|
dmobj_IDirectMusicObject_GetDescriptor,
|
|
|
|
dmobj_IDirectMusicObject_SetDescriptor,
|
2018-03-11 22:20:42 +01:00
|
|
|
graph_IDirectMusicObject_ParseDescriptor
|
2003-08-23 01:53:27 +02:00
|
|
|
};
|
|
|
|
|
2018-03-13 00:23:26 +01:00
|
|
|
static HRESULT WINAPI graph_IPersistStream_Load(IPersistStream *iface, IStream *stream)
|
2014-02-28 05:57:06 +01:00
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IPersistStream(iface);
|
2018-03-13 00:23:26 +01:00
|
|
|
|
|
|
|
FIXME("(%p, %p): Loading not implemented yet\n", This, stream);
|
|
|
|
|
|
|
|
return IDirectMusicObject_ParseDescriptor(&This->dmobj.IDirectMusicObject_iface, stream,
|
|
|
|
&This->dmobj.desc);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2015-06-15 01:22:26 +02:00
|
|
|
static const IPersistStreamVtbl persiststream_vtbl = {
|
|
|
|
dmobj_IPersistStream_QueryInterface,
|
|
|
|
dmobj_IPersistStream_AddRef,
|
|
|
|
dmobj_IPersistStream_Release,
|
|
|
|
dmobj_IPersistStream_GetClassID,
|
|
|
|
unimpl_IPersistStream_IsDirty,
|
2018-03-13 00:23:26 +01:00
|
|
|
graph_IPersistStream_Load,
|
2015-06-15 01:22:26 +02:00
|
|
|
unimpl_IPersistStream_Save,
|
|
|
|
unimpl_IPersistStream_GetSizeMax
|
2003-08-23 01:53:27 +02:00
|
|
|
};
|
2004-01-20 01:21:40 +01:00
|
|
|
|
|
|
|
/* for ClassFactory */
|
2014-02-28 05:57:06 +01:00
|
|
|
HRESULT WINAPI create_dmgraph(REFIID riid, void **ret_iface)
|
2014-01-10 10:41:27 +01:00
|
|
|
{
|
2014-02-28 05:57:06 +01:00
|
|
|
IDirectMusicGraphImpl* obj;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
*ret_iface = NULL;
|
2004-05-20 03:15:30 +02:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicGraphImpl));
|
|
|
|
if (!obj)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
obj->IDirectMusicGraph_iface.lpVtbl = &DirectMusicGraphVtbl;
|
|
|
|
obj->ref = 1;
|
2015-06-15 01:22:26 +02:00
|
|
|
dmobject_init(&obj->dmobj, &CLSID_DirectMusicGraph, (IUnknown *)&obj->IDirectMusicGraph_iface);
|
|
|
|
obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl;
|
|
|
|
obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
|
2014-02-28 05:57:06 +01:00
|
|
|
list_init(&obj->Tools);
|
|
|
|
|
|
|
|
hr = IDirectMusicGraph_QueryInterface(&obj->IDirectMusicGraph_iface, riid, ret_iface);
|
|
|
|
IDirectMusicGraph_Release(&obj->IDirectMusicGraph_iface);
|
|
|
|
|
|
|
|
return hr;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|