2003-07-21 22:10:14 +00:00
|
|
|
/* IDirectMusicScript
|
|
|
|
*
|
2004-01-20 00:21:40 +00:00
|
|
|
* Copyright (C) 2003-2004 Rok Mandeljc
|
2004-05-11 22:18:43 +00:00
|
|
|
* Copyright (C) 2003-2004 Raphael Junqueira
|
2003-07-21 22:10:14 +00:00
|
|
|
*
|
2007-05-30 10:54:07 +00: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-21 22:10:14 +00: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 10:54:07 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2003-07-21 22:10:14 +00:00
|
|
|
*
|
2007-05-30 10:54:07 +00: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-21 22:10:14 +00:00
|
|
|
*/
|
|
|
|
|
2004-03-09 19:21:33 +00:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2003-07-21 22:10:14 +00:00
|
|
|
#include "dmscript_private.h"
|
|
|
|
|
2003-08-22 23:53:27 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dmscript);
|
2004-01-20 00:21:40 +00:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(dmfile);
|
2003-07-21 22:10:14 +00:00
|
|
|
|
2004-03-09 19:21:33 +00:00
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static ULONG WINAPI IDirectMusicScriptImpl_IUnknown_AddRef (LPUNKNOWN iface);
|
|
|
|
static ULONG WINAPI IDirectMusicScriptImpl_IDirectMusicScript_AddRef (LPDIRECTMUSICSCRIPT iface);
|
|
|
|
static ULONG WINAPI IDirectMusicScriptImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface);
|
|
|
|
static ULONG WINAPI IDirectMusicScriptImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface);
|
|
|
|
|
2004-01-20 00:21:40 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectMusicScriptImpl implementation
|
|
|
|
*/
|
|
|
|
/* IDirectMusicScriptImpl IUnknown part: */
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, UnknownVtbl, iface);
|
|
|
|
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj);
|
|
|
|
|
|
|
|
if (IsEqualIID (riid, &IID_IUnknown)) {
|
|
|
|
*ppobj = (LPVOID)&This->UnknownVtbl;
|
|
|
|
IDirectMusicScriptImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
|
|
|
return S_OK;
|
|
|
|
} else if (IsEqualIID (riid, &IID_IDirectMusicScript)) {
|
|
|
|
*ppobj = (LPVOID)&This->ScriptVtbl;
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicScript_AddRef ((LPDIRECTMUSICSCRIPT)&This->ScriptVtbl);
|
|
|
|
return S_OK;
|
|
|
|
} else if (IsEqualIID (riid, &IID_IDirectMusicObject)) {
|
|
|
|
*ppobj = (LPVOID)&This->ObjectVtbl;
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicObject_AddRef ((LPDIRECTMUSICOBJECT)&This->ObjectVtbl);
|
|
|
|
return S_OK;
|
|
|
|
} else if (IsEqualIID (riid, &IID_IPersistStream)) {
|
|
|
|
*ppobj = (LPVOID)&This->PersistStreamVtbl;
|
|
|
|
IDirectMusicScriptImpl_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj);
|
|
|
|
return E_NOINTERFACE;
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static ULONG WINAPI IDirectMusicScriptImpl_IUnknown_AddRef (LPUNKNOWN iface) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, UnknownVtbl, iface);
|
2005-01-24 11:31:45 +00:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-08 21:52:35 +00:00
|
|
|
TRACE("(%p): AddRef from %d\n", This, ref - 1);
|
2005-01-24 11:31:45 +00:00
|
|
|
|
2005-02-02 09:31:28 +00:00
|
|
|
DMSCRIPT_LockModule();
|
|
|
|
|
2005-01-24 11:31:45 +00:00
|
|
|
return ref;
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static ULONG WINAPI IDirectMusicScriptImpl_IUnknown_Release (LPUNKNOWN iface) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, UnknownVtbl, iface);
|
2005-01-24 11:31:45 +00:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-08 21:52:35 +00:00
|
|
|
TRACE("(%p): ReleaseRef to %d\n", This, ref);
|
2005-01-24 11:31:45 +00:00
|
|
|
|
2004-05-10 19:56:17 +00:00
|
|
|
if (ref == 0) {
|
2004-12-23 17:06:43 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->pHeader);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->pVersion);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->pwzLanguage);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->pwzSource);
|
2004-05-10 19:56:17 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
2005-02-02 09:31:28 +00:00
|
|
|
|
|
|
|
DMSCRIPT_UnlockModule();
|
|
|
|
|
2004-05-10 19:56:17 +00:00
|
|
|
return ref;
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2005-05-30 10:01:08 +00:00
|
|
|
static const IUnknownVtbl DirectMusicScript_Unknown_Vtbl = {
|
2004-05-10 19:56:17 +00:00
|
|
|
IDirectMusicScriptImpl_IUnknown_QueryInterface,
|
|
|
|
IDirectMusicScriptImpl_IUnknown_AddRef,
|
|
|
|
IDirectMusicScriptImpl_IUnknown_Release
|
2004-01-20 00:21:40 +00:00
|
|
|
};
|
2003-07-21 22:10:14 +00:00
|
|
|
|
2004-01-20 00:21:40 +00:00
|
|
|
/* IDirectMusicScriptImpl IDirectMusicScript part: */
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_QueryInterface (LPDIRECTMUSICSCRIPT iface, REFIID riid, LPVOID *ppobj) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface);
|
|
|
|
return IDirectMusicScriptImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static ULONG WINAPI IDirectMusicScriptImpl_IDirectMusicScript_AddRef (LPDIRECTMUSICSCRIPT iface) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface);
|
|
|
|
return IDirectMusicScriptImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
2004-01-20 00:21:40 +00:00
|
|
|
}
|
2003-07-21 22:10:14 +00:00
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static ULONG WINAPI IDirectMusicScriptImpl_IDirectMusicScript_Release (LPDIRECTMUSICSCRIPT iface) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface);
|
|
|
|
return IDirectMusicScriptImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
|
2004-01-20 00:21:40 +00:00
|
|
|
}
|
2003-07-21 22:10:14 +00:00
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_Init (LPDIRECTMUSICSCRIPT iface, IDirectMusicPerformance* pPerformance, DMUS_SCRIPT_ERRORINFO* pErrorInfo) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface);
|
|
|
|
FIXME("(%p, %p, %p): stub\n", This, pPerformance, pErrorInfo);
|
|
|
|
This->pPerformance = pPerformance;
|
|
|
|
return S_OK;
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_CallRoutine (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszRoutineName, DMUS_SCRIPT_ERRORINFO* pErrorInfo) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface);
|
|
|
|
FIXME("(%p, %s, %p): stub\n", This, debugstr_w(pwszRoutineName), pErrorInfo);
|
|
|
|
/*return E_NOTIMPL;*/
|
2004-05-11 22:18:43 +00:00
|
|
|
return S_OK;
|
|
|
|
/*return E_FAIL;*/
|
2004-01-20 00:21:40 +00:00
|
|
|
}
|
2003-07-21 22:10:14 +00:00
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_SetVariableVariant (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, VARIANT varValue, BOOL fSetRef, DMUS_SCRIPT_ERRORINFO* pErrorInfo) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface);
|
|
|
|
FIXME("(%p, %s, FIXME, %d, %p): stub\n", This, debugstr_w(pwszVariableName),/* varValue,*/ fSetRef, pErrorInfo);
|
|
|
|
return S_OK;
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_GetVariableVariant (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, VARIANT* pvarValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface);
|
|
|
|
FIXME("(%p, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), pvarValue, pErrorInfo);
|
|
|
|
return S_OK;
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_SetVariableNumber (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, LONG lValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface);
|
2006-10-08 21:52:35 +00:00
|
|
|
FIXME("(%p, %s, %i, %p): stub\n", This, debugstr_w(pwszVariableName), lValue, pErrorInfo);
|
2004-05-10 19:56:17 +00:00
|
|
|
return S_OK;
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_GetVariableNumber (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, LONG* plValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface);
|
|
|
|
FIXME("(%p, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), plValue, pErrorInfo);
|
|
|
|
return S_OK;
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_SetVariableObject (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, IUnknown* punkValue, DMUS_SCRIPT_ERRORINFO* pErrorInfo) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface);
|
|
|
|
FIXME("(%p, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), punkValue, pErrorInfo);
|
|
|
|
return S_OK;
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_GetVariableObject (LPDIRECTMUSICSCRIPT iface, WCHAR* pwszVariableName, REFIID riid, LPVOID* ppv, DMUS_SCRIPT_ERRORINFO* pErrorInfo) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface);
|
|
|
|
FIXME("(%p, %s, %s, %p, %p): stub\n", This, debugstr_w(pwszVariableName), debugstr_dmguid(riid), ppv, pErrorInfo);
|
|
|
|
return S_OK;
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_EnumRoutine (LPDIRECTMUSICSCRIPT iface, DWORD dwIndex, WCHAR* pwszName) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface);
|
2006-10-08 21:52:35 +00:00
|
|
|
FIXME("(%p, %d, %p): stub\n", This, dwIndex, pwszName);
|
2004-05-10 19:56:17 +00:00
|
|
|
return S_OK;
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicScript_EnumVariable (LPDIRECTMUSICSCRIPT iface, DWORD dwIndex, WCHAR* pwszName) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ScriptVtbl, iface);
|
2006-10-08 21:52:35 +00:00
|
|
|
FIXME("(%p, %d, %p): stub\n", This, dwIndex, pwszName);
|
2004-05-10 19:56:17 +00:00
|
|
|
return S_OK;
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
|
|
|
|
2005-05-30 10:01:08 +00:00
|
|
|
static const IDirectMusicScriptVtbl DirectMusicScript_Script_Vtbl = {
|
2004-05-10 19:56:17 +00:00
|
|
|
IDirectMusicScriptImpl_IDirectMusicScript_QueryInterface,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicScript_AddRef,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicScript_Release,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicScript_Init,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicScript_CallRoutine,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicScript_SetVariableVariant,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicScript_GetVariableVariant,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicScript_SetVariableNumber,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicScript_GetVariableNumber,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicScript_SetVariableObject,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicScript_GetVariableObject,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicScript_EnumRoutine,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicScript_EnumVariable
|
2003-07-21 22:10:14 +00:00
|
|
|
};
|
|
|
|
|
2004-01-20 00:21:40 +00:00
|
|
|
/* IDirectMusicScriptImpl IDirectMusicObject part: */
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicObject_QueryInterface (LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ppobj) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface);
|
|
|
|
return IDirectMusicScriptImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
|
2003-07-21 22:10:14 +00:00
|
|
|
}
|
2003-08-22 23:53:27 +00:00
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static ULONG WINAPI IDirectMusicScriptImpl_IDirectMusicObject_AddRef (LPDIRECTMUSICOBJECT iface) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface);
|
|
|
|
return IDirectMusicScriptImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static ULONG WINAPI IDirectMusicScriptImpl_IDirectMusicObject_Release (LPDIRECTMUSICOBJECT iface) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface);
|
|
|
|
return IDirectMusicScriptImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicObject_GetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface);
|
|
|
|
TRACE("(%p, %p)\n", This, pDesc);
|
|
|
|
/* 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);
|
|
|
|
return S_OK;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicObject_SetDescriptor (LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface);
|
|
|
|
TRACE("(%p, %p): setting descriptor:\n%s\n", This, pDesc, debugstr_DMUS_OBJECTDESC (pDesc));
|
2008-02-25 19:48:22 +00:00
|
|
|
|
2004-05-10 19:56:17 +00:00
|
|
|
/* According to MSDN, we should copy only given values, not whole struct */
|
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
|
2008-02-25 19:48:22 +00:00
|
|
|
This->pDesc->guidObject = pDesc->guidObject;
|
2004-05-10 19:56:17 +00:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_CLASS)
|
2008-02-25 19:48:22 +00:00
|
|
|
This->pDesc->guidClass = pDesc->guidClass;
|
2004-05-10 19:56:17 +00:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_NAME)
|
2005-04-18 10:30:55 +00:00
|
|
|
lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
|
2004-05-10 19:56:17 +00:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
|
2005-04-18 10:30:55 +00:00
|
|
|
lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
|
2004-05-10 19:56:17 +00:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
|
2005-04-18 10:30:55 +00:00
|
|
|
lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
|
2004-05-10 19:56:17 +00:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_VERSION)
|
2008-02-25 19:48:22 +00:00
|
|
|
This->pDesc->vVersion = pDesc->vVersion;
|
2004-05-10 19:56:17 +00:00
|
|
|
if (pDesc->dwValidData & DMUS_OBJ_DATE)
|
2008-02-25 19:48:22 +00:00
|
|
|
This->pDesc->ftDate = pDesc->ftDate;
|
2004-05-10 19:56:17 +00: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;
|
|
|
|
|
|
|
|
return S_OK;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IDirectMusicObject_ParseDescriptor (LPDIRECTMUSICOBJECT iface, LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) {
|
2004-05-10 19:56:17 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, ObjectVtbl, iface);
|
|
|
|
DMUS_PRIVATE_CHUNK Chunk;
|
|
|
|
DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
|
|
|
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
2008-02-25 19:48:22 +00:00
|
|
|
|
2004-01-20 00:21:40 +00:00
|
|
|
TRACE("(%p, %p, %p)\n", This, pStream, pDesc);
|
2008-02-25 19:48:22 +00:00
|
|
|
|
2004-01-20 00:21:40 +00:00
|
|
|
/* FIXME: should this be determined from stream? */
|
|
|
|
pDesc->dwValidData |= DMUS_OBJ_CLASS;
|
2008-02-25 19:48:22 +00:00
|
|
|
pDesc->guidClass = CLSID_DirectMusicScript;
|
|
|
|
|
2004-01-20 00:21:40 +00:00
|
|
|
IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
2006-10-08 21:52:35 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-01-20 00:21:40 +00:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case FOURCC_RIFF: {
|
|
|
|
IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
|
|
|
|
TRACE_(dmfile)(": RIFF chunk of type %s", debugstr_fourcc(Chunk.fccID));
|
|
|
|
StreamSize = Chunk.dwSize - sizeof(FOURCC);
|
|
|
|
StreamCount = 0;
|
|
|
|
if (Chunk.fccID == DMUS_FOURCC_SCRIPT_FORM) {
|
|
|
|
TRACE_(dmfile)(": script form\n");
|
|
|
|
do {
|
|
|
|
IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-08 21:52:35 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-01-20 00:21:40 +00:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
case DMUS_FOURCC_GUID_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": GUID chunk\n");
|
|
|
|
pDesc->dwValidData |= DMUS_OBJ_OBJECT;
|
|
|
|
IStream_Read (pStream, &pDesc->guidObject, Chunk.dwSize, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_VERSION_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": version chunk\n");
|
|
|
|
pDesc->dwValidData |= DMUS_OBJ_VERSION;
|
|
|
|
IStream_Read (pStream, &pDesc->vVersion, Chunk.dwSize, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_CATEGORY_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": category chunk\n");
|
|
|
|
pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
|
|
|
|
IStream_Read (pStream, pDesc->wszCategory, Chunk.dwSize, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FOURCC_LIST: {
|
|
|
|
IStream_Read (pStream, &Chunk.fccID, sizeof(FOURCC), NULL);
|
|
|
|
TRACE_(dmfile)(": LIST chunk of type %s", debugstr_fourcc(Chunk.fccID));
|
|
|
|
ListSize[0] = Chunk.dwSize - sizeof(FOURCC);
|
|
|
|
ListCount[0] = 0;
|
|
|
|
switch (Chunk.fccID) {
|
|
|
|
/* evil M$ UNFO list, which can (!?) contain INFO elements */
|
|
|
|
case DMUS_FOURCC_UNFO_LIST: {
|
|
|
|
TRACE_(dmfile)(": UNFO list\n");
|
|
|
|
do {
|
|
|
|
IStream_Read (pStream, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-08 21:52:35 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = 0x%04x)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-01-20 00:21:40 +00:00
|
|
|
switch (Chunk.fccID) {
|
|
|
|
/* don't ask me why, but M$ puts INFO elements in UNFO list sometimes
|
|
|
|
(though strings seem to be valid unicode) */
|
|
|
|
case mmioFOURCC('I','N','A','M'):
|
|
|
|
case DMUS_FOURCC_UNAM_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": name chunk\n");
|
|
|
|
pDesc->dwValidData |= DMUS_OBJ_NAME;
|
|
|
|
IStream_Read (pStream, pDesc->wszName, Chunk.dwSize, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case mmioFOURCC('I','A','R','T'):
|
|
|
|
case DMUS_FOURCC_UART_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": artist chunk (ignored)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case mmioFOURCC('I','C','O','P'):
|
|
|
|
case DMUS_FOURCC_UCOP_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": copyright chunk (ignored)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
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-08 21:52:35 +00:00
|
|
|
TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
|
2004-01-20 00:21:40 +00:00
|
|
|
} while (ListCount[0] < ListSize[0]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown (skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-08 21:52:35 +00:00
|
|
|
TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
|
2004-01-20 00:21:40 +00:00
|
|
|
} while (StreamCount < StreamSize);
|
|
|
|
} else {
|
|
|
|
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
|
|
|
|
liMove.QuadPart = StreamSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE_(dmfile)(": reading finished\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unexpected chunk; loading failed)\n");
|
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
|
|
|
IStream_Seek (pStream, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
|
|
|
|
return DMUS_E_INVALIDFILE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-25 01:30:03 +00:00
|
|
|
TRACE(": returning descriptor:\n%s\n", debugstr_DMUS_OBJECTDESC (pDesc));
|
2004-01-20 00:21:40 +00:00
|
|
|
|
2003-08-22 23:53:27 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-05-30 10:01:08 +00:00
|
|
|
static const IDirectMusicObjectVtbl DirectMusicScript_Object_Vtbl = {
|
2004-05-11 22:18:43 +00:00
|
|
|
IDirectMusicScriptImpl_IDirectMusicObject_QueryInterface,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicObject_AddRef,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicObject_Release,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicObject_GetDescriptor,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicObject_SetDescriptor,
|
|
|
|
IDirectMusicScriptImpl_IDirectMusicObject_ParseDescriptor
|
2003-08-22 23:53:27 +00:00
|
|
|
};
|
|
|
|
|
2004-01-20 00:21:40 +00:00
|
|
|
/* IDirectMusicScriptImpl IPersistStream part: */
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) {
|
2004-05-11 22:18:43 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, PersistStreamVtbl, iface);
|
|
|
|
return IDirectMusicScriptImpl_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj);
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static ULONG WINAPI IDirectMusicScriptImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface) {
|
2004-05-11 22:18:43 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, PersistStreamVtbl, iface);
|
|
|
|
return IDirectMusicScriptImpl_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl);
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static ULONG WINAPI IDirectMusicScriptImpl_IPersistStream_Release (LPPERSISTSTREAM iface) {
|
2004-05-11 22:18:43 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, PersistStreamVtbl, iface);
|
|
|
|
return IDirectMusicScriptImpl_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl);
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) {
|
2004-05-11 22:18:43 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, PersistStreamVtbl, iface);
|
|
|
|
TRACE("(%p, %p)\n", This, pClassID);
|
2008-02-25 19:48:22 +00:00
|
|
|
*pClassID = CLSID_DirectMusicScript;
|
2004-05-11 22:18:43 +00:00
|
|
|
return S_OK;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IPersistStream_IsDirty (LPPERSISTSTREAM iface) {
|
2004-05-11 22:18:43 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, PersistStreamVtbl, iface);
|
|
|
|
FIXME("(%p): stub, always S_FALSE\n", This);
|
|
|
|
return S_FALSE;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) {
|
2004-01-20 00:21:40 +00:00
|
|
|
ICOM_THIS_MULTI(IDirectMusicScriptImpl, PersistStreamVtbl, iface);
|
|
|
|
|
2004-03-09 19:21:33 +00:00
|
|
|
DMUS_PRIVATE_CHUNK Chunk;
|
|
|
|
DWORD StreamSize, StreamCount, ListSize[3], ListCount[3];
|
2004-01-20 00:21:40 +00:00
|
|
|
LARGE_INTEGER liMove; /* used when skipping chunks */
|
2004-03-12 01:53:05 +00:00
|
|
|
LPDIRECTMUSICGETLOADER pGetLoader = NULL;
|
|
|
|
LPDIRECTMUSICLOADER pLoader = NULL;
|
2004-01-20 00:21:40 +00:00
|
|
|
|
|
|
|
FIXME("(%p, %p): Loading not implemented yet\n", This, pStm);
|
2004-03-09 19:21:33 +00:00
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
2006-10-08 21:52:35 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-03-09 19:21:33 +00:00
|
|
|
switch (Chunk.fccID) {
|
2004-01-20 00:21:40 +00:00
|
|
|
case FOURCC_RIFF: {
|
2004-03-09 19:21:33 +00: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 00:21:40 +00:00
|
|
|
StreamCount = 0;
|
2004-03-09 19:21:33 +00:00
|
|
|
switch (Chunk.fccID) {
|
2004-01-20 00:21:40 +00:00
|
|
|
case DMUS_FOURCC_SCRIPT_FORM: {
|
|
|
|
TRACE_(dmfile)(": script form\n");
|
|
|
|
do {
|
2004-03-09 19:21:33 +00:00
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
StreamCount += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-08 21:52:35 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-03-09 19:21:33 +00: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 21:52:35 +00:00
|
|
|
TRACE_(dmfile)("version: 0x%08x.0x%08x\n", This->pVersion->dwVersionMS, This->pVersion->dwVersionLS);
|
2004-03-09 19:21:33 +00: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 12:14:56 +00:00
|
|
|
TRACE_(dmfile)("using language: %s\n", debugstr_w(This->pwzLanguage));
|
2004-03-09 19:21:33 +00: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");
|
|
|
|
write( 2, str, count );
|
|
|
|
HeapFree(GetProcessHeap(), 0, str);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2004-01-20 00:21:40 +00:00
|
|
|
case DMUS_FOURCC_GUID_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": GUID chunk\n");
|
|
|
|
This->pDesc->dwValidData |= DMUS_OBJ_OBJECT;
|
2004-03-09 19:21:33 +00:00
|
|
|
IStream_Read (pStm, &This->pDesc->guidObject, Chunk.dwSize, NULL);
|
2004-01-20 00:21:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_VERSION_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": version chunk\n");
|
|
|
|
This->pDesc->dwValidData |= DMUS_OBJ_VERSION;
|
2004-03-09 19:21:33 +00:00
|
|
|
IStream_Read (pStm, &This->pDesc->vVersion, Chunk.dwSize, NULL);
|
2004-01-20 00:21:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DMUS_FOURCC_CATEGORY_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": category chunk\n");
|
|
|
|
This->pDesc->dwValidData |= DMUS_OBJ_CATEGORY;
|
2004-03-09 19:21:33 +00:00
|
|
|
IStream_Read (pStm, This->pDesc->wszCategory, Chunk.dwSize, NULL);
|
2004-01-20 00:21:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-03-12 01:53:05 +00:00
|
|
|
case FOURCC_RIFF: {
|
|
|
|
IDirectMusicObject* pObject = NULL;
|
|
|
|
DMUS_OBJECTDESC desc;
|
2004-04-02 19:14:08 +00:00
|
|
|
|
|
|
|
ZeroMemory ((LPVOID)&desc, sizeof(DMUS_OBJECTDESC));
|
|
|
|
desc.dwSize = sizeof(DMUS_OBJECTDESC);
|
2004-03-12 01:53:05 +00: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 00:21:40 +00:00
|
|
|
case FOURCC_LIST: {
|
2004-03-09 19:21:33 +00: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 00:21:40 +00:00
|
|
|
ListCount[0] = 0;
|
2004-03-09 19:21:33 +00:00
|
|
|
switch (Chunk.fccID) {
|
2004-01-20 00:21:40 +00:00
|
|
|
case DMUS_FOURCC_UNFO_LIST: {
|
|
|
|
TRACE_(dmfile)(": UNFO list\n");
|
|
|
|
do {
|
2004-03-09 19:21:33 +00:00
|
|
|
IStream_Read (pStm, &Chunk, sizeof(FOURCC)+sizeof(DWORD), NULL);
|
|
|
|
ListCount[0] += sizeof(FOURCC) + sizeof(DWORD) + Chunk.dwSize;
|
2006-10-08 21:52:35 +00:00
|
|
|
TRACE_(dmfile)(": %s chunk (size = %d)", debugstr_fourcc (Chunk.fccID), Chunk.dwSize);
|
2004-03-09 19:21:33 +00:00
|
|
|
switch (Chunk.fccID) {
|
2004-01-20 00:21:40 +00: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");
|
|
|
|
This->pDesc->dwValidData |= DMUS_OBJ_NAME;
|
2004-03-09 19:21:33 +00:00
|
|
|
IStream_Read (pStm, This->pDesc->wszName, Chunk.dwSize, NULL);
|
2004-01-20 00:21:40 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case mmioFOURCC('I','A','R','T'):
|
|
|
|
case DMUS_FOURCC_UART_CHUNK: {
|
|
|
|
TRACE_(dmfile)(": artist chunk (ignored)\n");
|
2004-03-09 19:21:33 +00:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-01-20 00:21:40 +00: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 19:21:33 +00:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-01-20 00:21:40 +00: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 19:21:33 +00:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-01-20 00:21:40 +00: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 19:21:33 +00:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-01-20 00:21:40 +00:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2004-03-12 01:53:05 +00:00
|
|
|
TRACE_(dmfile)(": unknown sub-chunk (irrevelant & skipping)\n");
|
2004-03-09 19:21:33 +00:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-01-20 00:21:40 +00:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-08 21:52:35 +00:00
|
|
|
TRACE_(dmfile)(": ListCount[0] = %d < ListSize[0] = %d\n", ListCount[0], ListSize[0]);
|
2004-01-20 00:21:40 +00:00
|
|
|
} while (ListCount[0] < ListSize[0]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown (skipping)\n");
|
2004-03-09 19:21:33 +00:00
|
|
|
liMove.QuadPart = Chunk.dwSize - sizeof(FOURCC);
|
2004-01-20 00:21:40 +00:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
TRACE_(dmfile)(": unknown chunk (irrevelant & skipping)\n");
|
2004-03-09 19:21:33 +00:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-01-20 00:21:40 +00:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-08 21:52:35 +00:00
|
|
|
TRACE_(dmfile)(": StreamCount[0] = %d < StreamSize[0] = %d\n", StreamCount, StreamSize);
|
2004-01-20 00:21:40 +00: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 19:21:33 +00:00
|
|
|
liMove.QuadPart = Chunk.dwSize;
|
2004-01-20 00:21:40 +00:00
|
|
|
IStream_Seek (pStm, liMove, STREAM_SEEK_CUR, NULL); /* skip the rest of the chunk */
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-22 23:53:27 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) {
|
2004-05-10 19:56:17 +00:00
|
|
|
return E_NOTIMPL;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-10 09:56:19 +00:00
|
|
|
static HRESULT WINAPI IDirectMusicScriptImpl_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) {
|
2004-05-10 19:56:17 +00:00
|
|
|
return E_NOTIMPL;
|
2003-08-22 23:53:27 +00:00
|
|
|
}
|
|
|
|
|
2005-05-30 10:01:08 +00:00
|
|
|
static const IPersistStreamVtbl DirectMusicScript_PersistStream_Vtbl = {
|
2004-05-10 19:56:17 +00:00
|
|
|
IDirectMusicScriptImpl_IPersistStream_QueryInterface,
|
|
|
|
IDirectMusicScriptImpl_IPersistStream_AddRef,
|
|
|
|
IDirectMusicScriptImpl_IPersistStream_Release,
|
|
|
|
IDirectMusicScriptImpl_IPersistStream_GetClassID,
|
|
|
|
IDirectMusicScriptImpl_IPersistStream_IsDirty,
|
|
|
|
IDirectMusicScriptImpl_IPersistStream_Load,
|
|
|
|
IDirectMusicScriptImpl_IPersistStream_Save,
|
|
|
|
IDirectMusicScriptImpl_IPersistStream_GetSizeMax
|
2003-08-22 23:53:27 +00:00
|
|
|
};
|
2004-01-20 00:21:40 +00:00
|
|
|
|
|
|
|
/* for ClassFactory */
|
|
|
|
HRESULT WINAPI DMUSIC_CreateDirectMusicScriptImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
|
2004-05-10 19:56:17 +00:00
|
|
|
IDirectMusicScriptImpl* obj;
|
|
|
|
|
|
|
|
obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicScriptImpl));
|
|
|
|
if (NULL == obj) {
|
2005-01-26 20:40:49 +00:00
|
|
|
*ppobj = NULL;
|
2004-05-10 19:56:17 +00:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
obj->UnknownVtbl = &DirectMusicScript_Unknown_Vtbl;
|
|
|
|
obj->ScriptVtbl = &DirectMusicScript_Script_Vtbl;
|
|
|
|
obj->ObjectVtbl = &DirectMusicScript_Object_Vtbl;
|
|
|
|
obj->PersistStreamVtbl = &DirectMusicScript_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 19:48:22 +00:00
|
|
|
obj->pDesc->guidClass = CLSID_DirectMusicScript;
|
2004-05-10 19:56:17 +00:00
|
|
|
obj->ref = 0; /* will be inited by QueryInterface */
|
2008-02-25 19:48:22 +00:00
|
|
|
|
2004-05-10 19:56:17 +00:00
|
|
|
return IDirectMusicScriptImpl_IUnknown_QueryInterface ((LPUNKNOWN)&obj->UnknownVtbl, lpcGUID, ppobj);
|
2004-01-20 00:21:40 +00:00
|
|
|
}
|