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

dmband: Implement band track GUID_ConnectToDLSCollection parameter.

parent 8645d9eb
......@@ -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;
}
......@@ -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))
......
......@@ -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 */
......@@ -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 */
......
......@@ -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;
......
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