* Sync with Wine 1.7.27.
CORE-8540

svn path=/trunk/; revision=64300
This commit is contained in:
Amine Khaldi 2014-09-26 09:19:09 +00:00
parent 98c5be0de9
commit 03c321a925
12 changed files with 351 additions and 269 deletions

View file

@ -7,6 +7,7 @@ list(APPEND SOURCE
buffer.c
clock.c
collection.c
dmobject.c
dmusic.c
dmusic_main.c
download.c

View file

@ -55,8 +55,6 @@ static ULONG WINAPI IDirectMusicBufferImpl_AddRef(LPDIRECTMUSICBUFFER iface)
TRACE("(%p)->(): new ref = %u\n", iface, ref);
DMUSIC_LockModule();
return ref;
}
@ -70,9 +68,8 @@ static ULONG WINAPI IDirectMusicBufferImpl_Release(LPDIRECTMUSICBUFFER iface)
if (!ref) {
HeapFree(GetProcessHeap(), 0, This->data);
HeapFree(GetProcessHeap(), 0, This);
}
DMUSIC_UnlockModule();
}
return ref;
}
@ -277,7 +274,6 @@ static const IDirectMusicBufferVtbl DirectMusicBuffer_Vtbl = {
HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface)
{
IDirectMusicBufferImpl* dmbuffer;
HRESULT hr;
TRACE("(%p, %p)\n", desc, ret_iface);
@ -288,7 +284,7 @@ HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_i
return E_OUTOFMEMORY;
dmbuffer->IDirectMusicBuffer_iface.lpVtbl = &DirectMusicBuffer_Vtbl;
dmbuffer->ref = 0; /* Will be inited by QueryInterface */
dmbuffer->ref = 1;
if (IsEqualGUID(&desc->guidBufferFormat, &GUID_NULL))
dmbuffer->format = KSDATAFORMAT_SUBTYPE_MIDI;
@ -302,12 +298,8 @@ HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_i
return E_OUTOFMEMORY;
}
hr = IDirectMusicBufferImpl_QueryInterface((LPDIRECTMUSICBUFFER)dmbuffer, &IID_IDirectMusicBuffer, ret_iface);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, dmbuffer->data);
HeapFree(GetProcessHeap(), 0, dmbuffer);
}
DMUSIC_LockModule();
*ret_iface = &dmbuffer->IDirectMusicBuffer_iface;
return hr;
return S_OK;
}

View file

@ -48,8 +48,6 @@ static ULONG WINAPI IReferenceClockImpl_AddRef(IReferenceClock *iface)
TRACE("(%p)->(): new ref = %u\n", This, ref);
DMUSIC_LockModule();
return ref;
}
@ -60,10 +58,10 @@ static ULONG WINAPI IReferenceClockImpl_Release(IReferenceClock *iface)
TRACE("(%p)->(): new ref = %u\n", This, ref);
if (!ref)
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
DMUSIC_UnlockModule();
}
return ref;
}
@ -121,6 +119,7 @@ static const IReferenceClockVtbl ReferenceClock_Vtbl = {
HRESULT DMUSIC_CreateReferenceClockImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNOWN unkouter)
{
IReferenceClockImpl* clock;
HRESULT hr;
TRACE("(%p,%p,%p)\n", riid, ret_iface, unkouter);
@ -131,9 +130,13 @@ HRESULT DMUSIC_CreateReferenceClockImpl(LPCGUID riid, LPVOID* ret_iface, LPUNKNO
}
clock->IReferenceClock_iface.lpVtbl = &ReferenceClock_Vtbl;
clock->ref = 0; /* Will be inited by QueryInterface */
clock->ref = 1;
clock->rtTime = 0;
clock->pClockInfo.dwSize = sizeof (DMUS_CLOCKINFO);
return IReferenceClockImpl_QueryInterface((IReferenceClock*)clock, riid, ret_iface);
DMUSIC_LockModule();
hr = IReferenceClockImpl_QueryInterface(&clock->IReferenceClock_iface, riid, ret_iface);
IReferenceClockImpl_Release(&clock->IReferenceClock_iface);
return hr;
}

View file

