From 41c6ffea440f0814b16b3499f4d7dbdfdd7699e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20H=C3=B6hle?= Date: Sun, 21 Aug 2011 06:53:56 +0200 Subject: [PATCH] winecoreaudio: Release buffer memory. --- dlls/winecoreaudio.drv/mmdevdrv.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index c45a8c61619..79cf5e39ea0 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -509,16 +509,27 @@ static ULONG WINAPI AudioClient_Release(IAudioClient *iface) ref = InterlockedDecrement(&This->ref); TRACE("(%p) Refcount now %u\n", This, ref); if(!ref){ - IAudioClient_Stop(iface); - if(This->aqueue) + if(This->aqueue){ + AQBuffer *buf, *next; + if(This->public_buffer){ + buf = This->public_buffer->mUserData; + list_add_tail(&This->avail_buffers, &buf->entry); + } + IAudioClient_Stop(iface); + AudioQueueStop(This->aqueue, 1); + /* Stopped synchronously, all buffers returned. */ + LIST_FOR_EACH_ENTRY_SAFE(buf, next, &This->avail_buffers, AQBuffer, entry){ + AudioQueueFreeBuffer(This->aqueue, buf->buf); + HeapFree(GetProcessHeap(), 0, buf); + } AudioQueueDispose(This->aqueue, 1); + } if(This->session){ EnterCriticalSection(&g_sessions_lock); list_remove(&This->entry); LeaveCriticalSection(&g_sessions_lock); } HeapFree(GetProcessHeap(), 0, This->vols); - HeapFree(GetProcessHeap(), 0, This->public_buffer); CoTaskMemFree(This->fmt); IMMDevice_Release(This->parent); HeapFree(GetProcessHeap(), 0, This);