2012-05-04 20:51:30 +02:00
|
|
|
/*
|
|
|
|
* IDirectMusicInstrument Implementation
|
2003-07-22 00:10:14 +02:00
|
|
|
*
|
2004-01-20 01:21:40 +01:00
|
|
|
* Copyright (C) 2003-2004 Rok Mandeljc
|
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
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dmusic_private.h"
|
2019-12-13 00:29:06 +01:00
|
|
|
#include "dmobject.h"
|
2003-07-22 00:10:14 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
|
|
|
|
|
2012-05-04 20:51:30 +02:00
|
|
|
static const GUID IID_IDirectMusicInstrumentPRIVATE = { 0xbcb20080, 0xa40c, 0x11d1, { 0x86, 0xbc, 0x00, 0xc0, 0x4f, 0xbf, 0x8f, 0xef } };
|
2006-06-10 11:57:22 +02:00
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicInstrument IUnknown part: */
|
2012-05-04 20:51:30 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicInstrumentImpl_QueryInterface(LPDIRECTMUSICINSTRUMENT iface, REFIID riid, LPVOID *ret_iface)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%s, %p)\n", iface, debugstr_dmguid(riid), ret_iface);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IDirectMusicInstrument))
|
|
|
|
{
|
|
|
|
*ret_iface = iface;
|
|
|
|
IDirectMusicInstrument_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IDirectMusicInstrumentPRIVATE))
|
|
|
|
{
|
|
|
|
/* it seems to me that this interface is only basic IUnknown, without any
|
|
|
|
* other inherited functions... *sigh* this is the worst scenario, since it means
|
|
|
|
* that whoever calls it knows the layout of original implementation table and therefore
|
|
|
|
* tries to get data by direct access... expect crashes
|
|
|
|
*/
|
|
|
|
FIXME("*sigh*... requested private/unspecified interface\n");
|
|
|
|
|
|
|
|
*ret_iface = iface;
|
|
|
|
IDirectMusicInstrument_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p)->(%s, %p): not found\n", iface, debugstr_dmguid(riid), ret_iface);
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2012-05-04 20:51:30 +02:00
|
|
|
static ULONG WINAPI IDirectMusicInstrumentImpl_AddRef(LPDIRECTMUSICINSTRUMENT iface)
|
|
|
|
{
|
2012-05-11 08:19:18 +02:00
|
|
|
IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2012-05-11 08:19:18 +02:00
|
|
|
TRACE("(%p)->(): new ref = %u\n", iface, ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2012-05-11 08:19:18 +02:00
|
|
|
return ref;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2012-05-04 20:51:30 +02:00
|
|
|
static ULONG WINAPI IDirectMusicInstrumentImpl_Release(LPDIRECTMUSICINSTRUMENT iface)
|
|
|
|
{
|
2012-05-11 08:19:18 +02:00
|
|
|
IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2012-05-11 08:19:18 +02:00
|
|
|
TRACE("(%p)->(): new ref = %u\n", iface, ref);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2012-05-11 08:19:18 +02:00
|
|
|
if (!ref)
|
2012-12-21 10:27:38 +01:00
|
|
|
{
|
2013-01-22 08:35:56 +01:00
|
|
|
ULONG i;
|
|
|
|
|
2012-12-21 10:27:38 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->regions);
|
2013-01-22 08:35:56 +01:00
|
|
|
for (i = 0; i < This->nb_articulations; i++)
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->articulations->connections);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->articulations);
|
2012-05-11 08:19:18 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2014-05-31 19:22:48 +02:00
|
|
|
DMUSIC_UnlockModule();
|
2012-12-21 10:27:38 +01:00
|
|
|
}
|
2005-01-26 20:41:43 +01:00
|
|
|
|
2012-05-11 08:19:18 +02:00
|
|
|
return ref;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
/* IDirectMusicInstrumentImpl IDirectMusicInstrument part: */
|
2012-05-04 20:51:30 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicInstrumentImpl_GetPatch(LPDIRECTMUSICINSTRUMENT iface, DWORD* pdwPatch)
|
|
|
|
{
|
|
|
|
IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2012-05-04 20:51:30 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, pdwPatch);
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2012-12-21 10:27:46 +01:00
|
|
|
*pdwPatch = MIDILOCALE2Patch(&This->header.Locale);
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2012-05-04 20:51:30 +02:00
|
|
|
return S_OK;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
2003-07-22 00:10:14 +02:00
|
|
|
|
2012-05-04 20:51:30 +02:00
|
|
|
static HRESULT WINAPI IDirectMusicInstrumentImpl_SetPatch(LPDIRECTMUSICINSTRUMENT iface, DWORD dwPatch)
|
|
|
|
{
|
|
|
|
IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d): stub\n", This, dwPatch);
|
|
|
|
|
2012-12-21 10:27:46 +01:00
|
|
|
Patch2MIDILOCALE(dwPatch, &This->header.Locale);
|
2012-05-04 20:51:30 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|
|
|
|
|
2012-05-04 20:51:30 +02:00
|
|
|
static const IDirectMusicInstrumentVtbl DirectMusicInstrument_Vtbl =
|
|
|
|
{
|
|
|
|
IDirectMusicInstrumentImpl_QueryInterface,
|
|
|
|
IDirectMusicInstrumentImpl_AddRef,
|
|
|
|
IDirectMusicInstrumentImpl_Release,
|
|
|
|
IDirectMusicInstrumentImpl_GetPatch,
|
|
|
|
IDirectMusicInstrumentImpl_SetPatch
|
2003-07-22 00:10:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* for ClassFactory */
|
2012-04-24 11:37:20 +02:00
|
|
|
HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
|
2004-01-20 01:21:40 +01:00
|
|
|
IDirectMusicInstrumentImpl* dminst;
|
2014-05-31 19:22:48 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2004-01-20 01:21:40 +01:00
|
|
|
dminst = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicInstrumentImpl));
|
|
|
|
if (NULL == dminst) {
|
2004-12-22 16:13:20 +01:00
|
|
|
*ppobj = NULL;
|
2004-01-20 01:21:40 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2012-05-04 20:51:30 +02:00
|
|
|
dminst->IDirectMusicInstrument_iface.lpVtbl = &DirectMusicInstrument_Vtbl;
|
2014-05-31 19:22:48 +02:00
|
|
|
dminst->ref = 1;
|
|
|
|
|
|
|
|
DMUSIC_LockModule();
|
|
|
|
hr = IDirectMusicInstrument_QueryInterface(&dminst->IDirectMusicInstrument_iface, lpcGUID,
|
|
|
|
ppobj);
|
|
|
|
IDirectMusicInstrument_Release(&dminst->IDirectMusicInstrument_iface);
|
|
|
|
|
|
|
|
return hr;
|
2004-01-20 01:21:40 +01:00
|
|
|
}
|
|
|
|
|
2012-03-30 15:38:41 +02:00
|
|
|
static HRESULT read_from_stream(IStream *stream, void *data, ULONG size)
|
|
|
|
{
|
2012-05-11 08:19:10 +02:00
|
|
|
ULONG bytes_read;
|
2012-03-30 15:38:41 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2012-05-11 08:19:10 +02:00
|
|
|
hr = IStream_Read(stream, data, size, &bytes_read);
|
2012-03-30 15:38:41 +02:00
|
|
|
if(FAILED(hr)){
|
|
|
|
TRACE("IStream_Read failed: %08x\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
2012-05-11 08:19:10 +02:00
|
|
|
if (bytes_read < size) {
|
|
|
|
TRACE("Didn't read full chunk: %u < %u\n", bytes_read, size);
|
2012-03-30 15:38:41 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline DWORD subtract_bytes(DWORD len, DWORD bytes)
|
|
|
|
{
|
|
|
|
if(bytes > len){
|
|
|
|
TRACE("Apparent mismatch in chunk lengths? %u bytes remaining, %u bytes read\n", len, bytes);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return len - bytes;
|
|
|
|
}
|
|
|
|
|
2012-12-19 09:58:03 +01:00
|
|
|
static inline HRESULT advance_stream(IStream *stream, ULONG bytes)
|
2012-03-30 15:38:41 +02:00
|
|
|
{
|
|
|
|
LARGE_INTEGER move;
|
2012-12-19 09:58:03 +01:00
|
|
|
HRESULT ret;
|
2012-03-30 15:38:41 +02:00
|
|
|
|
2012-12-19 09:58:03 +01:00
|
|
|
move.QuadPart = bytes;
|
2012-03-30 15:38:41 +02:00
|
|
|
|
2012-12-19 09:58:03 +01:00
|
|
|
ret = IStream_Seek(stream, move, STREAM_SEEK_CUR, NULL);
|
|
|
|
if (FAILED(ret))
|
|
|
|
WARN("IStream_Seek failed: %08x\n", ret);
|
|
|
|
|
|
|
|
return ret;
|
2012-03-30 15:38:41 +02:00
|
|
|
}
|
|
|
|
|
2012-12-21 10:27:38 +01:00
|
|
|
static HRESULT load_region(IDirectMusicInstrumentImpl *This, IStream *stream, instrument_region *region, ULONG length)
|
|
|
|
{
|
|
|
|
HRESULT ret;
|
|
|
|
DMUS_PRIVATE_CHUNK chunk;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %p, %u)\n", This, stream, region, length);
|
|
|
|
|
|
|
|
while (length)
|
|
|
|
{
|
|
|
|
ret = read_from_stream(stream, &chunk, sizeof(chunk));
|
|
|
|
if (FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
length = subtract_bytes(length, sizeof(chunk));
|
|
|
|
|
|
|
|
switch (chunk.fccID)
|
|
|
|
{
|
|
|
|
case FOURCC_RGNH:
|
|
|
|
TRACE("RGNH chunk (region header): %u bytes\n", chunk.dwSize);
|
|
|
|
|
|
|
|
ret = read_from_stream(stream, ®ion->header, sizeof(region->header));
|
|
|
|
if (FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
length = subtract_bytes(length, sizeof(region->header));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FOURCC_WSMP:
|
|
|
|
TRACE("WSMP chunk (wave sample): %u bytes\n", chunk.dwSize);
|
|
|
|
|
|
|
|
ret = read_from_stream(stream, ®ion->wave_sample, sizeof(region->wave_sample));
|
|
|
|
if (FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
length = subtract_bytes(length, sizeof(region->wave_sample));
|
|
|
|
|
|
|
|
if (!(region->loop_present = (chunk.dwSize != sizeof(region->wave_sample))))
|
|
|
|
break;
|
|
|
|
|
|
|
|
ret = read_from_stream(stream, ®ion->wave_loop, sizeof(region->wave_loop));
|
|
|
|
if (FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
length = subtract_bytes(length, sizeof(region->wave_loop));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FOURCC_WLNK:
|
|
|
|
TRACE("WLNK chunk (wave link): %u bytes\n", chunk.dwSize);
|
|
|
|
|
|
|
|
ret = read_from_stream(stream, ®ion->wave_link, sizeof(region->wave_link));
|
|
|
|
if (FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
length = subtract_bytes(length, sizeof(region->wave_link));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
TRACE("Unknown chunk %s (skipping): %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
|
|
|
|
|
|
|
|
ret = advance_stream(stream, chunk.dwSize);
|
|
|
|
if (FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
length = subtract_bytes(length, chunk.dwSize);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-01-22 08:35:56 +01:00
|
|
|
static HRESULT load_articulation(IDirectMusicInstrumentImpl *This, IStream *stream, ULONG length)
|
|
|
|
{
|
|
|
|
HRESULT ret;
|
|
|
|
instrument_articulation *articulation;
|
|
|
|
|
|
|
|
if (!This->articulations)
|
|
|
|
This->articulations = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->articulations));
|
|
|
|
else
|
|
|
|
This->articulations = HeapReAlloc(GetProcessHeap(), 0, This->articulations, sizeof(*This->articulations) * (This->nb_articulations + 1));
|
|
|
|
if (!This->articulations)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
articulation = &This->articulations[This->nb_articulations];
|
|
|
|
|
|
|
|
ret = read_from_stream(stream, &articulation->connections_list, sizeof(CONNECTIONLIST));
|
|
|
|
if (FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
articulation->connections = HeapAlloc(GetProcessHeap(), 0, sizeof(CONNECTION) * articulation->connections_list.cConnections);
|
|
|
|
if (!articulation->connections)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
ret = read_from_stream(stream, articulation->connections, sizeof(CONNECTION) * articulation->connections_list.cConnections);
|
|
|
|
if (FAILED(ret))
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, articulation->connections);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
subtract_bytes(length, sizeof(CONNECTIONLIST) + sizeof(CONNECTION) * articulation->connections_list.cConnections);
|
|
|
|
|
|
|
|
This->nb_articulations++;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-19 09:58:03 +01:00
|
|
|
/* Function that loads all instrument data and which is called from IDirectMusicCollection_GetInstrument as in native */
|
|
|
|
HRESULT IDirectMusicInstrumentImpl_CustomLoad(IDirectMusicInstrument *iface, IStream *stream)
|
2012-03-30 15:38:41 +02:00
|
|
|
{
|
2012-05-04 20:51:30 +02:00
|
|
|
IDirectMusicInstrumentImpl *This = impl_from_IDirectMusicInstrument(iface);
|
2012-03-30 15:38:41 +02:00
|
|
|
HRESULT hr;
|
2012-12-19 09:58:03 +01:00
|
|
|
DMUS_PRIVATE_CHUNK chunk;
|
2012-12-21 10:27:38 +01:00
|
|
|
ULONG i = 0;
|
2012-12-19 09:58:03 +01:00
|
|
|
ULONG length = This->length;
|
2004-01-20 01:21:40 +01:00
|
|
|
|
2012-12-19 09:58:03 +01:00
|
|
|
TRACE("(%p, %p): offset = 0x%s, length = %u)\n", This, stream, wine_dbgstr_longlong(This->liInstrumentPosition.QuadPart), This->length);
|
2003-08-23 01:53:27 +02:00
|
|
|
|
2012-12-21 10:27:38 +01:00
|
|
|
if (This->loaded)
|
|
|
|
return S_OK;
|
|
|
|
|
2012-03-30 15:38:41 +02:00
|
|
|
hr = IStream_Seek(stream, This->liInstrumentPosition, STREAM_SEEK_SET, NULL);
|
2012-12-19 09:58:03 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2012-03-30 15:38:41 +02:00
|
|
|
WARN("IStream_Seek failed: %08x\n", hr);
|
2012-12-19 09:58:03 +01:00
|
|
|
return DMUS_E_UNSUPPORTED_STREAM;
|
2012-03-30 15:38:41 +02:00
|
|
|
}
|
|
|
|
|
2012-12-21 10:27:46 +01:00
|
|
|
This->regions = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->regions) * This->header.cRegions);
|
2012-12-21 10:27:38 +01:00
|
|
|
if (!This->regions)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2012-12-19 09:58:03 +01:00
|
|
|
while (length)
|
|
|
|
{
|
|
|
|
hr = read_from_stream(stream, &chunk, sizeof(chunk));
|
|
|
|
if (FAILED(hr))
|
2012-12-21 10:27:38 +01:00
|
|
|
goto error;
|
2012-03-30 15:38:41 +02:00
|
|
|
|
2012-12-19 09:58:03 +01:00
|
|
|
length = subtract_bytes(length, sizeof(chunk) + chunk.dwSize);
|
|
|
|
|
|
|
|
switch (chunk.fccID)
|
|
|
|
{
|
|
|
|
case FOURCC_INSH:
|
|
|
|
case FOURCC_DLID:
|
|
|
|
TRACE("Chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
|
|
|
|
|
|
|
|
/* Instrument header and id are already set so just skip */
|
|
|
|
hr = advance_stream(stream, chunk.dwSize);
|
|
|
|
if (FAILED(hr))
|
2012-12-21 10:27:38 +01:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
break;
|
2012-03-30 15:38:41 +02:00
|
|
|
|
2012-12-21 10:27:38 +01:00
|
|
|
case FOURCC_LIST: {
|
|
|
|
DWORD size = chunk.dwSize;
|
|
|
|
|
|
|
|
TRACE("LIST chunk: %u bytes\n", chunk.dwSize);
|
|
|
|
|
|
|
|
hr = read_from_stream(stream, &chunk.fccID, sizeof(chunk.fccID));
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
size = subtract_bytes(size, sizeof(chunk.fccID));
|
|
|
|
|
|
|
|
switch (chunk.fccID)
|
|
|
|
{
|
|
|
|
case FOURCC_LRGN:
|
|
|
|
TRACE("LRGN chunk (regions list): %u bytes\n", size);
|
|
|
|
|
|
|
|
while (size)
|
|
|
|
{
|
|
|
|
hr = read_from_stream(stream, &chunk, sizeof(chunk));
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (chunk.fccID != FOURCC_LIST)
|
|
|
|
{
|
|
|
|
TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = read_from_stream(stream, &chunk.fccID, sizeof(chunk.fccID));
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (chunk.fccID == FOURCC_RGN)
|
|
|
|
{
|
2013-01-22 08:35:56 +01:00
|
|
|
TRACE("RGN chunk (region): %u bytes\n", chunk.dwSize);
|
2012-12-21 10:27:38 +01:00
|
|
|
hr = load_region(This, stream, &This->regions[i++], chunk.dwSize - sizeof(chunk.fccID));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
|
|
|
|
hr = advance_stream(stream, chunk.dwSize - sizeof(chunk.fccID));
|
|
|
|
}
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
size = subtract_bytes(size, chunk.dwSize + sizeof(chunk));
|
2013-01-22 08:35:56 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FOURCC_LART:
|
|
|
|
TRACE("LART chunk (articulations list): %u bytes\n", size);
|
|
|
|
|
|
|
|
while (size)
|
|
|
|
{
|
|
|
|
hr = read_from_stream(stream, &chunk, sizeof(chunk));
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (chunk.fccID == FOURCC_ART1)
|
|
|
|
{
|
|
|
|
TRACE("ART1 chunk (level 1 articulation): %u bytes\n", chunk.dwSize);
|
|
|
|
hr = load_articulation(This, stream, chunk.dwSize);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
|
|
|
|
hr = advance_stream(stream, chunk.dwSize);
|
|
|
|
}
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
size = subtract_bytes(size, chunk.dwSize + sizeof(chunk));
|
2012-12-21 10:27:38 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
|
|
|
|
|
|
|
|
hr = advance_stream(stream, chunk.dwSize - sizeof(chunk.fccID));
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
size = subtract_bytes(size, chunk.dwSize - sizeof(chunk.fccID));
|
|
|
|
break;
|
|
|
|
}
|
2012-12-19 09:58:03 +01:00
|
|
|
break;
|
2012-12-21 10:27:38 +01:00
|
|
|
}
|
2012-12-19 09:58:03 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
TRACE("Unknown chunk %s: %u bytes\n", debugstr_fourcc(chunk.fccID), chunk.dwSize);
|
|
|
|
|
|
|
|
hr = advance_stream(stream, chunk.dwSize);
|
|
|
|
if (FAILED(hr))
|
2012-12-21 10:27:38 +01:00
|
|
|
goto error;
|
2012-12-19 09:58:03 +01:00
|
|
|
|
|
|
|
break;
|
2012-03-30 15:38:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-21 10:27:38 +01:00
|
|
|
This->loaded = TRUE;
|
|
|
|
|
2012-03-30 15:38:41 +02:00
|
|
|
return S_OK;
|
2012-12-21 10:27:38 +01:00
|
|
|
|
|
|
|
error:
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->regions);
|
|
|
|
This->regions = NULL;
|
|
|
|
|
|
|
|
return DMUS_E_UNSUPPORTED_STREAM;
|
2003-07-22 00:10:14 +02:00
|
|
|
}
|