@ -24,26 +24,44 @@
WINE_DECLARE_DEBUG_CHANNEL(dmfile);
/*****************************************************************************
* IDirectMusicCollectionImpl implementation
*/
typedef struct IDirectMusicCollectionImpl {
IDirectMusicCollection IDirectMusicCollection_iface;
struct dmobject dmobj;
LONG ref;
/* IDirectMusicCollectionImpl fields */
IStream *pStm; /* stream from which we load collection and later instruments */
LARGE_INTEGER liCollectionPosition; /* offset in a stream where collection was loaded from */
LARGE_INTEGER liWavePoolTablePosition; /* offset in a stream where wave pool table can be found */
CHAR *szCopyright; /* FIXME: should probably be placed somewhere else */
DLSHEADER *pHeader;
/* pool table */
POOLTABLE *pPoolTable;
POOLCUE *pPoolCues;
/* instruments */
struct list Instruments;
} IDirectMusicCollectionImpl;
static inline IDirectMusicCollectionImpl *impl_from_IDirectMusicCollection(IDirectMusicCollection *iface)
{
return CONTAINING_RECORD(iface, IDirectMusicCollectionImpl, IDirectMusicCollection_iface);
}
static inline IDirectMusicCollectionImpl *impl_from_IDirectMusicObject(IDirectMusicObject *iface)
static inline struct dmobject *impl_from_IDirectMusicObject(IDirectMusicObject *iface)
{
return CONTAINING_RECORD(iface, IDirectMusicCollectionImpl, IDirectMusicObject_iface);
return CONTAINING_RECORD(iface, struct dmobject, IDirectMusicObject_iface);
}
static inline IDirectMusicCollectionImpl *impl_from_IPersistStream(IPersistStream *iface)
{
return CONTAINING_RECORD(iface, IDirectMusicCollectionImpl, IPersistStream_iface);
return CONTAINING_RECORD(iface, IDirectMusicCollectionImpl, dmobj.IPersistStream_iface);
}
/*****************************************************************************
* IDirectMusicCollectionImpl implementation
*/
/* IDirectMusicCollectionImpl IUnknown part: */
static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_QueryInterface(LPDIRECTMUSICCOLLECTION iface, REFIID riid, LPVOID *ret_iface)
static HRESULT WINAPI IDirectMusicCollectionImpl_QueryInterface(IDirectMusicCollection *iface,
REFIID riid, void **ret_iface)
{
IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
@ -54,9 +72,9 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_QueryInt
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicCollection))
*ret_iface = iface;
else if (IsEqualIID(riid, &IID_IDirectMusicObject))
*ret_iface = &This->IDirectMusicObject_iface;
*ret_iface = &This->dmobj.IDirectMusicObject_iface;
else if (IsEqualIID(riid, &IID_IPersistStream))
*ret_iface = &This->IPersistStream_iface;
*ret_iface = &This->dmobj.IPersistStream_iface;
else
{
WARN("(%p/%p)->(%s, %p): not found\n", iface, This, debugstr_dmguid(riid), ret_iface);
@ -67,35 +85,34 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_QueryInt
return S_OK;
}
static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_AddRef(LPDIRECTMUSICCOLLECTION iface)
static ULONG WINAPI IDirectMusicCollectionImpl_AddRef(IDirectMusicCollection *iface)
{
IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref);
DMUSIC_LockModule();
return ref;
}
static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_Release(LPDIRECTMUSICCOLLECTION iface)
static ULONG WINAPI IDirectMusicCollectionImpl_Release(IDirectMusicCollection *iface)
{
IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p/%p)->(): new ref = %u\n", iface, This, ref);
if (!ref)
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
DMUSIC_UnlockModule();
}
return ref;
}
/* IDirectMusicCollection Interface follows: */
static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_GetInstrument(LPDIRECTMUSICCOLLECTION iface, DWORD patch, IDirectMusicInstrument** instrument)
static HRESULT WINAPI IDirectMusicCollectionImpl_GetInstrument(IDirectMusicCollection *iface,
DWORD patch, IDirectMusicInstrument **instrument)
{
IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
DMUS_PRIVATE_INSTRUMENTENTRY *inst_entry;
@ -121,7 +138,8 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_GetInstr
return DMUS_E_INVALIDPATCH;
}
static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_EnumInstrument(LPDIRECTMUSICCOLLECTION iface, DWORD index, DWORD* patch, LPWSTR name, DWORD name_length)
static HRESULT WINAPI IDirectMusicCollectionImpl_EnumInstrument(IDirectMusicCollection *iface,
DWORD index, DWORD *patch, LPWSTR name, DWORD name_length)
{
IDirectMusicCollectionImpl *This = impl_from_IDirectMusicCollection(iface);
DWORD i = 0;
@ -150,96 +168,14 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicCollection_EnumInst
}
static const IDirectMusicCollectionVtbl DirectMusicCollection_Collection_Vtbl = {
IDirectMusicCollectionImpl_IDirectMusicCollection_QueryInterface,
IDirectMusicCollectionImpl_IDirectMusicCollection_AddRef,
IDirectMusicCollectionImpl_IDirectMusicCollection_Release,
IDirectMusicCollectionImpl_IDirectMusicCollection_GetInstrument,
IDirectMusicCollectionImpl_IDirectMusicCollection_EnumInstrument
IDirectMusicCollectionImpl_QueryInterface,
IDirectMusicCollectionImpl_AddRef,
IDirectMusicCollectionImpl_Release,
IDirectMusicCollectionImpl_GetInstrument,
IDirectMusicCollectionImpl_EnumInstrument
};
/* IDirectMusicCollectionImpl IDirectMusicObject part: */
static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_QueryInterface(LPDIRECTMUSICOBJECT iface, REFIID riid, LPVOID *ret_iface)
{
IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
return IDirectMusicCollection_QueryInterface(&This->IDirectMusicCollection_iface, riid, ret_iface);
}
static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_AddRef(LPDIRECTMUSICOBJECT iface)
{
IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
return IDirectMusicCollection_AddRef(&This->IDirectMusicCollection_iface);
}
static ULONG WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_Release(LPDIRECTMUSICOBJECT iface)
{
IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
return IDirectMusicCollection_Release(&This->IDirectMusicCollection_iface);
}
static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_GetDescriptor(LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
{
IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
TRACE("(%p/%p)->(%p)\n", iface, This, pDesc);
if (!pDesc)
return E_POINTER;
memcpy (pDesc, This->pDesc, This->pDesc->dwSize);
return S_OK;
}
static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_SetDescriptor(LPDIRECTMUSICOBJECT iface, LPDMUS_OBJECTDESC pDesc)
{
IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
HRESULT ret = S_OK;
TRACE("(%p, %p)\n", iface, pDesc);
if (!pDesc)
return E_POINTER;
if (TRACE_ON(dmusic))
{
TRACE("Setting descriptor:\n");
dump_DMUS_OBJECTDESC(pDesc);
}
/* According to MSDN, we should copy only given values, not whole struct */
if (pDesc->dwValidData & DMUS_OBJ_OBJECT)
This->pDesc->guidObject = pDesc->guidObject;
if (pDesc->dwValidData & DMUS_OBJ_CLASS)
{
pDesc->dwValidData &= ~DMUS_OBJ_CLASS;
ret = S_FALSE;
}
if (pDesc->dwValidData & DMUS_OBJ_NAME)
lstrcpynW(This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
lstrcpynW(This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
lstrcpynW(This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
if (pDesc->dwValidData & DMUS_OBJ_VERSION)
This->pDesc->vVersion = pDesc->vVersion;
if (pDesc->dwValidData & DMUS_OBJ_DATE)
This->pDesc->ftDate = pDesc->ftDate;
if (pDesc->dwValidData & DMUS_OBJ_MEMORY) {
This->pDesc->llMemLength = pDesc->llMemLength;
memcpy (This->pDesc->pbMemData, pDesc->pbMemData, pDesc->llMemLength);
}
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 ret;
}
static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)
{
ULONG read;
@ -258,9 +194,10 @@ static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)
return S_OK;
}
static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_ParseDescriptor(LPDIRECTMUSICOBJECT iface, LPSTREAM stream, LPDMUS_OBJECTDESC desc)
static HRESULT WINAPI IDirectMusicObjectImpl_ParseDescriptor(IDirectMusicObject *iface,
IStream *stream, DMUS_OBJECTDESC *desc)
{
IDirectMusicCollectionImpl *This = impl_from_IDirectMusicObject(iface);
struct dmobject *This = impl_from_IDirectMusicObject(iface);
DMUS_PRIVATE_CHUNK chunk;
DWORD StreamSize, StreamCount, ListSize[1], ListCount[1];
LARGE_INTEGER liMove; /* used when skipping chunks */
@ -270,7 +207,7 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_ParseDescrip
/* FIXME: should this be determined from stream? */
desc->dwValidData |= DMUS_OBJ_CLASS;
desc->guidClass = This->pDesc->guidClass;
desc->guidClass = This->desc.guidClass;
hr = read_from_stream(stream, &chunk, sizeof(FOURCC) + sizeof(DWORD));
if (FAILED(hr))
@ -446,45 +383,18 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IDirectMusicObject_ParseDescrip
return S_OK;
}
static const IDirectMusicObjectVtbl DirectMusicCollection_Object_Vtbl = {
IDirectMusicCollectionImpl_IDirectMusicObject_QueryInterface,
IDirectMusicCollectionImpl_IDirectMusicObject_AddRef,
IDirectMusicCollectionImpl_IDirectMusicObject_Release,
IDirectMusicCollectionImpl_IDirectMusicObject_GetDescriptor,
IDirectMusicCollectionImpl_IDirectMusicObject_SetDescriptor,
IDirectMusicCollectionImpl_IDirectMusicObject_ParseDescriptor
static const IDirectMusicObjectVtbl dmobject_vtbl = {
dmobj_IDirectMusicObject_QueryInterface,
dmobj_IDirectMusicObject_AddRef,
dmobj_IDirectMusicObject_Release,
dmobj_IDirectMusicObject_GetDescriptor,
dmobj_IDirectMusicObject_SetDescriptor,
IDirectMusicObjectImpl_ParseDescriptor
};
/* IDirectMusicCollectionImpl IPersistStream part: */
static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_QueryInterface(LPPERSISTSTREAM iface, REFIID riid, LPVOID *ret_iface)
{
IDirectMusicCollectionImpl *This = impl_from_IPersistStream(iface);
return IDirectMusicCollection_QueryInterface(&This->IDirectMusicCollection_iface, riid, ret_iface);
}
static ULONG WINAPI IDirectMusicCollectionImpl_IPersistStream_AddRef (LPPERSISTSTREAM iface)
{
IDirectMusicCollectionImpl *This = impl_from_IPersistStream(iface);
return IDirectMusicCollection_AddRef(&This->IDirectMusicCollection_iface);
}
static ULONG WINAPI IDirectMusicCollectionImpl_IPersistStream_Release (LPPERSISTSTREAM iface)
{
IDirectMusicCollectionImpl *This = impl_from_IPersistStream(iface);
return IDirectMusicCollection_Release(&This->IDirectMusicCollection_iface);
}
static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_GetClassID(LPPERSISTSTREAM iface, CLSID* pClassID)
{
return E_NOTIMPL;
}
static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_IsDirty(LPPERSISTSTREAM iface)
{
return E_NOTIMPL;
}
static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load(LPPERSISTSTREAM iface, IStream* stream)
static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface,
IStream *stream)
{
IDirectMusicCollectionImpl *This = impl_from_IPersistStream(iface);
DMUS_PRIVATE_CHUNK chunk;
@ -534,14 +444,14 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load(LPPERSISTST
}
case FOURCC_DLID: {
TRACE_(dmfile)(": DLID (GUID) chunk\n");
This->pDesc->dwValidData |= DMUS_OBJ_OBJECT;
IStream_Read(stream, &This->pDesc->guidObject, chunk.dwSize, NULL);
This->dmobj.desc.dwValidData |= DMUS_OBJ_OBJECT;
IStream_Read(stream, &This->dmobj.desc.guidObject, chunk.dwSize, NULL);
break;
}
case FOURCC_VERS: {
TRACE_(dmfile)(": version chunk\n");
This->pDesc->dwValidData |= DMUS_OBJ_VERSION;
IStream_Read(stream, &This->pDesc->vVersion, chunk.dwSize, NULL);
This->dmobj.desc.dwValidData |= DMUS_OBJ_VERSION;
IStream_Read(stream, &This->dmobj.desc.vVersion, chunk.dwSize, NULL);
break;
}
case FOURCC_PTBL: {
@ -569,9 +479,9 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load(LPPERSISTST
case mmioFOURCC('I','N','A','M'): {
CHAR szName[DMUS_MAX_NAME];
TRACE_(dmfile)(": name chunk\n");
This->pDesc->dwValidData |= DMUS_OBJ_NAME;
This->dmobj.desc.dwValidData |= DMUS_OBJ_NAME;
IStream_Read(stream, szName, chunk.dwSize, NULL);
MultiByteToWideChar(CP_ACP, 0, szName, -1, This->pDesc->wszName, DMUS_MAX_NAME);
MultiByteToWideChar(CP_ACP, 0, szName, -1, This->dmobj.desc.wszName, DMUS_MAX_NAME);
if (even_or_odd(chunk.dwSize)) {
ListCount[0]++;
liMove.QuadPart = 1;
@ -765,13 +675,13 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load(LPPERSISTST
struct list *listEntry;
TRACE("*** IDirectMusicCollection (%p) ***\n", &This->IDirectMusicCollection_iface);
if (This->pDesc->dwValidData & DMUS_OBJ_OBJECT)
TRACE(" - GUID = %s\n", debugstr_dmguid(&This->pDesc->guidObject));
if (This->pDesc->dwValidData & DMUS_OBJ_VERSION)
TRACE(" - Version = %i,%i,%i,%i\n", (This->pDesc->vVersion.dwVersionMS >> 8) & 0x0000FFFF, This->pDesc->vVersion.dwVersionMS & 0x0000FFFF,
(This->pDesc->vVersion.dwVersionLS >> 8) & 0x0000FFFF, This->pDesc->vVersion.dwVersionLS & 0x0000FFFF);
if (This->pDesc->dwValidData & DMUS_OBJ_NAME)
TRACE(" - Name = %s\n", debugstr_w(This->pDesc->wszName));
if (This->dmobj.desc.dwValidData & DMUS_OBJ_OBJECT)
TRACE(" - GUID = %s\n", debugstr_dmguid(&This->dmobj.desc.guidObject));
if (This->dmobj.desc.dwValidData & DMUS_OBJ_VERSION)
TRACE(" - Version = %i,%i,%i,%i\n", (This->dmobj.desc.vVersion.dwVersionMS >> 8) & 0x0000FFFF, This->dmobj.desc.vVersion.dwVersionMS & 0x0000FFFF,
(This->dmobj.desc.vVersion.dwVersionLS >> 8) & 0x0000FFFF, This->dmobj.desc.vVersion.dwVersionLS & 0x0000FFFF);
if (This->dmobj.desc.dwValidData & DMUS_OBJ_NAME)
TRACE(" - Name = %s\n", debugstr_w(This->dmobj.desc.wszName));
TRACE(" - Collection header:\n");
TRACE(" - cInstruments: %d\n", This->pHeader->cInstruments);
@ -787,29 +697,18 @@ static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Load(LPPERSISTST
return S_OK;
}
static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_Save(LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty)
{
return E_NOTIMPL;
}
static HRESULT WINAPI IDirectMusicCollectionImpl_IPersistStream_GetSizeMax(LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize)
{
return E_NOTIMPL;
}
static const IPersistStreamVtbl DirectMusicCollection_PersistStream_Vtbl = {
IDirectMusicCollectionImpl_IPersistStream_QueryInterface,
IDirectMusicCollectionImpl_IPersistStream_AddRef,
IDirectMusicCollectionImpl_IPersistStream_Release,
IDirectMusicCollectionImpl_IPersistStream_GetClassID,
IDirectMusicCollectionImpl_IPersistStream_IsDirty,
IDirectMusicCollectionImpl_IPersistStream_Load,
IDirectMusicCollectionImpl_IPersistStream_Save,
IDirectMusicCollectionImpl_IPersistStream_GetSizeMax
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
};
/* for ClassFactory */
HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl(LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter)
{
IDirectMusicCollectionImpl* obj;
@ -824,15 +723,15 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl(LPCGUID lpcGUID, LPVOID* p
return E_OUTOFMEMORY;
obj->IDirectMusicCollection_iface.lpVtbl = &DirectMusicCollection_Collection_Vtbl;
obj->IDirectMusicObject_iface.lpVtbl = &DirectMusicCollection_Object_Vtbl;
obj->IPersistStream_iface.lpVtbl = &DirectMusicCollection_PersistStream_Vtbl;
obj->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC));
DM_STRUCT_INIT(obj->pDesc);
obj->pDesc->dwValidData |= DMUS_OBJ_CLASS;
obj->pDesc->guidClass = CLSID_DirectMusicCollection;
obj->ref = 1;
dmobject_init(&obj->dmobj, &CLSID_DirectMusicCollection,
(IUnknown*)&obj->IDirectMusicCollection_iface);
obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl;
obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
list_init (&obj->Instruments);
DMUSIC_LockModule();
hr = IDirectMusicCollection_QueryInterface(&obj->IDirectMusicCollection_iface, lpcGUID, ppobj);
IDirectMusicCollection_Release(&obj->IDirectMusicCollection_iface);

View file

@ -0,0 +1,164 @@
/*
* Base IDirectMusicObject Implementation
*
* Copyright (C) 2003-2004 Rok Mandeljc
* Copyright (C) 2014 Michael Stefaniuc
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* 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
*/
#include "dmusic_private.h"
/* Generic IDirectMusicObject methods */
static inline struct dmobject *impl_from_IDirectMusicObject(IDirectMusicObject *iface)
{
return CONTAINING_RECORD(iface, struct dmobject, IDirectMusicObject_iface);
}
HRESULT WINAPI dmobj_IDirectMusicObject_QueryInterface(IDirectMusicObject *iface, REFIID riid,
void **ret_iface)
{
struct dmobject *This = impl_from_IDirectMusicObject(iface);
return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface);
}
ULONG WINAPI dmobj_IDirectMusicObject_AddRef(IDirectMusicObject *iface)
{
struct dmobject *This = impl_from_IDirectMusicObject(iface);
return IUnknown_AddRef(This->outer_unk);
}
ULONG WINAPI dmobj_IDirectMusicObject_Release(IDirectMusicObject *iface)
{
struct dmobject *This = impl_from_IDirectMusicObject(iface);
return IUnknown_Release(This->outer_unk);
}
HRESULT WINAPI dmobj_IDirectMusicObject_GetDescriptor(IDirectMusicObject *iface,
DMUS_OBJECTDESC *desc)
{
struct dmobject *This = impl_from_IDirectMusicObject(iface);
TRACE("(%p/%p)->(%p)\n", iface, This, desc);
if (!desc)
return E_POINTER;
memcpy(desc, &This->desc, This->desc.dwSize);
return S_OK;
}
HRESULT WINAPI dmobj_IDirectMusicObject_SetDescriptor(IDirectMusicObject *iface,
DMUS_OBJECTDESC *desc)
{
struct dmobject *This = impl_from_IDirectMusicObject(iface);
HRESULT ret = S_OK;
TRACE("(%p, %p)\n", iface, desc);
if (!desc)
return E_POINTER;
/* Immutable property */
if (desc->dwValidData & DMUS_OBJ_CLASS)
{
desc->dwValidData &= ~DMUS_OBJ_CLASS;
ret = S_FALSE;
}
/* Set only valid fields */
if (desc->dwValidData & DMUS_OBJ_OBJECT)
This->desc.guidObject = desc->guidObject;
if (desc->dwValidData & DMUS_OBJ_NAME)
lstrcpynW(This->desc.wszName, desc->wszName, DMUS_MAX_NAME);
if (desc->dwValidData & DMUS_OBJ_CATEGORY)
lstrcpynW(This->desc.wszCategory, desc->wszCategory, DMUS_MAX_CATEGORY);
if (desc->dwValidData & DMUS_OBJ_FILENAME)
lstrcpynW(This->desc.wszFileName, desc->wszFileName, DMUS_MAX_FILENAME);
if (desc->dwValidData & DMUS_OBJ_VERSION)
This->desc.vVersion = desc->vVersion;
if (desc->dwValidData & DMUS_OBJ_DATE)
This->desc.ftDate = desc->ftDate;
if (desc->dwValidData & DMUS_OBJ_MEMORY) {
This->desc.llMemLength = desc->llMemLength;
memcpy(This->desc.pbMemData, desc->pbMemData, desc->llMemLength);
}
if (desc->dwValidData & DMUS_OBJ_STREAM)
IStream_Clone(desc->pStream, &This->desc.pStream);
This->desc.dwValidData |= desc->dwValidData;
return ret;
}
/* Generic IPersistStream methods */
static inline struct dmobject *impl_from_IPersistStream(IPersistStream *iface)
{
return CONTAINING_RECORD(iface, struct dmobject, IPersistStream_iface);
}
HRESULT WINAPI dmobj_IPersistStream_QueryInterface(IPersistStream *iface, REFIID riid,
void **ret_iface)
{
struct dmobject *This = impl_from_IPersistStream(iface);
return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface);
}
ULONG WINAPI dmobj_IPersistStream_AddRef(IPersistStream *iface)
{
struct dmobject *This = impl_from_IPersistStream(iface);
return IUnknown_AddRef(This->outer_unk);
}
ULONG WINAPI dmobj_IPersistStream_Release(IPersistStream *iface)
{
struct dmobject *This = impl_from_IPersistStream(iface);
return IUnknown_Release(This->outer_unk);
}
/* IPersistStream methods not implemented in native */
HRESULT WINAPI unimpl_IPersistStream_GetClassID(IPersistStream *iface, CLSID *class)
{
TRACE("(%p, %p): method not implemented\n", iface, class);
return E_NOTIMPL;
}
HRESULT WINAPI unimpl_IPersistStream_IsDirty(IPersistStream *iface)
{
TRACE("(%p): method not implemented, always returning S_FALSE\n", iface);
return S_FALSE;
}
HRESULT WINAPI unimpl_IPersistStream_Save(IPersistStream *iface, IStream *stream,
BOOL clear_dirty)
{
TRACE("(%p, %p, %d): method not implemented\n", iface, stream, clear_dirty);
return E_NOTIMPL;
}
HRESULT WINAPI unimpl_IPersistStream_GetSizeMax(IPersistStream *iface, ULARGE_INTEGER *size)
{
TRACE("(%p, %p): method not implemented\n", iface, size);
return E_NOTIMPL;
}
void dmobject_init(struct dmobject *dmobj, const GUID *class, IUnknown *outer_unk)
{
dmobj->outer_unk = outer_unk;
dmobj->desc.dwSize = sizeof(dmobj->desc);
dmobj->desc.dwValidData = DMUS_OBJ_CLASS;
dmobj->desc.guidClass = *class;
}

View file

@ -0,0 +1,55 @@
/*
* Base IDirectMusicObject Implementation
*
* Copyright (C) 2014 Michael Stefaniuc
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* 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
*/
#pragma once
struct dmobject {
IDirectMusicObject IDirectMusicObject_iface;
IPersistStream IPersistStream_iface;
IUnknown *outer_unk;
DMUS_OBJECTDESC desc;
};
void dmobject_init(struct dmobject *dmobj, const GUID *class, IUnknown *outer_unk) DECLSPEC_HIDDEN;
/* Generic IDirectMusicObject methods */
HRESULT WINAPI dmobj_IDirectMusicObject_QueryInterface(IDirectMusicObject *iface, REFIID riid,
void **ret_iface) DECLSPEC_HIDDEN;
ULONG WINAPI dmobj_IDirectMusicObject_AddRef(IDirectMusicObject *iface) DECLSPEC_HIDDEN;
ULONG WINAPI dmobj_IDirectMusicObject_Release(IDirectMusicObject *iface) DECLSPEC_HIDDEN;
HRESULT WINAPI dmobj_IDirectMusicObject_GetDescriptor(IDirectMusicObject *iface,
DMUS_OBJECTDESC *desc) DECLSPEC_HIDDEN;
HRESULT WINAPI dmobj_IDirectMusicObject_SetDescriptor(IDirectMusicObject *iface,
DMUS_OBJECTDESC *desc) DECLSPEC_HIDDEN;
/* Generic IPersistStream methods */
HRESULT WINAPI dmobj_IPersistStream_QueryInterface(IPersistStream *iface, REFIID riid,
void **ret_iface) DECLSPEC_HIDDEN;
ULONG WINAPI dmobj_IPersistStream_AddRef(IPersistStream *iface) DECLSPEC_HIDDEN;
ULONG WINAPI dmobj_IPersistStream_Release(IPersistStream *iface) DECLSPEC_HIDDEN;
/* IPersistStream methods not implemented in native */
HRESULT WINAPI unimpl_IPersistStream_GetClassID(IPersistStream *iface,
CLSID *class) DECLSPEC_HIDDEN;
HRESULT WINAPI unimpl_IPersistStream_IsDirty(IPersistStream *iface) DECLSPEC_HIDDEN;
HRESULT WINAPI unimpl_IPersistStream_Save(IPersistStream *iface, IStream *stream,
BOOL clear_dirty) DECLSPEC_HIDDEN;
HRESULT WINAPI unimpl_IPersistStream_GetSizeMax(IPersistStream *iface,
ULARGE_INTEGER *size) DECLSPEC_HIDDEN;

View file

@ -59,8 +59,6 @@ static ULONG WINAPI IDirectMusic8Impl_AddRef(LPDIRECTMUSIC8 iface)
TRACE("(%p)->(): new ref = %u\n", This, ref);
DMUSIC_LockModule();
return ref;
}
@ -72,12 +70,12 @@ static ULONG WINAPI IDirectMusic8Impl_Release(LPDIRECTMUSIC8 iface)
TRACE("(%p)->(): new ref = %u\n", This, ref);
if (!ref) {
IReferenceClock_Release(&This->pMasterClock->IReferenceClock_iface);
HeapFree(GetProcessHeap(), 0, This->system_ports);
HeapFree(GetProcessHeap(), 0, This->ppPorts);
HeapFree(GetProcessHeap(), 0, This);
}
DMUSIC_UnlockModule();
}
return ref;
}
@ -210,8 +208,10 @@ static HRESULT WINAPI IDirectMusic8Impl_GetMasterClock(LPDIRECTMUSIC8 iface, LPG
if (guid_clock)
*guid_clock = This->pMasterClock->pClockInfo.guidClock;
if (reference_clock)
*reference_clock = (IReferenceClock*)This->pMasterClock;
if (reference_clock) {
*reference_clock = &This->pMasterClock->IReferenceClock_iface;
IReferenceClock_AddRef(*reference_clock);
}
return S_OK;
}
@ -414,7 +414,7 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicImpl(LPCGUID riid, LPVOID* ret_iface, LPU
return E_OUTOFMEMORY;
dmusic->IDirectMusic8_iface.lpVtbl = &DirectMusic8_Vtbl;
dmusic->ref = 0; /* Will be inited by QueryInterface */
dmusic->ref = 1;
dmusic->pMasterClock = NULL;
dmusic->ppPorts = NULL;
dmusic->nrofports = 0;
@ -424,14 +424,11 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicImpl(LPCGUID riid, LPVOID* ret_iface, LPU
return ret;
}
ret = IDirectMusic8Impl_QueryInterface(&dmusic->IDirectMusic8_iface, riid, ret_iface);
if (FAILED(ret)) {
IReferenceClock_Release(&dmusic->pMasterClock->IReferenceClock_iface);
HeapFree(GetProcessHeap(), 0, dmusic);
return ret;
}
create_system_ports_list(dmusic);
return S_OK;
DMUSIC_LockModule();
ret = IDirectMusic8Impl_QueryInterface(&dmusic->IDirectMusic8_iface, riid, ret_iface);
IDirectMusic8Impl_Release(&dmusic->IDirectMusic8_iface);
return ret;
}

View file

@ -22,7 +22,7 @@
#ifndef __WINE_DMUSIC_PRIVATE_H
#define __WINE_DMUSIC_PRIVATE_H
#include <config.h>
#include <wine/config.h>
#include <stdarg.h>
@ -42,6 +42,8 @@
#include <wine/list.h>
#include <wine/unicode.h>
#include "dmobject.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
/*****************************************************************************
@ -53,7 +55,6 @@ typedef struct IDirectMusicDownloadedInstrumentImpl IDirectMusicDownloadedInstru
typedef struct IDirectMusicDownloadImpl IDirectMusicDownloadImpl;
typedef struct IReferenceClockImpl IReferenceClockImpl;
typedef struct IDirectMusicCollectionImpl IDirectMusicCollectionImpl;
typedef struct IDirectMusicInstrumentImpl IDirectMusicInstrumentImpl;
typedef struct SynthPortImpl SynthPortImpl;
@ -211,30 +212,6 @@ typedef struct _DMUS_PRIVATE_POOLCUE {
struct list entry; /* for listing elements */
} DMUS_PRIVATE_POOLCUE, *LPDMUS_PRIVATE_POOLCUE;
/*****************************************************************************
* IDirectMusicCollectionImpl implementation structure
*/
struct IDirectMusicCollectionImpl {
/* IUnknown fields */
IDirectMusicCollection IDirectMusicCollection_iface;
IDirectMusicObject IDirectMusicObject_iface;
IPersistStream IPersistStream_iface;
LONG ref;
/* IDirectMusicCollectionImpl fields */
IStream *pStm; /* stream from which we load collection and later instruments */
LARGE_INTEGER liCollectionPosition; /* offset in a stream where collection was loaded from */
LARGE_INTEGER liWavePoolTablePosition; /* offset in a stream where wave pool table can be found */
LPDMUS_OBJECTDESC pDesc;
CHAR* szCopyright; /* FIXME: should probably placed somewhere else */
LPDLSHEADER pHeader;
/* pool table */
LPPOOLTABLE pPoolTable;
LPPOOLCUE pPoolCues;
/* instruments */
struct list Instruments;
};
/*****************************************************************************
* IDirectMusicInstrumentImpl implementation structure
*/
@ -296,13 +273,6 @@ typedef struct {
const char* name;
} guid_info;
/* used for initialising structs (primarily for DMUS_OBJECTDESC) */
#define DM_STRUCT_INIT(x) \
do { \
memset((x), 0, sizeof(*(x))); \
(x)->dwSize = sizeof(*x); \
} while (0)
#define FE(x) { x, #x }
#define GE(x) { &x, #x }

View file

@ -50,8 +50,6 @@ static ULONG WINAPI IDirectMusicDownloadImpl_AddRef(IDirectMusicDownload *iface)
TRACE("(%p)->(): new ref = %u\n", iface, ref);
DMUSIC_LockModule();
return ref;
}
@ -62,10 +60,10 @@ static ULONG WINAPI IDirectMusicDownloadImpl_Release(IDirectMusicDownload *iface
TRACE("(%p)->(): new ref = %u\n", iface, ref);
if (!ref)
if (!ref) {
HeapFree(GetProcessHeap(), 0, This);
DMUSIC_UnlockModule();
}
return ref;
}
@ -100,5 +98,7 @@ HRESULT DMUSIC_CreateDirectMusicDownloadImpl(const GUID *guid, void **ret_iface,
download->IDirectMusicDownload_iface.lpVtbl = &DirectMusicDownload_Vtbl;
download->ref = 1;
*ret_iface = download;
DMUSIC_LockModule();
return S_OK;
}

View file

@ -60,8 +60,6 @@ static ULONG WINAPI IDirectMusicInstrumentImpl_AddRef(LPDIRECTMUSICINSTRUMENT if
TRACE("(%p)->(): new ref = %u\n", iface, ref);
DMUSIC_LockModule();
return ref;
}
@ -81,9 +79,8 @@ static ULONG WINAPI IDirectMusicInstrumentImpl_Release(LPDIRECTMUSICINSTRUMENT i
HeapFree(GetProcessHeap(), 0, This->articulations->connections);
HeapFree(GetProcessHeap(), 0, This->articulations);
HeapFree(GetProcessHeap(), 0, This);
}
DMUSIC_UnlockModule();
}
return ref;
}
@ -123,6 +120,7 @@ static const IDirectMusicInstrumentVtbl DirectMusicInstrument_Vtbl =
/* for ClassFactory */
HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
IDirectMusicInstrumentImpl* dminst;
HRESULT hr;
dminst = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicInstrumentImpl));
if (NULL == dminst) {
@ -130,9 +128,14 @@ HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj,
return E_OUTOFMEMORY;
}
dminst->IDirectMusicInstrument_iface.lpVtbl = &DirectMusicInstrument_Vtbl;
dminst->ref = 0; /* will be inited by QueryInterface */
dminst->ref = 1;
return IDirectMusicInstrument_QueryInterface(&dminst->IDirectMusicInstrument_iface, lpcGUID, ppobj);
DMUSIC_LockModule();
hr = IDirectMusicInstrument_QueryInterface(&dminst->IDirectMusicInstrument_iface, lpcGUID,
ppobj);
IDirectMusicInstrument_Release(&dminst->IDirectMusicInstrument_iface);
return hr;
}
static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)

