From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmband/band.c | 26 ++++++++++++++++++++++ dlls/dmband/bandtrack.c | 7 +++++- dlls/dmband/dmband_private.h | 2 ++ dlls/dmusic/dmobject.c | 43 +++++++++++++++++++++++++----------- dlls/dmusic/dmobject.h | 3 +++ 5 files changed, 67 insertions(+), 14 deletions(-)
diff --git a/dlls/dmband/band.c b/dlls/dmband/band.c index d91775681bb..361df5f8986 100644 --- a/dlls/dmband/band.c +++ b/dlls/dmband/band.c @@ -59,6 +59,7 @@ struct band struct dmobject dmobj; LONG ref; struct list instruments; + IDirectMusicCollection *collection; };
static inline struct band *impl_from_IDirectMusicBand(IDirectMusicBand *iface) @@ -117,6 +118,7 @@ static ULONG WINAPI band_Release(IDirectMusicBand *iface) instrument_entry_destroy(entry); }
+ if (This->collection) IDirectMusicCollection_Release(This->collection); free(This); }
@@ -336,11 +338,23 @@ static inline struct band *impl_from_IPersistStream(IPersistStream *iface) static HRESULT WINAPI band_persist_stream_Load(IPersistStream *iface, IStream *stream) { struct band *This = impl_from_IPersistStream(iface); + DMUS_OBJECTDESC default_desc = + { + .dwSize = sizeof(DMUS_OBJECTDESC), + .dwValidData = DMUS_OBJ_OBJECT | DMUS_OBJ_CLASS, + .guidClass = CLSID_DirectMusicCollection, + .guidObject = GUID_DefaultGMCollection, + }; struct chunk_entry chunk = {0}; HRESULT hr;
TRACE("%p, %p\n", iface, stream);
+ if (This->collection) IDirectMusicCollection_Release(This->collection); + if (FAILED(hr = stream_get_object(stream, &default_desc, &IID_IDirectMusicCollection, + (void **)&This->collection))) + WARN("Failed to load default collection from loader, hr %#lx\n", hr); + if ((hr = stream_get_chunk(stream, &chunk)) == S_OK) { switch (MAKE_IDTYPE(chunk.id, chunk.type)) @@ -408,3 +422,15 @@ HRESULT create_dmband(REFIID lpcGUID, void **ppobj)
return hr; } + +HRESULT band_connect_to_collection(IDirectMusicBand *iface, IDirectMusicCollection *collection) +{ + struct band *This = impl_from_IDirectMusicBand(iface); + + TRACE("%p, %p\n", iface, collection); + + if (This->collection) IDirectMusicCollection_Release(This->collection); + if ((This->collection = collection)) IDirectMusicCollection_AddRef(This->collection); + + return S_OK; +} diff --git a/dlls/dmband/bandtrack.c b/dlls/dmband/bandtrack.c index ab12e1f1355..45dc7ace86a 100644 --- a/dlls/dmband/bandtrack.c +++ b/dlls/dmband/bandtrack.c @@ -182,7 +182,12 @@ static HRESULT WINAPI band_track_SetParam(IDirectMusicTrack8 *iface, REFGUID typ else if (IsEqualGUID(type, &GUID_Clear_All_Bands)) FIXME("GUID_Clear_All_Bands not handled yet\n"); else if (IsEqualGUID(type, &GUID_ConnectToDLSCollection)) - FIXME("GUID_ConnectToDLSCollection not handled yet\n"); + { + struct band_entry *entry; + + LIST_FOR_EACH_ENTRY(entry, &This->bands, struct band_entry, entry) + band_connect_to_collection(entry->band, param); + } else if (IsEqualGUID(type, &GUID_Disable_Auto_Download)) FIXME("GUID_Disable_Auto_Download not handled yet\n"); else if (IsEqualGUID(type, &GUID_Download)) diff --git a/dlls/dmband/dmband_private.h b/dlls/dmband/dmband_private.h index 444fe5ccf55..a12b9f8cc82 100644 --- a/dlls/dmband/dmband_private.h +++ b/dlls/dmband/dmband_private.h @@ -47,4 +47,6 @@ extern HRESULT create_dmband(REFIID riid, void **ret_iface); extern HRESULT create_dmbandtrack(REFIID riid, void **ret_iface);
+extern HRESULT band_connect_to_collection(IDirectMusicBand *iface, IDirectMusicCollection *collection); + #endif /* __WINE_DMBAND_PRIVATE_H */ diff --git a/dlls/dmusic/dmobject.c b/dlls/dmusic/dmobject.c index 3007aceef3e..8cb4719c4e6 100644 --- a/dlls/dmusic/dmobject.c +++ b/dlls/dmusic/dmobject.c @@ -444,6 +444,35 @@ HRESULT stream_chunk_get_wstr(IStream *stream, const struct chunk_entry *chunk, return S_OK; }
+HRESULT stream_get_loader(IStream *stream, IDirectMusicLoader **ret_loader) +{ + IDirectMusicGetLoader *getter; + HRESULT hr; + + if (SUCCEEDED(hr = IStream_QueryInterface(stream, &IID_IDirectMusicGetLoader, (void**)&getter))) + { + hr = IDirectMusicGetLoader_GetLoader(getter, ret_loader); + IDirectMusicGetLoader_Release(getter); + } + + if (FAILED(hr)) *ret_loader = NULL; + return hr; +} + +HRESULT stream_get_object(IStream *stream, DMUS_OBJECTDESC *desc, REFIID iid, void **ret_iface) +{ + IDirectMusicLoader *loader; + HRESULT hr; + + if (SUCCEEDED(hr = stream_get_loader(stream, &loader))) + { + hr = IDirectMusicLoader_GetObject(loader, desc, iid, (void **)ret_iface); + IDirectMusicLoader_Release(loader); + } + + if (FAILED(hr)) *ret_iface = NULL; + return hr; +}
/* Generic IDirectMusicObject methods */ @@ -626,8 +655,6 @@ HRESULT dmobj_parsereference(IStream *stream, const struct chunk_entry *list, IDirectMusicObject **dmobj) { struct chunk_entry chunk = {.parent = list}; - IDirectMusicGetLoader *getloader; - IDirectMusicLoader *loader; DMUS_OBJECTDESC desc; DMUS_IO_REFERENCE reference; HRESULT hr; @@ -650,17 +677,7 @@ HRESULT dmobj_parsereference(IStream *stream, const struct chunk_entry *list, desc.dwValidData |= DMUS_OBJ_CLASS; dump_DMUS_OBJECTDESC(&desc);
- if (FAILED(hr = IStream_QueryInterface(stream, &IID_IDirectMusicGetLoader, (void**)&getloader))) - return hr; - hr = IDirectMusicGetLoader_GetLoader(getloader, &loader); - IDirectMusicGetLoader_Release(getloader); - if (FAILED(hr)) - return hr; - - hr = IDirectMusicLoader_GetObject(loader, &desc, &IID_IDirectMusicObject, (void**)dmobj); - IDirectMusicLoader_Release(loader); - - return hr; + return stream_get_object(stream, &desc, &IID_IDirectMusicObject, (void **)dmobj); }
/* Generic IPersistStream methods */ diff --git a/dlls/dmusic/dmobject.h b/dlls/dmusic/dmobject.h index ae06935dfea..82ac05f31b9 100644 --- a/dlls/dmusic/dmobject.h +++ b/dlls/dmusic/dmobject.h @@ -44,6 +44,9 @@ HRESULT stream_chunk_get_data(IStream *stream, const struct chunk_entry *chunk, HRESULT stream_chunk_get_wstr(IStream *stream, const struct chunk_entry *chunk, WCHAR *str, ULONG size);
+HRESULT stream_get_loader(IStream *stream, IDirectMusicLoader **ret_loader); +HRESULT stream_get_object(IStream *stream, DMUS_OBJECTDESC *desc, REFIID riid, void **ret_iface); + static inline HRESULT stream_reset_chunk_data(IStream *stream, const struct chunk_entry *chunk) { LARGE_INTEGER offset;