From: Anton Baskanov baskanov@gmail.com
--- dlls/dmusic/port.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/dlls/dmusic/port.c b/dlls/dmusic/port.c index 84a9e759ab2..e4cf711d037 100644 --- a/dlls/dmusic/port.c +++ b/dlls/dmusic/port.c @@ -28,6 +28,7 @@ struct download_entry { struct list entry; IDirectMusicDownload *download; + BOOL data_in_use; HANDLE handle; DWORD id; }; @@ -522,6 +523,7 @@ static HRESULT WINAPI synth_port_download_Download(IDirectMusicPortDownload *ifa IDirectMusicDownload_AddRef(download); entry->id = info->dwDLId; entry->handle = handle; + entry->data_in_use = !can_free; list_add_tail(&This->downloads, &entry->entry); }
@@ -529,6 +531,13 @@ static HRESULT WINAPI synth_port_download_Download(IDirectMusicPortDownload *ifa return hr; }
+static HRESULT CALLBACK unload_callback(HANDLE handle, HANDLE user_data) +{ + IDirectMusicDownload *download = (IDirectMusicDownload *)user_data; + IDirectMusicDownload_Release(download); + return S_OK; +} + static HRESULT WINAPI synth_port_download_Unload(IDirectMusicPortDownload *iface, IDirectMusicDownload *download) { struct synth_port *This = synth_from_IDirectMusicPortDownload(iface); @@ -544,7 +553,8 @@ static HRESULT WINAPI synth_port_download_Unload(IDirectMusicPortDownload *iface if (entry->download == download) { list_remove(&entry->entry); - IDirectMusicDownload_Release(entry->download); + if (!entry->data_in_use) + IDirectMusicDownload_Release(entry->download); handle = entry->handle; free(entry); break; @@ -552,7 +562,7 @@ static HRESULT WINAPI synth_port_download_Unload(IDirectMusicPortDownload *iface }
if (!handle) return S_OK; - return IDirectMusicSynth_Unload(This->synth, handle, NULL, NULL); + return IDirectMusicSynth_Unload(This->synth, handle, unload_callback, download); }
static const IDirectMusicPortDownloadVtbl synth_port_download_vtbl = {