View file

@ -69,8 +69,6 @@ static ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_AddRef(LPDIRECTMUSICDOW
TRACE("(%p)->(): new ref = %u\n", iface, ref);
DMUSIC_LockModule();
return ref;
}
@ -85,9 +83,8 @@ static ULONG WINAPI IDirectMusicDownloadedInstrumentImpl_Release(LPDIRECTMUSICDO
{
HeapFree(GetProcessHeap(), 0, This->data);
HeapFree(GetProcessHeap(), 0, This);
}
DMUSIC_UnlockModule();
}
return ref;
}
@ -122,6 +119,7 @@ static HRESULT DMUSIC_CreateDirectMusicDownloadedInstrumentImpl(IDirectMusicDown
object->ref = 1;
*instrument = &object->IDirectMusicDownloadedInstrument_iface;
DMUSIC_LockModule();
return S_OK;
}

View file

@ -37,7 +37,7 @@ reactos/dll/directx/wine/ddraw # Synced to Wine-1.7.27
reactos/dll/directx/wine/devenum # Synced to Wine-1.7.27
reactos/dll/directx/wine/dinput # Synced to Wine-1.7.27
reactos/dll/directx/wine/dinput8 # Synced to Wine-1.7.27
reactos/dll/directx/wine/dmusic # Synced to Wine-1.7.17
reactos/dll/directx/wine/dmusic # Synced to Wine-1.7.27
reactos/dll/directx/wine/dplay # Synced to Wine-1.7.17
reactos/dll/directx/wine/dplayx # Synced to Wine-1.7.17
reactos/dll/directx/wine/dsound # Synced to Wine-1.5.26