2003-07-22 00:10:14 +02:00
|
|
|
/* IDirectMusicScript
|
|
|
|
*
|
2004-01-20 01:21:40 +01:00
|
|
|
* Copyright (C) 2003-2004 Rok Mandeljc
|
2004-05-12 00:18:43 +02:00
|
|
|
* Copyright (C) 2003-2004 Raphael Junqueira
|
2003-07-22 00:10:14 +02:00
|
|
|
*
|
2007-05-30 12:54:07 +02:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2003-07-22 00:10:14 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-05-30 12:54:07 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2003-07-22 00:10:14 +02:00
|
|
|
*
|
2007-05-30 12:54:07 +02:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-07-22 00:10:14 +02:00
|
|
|
*/
|
|
|
|
|
2004-03-09 20:21:33 +01:00
|
|
|
|
2019-06-03 10:30:14 +02:00
|
|
|
#include <stdio.h>
|
2004-03-09 20:21:33 +01:00
|
|
|
|
2003-07-22 00:10:14 +02:00
|
|
|
#include "dmscript_private.h"
|
2015-04-28 00:15:18 +02:00
|
|
|
#include "dmobject.h"
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dmscript);
|
2004-01-20 01:21:40 +01:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(dmfile);
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2004-03-09 20:21:33 +01:00
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectMusicScriptImpl implementation
|
|
|
|
*/
|
2014-05-30 23:03:53 +02:00
|
|
|
typedef struct IDirectMusicScriptImpl {
|
|
|
|
IDirectMusicScript IDirectMusicScript_iface;
|
2015-04-28 00:15:18 +02:00
|
|
|
struct dmobject dmobj;
|
2014-05-30 23:03:53 +02:00
|
|
|
LONG ref;
|
|
|
|
IDirectMusicPerformance *pPerformance;
|
|
|
|
DMUS_IO_SCRIPT_HEADER *pHeader;
|
|
|
|
DMUS_IO_VERSION *pVersion;
|
|
|
|
WCHAR *pwzLanguage;
|
|
|
|
WCHAR *pwzSource;
|
|
|
|
} IDirectMusicScriptImpl;
|
|
|
|
|
2014-01-12 22:03:06 +01:00
|
|
|
static inline IDirectMusicScriptImpl *impl_from_IDirectMusicScript(IDirectMusicScript *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicScriptImpl, IDirectMusicScript_iface);
|
|
|
|
}
|
|
|
|
|
2014-01-12 22:01:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_QueryInterface(IDirectMusicScript *iface, REFIID riid,
|
2014-01-12 22:04:51 +01:00
|
|
|
void **ret_iface)
|
2014-01-12 22:01:03 +01:00
|
|
|
{
|
2014-01-12 22:04:51 +01:00
|
|
|
IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
|
|
|
|
|
|
|
|
*ret_iface = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicScript))
|
|
|
|
*ret_iface = iface;
|
|
|
|
else if (IsEqualIID(riid, &IID_IDirectMusicObject))
|
2015-04-28 00:15:18 +02:00
|
|
|
*ret_iface = &This->dmobj.IDirectMusicObject_iface;
|
2014-01-12 22:04:51 +01:00
|
|
|
else if (IsEqualIID(riid, &IID_IPersistStream))
|
2015-04-28 00:15:18 +02:00
|
|
|
*ret_iface = &This->dmobj.IPersistStream_iface;
|
2014-01-12 22:04:51 +01:00
|
|
|
else {
|
|
|
|
WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ret_iface);
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-01-12 22:01:03 +01:00
|
|
|
static ULONG WINAPI IDirectMusicScriptImpl_AddRef(IDirectMusicScript *iface)
|
|
|
|
{
|
2014-01-12 22:04:51 +01:00
|
|
|
IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2014-01-12 22:01:03 +01:00
|
|
|
static ULONG WINAPI IDirectMusicScriptImpl_Release(IDirectMusicScript *iface)
|
|
|
|
{
|
2014-01-12 22:04:51 +01:00
|
|
|
IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->pHeader);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->pVersion);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->pwzLanguage);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->pwzSource);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
DMSCRIPT_UnlockModule();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2014-01-12 22:01:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_Init(IDirectMusicScript *iface,
|
|
|
|
IDirectMusicPerformance *pPerformance, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
|
|
|
|
{
|
2014-01-12 22:03:06 +01:00
|
|
|
IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
|
2004-05-10 21:56:17 +02:00
|
|
|
FIXME("(%p, %p, %p): stub\n", This, pPerformance, pErrorInfo);
|
|
|
|
This->pPerformance = pPerformance;
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-01-12 22:01:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_CallRoutine(IDirectMusicScript *iface,
|
|
|
|
WCHAR *pwszRoutineName, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
|
|
|
|
{
|
2014-01-12 22:03:06 +01:00
|
|
|
IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
|
2004-05-10 21:56:17 +02:00
|
|
|
FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszRoutineName), pErrorInfo);
|
|
|
|
/*return E_NOTIMPL;*/
|
2004-05-12 00:18:43 +02:00
|
|
|
return S_OK;
|
|
|
|
/*return E_FAIL;*/
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2014-01-12 22:01:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_SetVariableVariant(IDirectMusicScript *iface,
|
|
|
|
WCHAR *pwszVariableName, VARIANT varValue, BOOL fSetRef, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
|
|
|
|
{
|
2014-01-12 22:03:06 +01:00
|
|
|
IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
|
2004-05-10 21:56:17 +02:00
|
|
|
FIXME("(%p, %s, FIXME, %d, %p): stub\n", This, debugstr_w(pwszVariableName),/* varValue,*/ fSetRef, pErrorInfo);
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-01-12 22:01:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_GetVariableVariant(IDirectMusicScript *iface,
|
|
|
|
WCHAR *pwszVariableName, VARIANT *pvarValue, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
|
|
|
|
{
|
2014-01-12 22:03:06 +01:00
|
|
|
IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
|
2004-05-10 21:56:17 +02:00
|
|
|
FIXME("(%p, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), pvarValue, pErrorInfo);
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-01-12 22:01:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_SetVariableNumber(IDirectMusicScript *iface,
|
|
|
|
WCHAR *pwszVariableName, LONG lValue, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
|
|
|
|
{
|
2014-01-12 22:03:06 +01:00
|
|
|
IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
|
2006-10-08 23:52:35 +02:00
|
|
|
FIXME("(%p, %s, %i, %p): stub\n", This, debugstr_w(pwszVariableName), lValue, pErrorInfo);
|
2004-05-10 21:56:17 +02:00
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-01-12 22:01:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_GetVariableNumber(IDirectMusicScript *iface,
|
|
|
|
WCHAR *pwszVariableName, LONG *plValue, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
|
|
|
|
{
|
2014-01-12 22:03:06 +01:00
|
|
|
IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
|
2004-05-10 21:56:17 +02:00
|
|
|
FIXME("(%p, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), plValue, pErrorInfo);
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-01-12 22:01:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_SetVariableObject(IDirectMusicScript *iface,
|
|
|
|
WCHAR *pwszVariableName, IUnknown *punkValue, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
|
|
|
|
{
|
2014-01-12 22:03:06 +01:00
|
|
|
IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
|
2004-05-10 21:56:17 +02:00
|
|
|
FIXME("(%p, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), punkValue, pErrorInfo);
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-01-12 22:01:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_GetVariableObject(IDirectMusicScript *iface,
|
|
|
|
WCHAR *pwszVariableName, REFIID riid, void **ppv, DMUS_SCRIPT_ERRORINFO *pErrorInfo)
|
|
|
|
{
|
2014-01-12 22:03:06 +01:00
|
|
|
IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
|
2004-05-10 21:56:17 +02:00
|
|
|
FIXME("(%p, %s, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), debugstr_dmguid(riid), ppv, pErrorInfo);
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-01-12 22:01:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_EnumRoutine(IDirectMusicScript *iface, DWORD dwIndex,
|
|
|
|
WCHAR *pwszName)
|
|
|
|
{
|
2014-01-12 22:03:06 +01:00
|
|
|
IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
|
2006-10-08 23:52:35 +02:00
|
|
|
FIXME("(%p, %d, %p): stub\n", This, dwIndex, pwszName);
|
2004-05-10 21:56:17 +02:00
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-01-12 22:01:03 +01:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_EnumVariable(IDirectMusicScript *iface, DWORD dwIndex,
|
|
|
|
WCHAR *pwszName)
|
|
|
|
{
|
2014-01-12 22:03:06 +01:00
|
|
|
IDirectMusicScriptImpl *This = impl_from_IDirectMusicScript(iface);
|
2006-10-08 23:52:35 +02:00
|
|
|
FIXME("(%p, %d, %p): stub\n", This, dwIndex, pwszName);
|
2004-05-10 21:56:17 +02:00
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2014-01-12 22:03:06 +01:00
|
|
|
static const IDirectMusicScriptVtbl dmscript_vtbl = {
|
2014-01-12 22:01:03 +01:00
|
|
|
IDirectMusicScriptImpl_QueryInterface,
|
|
|
|
IDirectMusicScriptImpl_AddRef,
|
|
|
|
IDirectMusicScriptImpl_Release,
|
|
|
|
IDirectMusicScriptImpl_Init,
|
|
|
|
IDirectMusicScriptImpl_CallRoutine,
|
|
|
|
IDirectMusicScriptImpl_SetVariableVariant,
|
|
|
|
IDirectMusicScriptImpl_GetVariableVariant,
|
|
|
|
IDirectMusicScriptImpl_SetVariableNumber,
|
|
|
|
IDirectMusicScriptImpl_GetVariableNumber,
|
|
|
|
IDirectMusicScriptImpl_SetVariableObject,
|
|
|
|
IDirectMusicScriptImpl_GetVariableObject,
|
|
|
|
IDirectMusicScriptImpl_EnumRoutine,
|
|
|
|
IDirectMusicScriptImpl_EnumVariable
|
2003-07-22 00:10:14 +02:00
|
|
|
};
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicScriptImpl IDirectMusicObject part: */
|
2015-04-28 00:15:18 +02:00
|
|
|
static inline IDirectMusicScriptImpl *impl_from_IDirectMusicObject(IDirectMusicObject *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicScriptImpl, dmobj.IDirectMusicObject_iface);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2018-08-02 21:54:40 +02:00
|
|
|
static HRESULT WINAPI script_IDirectMusicObject_ParseDescriptor(IDirectMusicObject *iface,
|
|
|
|
IStream *stream, DMUS_OBJECTDESC *desc)
|
2015-04-28 00:15:18 +02:00
|
|
|
{
|
2018-08-02 21:54:40 +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_SCRIPT_FORM) {
|
|
|
|
TRACE("loading failed: unexpected %s\n", debugstr_chunk(&riff));
|
|
|
|
stream_skip_chunk(stream, &riff);
|
|
|
|
return DMUS_E_SCRIPT_INVALID_FILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = dmobj_parsedescriptor(stream, &riff, desc,
|
|
|
|
DMUS_OBJ_OBJECT|DMUS_OBJ_NAME|DMUS_OBJ_NAME_INAM|DMUS_OBJ_CATEGORY|DMUS_OBJ_VERSION);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (desc->dwValidData) {
|
|
|
|
desc->guidClass = CLSID_DirectMusicScript;
|
|
|
|
desc->dwValidData |= DMUS_OBJ_CLASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC(desc));
|
|
|
|
return S_OK;
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2015-04-28 00:15:18 +02:00
|
|
|
static const IDirectMusicObjectVtbl dmobject_vtbl = {
|
|
|
|
dmobj_IDirectMusicObject_QueryInterface,
|
|
|
|
dmobj_IDirectMusicObject_AddRef,
|
|
|
|
dmobj_IDirectMusicObject_Release,
|
|
|
|
dmobj_IDirectMusicObject_GetDescriptor,
|
|
|
|
dmobj_IDirectMusicObject_SetDescriptor,
|
2018-08-02 21:54:40 +02:00
|
|
|
script_IDirectMusicObject_ParseDescriptor
|
2003-08-23 01:53:27 +02:00
|
|
|
};
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicScriptImpl IPersistStream part: */
|
2015-04-28 00:15:18 +02:00
|
|
|
static inline IDirectMusicScriptImpl *impl_from_IPersistStream(IPersistStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicScriptImpl, dmobj.IPersistStream_iface);
|
2003-08-23 01:53:27 +02:00
|
|
|
}
|
|
|
|
|
2015-04-28 00:15:18 +02:00
|
|
|
static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pStm)
|
|
|
|
{
|
|
|
|
IDirectMusicScriptImpl *This = impl_from_IPersistStream(iface);
|
2004-03-09 20:21:33 +01:00
|
|
|
DMUS_PRIVATE_CHUNK Chunk;
|
|
|
|
DWORD StreamSize, StreamCount, ListSize[3], ListCount[3];
|
2004-01-20 01:21:40 +01:00
|
|
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
2004-03-12 02:53:05 +01:00
|
|
|
LPDIRECTMUSICGETLOADER pGetLoader = NULL;
|
|
|
|
LPDIRECTMUSICLOADER pLoader = NULL;
|
2004-01-20 01:21:40 +01:00
|
|
|
|
|
|
|
FIXME("(%p, %p): Loading not implemented yet\n", This, pStm);
|
2004-03-09 20:21:33 +01:00
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
2006-10-08 23:52:35 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-03-09 20:21:33 +01:00
|
|
|
switch (Chunk.fccID) {
|
2004-01-20 01:21:40 +01:00
|
|
|
case FOURCC_RIFF: {
|
2004-03-09 20:21:33 +01:00
|
|
|
IStream_Read (pStm, &Chunk.fccID, sizeof(FOURCC), NULL);
|
|
|
|
TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
|
|
|
|
StreamSize = Chunk.dwSize - sizeof(FOURCC);
|
2004-01-20 01:21:40 +01:00
|
|
|
StreamCount = 0;
|
2004-03-09 20:21:33 +01:00
|
|
|
switch (Chunk.fccID) {
|
2004-01-20 01:21:40 +01:00
|
|
|
case DMUS_FOURCC_SCRIPT_FORM: {
|
|
|
|
TRACE_(dmfile)(": script form\n");
|
|
|
|
do {
|
2004-03-09 20:21:33 +01:00
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-08 23:52:35 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-03-09 20:21:33 +01:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case DMUS_FOURCC_SCRIPT_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": script header chunk\n");
|
|
|
|
This->pHeader = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
|
|
|
|
IStream_Read (pStm, This->pHeader, Chunk.dwSize, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_SCRIPTVERSION_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": script version chunk\n");
|
|
|
|
This->pVersion = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
|
|
|
|
IStream_Read (pStm, This->pVersion, Chunk.dwSize, NULL);
|
2006-10-08 23:52:35 +02:00
|
|
|
TRACE_(dmfile)("version: 0x%08x.0x%08x\n", This->pVersion->dwVersionMS, This->pVersion->dwVersionLS);
|
2004-03-09 20:21:33 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_SCRIPTLANGUAGE_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": script language chunk\n");
|
|
|
|
This->pwzLanguage = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
|
|
|
|
IStream_Read (pStm, This->pwzLanguage, Chunk.dwSize, NULL);
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE_(dmfile)("using language: %s\n", debugstr_w(This->pwzLanguage));
|
2004-03-09 20:21:33 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_SCRIPTSOURCE_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": script source chunk\n");
|
|
|
|
This->pwzSource = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, Chunk.dwSize);
|
|
|
|
IStream_Read (pStm, This->pwzSource, Chunk.dwSize, NULL);
|
|
|
|
if (TRACE_ON(dmscript)) {
|
|
|
|
int count = WideCharToMultiByte(CP_ACP, 0, This->pwzSource, -1, NULL, 0, NULL, NULL);
|
|
|
|
LPSTR str = HeapAlloc(GetProcessHeap (), 0, count);
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, This->pwzSource, -1, str, count, NULL, NULL);
|
|
|
|
str[count-1] = '\n';
|
|
|
|
TRACE("source:\n");
|
2019-06-03 10:30:14 +02:00
|
|
|
fwrite( str, 1, count, stderr );
|
2004-03-09 20:21:33 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, str);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2004-01-20 01:21:40 +01:00
|
|
|
case DMUS_FOURCC_GUID_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": GUID chunk\n");
|
2015-04-28 00:17:31 +02:00
|
|
|
This->dmobj.desc.dwValidData |= DMUS_OBJ_OBJECT;
|
|
|
|
IStream_Read (pStm, &This->dmobj.desc.guidObject, Chunk.dwSize, NULL);
|
2004-01-20 01:21:40 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_VERSION_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": version chunk\n");
|
2015-04-28 00:17:31 +02:00
|
|
|
This->dmobj.desc.dwValidData |= DMUS_OBJ_VERSION;
|
|
|
|
IStream_Read (pStm, &This->dmobj.desc.vVersion, Chunk.dwSize, NULL);
|
2004-01-20 01:21:40 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_CATEGORY_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": category chunk\n");
|
2015-04-28 00:17:31 +02:00
|
|
|
This->dmobj.desc.dwValidData |= DMUS_OBJ_CATEGORY;
|
|
|
|
IStream_Read (pStm, This->dmobj.desc.wszCategory, Chunk.dwSize, NULL);
|
2004-01-20 01:21:40 +01:00
|
|
|
break;
|
|
|
|
}
|
2004-03-12 02:53:05 +01:00
|
|
|
case FOURCC_RIFF: {
|
|
|
|
IDirectMusicObject* pObject = NULL;
|
|
|
|
DMUS_OBJECTDESC desc;
|
2004-04-02 21:14:08 +02:00
|
|
|
|
2009-01-13 10:56:48 +01:00
|
|
|
ZeroMemory (&desc, sizeof(DMUS_OBJECTDESC));
|
2004-04-02 21:14:08 +02:00
|
|
|
desc.dwSize = sizeof(DMUS_OBJECTDESC);
|
2004-03-12 02:53:05 +01:00
|
|
|
desc.dwValidData = DMUS_OBJ_STREAM | DMUS_OBJ_CLASS;
|
|
|
|
desc.guidClass = CLSID_DirectMusicContainer;
|
|
|
|
desc.pStream = NULL;
|
|
|
|
IStream_Clone (pStm, &desc.pStream);
|
|
|
|
|
|
|
|
liMove.QuadPart = 0;
|
|
|
|
liMove.QuadPart -= (sizeof(FOURCC) + sizeof(DWORD));
|
|
|
|
IStream_Seek (desc.pStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
|
|
|
|
IStream_QueryInterface (pStm, &IID_IDirectMusicGetLoader, (LPVOID*)&pGetLoader);
|
|
|
|
IDirectMusicGetLoader_GetLoader (pGetLoader, &pLoader);
|
|
|
|
IDirectMusicGetLoader_Release (pGetLoader);
|
|
|
|
|
|
|
|
if (SUCCEEDED(IDirectMusicLoader_GetObject (pLoader, &desc, &IID_IDirectMusicObject, (LPVOID*) &pObject))) {
|
|
|
|
IDirectMusicObject_Release (pObject);
|
|
|
|
} else {
|
|
|
|
ERR_(dmfile)("Error on GetObject while trying to load Scrip SubContainer\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
IDirectMusicLoader_Release (pLoader); pLoader = NULL; /* release loader */
|
|
|
|
IStream_Release(desc.pStream); desc.pStream = NULL; /* release cloned stream */
|
|
|
|
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
/*
|
|
|
|
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) {
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown (skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
2004-01-20 01:21:40 +01:00
|
|
|
case FOURCC_LIST: {
|
2004-03-09 20:21:33 +01:00
|
|
|
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);
|
2004-01-20 01:21:40 +01:00
|
|
|
ListCount[0] = 0;
|
2004-03-09 20:21:33 +01:00
|
|
|
switch (Chunk.fccID) {
|
2004-01-20 01:21:40 +01:00
|
|
|
case DMUS_FOURCC_UNFO_LIST: {
|
|
|
|
TRACE_(dmfile)(": UNFO list\n");
|
|
|
|
do {
|
2004-03-09 20:21:33 +01:00
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-08 23:52:35 +02:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-03-09 20:21:33 +01:00
|
|
|
switch (Chunk.fccID) {
|
2004-01-20 01:21:40 +01:00
|
|
|
/* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
|
|
|
|
(though strings seem to be valid unicode) */
|
|
|
|
case mmioFOURCC('I','N','A','M'):
|
|
|
|
case DMUS_FOURCC_UNAM_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": name chunk\n");
|
2015-04-28 00:17:31 +02:00
|
|
|
This->dmobj.desc.dwValidData |= DMUS_OBJ_NAME;
|
|
|
|
IStream_Read (pStm, This->dmobj.desc.wszName, Chunk.dwSize, NULL);
|
2004-01-20 01:21:40 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case mmioFOURCC('I','A','R','T'):
|
|
|
|
case DMUS_FOURCC_UART_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": artist chunk (ignored)\n");
|
2004-03-09 20:21:33 +01:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-01-20 01:21:40 +01:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case mmioFOURCC('I','C','O','P'):
|
|
|
|
case DMUS_FOURCC_UCOP_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": copyright chunk (ignored)\n");
|
2004-03-09 20:21:33 +01:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-01-20 01:21:40 +01:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case mmioFOURCC('I','S','B','J'):
|
|
|
|
case DMUS_FOURCC_USBJ_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": subject chunk (ignored)\n");
|
2004-03-09 20:21:33 +01:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-01-20 01:21:40 +01:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case mmioFOURCC('I','C','M','T'):
|
|
|
|
case DMUS_FOURCC_UCMT_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": comment chunk (ignored)\n");
|
2004-03-09 20:21:33 +01:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-01-20 01:21:40 +01:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2011-07-27 13:38:43 +02:00
|
|
|
TRACE_(dmfile)(": unknown sub-chunk (irrelevant & skipping)\n");
|
2004-03-09 20:21:33 +01:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-01-20 01:21:40 +01:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-08 23:52:35 +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");
|
2004-03-09 20:21:33 +01:00
|
|
|
liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
|
2004-01-20 01:21:40 +01:00
|
|
|
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-03-09 20:21:33 +01:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-01-20 01:21:40 +01:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-08 23:52:35 +02:00
|
|
|
TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
|
2004-01-20 01:21:40 +01:00
|
|
|
} while (StreamCount < StreamSize);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
|
|
|
|
liMove.QuadPart = StreamSize;
|
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE_(dmfile)(": reading finished\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
|
2004-03-09 20:21:33 +01:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-01-20 01:21:40 +01:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-23 01:53:27 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-04-28 00:15:18 +02:00
|
|
|
static const IPersistStreamVtbl persiststream_vtbl = {
|
|
|
|
dmobj_IPersistStream_QueryInterface,
|
|
|
|
dmobj_IPersistStream_AddRef,
|
|
|
|
dmobj_IPersistStream_Release,
|
|
|
|
unimpl_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-12 22:03:06 +01:00
|
|
|
HRESULT WINAPI DMUSIC_CreateDirectMusicScriptImpl(REFIID lpcGUID, void **ppobj, IUnknown *pUnkOuter)
|
|
|
|
{
|
|
|
|
IDirectMusicScriptImpl *obj;
|
2014-01-12 22:04:51 +01:00
|
|
|
HRESULT hr;
|
2014-01-12 22:03:06 +01:00
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
|
|
|
|
if (pUnkOuter)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2004-05-10 21:56:17 +02:00
|
|
|
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicScriptImpl));
|
2014-01-12 22:03:06 +01:00
|
|
|
if (!obj)
|
2004-05-10 21:56:17 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2014-01-12 22:03:06 +01:00
|
|
|
|
|
|
|
obj->IDirectMusicScript_iface.lpVtbl = &dmscript_vtbl;
|
2014-01-12 22:04:51 +01:00
|
|
|
obj->ref = 1;
|
2015-04-28 00:15:18 +02:00
|
|
|
dmobject_init(&obj->dmobj, &CLSID_DirectMusicScript, (IUnknown*)&obj->IDirectMusicScript_iface);
|
|
|
|
obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl;
|
|
|
|
obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
|
2014-01-12 22:04:51 +01:00
|
|
|
|
|
|
|
DMSCRIPT_LockModule();
|
|
|
|
hr = IDirectMusicScript_QueryInterface(&obj->IDirectMusicScript_iface, lpcGUID, ppobj);
|
|
|
|
IDirectMusicScript_Release(&obj->IDirectMusicScript_iface);
|
2008-02-25 20:48:22 +01:00
|
|
|
|
2014-01-12 22:04:51 +01:00
|
|
|
return hr;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|