2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicWave Implementation
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003-2004 Rok Mandeljc
|
|
|
|
*
|
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.
|
2004-01-20 01:21:40 +01: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.
|
2004-01-20 01:21:40 +01: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
|
2004-01-20 01:21:40 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dswave_private.h"
|
2015-06-10 01:04:56 +02:00
|
|
|
#include "dmobject.h"
|
2004-01-20 01:21:40 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dswave);
|
2020-09-25 21:14:32 +02:00
|
|
|
|
2004-02-25 02:30:03 +01:00
|
|
|
/* an interface that is, according to my tests, obtained by loader after loading object; is it acting
|
|
|
|
as some sort of bridge between object and loader? */
|
2005-06-01 21:57:42 +02:00
|
|
|
static const GUID IID_IDirectMusicWavePRIVATE = {0x69e934e4,0x97f1,0x4f1d,{0x88,0xe8,0xf2,0xac,0x88,0x67,0x13,0x27}};
|
2004-01-20 01:21:40 +01:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectMusicWaveImpl implementation
|
|
|
|
*/
|
2015-06-10 01:00:28 +02:00
|
|
|
typedef struct IDirectMusicWaveImpl {
|
|
|
|
IUnknown IUnknown_iface;
|
2015-06-10 01:04:56 +02:00
|
|
|
struct dmobject dmobj;
|
2015-06-10 01:00:28 +02:00
|
|
|
LONG ref;
|
|
|
|
} IDirectMusicWaveImpl;
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicWaveImpl IUnknown part: */
|
2015-06-10 01:00:28 +02:00
|
|
|
static inline IDirectMusicWaveImpl *impl_from_IUnknown(IUnknown *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicWaveImpl, IUnknown_iface);
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
|
|
|
|
2015-06-10 01:00:28 +02:00
|
|
|
static HRESULT WINAPI IUnknownImpl_QueryInterface(IUnknown *iface, REFIID riid, void **ret_iface)
|
|
|
|
{
|
|
|
|
IDirectMusicWaveImpl *This = impl_from_IUnknown(iface);
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface);
|
|
|
|
|
|
|
|
*ret_iface = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
*ret_iface = iface;
|
|
|
|
else if (IsEqualIID(riid, &IID_IDirectMusicObject))
|
2015-06-10 01:04:56 +02:00
|
|
|
*ret_iface = &This->dmobj.IDirectMusicObject_iface;
|
2015-06-10 01:00:28 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_IPersistStream))
|
2015-06-10 01:04:56 +02:00
|
|
|
*ret_iface = &This->dmobj.IPersistStream_iface;
|
2015-06-10 01:00:28 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_IDirectMusicWavePRIVATE)) {
|
|
|
|
FIXME("(%p, %s, %p): Unsupported private interface\n", This, debugstr_guid(riid), ret_iface);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
} 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;
|
|
|
|
}
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2015-06-10 01:00:28 +02:00
|
|
|
static ULONG WINAPI IUnknownImpl_AddRef(IUnknown *iface)
|
|
|
|
{
|
|
|
|
IDirectMusicWaveImpl *This = impl_from_IUnknown(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2022-02-04 22:36:00 +01:00
|
|
|
TRACE("(%p) ref=%ld\n", This, ref);
|
2005-02-01 15:21:37 +01:00
|
|
|
|
2015-06-10 01:00:28 +02:00
|
|
|
return ref;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
|
|
|
|
2015-06-10 01:00:28 +02:00
|
|
|
static ULONG WINAPI IUnknownImpl_Release(IUnknown *iface)
|
|
|
|
{
|
|
|
|
IDirectMusicWaveImpl *This = impl_from_IUnknown(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2022-02-04 22:36:00 +01:00
|
|
|
TRACE("(%p) ref=%ld\n", This, ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2015-06-10 01:00:28 +02:00
|
|
|
if (!ref) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
DSWAVE_UnlockModule();
|
|
|
|
}
|
2005-02-01 15:21:37 +01:00
|
|
|
|
2015-06-10 01:00:28 +02:00
|
|
|
return ref;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
|
|
|
|
2015-06-10 01:00:28 +02:00
|
|
|
static const IUnknownVtbl unknown_vtbl = {
|
|
|
|
IUnknownImpl_QueryInterface,
|
|
|
|
IUnknownImpl_AddRef,
|
|
|
|
IUnknownImpl_Release
|
2004-01-20 01:21:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* IDirectMusicWaveImpl IDirectMusicObject part: */
|
2018-07-17 23:55:33 +02:00
|
|
|
static HRESULT WINAPI wave_IDirectMusicObject_ParseDescriptor(IDirectMusicObject *iface,
|
|
|
|
IStream *stream, DMUS_OBJECTDESC *desc)
|
2015-06-10 01:04:56 +02:00
|
|
|
{
|
2018-07-17 23:55:33 +02:00
|
|
|
struct chunk_entry riff = {0};
|
|
|
|
HRESULT hr;
|
2004-01-20 01:21:40 +01:00
|
|
|
|
2018-07-17 23:55:33 +02:00
|
|
|
TRACE("(%p, %p, %p)\n", iface, stream, desc);
|
2008-02-26 21:20:15 +01:00
|
|
|
|
2018-07-17 23:55:33 +02:00
|
|
|
if (!stream || !desc)
|
|
|
|
return E_POINTER;
|
2008-02-26 21:20:15 +01:00
|
|
|
|
2018-07-17 23:55:33 +02:00
|
|
|
if ((hr = stream_get_chunk(stream, &riff)) != S_OK)
|
|
|
|
return hr;
|
|
|
|
if (riff.id != FOURCC_RIFF || riff.type != mmioFOURCC('W','A','V','E')) {
|
|
|
|
TRACE("loading failed: unexpected %s\n", debugstr_chunk(&riff));
|
|
|
|
stream_skip_chunk(stream, &riff);
|
|
|
|
return DMUS_E_CHUNKNOTFOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = dmobj_parsedescriptor(stream, &riff, desc,
|
|
|
|
DMUS_OBJ_NAME_INFO | DMUS_OBJ_OBJECT | DMUS_OBJ_VERSION);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2019-12-13 00:29:07 +01:00
|
|
|
TRACE("returning descriptor:\n");
|
|
|
|
dump_DMUS_OBJECTDESC(desc);
|
2018-07-17 23:55:33 +02:00
|
|
|
return S_OK;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
|
|
|
|
2015-06-10 01:04:56 +02:00
|
|
|
static const IDirectMusicObjectVtbl dmobject_vtbl = {
|
|
|
|
dmobj_IDirectMusicObject_QueryInterface,
|
|
|
|
dmobj_IDirectMusicObject_AddRef,
|
|
|
|
dmobj_IDirectMusicObject_Release,
|
|
|
|
dmobj_IDirectMusicObject_GetDescriptor,
|
|
|
|
dmobj_IDirectMusicObject_SetDescriptor,
|
2018-07-17 23:55:33 +02:00
|
|
|
wave_IDirectMusicObject_ParseDescriptor
|
2004-01-20 01:21:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* IDirectMusicWaveImpl IPersistStream part: */
|
2015-06-10 01:04:56 +02:00
|
|
|
static inline IDirectMusicWaveImpl *impl_from_IPersistStream(IPersistStream *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectMusicWaveImpl, dmobj.IPersistStream_iface);
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
|
|
|
|
2020-09-25 21:14:32 +02:00
|
|
|
static HRESULT WINAPI wave_IPersistStream_Load(IPersistStream *iface, IStream *stream)
|
2015-06-10 01:04:56 +02:00
|
|
|
{
|
2020-09-25 21:14:32 +02:00
|
|
|
IDirectMusicWaveImpl *This = impl_from_IPersistStream(iface);
|
|
|
|
struct chunk_entry riff = {0};
|
|
|
|
|
|
|
|
/* Without the private interface the implementation should go to dmime/segment.c */
|
|
|
|
FIXME("(%p, %p): loading not implemented (only descriptor is loaded)\n", This, stream);
|
|
|
|
|
|
|
|
if (!stream)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
if (stream_get_chunk(stream, &riff) != S_OK || riff.id != FOURCC_RIFF ||
|
|
|
|
riff.type != mmioFOURCC('W','A','V','E'))
|
|
|
|
return DMUS_E_UNSUPPORTED_STREAM;
|
|
|
|
stream_reset_chunk_start(stream, &riff);
|
|
|
|
|
|
|
|
return IDirectMusicObject_ParseDescriptor(&This->dmobj.IDirectMusicObject_iface, stream,
|
|
|
|
&This->dmobj.desc);
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
|
|
|
|
2015-06-10 01:04:56 +02:00
|
|
|
static const IPersistStreamVtbl persiststream_vtbl = {
|
|
|
|
dmobj_IPersistStream_QueryInterface,
|
|
|
|
dmobj_IPersistStream_AddRef,
|
|
|
|
dmobj_IPersistStream_Release,
|
|
|
|
dmobj_IPersistStream_GetClassID,
|
|
|
|
unimpl_IPersistStream_IsDirty,
|
2020-09-25 21:14:32 +02:00
|
|
|
wave_IPersistStream_Load,
|
2015-06-10 01:04:56 +02:00
|
|
|
unimpl_IPersistStream_Save,
|
|
|
|
unimpl_IPersistStream_GetSizeMax
|
2004-01-20 01:21:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* for ClassFactory */
|
2014-03-13 23:45:16 +01:00
|
|
|
HRESULT WINAPI create_dswave(REFIID lpcGUID, void **ppobj)
|
|
|
|
{
|
2015-06-10 01:07:49 +02:00
|
|
|
IDirectMusicWaveImpl *obj;
|
2015-06-10 01:00:28 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2015-06-10 01:07:49 +02:00
|
|
|
obj = HeapAlloc(GetProcessHeap(), 0, sizeof(IDirectMusicWaveImpl));
|
|
|
|
if (!obj) {
|
|
|
|
*ppobj = NULL;
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2015-06-10 01:00:28 +02:00
|
|
|
obj->IUnknown_iface.lpVtbl = &unknown_vtbl;
|
|
|
|
obj->ref = 1;
|
2015-06-10 01:04:56 +02:00
|
|
|
dmobject_init(&obj->dmobj, &CLSID_DirectSoundWave, &obj->IUnknown_iface);
|
|
|
|
obj->dmobj.IDirectMusicObject_iface.lpVtbl = &dmobject_vtbl;
|
|
|
|
obj->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl;
|
2008-02-26 21:20:15 +01:00
|
|
|
|
2015-06-10 01:00:28 +02:00
|
|
|
DSWAVE_LockModule();
|
|
|
|
hr = IUnknown_QueryInterface(&obj->IUnknown_iface, lpcGUID, ppobj);
|
|
|
|
IUnknown_Release(&obj->IUnknown_iface);
|
|
|
|
return hr;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|