diff --git a/dlls/dmusic/collection.c b/dlls/dmusic/collection.c index b7c11dacb77..1074c4e2868 100644 --- a/dlls/dmusic/collection.c +++ b/dlls/dmusic/collection.c @@ -25,6 +25,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmusic); struct instrument_entry { struct list entry; + DWORD patch; DMUS_OBJECTDESC desc; IDirectMusicInstrument *instrument; }; @@ -176,15 +177,12 @@ static HRESULT WINAPI collection_GetInstrument(IDirectMusicCollection *iface, { struct collection *This = impl_from_IDirectMusicCollection(iface); struct instrument_entry *entry; - DWORD inst_patch; - HRESULT hr; TRACE("(%p, %lu, %p)\n", iface, patch, instrument); LIST_FOR_EACH_ENTRY(entry, &This->instruments, struct instrument_entry, entry) { - if (FAILED(hr = IDirectMusicInstrument_GetPatch(entry->instrument, &inst_patch))) return hr; - if (patch == inst_patch) + if (patch == entry->patch) { *instrument = entry->instrument; IDirectMusicInstrument_AddRef(entry->instrument); @@ -202,14 +200,13 @@ static HRESULT WINAPI collection_EnumInstrument(IDirectMusicCollection *iface, { struct collection *This = impl_from_IDirectMusicCollection(iface); struct instrument_entry *entry; - HRESULT hr; TRACE("(%p, %ld, %p, %p, %ld)\n", iface, index, patch, name, name_length); LIST_FOR_EACH_ENTRY(entry, &This->instruments, struct instrument_entry, entry) { if (index--) continue; - if (FAILED(hr = IDirectMusicInstrument_GetPatch(entry->instrument, patch))) return hr; + *patch = entry->patch; if (name) lstrcpynW(name, entry->desc.wszName, name_length); return S_OK; } @@ -239,6 +236,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, This, &entry->desc, &entry->instrument); + if (SUCCEEDED(hr)) hr = IDirectMusicInstrument_GetPatch(entry->instrument, &entry->patch); if (SUCCEEDED(hr)) list_add_tail(&This->instruments, &entry->entry); else free(entry); break; diff --git a/dlls/dmusic/tests/dmusic.c b/dlls/dmusic/tests/dmusic.c index 6210cb05e6c..703251bb9da 100644 --- a/dlls/dmusic/tests/dmusic.c +++ b/dlls/dmusic/tests/dmusic.c @@ -1184,7 +1184,7 @@ static void test_download_instrument(void) static const LARGE_INTEGER zero = {0}; IDirectMusicDownloadedInstrument *downloaded; IDirectMusicCollection *collection; - IDirectMusicInstrument *instrument; + IDirectMusicInstrument *instrument, *tmp_instrument; IPersistStream *persist; IDirectMusicPort *port; IDirectMusic *dmusic; @@ -1299,6 +1299,22 @@ static void test_download_instrument(void) hr = IDirectMusicCollection_GetInstrument(collection, 0x1234, &instrument); ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicInstrument_GetPatch(instrument, &patch); + ok(hr == S_OK, "got %#lx\n", hr); + ok(patch == 0x1234, "got %#lx\n", patch); + hr = IDirectMusicInstrument_SetPatch(instrument, 0x4321); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicInstrument_GetPatch(instrument, &patch); + ok(hr == S_OK, "got %#lx\n", hr); + ok(patch == 0x4321, "got %#lx\n", patch); + + hr = IDirectMusicCollection_GetInstrument(collection, 0x1234, &tmp_instrument); + ok(hr == S_OK, "got %#lx\n", hr); + ok(instrument == tmp_instrument, "got %p\n", tmp_instrument); + hr = IDirectMusicInstrument_GetPatch(tmp_instrument, &patch); + ok(hr == S_OK, "got %#lx\n", hr); + ok(patch == 0x4321, "got %#lx\n", patch); + IDirectMusicInstrument_Release(tmp_instrument); check_interface(instrument, &IID_IDirectMusicObject, FALSE); check_interface(instrument, &IID_IDirectMusicDownload, FALSE);