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"
|
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dmime);
|
2004-01-20 01:21:40 +01:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(dmfile);
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
struct IDirectMusicGraphImpl {
|
|
|
|
IDirectMusicGraph IDirectMusicGraph_iface;
|
|
|
|
IDirectMusicObject IDirectMusicObject_iface;
|
|
|
|
IPersistStream IPersistStream_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
/* IDirectMusicGraphImpl fields */
|
2015-04-26 23:53:47 +02:00
|
|
|
DMUS_OBJECTDESC desc;
|
2014-02-28 05:57:06 +01:00
|
|
|
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_IDirectMusicObject(IDirectMusicObject *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicGraphImpl, IDirectMusicObject_iface);
|
|
|
|
}
|
2005-01-11 17:02:21 +01:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static inline IDirectMusicGraphImpl *impl_from_IPersistStream(IPersistStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicGraphImpl, IPersistStream_iface);
|
|
|
|
}
|
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))
|
|
|
|
*ret_iface = &This->IDirectMusicObject_iface;
|
|
|
|
else if (IsEqualIID(riid, &IID_IPersistStream))
|
|
|
|
*ret_iface = &This->IPersistStream_iface;
|
|
|
|
|
|
|
|
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
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
TRACE("(%p): %d\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
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
TRACE("(%p): %d\n", This, ref);
|
|
|
|
|
|
|
|
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
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
FIXME("(%p, %p, %p, %d, %i): 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;
|
2004-05-20 03:15:30 +02:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
FIXME("(%p, %d, %p): stub\n", This, dwIndex, ppTool);
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI DirectMusicObject_QueryInterface(IDirectMusicObject *iface, REFIID riid, void **ret_iface)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IDirectMusicObject(iface);
|
|
|
|
return IDirectMusicGraph_QueryInterface(&This->IDirectMusicGraph_iface, riid, ret_iface);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static ULONG WINAPI DirectMusicObject_AddRef(IDirectMusicObject *iface)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IDirectMusicObject(iface);
|
|
|
|
return IDirectMusicGraph_AddRef(&This->IDirectMusicGraph_iface);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static ULONG WINAPI DirectMusicObject_Release(IDirectMusicObject *iface)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IDirectMusicObject(iface);
|
|
|
|
return IDirectMusicGraph_Release(&This->IDirectMusicGraph_iface);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI DirectMusicObject_GetDescriptor(IDirectMusicObject *iface, DMUS_OBJECTDESC *desc)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IDirectMusicObject(iface);
|
|
|
|
TRACE("(%p, %p)\n", This, desc);
|
2015-04-26 23:53:47 +02:00
|
|
|
*desc = This->desc;
|
2014-02-28 05:57:06 +01:00
|
|
|
return S_OK;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI DirectMusicObject_SetDescriptor(IDirectMusicObject *iface, DMUS_OBJECTDESC *pDesc)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IDirectMusicObject(iface);
|
|
|
|
|
|
|
|
TRACE("(%p, %p): %s\n", This, pDesc, debugstr_DMUS_OBJECTDESC(pDesc));
|
|
|
|
|
|
|
|
/* According to MSDN, we should copy only given values, not whole struct */
|
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
|
2015-04-26 23:53:47 +02:00
|
|
|
This->desc.guidObject = pDesc->guidObject;
|
2014-02-28 05:57:06 +01:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_CLASS)
|
2015-04-26 23:53:47 +02:00
|
|
|
This->desc.guidClass = pDesc->guidClass;
|
2014-02-28 05:57:06 +01:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_NAME)
|
2015-04-26 23:53:47 +02:00
|
|
|
lstrcpynW (This->desc.wszName, pDesc->wszName, DMUS_MAX_NAME);
|
2014-02-28 05:57:06 +01:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
|
2015-04-26 23:53:47 +02:00
|
|
|
lstrcpynW (This->desc.wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
|
2014-02-28 05:57:06 +01:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
|
2015-04-26 23:53:47 +02:00
|
|
|
lstrcpynW (This->desc.wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
|
2014-02-28 05:57:06 +01:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_VERSION)
|
2015-04-26 23:53:47 +02:00
|
|
|
This->desc.vVersion = pDesc->vVersion;
|
2014-02-28 05:57:06 +01:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_DATE)
|
2015-04-26 23:53:47 +02:00
|
|
|
This->desc.ftDate = pDesc->ftDate;
|
2014-02-28 05:57:06 +01:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_MEMORY)
|
|
|
|
{
|
2015-04-26 23:53:47 +02:00
|
|
|
This->desc.llMemLength = pDesc->llMemLength;
|
|
|
|
memcpy(This->desc.pbMemData, pDesc->pbMemData, pDesc->llMemLength);
|
2014-02-28 05:57:06 +01:00
|
|
|
}
|
2003-08-23 01:53:27 +02:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
/* according to MSDN, we copy the stream */
|
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_STREAM)
|
2015-04-26 23:53:47 +02:00
|
|
|
IStream_Clone(pDesc->pStream, &This->desc.pStream);
|
2014-02-28 05:57:06 +01:00
|
|
|
|
|
|
|
/* add new flags */
|
2015-04-26 23:53:47 +02:00
|
|
|
This->desc.dwValidData |= pDesc->dwValidData;
|
2014-02-28 05:57:06 +01:00
|
|
|
return S_OK;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI DirectMusicObject_ParseDescriptor(IDirectMusicObject *iface, IStream *pStream, DMUS_OBJECTDESC *pDesc)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IDirectMusicObject(iface);
|
|
|
|
DMUS_PRIVATE_CHUNK Chunk;
|
|
|
|
DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
|
|
|
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
2003-08-23 01:53:27 +02:00
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
TRACE("(%p, %p, %p)\n", This, pStream, pDesc);
|
2008-02-23 16:19:04 +01:00
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* FIXME: should this be determined from stream? */
|
|
|
|
pDesc->dwValidData |= DMUS_OBJ_CLASS;
|
2008-02-23 16:19:04 +01:00
|
|
|
pDesc->guidClass = CLSID_DirectMusicGraph;
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-01-20 01:21:40 +01:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case FOURCC_RIFF: {
|
|
|
|
IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
|
|
|
|
TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
|
|
|
|
StreamSize = Chunk.dwSize - sizeof(FOURCC);
|
|
|
|
StreamCount = 0;
|
|
|
|
if (Chunk.fccID == DMUS_FOURCC_TOOLGRAPH_FORM) {
|
|
|
|
TRACE_(dmfile)(": graph form\n");
|
|
|
|
do {
|
|
|
|
IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-01-20 01:21:40 +01:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case DMUS_FOURCC_GUID_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": GUID chunk\n");
|
|
|
|
pDesc->dwValidData |= DMUS_OBJ_OBJECT;
|
|
|
|
IStream_Read (pStream, &pDesc->guidObject, Chunk.dwSize, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_VERSION_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": version chunk\n");
|
|
|
|
pDesc->dwValidData |= DMUS_OBJ_VERSION;
|
|
|
|
IStream_Read (pStream, &pDesc->vVersion, Chunk.dwSize, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_CATEGORY_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": category chunk\n");
|
|
|
|
pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
|
|
|
|
IStream_Read (pStream, pDesc->wszCategory, Chunk.dwSize, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FOURCC_LIST: {
|
|
|
|
IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
|
|
|
|
TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
|
|
|
|
ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
|
|
|
|
ListCount[0] = 0;
|
|
|
|
switch (Chunk.fccID) {
|
|
|
|
/* evil M$ UNFO list, which can (!?) contain INFO elements */
|
|
|
|
case DMUS_FOURCC_UNFO_LIST: {
|
|
|
|
TRACE_(dmfile)(": UNFO list\n");
|
|
|
|
do {
|
|
|
|
IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-01-20 01:21:40 +01:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
/* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
|
|
|
|
(though strings seem to be valid unicode) */
|
|
|
|
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 = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, 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 = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, 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 = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, 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 = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2011-07-30 12:03:08 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-01-20 01:21:40 +01:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
|
2004-01-20 01:21:40 +01:00
|
|
|
} while (ListCount[0] < ListSize[0]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown (skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2011-07-30 12:03:08 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-01-20 01:21:40 +01:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
|
2004-01-20 01:21:40 +01:00
|
|
|
} while (StreamCount < StreamSize);
|
|
|
|
} else {
|
|
|
|
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
|
|
|
|
liMove.QuadPart = StreamSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE_(dmfile)(": reading finished\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
|
|
|
|
return DMUS_E_INVALIDFILE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-25 02:30:03 +01:00
|
|
|
TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC (pDesc));
|
2004-01-20 01:21:40 +01:00
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static const IDirectMusicObjectVtbl DirectMusicObjectVtbl =
|
|
|
|
{
|
|
|
|
DirectMusicObject_QueryInterface,
|
|
|
|
DirectMusicObject_AddRef,
|
|
|
|
DirectMusicObject_Release,
|
|
|
|
DirectMusicObject_GetDescriptor,
|
|
|
|
DirectMusicObject_SetDescriptor,
|
|
|
|
DirectMusicObject_ParseDescriptor
|
2003-08-23 01:53:27 +02:00
|
|
|
};
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI PersistStream_QueryInterface(IPersistStream *iface, REFIID riid, void **ret_iface)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IPersistStream(iface);
|
|
|
|
return IDirectMusicGraph_QueryInterface(&This->IDirectMusicGraph_iface, riid, ret_iface);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static ULONG WINAPI PersistStream_AddRef(IPersistStream *iface)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IPersistStream(iface);
|
|
|
|
return IDirectMusicGraph_AddRef(&This->IDirectMusicGraph_iface);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static ULONG WINAPI PersistStream_Release(IPersistStream *iface)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IPersistStream(iface);
|
|
|
|
return IDirectMusicGraph_Release(&This->IDirectMusicGraph_iface);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI PersistStream_GetClassID(IPersistStream *iface, CLSID *clsid)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IPersistStream(iface);
|
2015-04-26 23:42:54 +02:00
|
|
|
TRACE("(%p) %p\n", This, clsid);
|
|
|
|
*clsid = CLSID_DirectMusicGraph;
|
|
|
|
return S_OK;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI PersistStream_IsDirty(IPersistStream *iface)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IPersistStream(iface);
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
return E_NOTIMPL;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI PersistStream_Load(IPersistStream *iface, IStream* pStm)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IPersistStream(iface);
|
2004-01-20 01:21:40 +01:00
|
|
|
FOURCC chunkID;
|
|
|
|
DWORD chunkSize, StreamSize, StreamCount, ListSize[3], ListCount[3];
|
|
|
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
|
|
|
|
|
|
|
FIXME("(%p, %p): Loading not implemented yet\n", This, pStm);
|
|
|
|
IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
|
|
|
|
IStream_Read (pStm, &chunkSize, sizeof(DWORD), NULL);
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (chunkID), chunkSize);
|
2004-01-20 01:21:40 +01:00
|
|
|
switch (chunkID) {
|
|
|
|
case FOURCC_RIFF: {
|
|
|
|
IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
|
|
|
|
TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(chunkID));
|
|
|
|
StreamSize = chunkSize - sizeof(FOURCC);
|
|
|
|
StreamCount = 0;
|
|
|
|
switch (chunkID) {
|
|
|
|
case DMUS_FOURCC_TOOLGRAPH_FORM: {
|
|
|
|
TRACE_(dmfile)(": graph form\n");
|
|
|
|
do {
|
|
|
|
IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
|
|
|
|
IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
|
|
|
|
StreamCount += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (chunkID), chunkSize);
|
2004-01-20 01:21:40 +01:00
|
|
|
switch (chunkID) {
|
|
|
|
case DMUS_FOURCC_GUID_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": GUID chunk\n");
|
2015-04-26 23:53:47 +02:00
|
|
|
This->desc.dwValidData |= DMUS_OBJ_OBJECT;
|
|
|
|
IStream_Read (pStm, &This->desc.guidObject, chunkSize, NULL);
|
2004-01-20 01:21:40 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_VERSION_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": version chunk\n");
|
2015-04-26 23:53:47 +02:00
|
|
|
This->desc.dwValidData |= DMUS_OBJ_VERSION;
|
|
|
|
IStream_Read (pStm, &This->desc.vVersion, chunkSize, NULL);
|
2004-01-20 01:21:40 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_CATEGORY_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": category chunk\n");
|
2015-04-26 23:53:47 +02:00
|
|
|
This->desc.dwValidData |= DMUS_OBJ_CATEGORY;
|
|
|
|
IStream_Read (pStm, This->desc.wszCategory, chunkSize, NULL);
|
2004-01-20 01:21:40 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FOURCC_LIST: {
|
|
|
|
IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
|
|
|
|
TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(chunkID));
|
|
|
|
ListSize[0] = chunkSize - sizeof(FOURCC);
|
|
|
|
ListCount[0] = 0;
|
|
|
|
switch (chunkID) {
|
|
|
|
case DMUS_FOURCC_UNFO_LIST: {
|
|
|
|
TRACE_(dmfile)(": UNFO list\n");
|
|
|
|
do {
|
|
|
|
IStream_Read (pStm, &chunkID, sizeof(FOURCC), NULL);
|
|
|
|
IStream_Read (pStm, &chunkSize, sizeof(FOURCC), NULL);
|
|
|
|
ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + chunkSize;
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (chunkID), chunkSize);
|
2004-01-20 01:21:40 +01:00
|
|
|
switch (chunkID) {
|
|
|
|
/* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
|
|
|
|
(though strings seem to be valid unicode) */
|
|
|
|
case mmioFOURCC('I','N','A','M'):
|
|
|
|
case DMUS_FOURCC_UNAM_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": name chunk\n");
|
2015-04-26 23:53:47 +02:00
|
|
|
This->desc.dwValidData |= DMUS_OBJ_NAME;
|
|
|
|
IStream_Read (pStm, This->desc.wszName, chunkSize, NULL);
|
2004-01-20 01:21:40 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case mmioFOURCC('I','A','R','T'):
|
|
|
|
case DMUS_FOURCC_UART_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": artist chunk (ignored)\n");
|
|
|
|
liMove.QuadPart = chunkSize;
|
|
|
|
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 = chunkSize;
|
|
|
|
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 = chunkSize;
|
|
|
|
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 = chunkSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2011-07-30 12:03:08 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-01-20 01:21:40 +01:00
|
|
|
liMove.QuadPart = chunkSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
|
2004-01-20 01:21:40 +01:00
|
|
|
} while (ListCount[0] < ListSize[0]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown (skipping)\n");
|
|
|
|
liMove.QuadPart = chunkSize - sizeof(FOURCC);
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2011-07-30 12:03:08 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-01-20 01:21:40 +01:00
|
|
|
liMove.QuadPart = chunkSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-10 01:07:26 +02:00
|
|
|
TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
|
2004-01-20 01:21:40 +01:00
|
|
|
} while (StreamCount < StreamSize);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
|
|
|
|
liMove.QuadPart = StreamSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE_(dmfile)(": reading finished\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
|
|
|
|
liMove.QuadPart = chunkSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI PersistStream_Save(IPersistStream *iface, IStream *stream, BOOL clear_dirty)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IPersistStream(iface);
|
2015-04-26 23:38:53 +02:00
|
|
|
TRACE("(%p) %p %d\n", This, stream, clear_dirty);
|
2014-02-28 05:57:06 +01:00
|
|
|
return E_NOTIMPL;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static HRESULT WINAPI PersistStream_GetSizeMax(IPersistStream *iface, ULARGE_INTEGER *size)
|
|
|
|
{
|
|
|
|
IDirectMusicGraphImpl *This = impl_from_IPersistStream(iface);
|
2015-04-26 23:38:53 +02:00
|
|
|
TRACE("(%p) %p\n", This, size);
|
2014-02-28 05:57:06 +01:00
|
|
|
return E_NOTIMPL;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2014-02-28 05:57:06 +01:00
|
|
|
static const IPersistStreamVtbl PersistStreamVtbl =
|
|
|
|
{
|
|
|
|
PersistStream_QueryInterface,
|
|
|
|
PersistStream_AddRef,
|
|
|
|
PersistStream_Release,
|
|
|
|
PersistStream_GetClassID,
|
|
|
|
PersistStream_IsDirty,
|
|
|
|
PersistStream_Load,
|
|
|
|
PersistStream_Save,
|
|
|
|
PersistStream_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->IDirectMusicObject_iface.lpVtbl = &DirectMusicObjectVtbl;
|
|
|
|
obj->IPersistStream_iface.lpVtbl = &PersistStreamVtbl;
|
2015-04-26 23:53:47 +02:00
|
|
|
DM_STRUCT_INIT(&obj->desc);
|
|
|
|
obj->desc.dwValidData |= DMUS_OBJ_CLASS;
|
|
|
|
obj->desc.guidClass = CLSID_DirectMusicGraph;
|
2014-02-28 05:57:06 +01:00
|
|
|
obj->ref = 1;
|
|
|
|
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
|
|
|
}
|