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"
|
2015-06-10 23:48:15 +02:00
|
|
|
#include "dmobject.h"
|
2019-11-26 21:14:39 +01:00
|
|
|
#include "wine/heap.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
|
|
|
|
2019-11-26 21:14:39 +01:00
|
|
|
struct style_band {
|
|
|
|
struct list entry;
|
|
|
|
IDirectMusicBand *pBand;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct style_partref_item {
|
|
|
|
struct list entry;
|
|
|
|
DMUS_OBJECTDESC desc;
|
|
|
|
DMUS_IO_PARTREF part_ref;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct style_motif {
|
|
|
|
struct list entry;
|
|
|
|
DWORD dwRhythm;
|
|
|
|
DMUS_IO_PATTERN pattern;
|
|
|
|
DMUS_OBJECTDESC desc;
|
|
|
|
/** optional for motifs */
|
|
|
|
DMUS_IO_MOTIFSETTINGS settings;
|
|
|
|
IDirectMusicBand *pBand;
|
|
|
|
struct list Items;
|
|
|
|
};
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectMusicStyleImpl implementation
|
|
|
|
*/
|
2014-06-09 13:29:47 +02:00
|
|
|
typedef struct IDirectMusicStyle8Impl {
|
|
|
|
IDirectMusicStyle8 IDirectMusicStyle8_iface;
|
2015-06-10 23:48:15 +02:00
|
|
|
struct dmobject dmobj;
|
2014-06-09 13:29:47 +02:00
|
|
|
LONG ref;
|
|
|
|
DMUS_IO_STYLE style;
|
2019-11-26 21:14:38 +01:00
|
|
|
struct list motifs;
|
|
|
|
struct list bands;
|
2014-06-09 13:29:47 +02:00
|
|
|
} IDirectMusicStyle8Impl;
|
|
|
|
|
2014-01-28 23:16:19 +01:00
|
|
|
static inline IDirectMusicStyle8Impl *impl_from_IDirectMusicStyle8(IDirectMusicStyle8 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicStyle8Impl, IDirectMusicStyle8_iface);
|
|
|
|
}
|
|
|
|
|
2014-01-28 23:19:07 +01:00
|
|
|
/* DirectMusicStyle8Impl IDirectMusicStyle8 part: */
|
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_QueryInterface(IDirectMusicStyle8 *iface, REFIID riid,
|
|
|
|
void **ret_iface)
|
|
|
|
{
|
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(iface);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
2014-01-28 23:19:07 +01:00
|
|
|
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
|
2005-01-24 12:31:45 +01:00
|
|
|
|
2014-01-28 23:19:07 +01:00
|
|
|
*ret_iface = NULL;
|
2003-04-08 23:42:00 +02:00
|
|
|
|
2014-01-28 23:19:07 +01:00
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicStyle) ||
|
|
|
|
IsEqualIID(riid, &IID_IDirectMusicStyle8))
|
|
|
|
*ret_iface = iface;
|
|
|
|
else if (IsEqualIID(riid, &IID_IDirectMusicObject))
|
2015-06-10 23:48:15 +02:00
|
|
|
*ret_iface = &This->dmobj.IDirectMusicObject_iface;
|
2014-01-28 23:19:07 +01:00
|
|
|
else if (IsEqualIID(riid, &IID_IPersistStream))
|
2015-06-10 23:48:15 +02:00
|
|
|
*ret_iface = &This->dmobj.IPersistStream_iface;
|
2014-01-28 23:19:07 +01:00
|
|
|
else {
|
|
|
|
WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2014-01-28 23:19:07 +01:00
|
|
|
IUnknown_AddRef((IUnknown*)*ret_iface);
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-28 23:15:03 +01:00
|
|
|
static ULONG WINAPI IDirectMusicStyle8Impl_AddRef(IDirectMusicStyle8 *iface)
|
|
|
|
{
|
2014-01-28 23:16:19 +01:00
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(iface);
|
2014-01-28 23:19:07 +01:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2014-01-28 23:15:03 +01:00
|
|
|
static ULONG WINAPI IDirectMusicStyle8Impl_Release(IDirectMusicStyle8 *iface)
|
|
|
|
{
|
2014-01-28 23:16:19 +01:00
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(iface);
|
2014-01-28 23:19:07 +01:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref) {
|
2019-11-26 21:14:40 +01:00
|
|
|
struct style_band *band, *band2;
|
|
|
|
struct style_motif *motif, *motif2;
|
|
|
|
struct style_partref_item *item, *item2;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(band, band2, &This->bands, struct style_band, entry) {
|
|
|
|
list_remove(&band->entry);
|
|
|
|
if (band->pBand)
|
|
|
|
IDirectMusicBand_Release(band->pBand);
|
|
|
|
heap_free(band);
|
|
|
|
}
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(motif, motif2, &This->motifs, struct style_motif, entry) {
|
|
|
|
list_remove(&motif->entry);
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(item, item2, &motif->Items, struct style_partref_item, entry) {
|
|
|
|
list_remove(&item->entry);
|
|
|
|
heap_free(item);
|
|
|
|
}
|
|
|
|
heap_free(motif);
|
|
|
|
}
|
|
|
|
heap_free(This);
|
2014-01-28 23:19:07 +01:00
|
|
|
DMSTYLE_UnlockModule();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
2003-06-07 02:39:18 +02:00
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicStyle8Impl IDirectMusicStyle(8) part: */
|
2014-01-28 23:15:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_GetBand(IDirectMusicStyle8 *iface, WCHAR *pwszName,
|
|
|
|
IDirectMusicBand **ppBand)
|
|
|
|
{
|
2014-01-28 23:16:19 +01:00
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(iface);
|
2004-01-20 01:21:40 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-01-28 23:15:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_EnumBand(IDirectMusicStyle8 *iface, DWORD dwIndex,
|
|
|
|
WCHAR *pwszName)
|
|
|
|
{
|
2014-01-28 23:16:19 +01:00
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(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
|
|
|
|
2014-01-28 23:15:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_GetDefaultBand(IDirectMusicStyle8 *iface,
|
|
|
|
IDirectMusicBand **ppBand)
|
|
|
|
{
|
2014-01-28 23:16:19 +01:00
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(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
|
|
|
}
|
|
|
|
|
2019-11-26 21:14:41 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_EnumMotif(IDirectMusicStyle8 *iface, DWORD index,
|
|
|
|
WCHAR *name)
|
2014-01-28 23:15:03 +01:00
|
|
|
{
|
2019-11-26 21:14:41 +01:00
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(iface);
|
|
|
|
const struct style_motif *motif = NULL;
|
|
|
|
const struct list *cursor;
|
|
|
|
unsigned int i = 0;
|
|
|
|
|
|
|
|
TRACE("(%p, %u, %p)\n", This, index, name);
|
|
|
|
|
|
|
|
if (!name)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
/* index is zero based */
|
|
|
|
LIST_FOR_EACH(cursor, &This->motifs) {
|
|
|
|
if (i == index) {
|
|
|
|
motif = LIST_ENTRY(cursor, struct style_motif, entry);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (!motif)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
if (motif->desc.dwValidData & DMUS_OBJ_NAME)
|
|
|
|
lstrcpynW(name, motif->desc.wszName, DMUS_MAX_NAME);
|
|
|
|
else
|
|
|
|
name[0] = 0;
|
|
|
|
|
|
|
|
TRACE("returning name: %s\n", debugstr_w(name));
|
|
|
|
return S_OK;
|
2003-04-08 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
2014-01-28 23:15:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_GetMotif(IDirectMusicStyle8 *iface, WCHAR *pwszName,
|
|
|
|
IDirectMusicSegment **ppSegment)
|
|
|
|
{
|
2014-01-28 23:16:19 +01:00
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(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
|
|
|
}
|
|
|
|
|
2014-01-28 23:15:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_GetDefaultChordMap(IDirectMusicStyle8 *iface,
|
|
|
|
IDirectMusicChordMap **ppChordMap)
|
|
|
|
{
|
2014-01-28 23:16:19 +01:00
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(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
|
|
|
}
|
|
|
|
|
2014-01-28 23:15:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_EnumChordMap(IDirectMusicStyle8 *iface, DWORD dwIndex,
|
|
|
|
WCHAR *pwszName)
|
|
|
|
{
|
2014-01-28 23:16:19 +01:00
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(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
|
|
|
}
|
|
|
|
|
2014-01-28 23:15:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_GetChordMap(IDirectMusicStyle8 *iface, WCHAR *pwszName,
|
|
|
|
IDirectMusicChordMap **ppChordMap)
|
|
|
|
{
|
2014-01-28 23:16:19 +01:00
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(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
|
|
|
}
|
|
|
|
|
2014-01-28 23:15:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_GetTimeSignature(IDirectMusicStyle8 *iface,
|
|
|
|
DMUS_TIMESIGNATURE *pTimeSig)
|
|
|
|
{
|
2014-01-28 23:16:19 +01:00
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(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
|
|
|
}
|
|
|
|
|
2014-01-28 23:15:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_GetEmbellishmentLength(IDirectMusicStyle8 *iface,
|
|
|
|
DWORD dwType, DWORD dwLevel, DWORD *pdwMin, DWORD *pdwMax)
|
|
|
|
{
|
2014-01-28 23:16:19 +01:00
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(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
|
|
|
}
|
|
|
|
|
2014-01-28 23:15:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_GetTempo(IDirectMusicStyle8 *iface, double *pTempo)
|
|
|
|
{
|
2014-01-28 23:16:19 +01:00
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(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
|
|
|
}
|
|
|
|
|
2014-01-28 23:15:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicStyle8Impl_EnumPattern(IDirectMusicStyle8 *iface, DWORD dwIndex,
|
|
|
|
DWORD dwPatternType, WCHAR *pwszName)
|
|
|
|
{
|
2014-01-28 23:16:19 +01:00
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IDirectMusicStyle8(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
|
|
|
}
|
|
|
|
|
2014-01-28 23:16:19 +01:00
|
|
|
static const IDirectMusicStyle8Vtbl dmstyle8_vtbl = {
|
2014-01-28 23:15:03 +01:00
|
|
|
IDirectMusicStyle8Impl_QueryInterface,
|
|
|
|
IDirectMusicStyle8Impl_AddRef,
|
|
|
|
IDirectMusicStyle8Impl_Release,
|
|
|
|
IDirectMusicStyle8Impl_GetBand,
|
|
|
|
IDirectMusicStyle8Impl_EnumBand,
|
|
|
|
IDirectMusicStyle8Impl_GetDefaultBand,
|
|
|
|
IDirectMusicStyle8Impl_EnumMotif,
|
|
|
|
IDirectMusicStyle8Impl_GetMotif,
|
|
|
|
IDirectMusicStyle8Impl_GetDefaultChordMap,
|
|
|
|
IDirectMusicStyle8Impl_EnumChordMap,
|
|
|
|
IDirectMusicStyle8Impl_GetChordMap,
|
|
|
|
IDirectMusicStyle8Impl_GetTimeSignature,
|
|
|
|
IDirectMusicStyle8Impl_GetEmbellishmentLength,
|
|
|
|
IDirectMusicStyle8Impl_GetTempo,
|
|
|
|
IDirectMusicStyle8Impl_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: */
|
2018-07-15 21:08:48 +02:00
|
|
|
static HRESULT WINAPI style_IDirectMusicObject_ParseDescriptor(IDirectMusicObject *iface,
|
|
|
|
IStream *stream, DMUS_OBJECTDESC *desc)
|
2015-06-10 23:48:15 +02:00
|
|
|
{
|
2018-07-15 21:08:48 +02:00
|
|
|
struct chunk_entry riff = {0};
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p)\n", iface, stream, desc);
|
|
|
|
|
|
|
|
if (!stream || !desc)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if ((hr = stream_get_chunk(stream, &riff)) != S_OK)
|
|
|
|
return hr;
|
|
|
|
if (riff.id != FOURCC_RIFF || riff.type != DMUS_FOURCC_STYLE_FORM) {
|
|
|
|
TRACE("loading failed: unexpected %s\n", debugstr_chunk(&riff));
|
|
|
|
stream_skip_chunk(stream, &riff);
|
|
|
|
return DMUS_E_CHUNKNOTFOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = dmobj_parsedescriptor(stream, &riff, desc,
|
|
|
|
DMUS_OBJ_OBJECT|DMUS_OBJ_NAME|DMUS_OBJ_NAME_INAM|DMUS_OBJ_VERSION);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
desc->guidClass = CLSID_DirectMusicStyle;
|
|
|
|
desc->dwValidData |= DMUS_OBJ_CLASS;
|
|
|
|
|
2019-11-21 20:17:45 +01:00
|
|
|
dump_DMUS_OBJECTDESC(desc);
|
2018-07-15 21:08:48 +02:00
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
2003-08-23 01:53:27 +02:00
|
|
|
|
2015-06-10 23:48:15 +02:00
|
|
|
static const IDirectMusicObjectVtbl dmobject_vtbl = {
|
|
|
|
dmobj_IDirectMusicObject_QueryInterface,
|
|
|
|
dmobj_IDirectMusicObject_AddRef,
|
|
|
|
dmobj_IDirectMusicObject_Release,
|
|
|
|
dmobj_IDirectMusicObject_GetDescriptor,
|
|
|
|
dmobj_IDirectMusicObject_SetDescriptor,
|
2018-07-15 21:08:48 +02:00
|
|
|
style_IDirectMusicObject_ParseDescriptor
|
2004-01-20 01:21:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* IDirectMusicStyle8Impl IPersistStream part: */
|
2015-06-10 23:48:15 +02:00
|
|
|
static inline IDirectMusicStyle8Impl *impl_from_IPersistStream(IPersistStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicStyle8Impl, dmobj.IPersistStream_iface);
|
2004-05-14 06:57:02 +02:00
|
|
|
}
|
|
|
|
|
2015-06-10 23:46:30 +02:00
|
|
|
static HRESULT load_band(IStream *pClonedStream, IDirectMusicBand **ppBand)
|
|
|
|
{
|
2004-05-14 23:36:15 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-06-10 23:46:30 +02:00
|
|
|
static HRESULT parse_part_ref_list(DMUS_PRIVATE_CHUNK *pChunk, IStream *pStm,
|
2019-11-26 21:14:39 +01:00
|
|
|
struct style_motif *pNewMotif)
|
2015-06-10 23:46:30 +02:00
|
|
|
{
|
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 */
|
2019-11-26 21:14:39 +01:00
|
|
|
struct style_partref_item *pNewItem = NULL;
|
2005-01-05 14:22:57 +01:00
|
|
|
|
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");
|
2019-11-26 21:14:39 +01:00
|
|
|
pNewItem = heap_alloc_zero(sizeof(*pNewItem));
|
2009-01-31 23:30:59 +01:00
|
|
|
if (!pNewItem) {
|
2005-01-05 14:22:57 +01:00
|
|
|
ERR(": no more memory\n");
|
2009-01-31 23:30:59 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2005-01-05 14:22:57 +01:00
|
|
|
}
|
|
|
|
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);
|
2015-07-07 10:12:22 +02:00
|
|
|
pNewItem->desc.dwSize = sizeof(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
|
|
|
|
2009-01-31 23:30:59 +01:00
|
|
|
if (!pNewItem) {
|
|
|
|
ERR(": pNewItem not yet allocated, chunk order bad?\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
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: {
|
2011-07-27 13:38:43 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-05-14 06:57:02 +02:00
|
|
|
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: {
|
2011-07-27 13:38:43 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-05-14 06:57:02 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-06-10 23:46:30 +02:00
|
|
|
static HRESULT parse_part_list(DMUS_PRIVATE_CHUNK *pChunk, IStream *pStm)
|
|
|
|
{
|
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;
|
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: {
|
2011-07-27 13:38:43 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-05-14 06:57:02 +02:00
|
|
|
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: {
|
2011-07-27 13:38:43 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-05-14 06:57:02 +02:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2011-07-27 13:38:43 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-05-14 06:57:02 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-06-10 23:47:41 +02:00
|
|
|
static HRESULT parse_pattern_list(IDirectMusicStyle8Impl *This, DMUS_PRIVATE_CHUNK *pChunk,
|
|
|
|
IStream *pStm)
|
|
|
|
{
|
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 */
|
2004-05-14 23:36:15 +02:00
|
|
|
IDirectMusicBand* pBand = NULL;
|
2019-11-26 21:14:39 +01:00
|
|
|
struct style_motif *pNewMotif = NULL;
|
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 */
|
2019-11-26 21:14:39 +01:00
|
|
|
pNewMotif = heap_alloc_zero(sizeof(*pNewMotif));
|
2004-05-14 23:36:15 +02:00
|
|
|
if (NULL == pNewMotif) {
|
|
|
|
ERR(": no more memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2019-11-26 21:14:38 +01:00
|
|
|
list_add_tail(&This->motifs, &pNewMotif->entry);
|
2004-05-14 23:36:15 +02:00
|
|
|
|
|
|
|
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 */
|
2015-07-07 10:12:22 +02:00
|
|
|
pNewMotif->desc.dwSize = sizeof(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);
|
2015-06-10 23:46:30 +02:00
|
|
|
|
|
|
|
hr = load_band(pClonedStream, &pBand);
|
2004-05-14 23:36:15 +02:00
|
|
|
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: {
|
2011-07-27 13:38:43 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-05-14 23:36:15 +02:00
|
|
|
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: {
|
2011-07-27 13:38:43 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-05-14 06:57:02 +02:00
|
|
|
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");
|
2015-06-10 23:46:30 +02:00
|
|
|
hr = parse_part_ref_list(&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: {
|
2011-07-27 13:38:43 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-05-14 06:57:02 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-06-10 23:47:41 +02:00
|
|
|
static HRESULT parse_style_form(IDirectMusicStyle8Impl *This, DMUS_PRIVATE_CHUNK *pChunk,
|
|
|
|
IStream *pStm)
|
|
|
|
{
|
2004-05-14 06:57:02 +02:00
|
|
|
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);
|
2015-06-10 23:48:15 +02:00
|
|
|
|
|
|
|
hr = IDirectMusicUtils_IPersistStream_ParseDescGeneric(&Chunk, pStm, &This->dmobj.desc);
|
2004-05-14 06:57:02 +02:00
|
|
|
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;
|
2019-11-26 21:14:39 +01:00
|
|
|
struct style_band *pNewBand;
|
2004-05-14 23:36:15 +02:00
|
|
|
|
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);
|
2015-06-10 23:46:30 +02:00
|
|
|
|
|
|
|
hr = load_band(pClonedStream, &pBand);
|
2004-05-14 06:57:02 +02:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
ERR(": could not load track\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
IStream_Release (pClonedStream);
|
2019-11-26 21:14:39 +01:00
|
|
|
|
|
|
|
pNewBand = heap_alloc_zero(sizeof(*pNewBand));
|
2004-05-14 23:36:15 +02:00
|
|
|
if (NULL == pNewBand) {
|
|
|
|
ERR(": no more memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
pNewBand->pBand = pBand;
|
|
|
|
IDirectMusicBand_AddRef(pBand);
|
2019-11-26 21:14:38 +01:00
|
|
|
list_add_tail(&This->bands, &pNewBand->entry);
|
2004-05-14 23:36:15 +02:00
|
|
|
|
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: {
|
2011-07-27 13:38:43 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-05-14 06:57:02 +02:00
|
|
|
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);
|
2015-06-10 23:48:15 +02:00
|
|
|
|
|
|
|
hr = IDirectMusicUtils_IPersistStream_ParseUNFOGeneric(&Chunk, pStm, &This->dmobj.desc);
|
2004-05-14 06:57:02 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
if (hr == S_FALSE) {
|
|
|
|
switch (Chunk.fccID) {
|
|
|
|
default: {
|
2011-07-27 13:38:43 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-05-14 06:57:02 +02:00
|
|
|
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");
|
2015-06-10 23:46:30 +02:00
|
|
|
hr = parse_part_list(&Chunk, pStm);
|
2004-05-14 06:57:02 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_PATTERN_LIST: {
|
|
|
|
TRACE_(dmfile)(": PATTERN list\n");
|
2015-06-10 23:47:41 +02:00
|
|
|
hr = parse_pattern_list(This, &Chunk, pStm);
|
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: {
|
2011-07-27 13:38:43 +02:00
|
|
|
TRACE_(dmfile)(": unknown chunk (irrelevant & skipping)\n");
|
2004-05-14 06:57:02 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-06-10 23:48:15 +02:00
|
|
|
static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pStm)
|
|
|
|
{
|
|
|
|
IDirectMusicStyle8Impl *This = impl_from_IPersistStream(iface);
|
2004-05-14 06:57:02 +02:00
|
|
|
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");
|
2015-06-10 23:47:41 +02:00
|
|
|
hr = parse_style_form(This, &Chunk, pStm);
|
2004-05-14 06:57:02 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-06-10 23:48:15 +02:00
|
|
|
static const IPersistStreamVtbl persiststream_vtbl = {
|
|
|
|
dmobj_IPersistStream_QueryInterface,
|
|
|
|
dmobj_IPersistStream_AddRef,
|
|
|
|
dmobj_IPersistStream_Release,
|
|
|
|
dmobj_IPersistStream_GetClassID,
|
|
|
|
unimpl_IPersistStream_IsDirty,
|
|
|
|
IPersistStreamImpl_Load,
|
|
|
|
unimpl_IPersistStream_Save,
|
|
|
|
unimpl_IPersistStream_GetSizeMax
|
2003-08-23 01:53:27 +02:00
|
|
|
};
|
2004-01-20 01:21:40 +01:00
|
|
|
|
|
|
|
/* for ClassFactory */
|
2014-01-15 01:08:41 +01:00
|
|
|
HRESULT WINAPI create_dmstyle(REFIID lpcGUID, void **ppobj)
|
|
|
|
{
|
2004-05-14 06:57:02 +02:00
|
|
|
IDirectMusicStyle8Impl* obj;
|
2014-01-28 23:19:07 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
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;
|
|
|
|
}
|
2014-01-28 23:16:19 +01:00
|
|
|
obj->IDirectMusicStyle8_iface.lpVtbl = &dmstyle8_vtbl;
|
2014-01-28 23:19:07 +01:00
|
|
|
obj->ref = 1;
|
2015-06-10 23:48:15 +02:00
|
|
|
dmobject_init(&obj->dmobj, &CLSID_DirectMusicStyle, (IUnknown *)&obj->IDirectMusicStyle8_iface);
|
|
|
|
obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl;
|
|
|
|
obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
|
2019-11-26 21:14:38 +01:00
|
|
|
list_init(&obj->bands);
|
|
|
|
list_init(&obj->motifs);
|
2004-05-14 23:36:15 +02:00
|
|
|
|
2014-01-28 23:19:07 +01:00
|
|
|
DMSTYLE_LockModule();
|
|
|
|
hr = IDirectMusicStyle8_QueryInterface(&obj->IDirectMusicStyle8_iface, lpcGUID, ppobj);
|
|
|
|
IDirectMusicStyle8_Release(&obj->IDirectMusicStyle8_iface);
|
|
|
|
|
|
|
|
return hr;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|