2003-07-22 00:10:14 +02:00
|
|
|
/* IDirectMusicStyle8 Implementation
|
2003-04-08 23:42:00 +02:00
|
|
|
*
|
2004-01-20 01:21:40 +01:00
|
|
|
* Copyright (C) 2003-2004 Rok Mandeljc
|
2004-05-14 06:57:02 +02:00
|
|
|
* Copyright (C) 2003-2004 Raphael Junqueira
|
2003-04-08 23:42:00 +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-04-08 23:42:00 +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-04-08 23:42:00 +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-04-08 23:42:00 +02:00
|
|
|
*/
|
|
|
|
|
2003-07-22 00:10:14 +02:00
|
|
|
#include "dmstyle_private.h"
|
2003-04-08 23:42:00 +02:00
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dmstyle);
|
2004-01-20 01:21:40 +01:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(dmfile);
|
2003-04-08 23:42:00 +02:00
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static ULONG WINAPI IDirectMusicStyle8Impl_IUnknown_AddRef (LPUNKNOWN iface);
|
|
|
|
static ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef (LPDIRECTMUSICSTYLE8 iface);
|
|
|
|
static ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface);
|
|
|
|
static ULONG WINAPI IDirectMusicStyle8Impl_IPersistStream_AddRef (LPPERSISTSTREAM iface);
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectMusicStyleImpl implementation
|
|
|
|
*/
|
|
|
|
/* IDirectMusicStyleImpl IUnknown part: */
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, UnknownVtbl, iface);
|
2004-02-25 02:30:03 +01:00
|
|
|
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
|
2004-01-20 01:21:40 +01:00
|
|
|
|
|
|
|
if (IsEqualIID (riid, &IID_IUnknown)) {
|
2009-01-13 10:57:08 +01:00
|
|
|
*ppobj = &This->UnknownVtbl;
|
2004-01-20 01:21:40 +01:00
|
|
|
IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
|
|
|
return S_OK;
|
|
|
|
} else if (IsEqualIID (riid, &IID_IDirectMusicStyle)) {
|
2009-01-13 10:57:08 +01:00
|
|
|
*ppobj = &This->StyleVtbl;
|
2004-01-20 01:21:40 +01:00
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef ((LPDIRECTMUSICSTYLE8)&This->StyleVtbl);
|
|
|
|
return S_OK;
|
2005-01-05 14:22:57 +01:00
|
|
|
} else if (IsEqualIID (riid, &IID_IDirectMusicStyle8)) {
|
2009-01-13 10:57:08 +01:00
|
|
|
*ppobj = &This->StyleVtbl;
|
2005-01-05 14:22:57 +01:00
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef ((LPDIRECTMUSICSTYLE8)&This->StyleVtbl);
|
|
|
|
return S_OK;
|
2004-01-20 01:21:40 +01:00
|
|
|
} else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
|
2009-01-13 10:57:08 +01:00
|
|
|
*ppobj = &This->ObjectVtbl;
|
2004-01-20 01:21:40 +01:00
|
|
|
IDirectMusicStyle8Impl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT)&This->ObjectVtbl);
|
|
|
|
return S_OK;
|
|
|
|
} else if (IsEqualIID (riid, &IID_IPersistStream)) {
|
2009-01-13 10:57:08 +01:00
|
|
|
*ppobj = &This->PersistStreamVtbl;
|
2004-01-20 01:21:40 +01:00
|
|
|
IDirectMusicStyle8Impl_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
2004-01-20 01:21:40 +01:00
|
|
|
|
2004-02-25 02:30:03 +01:00
|
|
|
WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
|
2003-04-08 23:42:00 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static ULONG WINAPI IDirectMusicStyle8Impl_IUnknown_AddRef (LPUNKNOWN iface) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, UnknownVtbl, iface);
|
2005-01-24 12:31:45 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-12 22:56:15 +02:00
|
|
|
TRACE("(%p): AddRef from %d\n", This, ref - 1);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
2005-01-24 20:33:23 +01:00
|
|
|
DMSTYLE_LockModule();
|
|
|
|
|
2005-01-24 12:31:45 +01:00
|
|
|
return ref;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static ULONG WINAPI IDirectMusicStyle8Impl_IUnknown_Release (LPUNKNOWN iface) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, UnknownVtbl, iface);
|
2005-01-24 12:31:45 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-12 22:56:15 +02:00
|
|
|
TRACE("(%p): ReleaseRef to %d\n", This, ref);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
if (ref == 0) {
|
2003-04-08 23:42:00 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
2005-01-24 20:33:23 +01:00
|
|
|
|
|
|
|
DMSTYLE_UnlockModule();
|
|
|
|
|
2003-04-08 23:42:00 +02:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IUnknownVtbl DirectMusicStyle8_Unknown_Vtbl = {
|
2004-01-20 01:21:40 +01:00
|
|
|
IDirectMusicStyle8Impl_IUnknown_QueryInterface,
|
|
|
|
IDirectMusicStyle8Impl_IUnknown_AddRef,
|
|
|
|
IDirectMusicStyle8Impl_IUnknown_Release
|
|
|
|
};
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicStyle8Impl IDirectMusicStyle8 part: */
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_QueryInterface (LPDIRECTMUSICSTYLE8 iface, REFIID riid, LPVOID *ppobj) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
|
|
|
return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef (LPDIRECTMUSICSTYLE8 iface) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
|
|
|
return IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
|
|
|
}
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_Release (LPDIRECTMUSICSTYLE8 iface) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
|
|
|
return IDirectMusicStyle8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
|
|
|
|
}
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicStyle8Impl IDirectMusicStyle(8) part: */
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetBand (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicBand** ppBand) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
|
|
|
FIXME("(%p, %p, %p): stub\n", This, pwszName, ppBand);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumBand (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
2006-10-12 22:56:15 +02:00
|
|
|
FIXME("(%p, %d, %p): stub\n", This, dwIndex, pwszName);
|
2004-01-20 01:21:40 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultBand (LPDIRECTMUSICSTYLE8 iface, IDirectMusicBand** ppBand) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p): stub\n", This, ppBand);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumMotif (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
2006-10-12 22:56:15 +02:00
|
|
|
FIXME("(%p, %d, %p): stub\n", This, dwIndex, pwszName);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetMotif (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicSegment** ppSegment) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p, %p): stub\n", This, pwszName, ppSegment);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultChordMap (LPDIRECTMUSICSTYLE8 iface, IDirectMusicChordMap** ppChordMap) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p): stub\n", This, ppChordMap);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumChordMap (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, WCHAR* pwszName) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
2006-10-12 22:56:15 +02:00
|
|
|
FIXME("(%p, %d, %p): stub\n", This, dwIndex, pwszName);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetChordMap (LPDIRECTMUSICSTYLE8 iface, WCHAR* pwszName, IDirectMusicChordMap** ppChordMap) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p, %p): stub\n", This, pwszName, ppChordMap);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTimeSignature (LPDIRECTMUSICSTYLE8 iface, DMUS_TIMESIGNATURE* pTimeSig) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p): stub\n", This, pTimeSig);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetEmbellishmentLength (LPDIRECTMUSICSTYLE8 iface, DWORD dwType, DWORD dwLevel, DWORD* pdwMin, DWORD* pdwMax) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
2006-10-12 22:56:15 +02:00
|
|
|
FIXME("(%p, %d, %d, %p, %p): stub\n", This, dwType, dwLevel, pdwMin, pdwMax);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTempo (LPDIRECTMUSICSTYLE8 iface, double* pTempo) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
2003-06-07 02:39:18 +02:00
|
|
|
FIXME("(%p, %p): stub\n", This, pTempo);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumPattern (LPDIRECTMUSICSTYLE8 iface, DWORD dwIndex, DWORD dwPatternType, WCHAR* pwszName) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, StyleVtbl, iface);
|
2006-10-12 22:56:15 +02:00
|
|
|
FIXME("(%p, %d, %d, %p): stub\n", This, dwIndex, dwPatternType, pwszName);
|
2003-06-07 02:39:18 +02:00
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IDirectMusicStyle8Vtbl DirectMusicStyle8_Style_Vtbl = {
|
2004-01-20 01:21:40 +01:00
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_QueryInterface,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_AddRef,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_Release,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_GetBand,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumBand,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultBand,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumMotif,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_GetMotif,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_GetDefaultChordMap,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumChordMap,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_GetChordMap,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTimeSignature,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_GetEmbellishmentLength,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_GetTempo,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicStyle8_EnumPattern
|
2003-04-08 23:42:00 +02:00
|
|
|
};
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicStyle8Impl IDirectMusicObject part: */
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
|
|
|
|
return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
|
|
|
|
return IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static ULONG WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
|
|
|
|
return IDirectMusicStyle8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
|
2003-08-23 01:53:27 +02:00
|
|
|
TRACE("(%p, %p)\n", This, pDesc);
|
2004-01-20 01:21:40 +01: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-23 01:53:27 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, iface);
|
2004-02-25 02:30:03 +01:00
|
|
|
TRACE("(%p, %p): setting descriptor:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC (pDesc));
|
2008-02-25 20:48:26 +01:00
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* According to MSDN, we should copy only given values, not whole struct */
|
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
|
2008-02-25 20:48:26 +01:00
|
|
|
This->pDesc->guidObject = pDesc->guidObject;
|
2004-01-20 01:21:40 +01:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_CLASS)
|
2008-02-25 20:48:26 +01:00
|
|
|
This->pDesc->guidClass = pDesc->guidClass;
|
2004-01-20 01:21:40 +01:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_NAME)
|
2005-04-18 12:30:55 +02:00
|
|
|
lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
|
2004-01-20 01:21:40 +01:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
|
2005-04-18 12:30:55 +02:00
|
|
|
lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
|
2004-01-20 01:21:40 +01:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
|
2005-04-18 12:30:55 +02:00
|
|
|
lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
|
2004-01-20 01:21:40 +01:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_VERSION)
|
2008-02-25 20:48:26 +01:00
|
|
|
This->pDesc->vVersion = pDesc->vVersion;
|
2004-01-20 01:21:40 +01:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_DATE)
|
2008-02-25 20:48:26 +01:00
|
|
|
This->pDesc->ftDate = pDesc->ftDate;
|
2004-01-20 01:21:40 +01:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
|
|
|
|
memcpy (&This->pDesc->llMemLength, &pDesc->llMemLength, sizeof (pDesc->llMemLength));
|
|
|
|
memcpy (This->pDesc->pbMemData, pDesc->pbMemData, sizeof (pDesc->pbMemData));
|
|
|
|
}
|
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_STREAM) {
|
|
|
|
/* according to MSDN, we copy the stream */
|
|
|
|
IStream_Clone (pDesc->pStream, &This->pDesc->pStream);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add new flags */
|
|
|
|
This->pDesc->dwValidData |= pDesc->dwValidData;
|
2003-08-23 01:53:27 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) {
|
2004-01-20 01:21:40 +01:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, ObjectVtbl, 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
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
TRACE("(%p, %p, %p)\n", This, pStream, pDesc);
|
2008-02-25 20:48:26 +01:00
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* FIXME: should this be determined from stream? */
|
|
|
|
pDesc->dwValidData |= DMUS_OBJ_CLASS;
|
2008-02-25 20:48:26 +01:00
|
|
|
pDesc->guidClass = CLSID_DirectMusicStyle;
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
2006-10-12 22:56:15 +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;
|
2004-02-25 02:30:03 +01:00
|
|
|
if (Chunk.fccID == DMUS_FOURCC_STYLE_FORM) {
|
|
|
|
TRACE_(dmfile)(": style form\n");
|
2004-01-20 01:21:40 +01:00
|
|
|
do {
|
|
|
|
IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-12 22:56:15 +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-12 22:56:15 +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: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-12 22:56:15 +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: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-12 22:56:15 +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;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
2004-01-20 01:21:40 +01:00
|
|
|
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));
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
2003-08-23 01:53:27 +02:00
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IDirectMusicObjectVtbl DirectMusicStyle8_Object_Vtbl = {
|
2004-05-14 06:57:02 +02:00
|
|
|
IDirectMusicStyle8Impl_IDirectMusicObject_QueryInterface,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicObject_AddRef,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicObject_Release,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicObject_GetDescriptor,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicObject_SetDescriptor,
|
|
|
|
IDirectMusicStyle8Impl_IDirectMusicObject_ParseDescriptor
|
2004-01-20 01:21:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* IDirectMusicStyle8Impl IPersistStream part: */
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
|
2004-05-14 06:57:02 +02:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
|
|
|
|
return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static ULONG WINAPI IDirectMusicStyle8Impl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
|
2004-05-14 06:57:02 +02:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
|
|
|
|
return IDirectMusicStyle8Impl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static ULONG WINAPI IDirectMusicStyle8Impl_IPersistStream_Release (LPPERSISTSTREAM iface) {
|
2004-05-14 06:57:02 +02:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
|
|
|
|
return IDirectMusicStyle8Impl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
|
2004-05-14 06:57:02 +02:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
|
|
|
|
TRACE("(%p, %p)\n", This, pClassID);
|
2008-02-25 20:48:26 +01:00
|
|
|
*pClassID = CLSID_DirectMusicStyle;
|
2004-05-14 06:57:02 +02:00
|
|
|
return S_OK;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
|
2004-05-14 06:57:02 +02:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
|
|
|
|
FIXME("(%p): stub, always S_FALSE\n", This);
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2004-05-14 23:36:15 +02:00
|
|
|
static HRESULT IDirectMusicStyle8Impl_IPersistStream_LoadBand (LPPERSISTSTREAM iface, IStream* pClonedStream, IDirectMusicBand** ppBand) {
|
|
|
|
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
IPersistStream* pPersistStream = NULL;
|
|
|
|
|
|
|
|
hr = CoCreateInstance (&CLSID_DirectMusicBand, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectMusicBand, (LPVOID*) ppBand);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ERR(": could not create object\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
/* acquire PersistStream interface */
|
|
|
|
hr = IDirectMusicBand_QueryInterface (*ppBand, &IID_IPersistStream, (LPVOID*) &pPersistStream);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ERR(": could not acquire IPersistStream\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
/* load */
|
|
|
|
hr = IPersistStream_Load (pPersistStream, pClonedStream);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ERR(": failed to load object\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* release all loading-related stuff */
|
|
|
|
IPersistStream_Release (pPersistStream);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePartRefList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm, LPDMUS_PRIVATE_STYLE_MOTIF pNewMotif) {
|
2004-05-14 06:57:02 +02:00
|
|
|
/*ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);*/
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
DMUS_PRIVATE_CHUNK Chunk;
|
|
|
|
DWORD ListSize[3], ListCount[3];
|
|
|
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
|
|
|
|
2005-01-05 14:22:57 +01:00
|
|
|
LPDMUS_PRIVATE_STYLE_PARTREF_ITEM pNewItem = NULL;
|
|
|
|
|
2004-05-14 06:57:02 +02:00
|
|
|
|
|
|
|
if (pChunk->fccID != DMUS_FOURCC_PARTREF_LIST) {
|
|
|
|
ERR_(dmfile)(": %s chunk should be a PARTREF list\n", debugstr_fourcc (pChunk->fccID));
|
|
|
|
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 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-14 06:57:02 +02:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case DMUS_FOURCC_PARTREF_CHUNK: {
|
2005-01-05 14:22:57 +01:00
|
|
|
TRACE_(dmfile)(": PartRef chunk\n");
|
|
|
|
pNewItem = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_PARTREF_ITEM));
|
|
|
|
if (NULL == pNewItem) {
|
|
|
|
ERR(": no more memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
hr = IStream_Read (pStm, &pNewItem->part_ref, sizeof(DMUS_IO_PARTREF), NULL);
|
|
|
|
/*TRACE_(dmfile)(" - sizeof %lu\n", sizeof(DMUS_IO_PARTREF));*/
|
|
|
|
list_add_tail (&pNewMotif->Items, &pNewItem->entry);
|
|
|
|
DM_STRUCT_INIT(&pNewItem->desc);
|
2004-05-14 06:57:02 +02:00
|
|
|
break;
|
2004-05-14 23:36:15 +02:00
|
|
|
}
|
2004-05-14 06:57:02 +02: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_UNFO_LIST: {
|
|
|
|
TRACE_(dmfile)(": UNFO list\n");
|
|
|
|
do {
|
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-12 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-14 06:57:02 +02:00
|
|
|
|
2005-01-05 14:22:57 +01:00
|
|
|
hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &pNewItem->desc);
|
2004-05-14 06:57:02 +02:00
|
|
|
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 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount[1], ListSize[1]);
|
2004-05-14 06:57:02 +02:00
|
|
|
} while (ListCount[1] < ListSize[1]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
|
|
|
|
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 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
|
2004-05-14 06:57:02 +02:00
|
|
|
} while (ListCount[0] < ListSize[0]);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePartList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
|
|
|
|
|
|
|
|
/*ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);*/
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
DMUS_PRIVATE_CHUNK Chunk;
|
|
|
|
DWORD ListSize[3], ListCount[3];
|
|
|
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
|
|
|
|
|
|
|
DMUS_OBJECTDESC desc;
|
2005-01-05 14:22:57 +01:00
|
|
|
DWORD dwSize = 0;
|
|
|
|
DWORD cnt = 0;
|
2004-05-14 06:57:02 +02:00
|
|
|
|
|
|
|
if (pChunk->fccID != DMUS_FOURCC_PART_LIST) {
|
|
|
|
ERR_(dmfile)(": %s chunk should be a PART list\n", debugstr_fourcc (pChunk->fccID));
|
|
|
|
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 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-14 06:57:02 +02:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case DMUS_FOURCC_PART_CHUNK: {
|
2006-06-13 14:10:12 +02:00
|
|
|
TRACE_(dmfile)(": Part chunk (skipping for now)\n" );
|
2004-05-14 06:57:02 +02:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_NOTE_CHUNK: {
|
2006-06-13 14:10:12 +02:00
|
|
|
TRACE_(dmfile)(": Note chunk (skipping for now)\n");
|
2005-01-05 14:22:57 +01:00
|
|
|
IStream_Read (pStm, &dwSize, sizeof(DWORD), NULL);
|
|
|
|
cnt = (Chunk.dwSize - sizeof(DWORD));
|
2006-10-12 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(" - dwSize: %u\n", dwSize);
|
2006-10-20 12:16:45 +02:00
|
|
|
TRACE_(dmfile)(" - cnt: %u (%u / %u)\n", cnt / dwSize, (DWORD)(Chunk.dwSize - sizeof(DWORD)), dwSize);
|
2005-01-05 14:22:57 +01:00
|
|
|
if (cnt % dwSize != 0) {
|
2006-10-05 11:11:03 +02:00
|
|
|
ERR("Invalid Array Size\n");
|
2005-01-05 14:22:57 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
cnt /= dwSize;
|
|
|
|
/** skip for now */
|
|
|
|
liMove.QuadPart = cnt * dwSize;
|
2004-05-14 06:57:02 +02:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_CURVE_CHUNK: {
|
2006-06-13 14:10:12 +02:00
|
|
|
TRACE_(dmfile)(": Curve chunk (skipping for now)\n");
|
2005-01-05 14:22:57 +01:00
|
|
|
IStream_Read (pStm, &dwSize, sizeof(DWORD), NULL);
|
|
|
|
cnt = (Chunk.dwSize - sizeof(DWORD));
|
2006-10-12 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(" - dwSize: %u\n", dwSize);
|
2006-10-20 12:16:45 +02:00
|
|
|
TRACE_(dmfile)(" - cnt: %u (%u / %u)\n", cnt / dwSize, (DWORD)(Chunk.dwSize - sizeof(DWORD)), dwSize);
|
2005-01-05 14:22:57 +01:00
|
|
|
if (cnt % dwSize != 0) {
|
2006-10-05 11:11:03 +02:00
|
|
|
ERR("Invalid Array Size\n");
|
2005-01-05 14:22:57 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
cnt /= dwSize;
|
|
|
|
/** skip for now */
|
|
|
|
liMove.QuadPart = cnt * dwSize;
|
2004-05-14 06:57:02 +02:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_MARKER_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": Marker chunk (skipping for now)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_RESOLUTION_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": Resolution chunk (skipping for now)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_ANTICIPATION_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": Anticipation chunk (skipping for now)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
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_UNFO_LIST: {
|
|
|
|
TRACE_(dmfile)(": UNFO list\n");
|
|
|
|
do {
|
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-12 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-14 06:57:02 +02:00
|
|
|
|
|
|
|
hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &desc);
|
|
|
|
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 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount[1], ListSize[1]);
|
2004-05-14 06:57:02 +02:00
|
|
|
} while (ListCount[1] < ListSize[1]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
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 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
|
2004-05-14 06:57:02 +02:00
|
|
|
} while (ListCount[0] < ListSize[0]);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
|
|
|
|
|
2004-05-14 23:36:15 +02:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
|
2004-05-14 06:57:02 +02:00
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
DMUS_PRIVATE_CHUNK Chunk;
|
|
|
|
DWORD ListSize[3], ListCount[3];
|
|
|
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
|
|
|
|
|
|
|
DMUS_OBJECTDESC desc;
|
2004-05-14 23:36:15 +02:00
|
|
|
IDirectMusicBand* pBand = NULL;
|
|
|
|
LPDMUS_PRIVATE_STYLE_MOTIF pNewMotif = NULL;
|
2004-05-14 06:57:02 +02:00
|
|
|
|
2004-05-14 23:36:15 +02:00
|
|
|
DM_STRUCT_INIT(&desc);
|
2004-05-14 06:57:02 +02:00
|
|
|
|
|
|
|
if (pChunk->fccID != DMUS_FOURCC_PATTERN_LIST) {
|
|
|
|
ERR_(dmfile)(": %s chunk should be a PATTERN list\n", debugstr_fourcc (pChunk->fccID));
|
|
|
|
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 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-14 06:57:02 +02:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case DMUS_FOURCC_PATTERN_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": Pattern chunk\n");
|
2004-05-14 23:36:15 +02:00
|
|
|
/** alloc new motif entry */
|
|
|
|
pNewMotif = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_MOTIF));
|
|
|
|
list_add_tail (&This->Motifs, &pNewMotif->entry);
|
|
|
|
if (NULL == pNewMotif) {
|
|
|
|
ERR(": no more memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
IStream_Read (pStm, &pNewMotif->pattern, Chunk.dwSize, NULL);
|
2004-05-14 06:57:02 +02:00
|
|
|
/** TODO trace pattern */
|
2004-05-14 23:36:15 +02:00
|
|
|
|
2008-04-02 22:10:47 +02:00
|
|
|
/** reset all data, as a new pattern begin */
|
2004-05-14 23:36:15 +02:00
|
|
|
DM_STRUCT_INIT(&pNewMotif->desc);
|
2005-01-05 14:22:57 +01:00
|
|
|
list_init (&pNewMotif->Items);
|
2004-05-14 06:57:02 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_RHYTHM_CHUNK: {
|
2006-11-07 00:38:49 +01:00
|
|
|
TRACE_(dmfile)(": Rhythm chunk\n");
|
|
|
|
IStream_Read (pStm, &pNewMotif->dwRhythm, sizeof(DWORD), NULL);
|
|
|
|
TRACE_(dmfile)(" - dwRhythm: %u\n", pNewMotif->dwRhythm);
|
2004-05-14 06:57:02 +02:00
|
|
|
/** TODO understand why some Chunks have size > 4 */
|
|
|
|
liMove.QuadPart = Chunk.dwSize - sizeof(DWORD);
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_MOTIFSETTINGS_CHUNK: {
|
2008-01-16 12:20:50 +01:00
|
|
|
TRACE_(dmfile)(": MotifSettings chunk (skipping for now)\n");
|
2004-05-14 23:36:15 +02:00
|
|
|
IStream_Read (pStm, &pNewMotif->settings, Chunk.dwSize, NULL);
|
|
|
|
/** TODO trace settings */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FOURCC_RIFF: {
|
|
|
|
/**
|
2008-04-02 22:10:47 +02:00
|
|
|
* should be embedded Bands into pattern
|
2004-05-14 23:36:15 +02:00
|
|
|
*/
|
|
|
|
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
|
|
|
|
TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
|
|
|
|
ListSize[1] = Chunk.dwSize - sizeof(FOURCC);
|
|
|
|
ListCount[1] = 0;
|
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case DMUS_FOURCC_BAND_FORM: {
|
|
|
|
LPSTREAM pClonedStream = NULL;
|
|
|
|
|
|
|
|
TRACE_(dmfile)(": BAND RIFF\n");
|
|
|
|
|
|
|
|
IStream_Clone (pStm, &pClonedStream);
|
|
|
|
|
|
|
|
liMove.QuadPart = 0;
|
|
|
|
liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD));
|
|
|
|
IStream_Seek (pClonedStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
|
|
|
|
hr = IDirectMusicStyle8Impl_IPersistStream_LoadBand (iface, pClonedStream, &pBand);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ERR(": could not load track\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
IStream_Release (pClonedStream);
|
|
|
|
|
|
|
|
pNewMotif->pBand = pBand;
|
|
|
|
IDirectMusicBand_AddRef(pBand);
|
|
|
|
|
2008-04-02 22:10:47 +02:00
|
|
|
IDirectMusicTrack_Release(pBand); pBand = NULL; /* now we can release it as it's inserted */
|
2004-05-14 23:36:15 +02:00
|
|
|
|
|
|
|
/** now safe move the cursor */
|
|
|
|
liMove.QuadPart = ListSize[1];
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = ListSize[1];
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-05-14 06:57:02 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
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_UNFO_LIST: {
|
|
|
|
TRACE_(dmfile)(": UNFO list\n");
|
|
|
|
do {
|
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
ListCount[1] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-12 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-14 06:57:02 +02:00
|
|
|
|
2004-05-14 23:36:15 +02:00
|
|
|
hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &pNewMotif->desc);
|
2004-05-14 06:57:02 +02:00
|
|
|
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 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": ListCount[1] = %d < ListSize[1] = %d\n", ListCount[1], ListSize[1]);
|
2004-05-14 06:57:02 +02:00
|
|
|
} while (ListCount[1] < ListSize[1]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_PARTREF_LIST: {
|
|
|
|
TRACE_(dmfile)(": PartRef list\n");
|
2004-05-14 23:36:15 +02:00
|
|
|
hr = IDirectMusicStyle8Impl_IPersistStream_ParsePartRefList (iface, &Chunk, pStm, pNewMotif);
|
2004-05-14 06:57:02 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-12 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
|
2004-05-14 06:57:02 +02:00
|
|
|
} while (ListCount[0] < ListSize[0]);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT IDirectMusicStyle8Impl_IPersistStream_ParseStyleForm (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) {
|
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
|
|
|
|
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
DMUS_PRIVATE_CHUNK Chunk;
|
|
|
|
DWORD StreamSize, StreamCount, ListSize[3], ListCount[3];
|
|
|
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
|
|
|
|
2004-05-14 23:36:15 +02:00
|
|
|
IDirectMusicBand* pBand = NULL;
|
|
|
|
|
2004-05-14 06:57:02 +02:00
|
|
|
if (pChunk->fccID != DMUS_FOURCC_STYLE_FORM) {
|
|
|
|
ERR_(dmfile)(": %s chunk should be a STYLE 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 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-14 06:57:02 +02:00
|
|
|
|
|
|
|
hr = IDirectMusicUtils_IPersistStream_ParseDescGeneric(&Chunk, pStm, This->pDesc);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
if (hr == S_FALSE) {
|
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case DMUS_FOURCC_STYLE_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": Style chunk\n");
|
|
|
|
IStream_Read (pStm, &This->style, sizeof(DMUS_IO_STYLE), NULL);
|
|
|
|
/** TODO dump DMUS_IO_TIMESIG style.timeSig */
|
|
|
|
TRACE_(dmfile)(" - dblTempo: %g\n", This->style.dblTempo);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FOURCC_RIFF: {
|
|
|
|
/**
|
2008-04-02 22:10:47 +02:00
|
|
|
* should be embedded Bands into style
|
2004-05-14 06:57:02 +02:00
|
|
|
*/
|
|
|
|
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
|
|
|
|
TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
|
|
|
|
ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
|
|
|
|
ListCount[0] = 0;
|
|
|
|
switch (Chunk.fccID) {
|
2004-05-14 23:36:15 +02:00
|
|
|
case DMUS_FOURCC_BAND_FORM: {
|
2004-05-14 06:57:02 +02:00
|
|
|
LPSTREAM pClonedStream = NULL;
|
2004-05-14 23:36:15 +02:00
|
|
|
LPDMUS_PRIVATE_STYLE_BAND pNewBand;
|
|
|
|
|
2004-05-14 06:57:02 +02:00
|
|
|
TRACE_(dmfile)(": BAND RIFF\n");
|
|
|
|
|
|
|
|
IStream_Clone (pStm, &pClonedStream);
|
|
|
|
|
|
|
|
liMove.QuadPart = 0;
|
|
|
|
liMove.QuadPart -= sizeof(FOURCC) + (sizeof(FOURCC)+sizeof(DWORD));
|
|
|
|
IStream_Seek (pClonedStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
|
2004-05-14 23:36:15 +02:00
|
|
|
hr = IDirectMusicStyle8Impl_IPersistStream_LoadBand (iface, pClonedStream, &pBand);
|
2004-05-14 06:57:02 +02:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
ERR(": could not load track\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
IStream_Release (pClonedStream);
|
|
|
|
|
2004-05-14 23:36:15 +02:00
|
|
|
pNewBand = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(DMUS_PRIVATE_STYLE_BAND));
|
|
|
|
if (NULL == pNewBand) {
|
|
|
|
ERR(": no more memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
pNewBand->pBand = pBand;
|
|
|
|
IDirectMusicBand_AddRef(pBand);
|
|
|
|
list_add_tail (&This->Bands, &pNewBand->entry);
|
|
|
|
|
2008-04-02 22:10:47 +02:00
|
|
|
IDirectMusicTrack_Release(pBand); pBand = NULL; /* now we can release it as it's inserted */
|
2004-05-14 23:36:15 +02:00
|
|
|
|
2008-04-02 22:10:47 +02:00
|
|
|
/** now safely move the cursor */
|
2004-05-14 06:57:02 +02:00
|
|
|
liMove.QuadPart = ListSize[0];
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = ListSize[0];
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
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 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-14 06:57:02 +02: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 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
|
2004-05-14 06:57:02 +02:00
|
|
|
} while (ListCount[0] < ListSize[0]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_PART_LIST: {
|
|
|
|
TRACE_(dmfile)(": PART list\n");
|
|
|
|
hr = IDirectMusicStyle8Impl_IPersistStream_ParsePartList (iface, &Chunk, pStm);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_PATTERN_LIST: {
|
|
|
|
TRACE_(dmfile)(": PATTERN list\n");
|
|
|
|
hr = IDirectMusicStyle8Impl_IPersistStream_ParsePatternList (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;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-10-12 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
|
2004-05-14 06:57:02 +02:00
|
|
|
} while (StreamCount < StreamSize);
|
|
|
|
|
|
|
|
return S_OK;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
|
2004-05-14 06:57:02 +02:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
|
|
|
|
|
|
|
|
DMUS_PRIVATE_CHUNK Chunk;
|
|
|
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
FIXME("(%p, %p): Loading\n", This, pStm);
|
|
|
|
|
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
2006-10-12 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-14 06:57:02 +02:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case FOURCC_RIFF: {
|
|
|
|
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
|
2006-10-12 22:56:15 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-05-14 06:57:02 +02:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case DMUS_FOURCC_STYLE_FORM: {
|
|
|
|
TRACE_(dmfile)(": Style form\n");
|
|
|
|
hr = IDirectMusicStyle8Impl_IPersistStream_ParseStyleForm (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); /* 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 (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
|
2004-05-14 06:57:02 +02:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
|
|
|
|
FIXME("(%p): Saving not implemented yet\n", This);
|
|
|
|
return E_NOTIMPL;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:56:49 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
|
2004-05-14 06:57:02 +02:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicStyle8Impl, PersistStreamVtbl, iface);
|
|
|
|
FIXME("(%p, %p): stub\n", This, pcbSize);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IPersistStreamVtbl DirectMusicStyle8_PersistStream_Vtbl = {
|
2004-05-14 06:57:02 +02:00
|
|
|
IDirectMusicStyle8Impl_IPersistStream_QueryInterface,
|
|
|
|
IDirectMusicStyle8Impl_IPersistStream_AddRef,
|
|
|
|
IDirectMusicStyle8Impl_IPersistStream_Release,
|
|
|
|
IDirectMusicStyle8Impl_IPersistStream_GetClassID,
|
|
|
|
IDirectMusicStyle8Impl_IPersistStream_IsDirty,
|
|
|
|
IDirectMusicStyle8Impl_IPersistStream_Load,
|
|
|
|
IDirectMusicStyle8Impl_IPersistStream_Save,
|
|
|
|
IDirectMusicStyle8Impl_IPersistStream_GetSizeMax
|
2003-08-23 01:53:27 +02:00
|
|
|
};
|
2004-01-20 01:21:40 +01:00
|
|
|
|
|
|
|
/* for ClassFactory */
|
|
|
|
HRESULT WINAPI DMUSIC_CreateDirectMusicStyleImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
|
2004-05-14 06:57:02 +02:00
|
|
|
IDirectMusicStyle8Impl* obj;
|
2004-01-20 01:21:40 +01:00
|
|
|
|
2004-05-14 06:57:02 +02:00
|
|
|
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicStyle8Impl));
|
|
|
|
if (NULL == obj) {
|
2004-12-22 16:13:20 +01:00
|
|
|
*ppobj = NULL;
|
2004-05-14 06:57:02 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
obj->UnknownVtbl = &DirectMusicStyle8_Unknown_Vtbl;
|
|
|
|
obj->StyleVtbl = &DirectMusicStyle8_Style_Vtbl;
|
|
|
|
obj->ObjectVtbl = &DirectMusicStyle8_Object_Vtbl;
|
|
|
|
obj->PersistStreamVtbl = &DirectMusicStyle8_PersistStream_Vtbl;
|
|
|
|
obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
|
|
|
|
DM_STRUCT_INIT(obj->pDesc);
|
|
|
|
obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
|
2008-02-25 20:48:26 +01:00
|
|
|
obj->pDesc->guidClass = CLSID_DirectMusicStyle;
|
2004-05-14 06:57:02 +02:00
|
|
|
obj->ref = 0; /* will be inited by QueryInterface */
|
2004-05-14 23:36:15 +02:00
|
|
|
list_init (&obj->Bands);
|
|
|
|
list_init (&obj->Motifs);
|
|
|
|
|
2004-05-14 06:57:02 +02:00
|
|
|
return IDirectMusicStyle8Impl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|