Commit 8316a779 authored by Jörg Höhle's avatar Jörg Höhle Committed by Alexandre Julliard

mmdevapi: Avoid HeapRealloc when no data need be copied.

parent 4654b3f6
...@@ -2029,12 +2029,9 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface, ...@@ -2029,12 +2029,9 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
(This->lcl_offs_frames + This->held_frames) % This->bufsize_frames; (This->lcl_offs_frames + This->held_frames) % This->bufsize_frames;
if(write_pos + frames > This->bufsize_frames){ if(write_pos + frames > This->bufsize_frames){
if(This->tmp_buffer_frames < frames){ if(This->tmp_buffer_frames < frames){
if(This->tmp_buffer) HeapFree(GetProcessHeap(), 0, This->tmp_buffer);
This->tmp_buffer = HeapReAlloc(GetProcessHeap(), 0, This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0,
This->tmp_buffer, frames * This->fmt->nBlockAlign); frames * This->fmt->nBlockAlign);
else
This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0,
frames * This->fmt->nBlockAlign);
if(!This->tmp_buffer){ if(!This->tmp_buffer){
LeaveCriticalSection(&This->lock); LeaveCriticalSection(&This->lock);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -2184,12 +2181,9 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface, ...@@ -2184,12 +2181,9 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface,
if(This->lcl_offs_frames + *frames > This->bufsize_frames){ if(This->lcl_offs_frames + *frames > This->bufsize_frames){
UINT32 chunk_bytes, offs_bytes, frames_bytes; UINT32 chunk_bytes, offs_bytes, frames_bytes;
if(This->tmp_buffer_frames < *frames){ if(This->tmp_buffer_frames < *frames){
if(This->tmp_buffer) HeapFree(GetProcessHeap(), 0, This->tmp_buffer);
This->tmp_buffer = HeapReAlloc(GetProcessHeap(), 0, This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0,
This->tmp_buffer, *frames * This->fmt->nBlockAlign); *frames * This->fmt->nBlockAlign);
else
This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0,
*frames * This->fmt->nBlockAlign);
if(!This->tmp_buffer){ if(!This->tmp_buffer){
LeaveCriticalSection(&This->lock); LeaveCriticalSection(&This->lock);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
......
...@@ -1738,12 +1738,9 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface, ...@@ -1738,12 +1738,9 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
(This->lcl_offs_frames + This->held_frames) % This->bufsize_frames; (This->lcl_offs_frames + This->held_frames) % This->bufsize_frames;
if(write_pos + frames > This->bufsize_frames){ if(write_pos + frames > This->bufsize_frames){
if(This->tmp_buffer_frames < frames){ if(This->tmp_buffer_frames < frames){
if(This->tmp_buffer) HeapFree(GetProcessHeap(), 0, This->tmp_buffer);
This->tmp_buffer = HeapReAlloc(GetProcessHeap(), 0, This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0,
This->tmp_buffer, frames * This->fmt->nBlockAlign); frames * This->fmt->nBlockAlign);
else
This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0,
frames * This->fmt->nBlockAlign);
if(!This->tmp_buffer){ if(!This->tmp_buffer){
LeaveCriticalSection(&This->lock); LeaveCriticalSection(&This->lock);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -1922,11 +1919,9 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface, ...@@ -1922,11 +1919,9 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface,
UINT32 chunk_bytes, offs_bytes, frames_bytes; UINT32 chunk_bytes, offs_bytes, frames_bytes;
if(This->tmp_buffer_frames < *frames){ if(This->tmp_buffer_frames < *frames){
if(This->tmp_buffer) if(This->tmp_buffer)
This->tmp_buffer = HeapReAlloc(GetProcessHeap(), 0, HeapFree(GetProcessHeap(), 0, This->tmp_buffer);
This->tmp_buffer, *frames * This->fmt->nBlockAlign); This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0,
else *frames * This->fmt->nBlockAlign);
This->tmp_buffer = HeapAlloc(GetProcessHeap(), 0,
*frames * This->fmt->nBlockAlign);
if(!This->tmp_buffer){ if(!This->tmp_buffer){
LeaveCriticalSection(&This->lock); LeaveCriticalSection(&This->lock);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
......
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