2003-07-21 22:10:14 +00:00
|
|
|
/* IDirectMusicBand Implementation
|
|
|
|
*
|
2004-01-20 00:21:40 +00:00
|
|
|
* Copyright (C) 2003-2004 Rok Mandeljc
|
2003-07-21 22:10:14 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-07-21 22:10:14 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dmband_private.h"
|
|
|
|
|
2003-08-22 23:53:27 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dmband);
|
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(dmfile);
|
2003-07-21 22:10:14 +00:00
|
|
|
|
2004-01-20 00:21:40 +00:00
|
|
|
|
2003-08-22 23:53:27 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectMusicBandImpl implementation
|
|
|
|
*/
|
2004-01-20 00:21:40 +00:00
|
|
|
/* IDirectMusicBandImpl IUnknown part: */
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, UnknownVtbl, iface);
|
|
|
|
|
2004-02-25 01:30:03 +00:00
|
|
|
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
|
2004-01-20 00:21:40 +00:00
|
|
|
if (IsEqualIID (riid, &IID_IUnknown)) {
|
|
|
|
*ppobj = (LPVOID)&This->UnknownVtbl;
|
2005-06-22 12:01:39 +00:00
|
|
|
IUnknown_AddRef (iface);
|
2004-01-20 00:21:40 +00:00
|
|
|
return S_OK;
|
|
|
|
} else if (IsEqualIID (riid, &IID_IDirectMusicBand)) {
|
|
|
|
*ppobj = (LPVOID)&This->BandVtbl;
|
2005-06-22 12:01:39 +00:00
|
|
|
IUnknown_AddRef (iface);
|
2004-01-20 00:21:40 +00:00
|
|
|
return S_OK;
|
|
|
|
} else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
|
|
|
|
*ppobj = (LPVOID)&This->ObjectVtbl;
|
2005-06-22 12:01:39 +00:00
|
|
|
IUnknown_AddRef (iface);
|
2004-01-20 00:21:40 +00:00
|
|
|
return S_OK;
|
|
|
|
} else if (IsEqualIID (riid, &IID_IPersistStream)) {
|
|
|
|
*ppobj = (LPVOID)&This->PersistStreamVtbl;
|
2005-06-22 12:01:39 +00:00
|
|
|
IUnknown_AddRef (iface);
|
2003-07-21 22:10:14 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
2004-01-20 00:21:40 +00:00
|
|
|
|
2004-02-25 01:30:03 +00:00
|
|
|
WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
|
2003-07-21 22:10:14 +00:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static ULONG WINAPI IDirectMusicBandImpl_IUnknown_AddRef (LPUNKNOWN iface) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, UnknownVtbl, iface);
|
2005-01-21 10:18:16 +00:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE("(%p) : AddRef from %d\n", This, ref - 1);
|
2005-01-21 10:18:16 +00:00
|
|
|
|
2005-01-31 20:40:26 +00:00
|
|
|
DMBAND_LockModule();
|
|
|
|
|
2005-01-21 10:18:16 +00:00
|
|
|
return ref;
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static ULONG WINAPI IDirectMusicBandImpl_IUnknown_Release (LPUNKNOWN iface) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, UnknownVtbl, iface);
|
2005-01-21 10:18:16 +00:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
|
2005-01-21 10:18:16 +00:00
|
|
|
|
2003-10-28 21:08:55 +00:00
|
|
|
if (ref == 0) {
|
2003-07-21 22:10:14 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
2005-01-31 20:40:26 +00:00
|
|
|
|
|
|
|
DMBAND_UnlockModule();
|
|
|
|
|
2003-07-21 22:10:14 +00:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2005-05-30 10:01:08 +00:00
|
|
|
static const IUnknownVtbl DirectMusicBand_Unknown_Vtbl = {
|
2004-01-20 00:21:40 +00:00
|
|
|
IDirectMusicBandImpl_IUnknown_QueryInterface,
|
|
|
|
IDirectMusicBandImpl_IUnknown_AddRef,
|
|
|
|
IDirectMusicBandImpl_IUnknown_Release
|
|
|
|
};
|
2003-07-21 22:10:14 +00:00
|
|
|
|
2004-01-20 00:21:40 +00:00
|
|
|
/* IDirectMusicBandImpl IDirectMusicBand part: */
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IDirectMusicBand_QueryInterface (LPDIRECTMUSICBAND iface, REFIID riid, LPVOID *ppobj) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, BandVtbl, iface);
|
2005-06-22 12:01:39 +00:00
|
|
|
return IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static ULONG WINAPI IDirectMusicBandImpl_IDirectMusicBand_AddRef (LPDIRECTMUSICBAND iface) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, BandVtbl, iface);
|
2005-06-22 12:01:39 +00:00
|
|
|
return IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
2004-01-20 00:21:40 +00:00
|
|
|
}
|
2003-07-21 22:10:14 +00:00
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static ULONG WINAPI IDirectMusicBandImpl_IDirectMusicBand_Release (LPDIRECTMUSICBAND iface) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, BandVtbl, iface);
|
2005-06-22 12:01:39 +00:00
|
|
|
return IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
|
2004-01-20 00:21:40 +00:00
|
|
|
}
|
2003-07-21 22:10:14 +00:00
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IDirectMusicBand_CreateSegment (LPDIRECTMUSICBAND iface, IDirectMusicSegment** ppSegment) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, BandVtbl, iface);
|
|
|
|
FIXME("(%p, %p): stub\n", This, ppSegment);
|
2003-07-21 22:10:14 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IDirectMusicBand_Download (LPDIRECTMUSICBAND iface, IDirectMusicPerformance* pPerformance) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, BandVtbl, iface);
|
2003-07-21 22:10:14 +00:00
|
|
|
FIXME("(%p, %p): stub\n", This, pPerformance);
|
2004-01-20 00:21:40 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
2003-07-21 22:10:14 +00:00
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IDirectMusicBand_Unload (LPDIRECTMUSICBAND iface, IDirectMusicPerformance* pPerformance) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, BandVtbl, iface);
|
|
|
|
FIXME("(%p, %p): stub\n", This, pPerformance);
|
2003-07-21 22:10:14 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-05-30 10:01:08 +00:00
|
|
|
static const IDirectMusicBandVtbl DirectMusicBand_Band_Vtbl = {
|
2004-01-20 00:21:40 +00:00
|
|
|
IDirectMusicBandImpl_IDirectMusicBand_QueryInterface,
|
|
|
|
IDirectMusicBandImpl_IDirectMusicBand_AddRef,
|
|
|
|
IDirectMusicBandImpl_IDirectMusicBand_Release,
|
|
|
|
IDirectMusicBandImpl_IDirectMusicBand_CreateSegment,
|
|
|
|
IDirectMusicBandImpl_IDirectMusicBand_Download,
|
|
|
|
IDirectMusicBandImpl_IDirectMusicBand_Unload
|
2003-07-21 22:10:14 +00:00
|
|
|
};
|
|
|
|
|
2004-01-20 00:21:40 +00:00
|
|
|
/* IDirectMusicBandImpl IDirectMusicObject part: */
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, ObjectVtbl, iface);
|
2005-06-22 12:01:39 +00:00
|
|
|
return IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
2003-08-22 23:53:27 +00:00
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static ULONG WINAPI IDirectMusicBandImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, ObjectVtbl, iface);
|
2005-06-22 12:01:39 +00:00
|
|
|
return IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static ULONG WINAPI IDirectMusicBandImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, ObjectVtbl, iface);
|
2005-06-22 12:01:39 +00:00
|
|
|
return IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, ObjectVtbl, iface);
|
2003-08-22 23:53:27 +00:00
|
|
|
TRACE("(%p, %p)\n", This, pDesc);
|
2004-01-20 00:21:40 +00:00
|
|
|
/* I think we shouldn't return pointer here since then values can be changed; it'd be a mess */
|
|
|
|
memcpy (pDesc, This->pDesc, This->pDesc->dwSize);
|
2003-08-22 23:53:27 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, ObjectVtbl, iface);
|
2004-05-14 04:57:02 +00:00
|
|
|
TRACE("(%p, %p): setting descriptor:\n", This, pDesc); debug_DMUS_OBJECTDESC (pDesc);
|
2003-08-22 23:53:27 +00:00
|
|
|
|
2004-01-20 00:21:40 +00:00
|
|
|
/* According to MSDN, we should copy only given values, not whole struct */
|
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
|
|
|
|
memcpy (&This->pDesc->guidObject, &pDesc->guidObject, sizeof (pDesc->guidObject));
|
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_CLASS)
|
|
|
|
memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
|
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_NAME)
|
2005-04-18 10:30:55 +00:00
|
|
|
lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
|
2004-01-20 00:21:40 +00:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
|
2005-04-18 10:30:55 +00:00
|
|
|
lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
|
2004-01-20 00:21:40 +00:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
|
2005-04-18 10:30:55 +00:00
|
|
|
lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
|
2004-01-20 00:21:40 +00:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_VERSION)
|
|
|
|
memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
|
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_DATE)
|
|
|
|
memcpy (&This->pDesc->ftDate, &pDesc->ftDate, sizeof (pDesc->ftDate));
|
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
|
|
|
|
memcpy (&This->pDesc->llMemLength, &pDesc->llMemLength, sizeof (pDesc->llMemLength));
|
|
|
|
memcpy (This->pDesc->pbMemData, pDesc->pbMemData, sizeof (pDesc->pbMemData));
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
2004-01-20 00:21:40 +00:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_STREAM) {
|
|
|
|
/* according to MSDN, we copy the stream */
|
|
|
|
IStream_Clone (pDesc->pStream, &This->pDesc->pStream);
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
2004-01-20 00:21:40 +00:00
|
|
|
|
|
|
|
/* add new flags */
|
|
|
|
This->pDesc->dwValidData |= pDesc->dwValidData;
|
2003-08-22 23:53:27 +00:00
|
|
|
|
2004-01-20 00:21:40 +00:00
|
|
|
return S_OK;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) {
|
2004-01-20 00:21:40 +00:00
|
|
|
DMUS_PRIVATE_CHUNK Chunk;
|
|
|
|
DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
|
2003-08-22 23:53:27 +00:00
|
|
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
2004-01-20 00:21:40 +00:00
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", pStream, pDesc);
|
2003-08-22 23:53:27 +00:00
|
|
|
|
2004-01-20 00:21:40 +00:00
|
|
|
/* FIXME: should this be determined from stream? */
|
|
|
|
pDesc->dwValidData |= DMUS_OBJ_CLASS;
|
|
|
|
memcpy (&pDesc->guidClass, &CLSID_DirectMusicBand, sizeof(CLSID));
|
|
|
|
|
|
|
|
IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-01-20 00:21:40 +00:00
|
|
|
switch (Chunk.fccID) {
|
2003-08-22 23:53:27 +00:00
|
|
|
case FOURCC_RIFF: {
|
2004-01-20 00:21:40 +00:00
|
|
|
IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
|
|
|
|
TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
|
|
|
|
StreamSize = Chunk.dwSize - sizeof(FOURCC);
|
2003-08-22 23:53:27 +00:00
|
|
|
StreamCount = 0;
|
2004-01-20 00:21:40 +00:00
|
|
|
if (Chunk.fccID == DMUS_FOURCC_BAND_FORM) {
|
|
|
|
TRACE_(dmfile)(": band form\n");
|
|
|
|
do {
|
|
|
|
IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-01-20 00:21:40 +00: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-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-01-20 00:21:40 +00: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;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
2004-01-20 00:21:40 +00:00
|
|
|
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;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
2004-01-20 00:21:40 +00:00
|
|
|
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: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
|
2004-01-20 00:21:40 +00: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;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
}
|
2004-01-20 00:21:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
2004-01-20 00:21:40 +00:00
|
|
|
}
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
|
2004-01-20 00:21:40 +00: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;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
2004-01-20 00:21:40 +00:00
|
|
|
|
2003-08-22 23:53:27 +00:00
|
|
|
TRACE_(dmfile)(": reading finished\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
|
2004-01-20 00:21:40 +00:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
|
|
|
|
return DMUS_E_INVALIDFILE;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
2004-01-20 00:21:40 +00:00
|
|
|
}
|
2003-08-22 23:53:27 +00:00
|
|
|
|
2004-05-14 04:57:02 +00:00
|
|
|
TRACE(": returning descriptor:\n"); debug_DMUS_OBJECTDESC (pDesc);
|
2004-01-20 00:21:40 +00:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-05-30 10:01:08 +00:00
|
|
|
static const IDirectMusicObjectVtbl DirectMusicBand_Object_Vtbl = {
|
2004-05-12 23:58:05 +00:00
|
|
|
IDirectMusicBandImpl_IDirectMusicObject_QueryInterface,
|
|
|
|
IDirectMusicBandImpl_IDirectMusicObject_AddRef,
|
|
|
|
IDirectMusicBandImpl_IDirectMusicObject_Release,
|
|
|
|
IDirectMusicBandImpl_IDirectMusicObject_GetDescriptor,
|
|
|
|
IDirectMusicBandImpl_IDirectMusicObject_SetDescriptor,
|
|
|
|
IDirectMusicBandImpl_IDirectMusicObject_ParseDescriptor
|
2004-01-20 00:21:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* IDirectMusicBandImpl IPersistStream part: */
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
|
2004-05-12 23:58:05 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, PersistStreamVtbl, iface);
|
2005-06-22 12:01:39 +00:00
|
|
|
return IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
|
2004-01-20 00:21:40 +00:00
|
|
|
}
|
2003-10-28 21:08:55 +00:00
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static ULONG WINAPI IDirectMusicBandImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
|
2004-05-12 23:58:05 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, PersistStreamVtbl, iface);
|
2005-06-22 12:01:39 +00:00
|
|
|
return IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
2004-01-20 00:21:40 +00:00
|
|
|
}
|
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static ULONG WINAPI IDirectMusicBandImpl_IPersistStream_Release (LPPERSISTSTREAM iface) {
|
2004-05-12 23:58:05 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, PersistStreamVtbl, iface);
|
2005-06-22 12:01:39 +00:00
|
|
|
return IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
|
2004-01-20 00:21:40 +00:00
|
|
|
}
|
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
|
2004-05-12 23:58:05 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, PersistStreamVtbl, iface);
|
|
|
|
TRACE("(%p, %p)\n", This, pClassID);
|
|
|
|
memcpy(pClassID, &CLSID_DirectMusicBand, sizeof(CLSID));
|
|
|
|
return S_OK;
|
2004-01-20 00:21:40 +00:00
|
|
|
}
|
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
|
2004-05-12 23:58:05 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, PersistStreamVtbl, iface);
|
|
|
|
FIXME("(%p): stub, always S_FALSE\n", This);
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT IDirectMusicBandImpl_IPersistStream_ParseInstrument (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
|
2004-05-13 05:19:47 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, PersistStreamVtbl, iface);
|
2004-05-12 23:58:05 +00:00
|
|
|
DMUS_PRIVATE_CHUNK Chunk;
|
|
|
|
DWORD ListSize[3], ListCount[3];
|
|
|
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
2004-05-13 05:19:47 +00:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
DMUS_IO_INSTRUMENT inst;
|
|
|
|
LPDMUS_PRIVATE_INSTRUMENT pNewInstrument;
|
|
|
|
IDirectMusicObject* pObject = NULL;
|
2004-05-12 23:58:05 +00:00
|
|
|
|
|
|
|
if (pChunk->fccID != DMUS_FOURCC_INSTRUMENT_LIST) {
|
2005-03-23 13:15:18 +00:00
|
|
|
ERR_(dmfile)(": %s chunk should be an INSTRUMENT list\n", debugstr_fourcc (pChunk->fccID));
|
2004-05-12 23:58:05 +00:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
|
|
|
|
ListCount[0] = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-12 23:58:05 +00:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case DMUS_FOURCC_INSTRUMENT_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": Instrument chunk\n");
|
|
|
|
if (Chunk.dwSize != sizeof(DMUS_IO_INSTRUMENT)) return E_FAIL;
|
|
|
|
IStream_Read (pStm, &inst, sizeof(DMUS_IO_INSTRUMENT), NULL);
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(" - dwPatch: %u\n", inst.dwPatch);
|
|
|
|
TRACE_(dmfile)(" - dwAssignPatch: %u\n", inst.dwAssignPatch);
|
|
|
|
TRACE_(dmfile)(" - dwNoteRanges[0]: %u\n", inst.dwNoteRanges[0]);
|
|
|
|
TRACE_(dmfile)(" - dwNoteRanges[1]: %u\n", inst.dwNoteRanges[1]);
|
|
|
|
TRACE_(dmfile)(" - dwNoteRanges[2]: %u\n", inst.dwNoteRanges[2]);
|
|
|
|
TRACE_(dmfile)(" - dwNoteRanges[3]: %u\n", inst.dwNoteRanges[3]);
|
|
|
|
TRACE_(dmfile)(" - dwPChannel: %u\n", inst.dwPChannel);
|
|
|
|
TRACE_(dmfile)(" - dwFlags: %u\n", inst.dwFlags);
|
2004-05-12 23:58:05 +00:00
|
|
|
TRACE_(dmfile)(" - bPan: %u\n", inst.bPan);
|
|
|
|
TRACE_(dmfile)(" - bVolume: %u\n", inst.bVolume);
|
|
|
|
TRACE_(dmfile)(" - nTranspose: %d\n", inst.nTranspose);
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(" - dwChannelPriority: %u\n", inst.dwChannelPriority);
|
2004-05-12 23:58:05 +00:00
|
|
|
TRACE_(dmfile)(" - nPitchBendRange: %d\n", inst.nPitchBendRange);
|
|
|
|
break;
|
2004-05-13 05:19:47 +00:00
|
|
|
}
|
|
|
|
case FOURCC_LIST: {
|
|
|
|
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
|
|
|
|
TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
|
|
|
|
ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
|
|
|
|
ListCount[1] = 0;
|
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case DMUS_FOURCC_REF_LIST: {
|
|
|
|
FIXME_(dmfile)(": DMRF (DM References) list\n");
|
|
|
|
hr = IDirectMusicUtils_IPersistStream_ParseReference (iface, &Chunk, pStm, &pObject);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ERR(": could not load Reference\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown (skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2004-05-12 23:58:05 +00:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
|
2004-05-12 23:58:05 +00:00
|
|
|
} while (ListCount[0] < ListSize[0]);
|
|
|
|
|
2004-05-13 05:19:47 +00:00
|
|
|
/*
|
|
|
|
* @TODO insert pNewInstrument into This
|
|
|
|
*/
|
|
|
|
pNewInstrument = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_INSTRUMENT));
|
|
|
|
if (NULL == pNewInstrument) {
|
|
|
|
ERR(": no more memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
memcpy(&pNewInstrument->pInstrument, &inst, sizeof(DMUS_IO_INSTRUMENT));
|
|
|
|
pNewInstrument->ppReferenceCollection = NULL;
|
|
|
|
if (NULL != pObject) {
|
|
|
|
IDirectMusicCollection* pCol = NULL;
|
|
|
|
hr = IDirectMusicObject_QueryInterface (pObject, &IID_IDirectMusicCollection, (void**) &pCol);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ERR(": failed to get IDirectMusicCollection Interface from DMObject\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
pNewInstrument->ppReferenceCollection = pCol;
|
|
|
|
IDirectMusicObject_Release(pObject);
|
|
|
|
}
|
|
|
|
list_add_tail (&This->Instruments, &pNewInstrument->entry);
|
|
|
|
|
2004-05-12 23:58:05 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT IDirectMusicBandImpl_IPersistStream_ParseInstrumentsList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
|
|
|
|
/*ICOM_THIS_MULTI(IDirectMusicBandImpl, PersistStreamVtbl, iface);*/
|
|
|
|
HRESULT hr;
|
|
|
|
DMUS_PRIVATE_CHUNK Chunk;
|
|
|
|
DWORD ListSize[3], ListCount[3];
|
|
|
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
|
|
|
|
|
|
|
if (pChunk->fccID != DMUS_FOURCC_INSTRUMENTS_LIST) {
|
2005-03-23 13:15:18 +00:00
|
|
|
ERR_(dmfile)(": %s chunk should be an INSTRUMENTS list\n", debugstr_fourcc (pChunk->fccID));
|
2004-05-12 23:58:05 +00:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ListSize[0] = pChunk->dwSize - sizeof(FOURCC);
|
|
|
|
ListCount[0] = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-12 23:58:05 +00:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case FOURCC_LIST: {
|
|
|
|
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
|
|
|
|
TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
|
|
|
|
ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
|
|
|
|
ListCount[1] = 0;
|
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case DMUS_FOURCC_INSTRUMENT_LIST: {
|
|
|
|
TRACE_(dmfile)(": Instrument list\n");
|
|
|
|
hr = IDirectMusicBandImpl_IPersistStream_ParseInstrument (iface, &Chunk, pStm);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = ListSize[1];
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
|
2004-05-12 23:58:05 +00:00
|
|
|
} while (ListCount[0] < ListSize[0]);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT IDirectMusicBandImpl_IPersistStream_ParseBandForm (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
|
|
|
|
|
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, PersistStreamVtbl, iface);
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
DMUS_PRIVATE_CHUNK Chunk;
|
|
|
|
DWORD StreamSize, StreamCount, ListSize[3], ListCount[3];
|
|
|
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
|
|
|
|
|
|
|
GUID tmp_guid;
|
|
|
|
|
|
|
|
if (pChunk->fccID != DMUS_FOURCC_BAND_FORM) {
|
|
|
|
ERR_(dmfile)(": %s chunk should be a BAND form\n", debugstr_fourcc (pChunk->fccID));
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
StreamSize = pChunk->dwSize - sizeof(FOURCC);
|
|
|
|
StreamCount = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-13 05:19:47 +00:00
|
|
|
|
|
|
|
hr = IDirectMusicUtils_IPersistStream_ParseDescGeneric(&Chunk, pStm, This->pDesc);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
if (hr == S_FALSE) {
|
2004-05-12 23:58:05 +00:00
|
|
|
switch (Chunk.fccID) {
|
2004-05-13 05:19:47 +00:00
|
|
|
case DMUS_FOURCC_GUID_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": GUID\n");
|
|
|
|
IStream_Read (pStm, &tmp_guid, sizeof(GUID), NULL);
|
|
|
|
TRACE_(dmfile)(" - guid: %s\n", debugstr_dmguid(&tmp_guid));
|
2004-05-12 23:58:05 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-05-13 05:19:47 +00:00
|
|
|
case FOURCC_LIST: {
|
|
|
|
IStream_Read (pStm, &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) {
|
|
|
|
case DMUS_FOURCC_UNFO_LIST: {
|
|
|
|
TRACE_(dmfile)(": UNFO list\n");
|
|
|
|
do {
|
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-13 05:19:47 +00:00
|
|
|
|
|
|
|
hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, This->pDesc);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
if (hr == S_FALSE) {
|
|
|
|
switch (Chunk.fccID) {
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
|
2004-05-13 05:19:47 +00:00
|
|
|
} while (ListCount[0] < ListSize[0]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_INSTRUMENTS_LIST: {
|
|
|
|
TRACE_(dmfile)(": INSTRUMENTS list\n");
|
|
|
|
hr = IDirectMusicBandImpl_IPersistStream_ParseInstrumentsList (iface, &Chunk, pStm);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown (skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2004-05-12 23:58:05 +00:00
|
|
|
}
|
|
|
|
default: {
|
2004-05-13 05:19:47 +00:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-05-12 23:58:05 +00:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
|
2004-05-12 23:58:05 +00:00
|
|
|
} while (StreamCount < StreamSize);
|
|
|
|
|
|
|
|
return S_OK;
|
2004-01-20 00:21:40 +00:00
|
|
|
}
|
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
|
2004-05-12 23:58:05 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, PersistStreamVtbl, iface);
|
|
|
|
|
|
|
|
DMUS_PRIVATE_CHUNK Chunk;
|
|
|
|
LARGE_INTEGER liMove;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2004-05-13 05:19:47 +00:00
|
|
|
TRACE("(%p,%p): loading\n", This, pStm);
|
2004-05-12 23:58:05 +00:00
|
|
|
|
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-12 23:58:05 +00:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case FOURCC_RIFF: {
|
|
|
|
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
|
2006-10-12 19:34:11 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-12 23:58:05 +00:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case DMUS_FOURCC_BAND_FORM: {
|
|
|
|
TRACE_(dmfile)(": Band form\n");
|
|
|
|
hr = IDirectMusicBandImpl_IPersistStream_ParseBandForm (iface, &Chunk, pStm);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE_(dmfile)(": reading finished\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
|
2004-05-12 23:58:05 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicBandImpl, PersistStreamVtbl, iface);
|
|
|
|
FIXME("(%p): Saving not implemented yet\n", This);
|
|
|
|
return E_NOTIMPL;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2005-06-22 12:01:39 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicBandImpl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
|
2004-05-12 23:58:05 +00:00
|
|
|
return E_NOTIMPL;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2005-05-30 10:01:08 +00:00
|
|
|
static const IPersistStreamVtbl DirectMusicBand_PersistStream_Vtbl = {
|
2004-05-12 23:58:05 +00:00
|
|
|
IDirectMusicBandImpl_IPersistStream_QueryInterface,
|
|
|
|
IDirectMusicBandImpl_IPersistStream_AddRef,
|
|
|
|
IDirectMusicBandImpl_IPersistStream_Release,
|
|
|
|
IDirectMusicBandImpl_IPersistStream_GetClassID,
|
|
|
|
IDirectMusicBandImpl_IPersistStream_IsDirty,
|
|
|
|
IDirectMusicBandImpl_IPersistStream_Load,
|
|
|
|
IDirectMusicBandImpl_IPersistStream_Save,
|
|
|
|
IDirectMusicBandImpl_IPersistStream_GetSizeMax
|
2003-08-22 23:53:27 +00:00
|
|
|
};
|
2004-01-20 00:21:40 +00:00
|
|
|
|
|
|
|
/* for ClassFactory */
|
|
|
|
HRESULT WINAPI DMUSIC_CreateDirectMusicBandImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
|
2004-05-12 23:58:05 +00:00
|
|
|
IDirectMusicBandImpl* obj;
|
2004-01-20 00:21:40 +00:00
|
|
|
|
2004-05-12 23:58:05 +00:00
|
|
|
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBandImpl));
|
|
|
|
if (NULL == obj) {
|
2004-12-22 15:13:20 +00:00
|
|
|
*ppobj = NULL;
|
2004-05-12 23:58:05 +00:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
obj->UnknownVtbl = &DirectMusicBand_Unknown_Vtbl;
|
|
|
|
obj->BandVtbl = &DirectMusicBand_Band_Vtbl;
|
|
|
|
obj->ObjectVtbl = &DirectMusicBand_Object_Vtbl;
|
|
|
|
obj->PersistStreamVtbl = &DirectMusicBand_PersistStream_Vtbl;
|
|
|
|
obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
|
|
|
|
DM_STRUCT_INIT(obj->pDesc);
|
|
|
|
obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
|
|
|
|
memcpy (&obj->pDesc->guidClass, &CLSID_DirectMusicBand, sizeof (CLSID));
|
|
|
|
obj->ref = 0; /* will be inited by QueryInterface */
|
|
|
|
list_init (&obj->Instruments);
|
|
|
|
|
|
|
|
return IDirectMusicBandImpl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);
|
2004-01-20 00:21:40 +00:00
|
|
|
}
|