Commit 3fa399b1 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dmusic: Parse instrument name from INFO list.

parent d30f914d
......@@ -25,6 +25,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmusic);
struct instrument_entry
{
struct list entry;
DMUS_OBJECTDESC desc;
IDirectMusicInstrument *instrument;
};
......@@ -156,13 +157,7 @@ static HRESULT WINAPI collection_EnumInstrument(IDirectMusicCollection *iface,
{
if (index--) continue;
if (FAILED(hr = IDirectMusicInstrument_GetPatch(entry->instrument, patch))) return hr;
if (name)
{
struct instrument *instrument = impl_from_IDirectMusicInstrument(entry->instrument);
DWORD length = min(lstrlenW(instrument->wszName), name_length - 1);
memcpy(name, instrument->wszName, length * sizeof(WCHAR));
name[length] = '\0';
}
if (name) lstrcpynW(name, entry->desc.wszName, name_length);
return S_OK;
}
......@@ -190,7 +185,7 @@ static HRESULT parse_lins_list(struct collection *This, IStream *stream, struct
{
case MAKE_IDTYPE(FOURCC_LIST, FOURCC_INS):
if (!(entry = malloc(sizeof(*entry)))) return E_OUTOFMEMORY;
hr = instrument_create_from_chunk(stream, &chunk, &entry->instrument);
hr = instrument_create_from_chunk(stream, &chunk, &entry->desc, &entry->instrument);
if (SUCCEEDED(hr)) list_add_tail(&This->instruments, &entry->entry);
else free(entry);
break;
......
......@@ -98,7 +98,7 @@ extern HRESULT DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj,
extern HRESULT download_create(DWORD size, IDirectMusicDownload **ret_iface);
extern HRESULT instrument_create_from_chunk(IStream *stream, struct chunk_entry *parent,
IDirectMusicInstrument **ret_iface);
DMUS_OBJECTDESC *desc, IDirectMusicInstrument **ret_iface);
/*****************************************************************************
* IDirectMusic8Impl implementation structure
......@@ -173,10 +173,7 @@ struct instrument
IDirectMusicInstrument IDirectMusicInstrument_iface;
LONG ref;
GUID id;
INSTHEADER header;
WCHAR wszName[DMUS_MAX_NAME];
/* instrument data */
struct list articulations;
struct list regions;
......
......@@ -266,11 +266,16 @@ static HRESULT parse_lrgn_list(struct instrument *This, IStream *stream, struct
return hr;
}
static HRESULT parse_ins_chunk(struct instrument *This, IStream *stream, struct chunk_entry *parent)
static HRESULT parse_ins_chunk(struct instrument *This, IStream *stream, struct chunk_entry *parent,
DMUS_OBJECTDESC *desc)
{
struct chunk_entry chunk = {.parent = parent};
HRESULT hr;
if (FAILED(hr = dmobj_parsedescriptor(stream, parent, desc, DMUS_OBJ_NAME_INFO|DMUS_OBJ_GUID_DLID))
|| FAILED(hr = stream_reset_chunk_data(stream, parent)))
return hr;
while ((hr = stream_next_chunk(stream, &chunk)) == S_OK)
{
switch (MAKE_IDTYPE(chunk.id, chunk.type))
......@@ -280,7 +285,8 @@ static HRESULT parse_ins_chunk(struct instrument *This, IStream *stream, struct
break;
case FOURCC_DLID:
hr = stream_chunk_get_data(stream, &chunk, &This->id, sizeof(This->id));
case MAKE_IDTYPE(FOURCC_LIST, DMUS_FOURCC_INFO_LIST):
/* already parsed by dmobj_parsedescriptor */
break;
case MAKE_IDTYPE(FOURCC_LIST, FOURCC_LRGN):
......@@ -303,7 +309,7 @@ static HRESULT parse_ins_chunk(struct instrument *This, IStream *stream, struct
}
HRESULT instrument_create_from_chunk(IStream *stream, struct chunk_entry *parent,
IDirectMusicInstrument **ret_iface)
DMUS_OBJECTDESC *desc, IDirectMusicInstrument **ret_iface)
{
IDirectMusicInstrument *iface;
struct instrument *This;
......@@ -314,7 +320,7 @@ HRESULT instrument_create_from_chunk(IStream *stream, struct chunk_entry *parent
if (FAILED(hr = instrument_create(&iface))) return hr;
This = impl_from_IDirectMusicInstrument(iface);
if (FAILED(hr = parse_ins_chunk(This, stream, parent)))
if (FAILED(hr = parse_ins_chunk(This, stream, parent, desc)))
{
IDirectMusicInstrument_Release(iface);
return DMUS_E_UNSUPPORTED_STREAM;
......@@ -323,14 +329,13 @@ HRESULT instrument_create_from_chunk(IStream *stream, struct chunk_entry *parent
if (TRACE_ON(dmusic))
{
TRACE("Created DirectMusicInstrument (%p) ***\n", This);
if (!IsEqualGUID(&This->id, &GUID_NULL))
TRACE(" - GUID = %s\n", debugstr_dmguid(&This->id));
TRACE(" - Instrument header:\n");
TRACE(" - cRegions: %ld\n", This->header.cRegions);
TRACE(" - Locale:\n");
TRACE(" - ulBank: %ld\n", This->header.Locale.ulBank);
TRACE(" - ulInstrument: %ld\n", This->header.Locale.ulInstrument);
TRACE(" => dwPatch: %ld\n", MIDILOCALE2Patch(&This->header.Locale));
if (desc->dwValidData & DMUS_OBJ_OBJECT) TRACE(" - guid: %s\n", debugstr_dmguid(&desc->guidObject));
}
*ret_iface = iface;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment