Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/winecoreaudio.drv/coreaudio.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c index a2bbc3e45c9..f242ebe54a8 100644 --- a/dlls/winecoreaudio.drv/coreaudio.c +++ b/dlls/winecoreaudio.drv/coreaudio.c @@ -92,7 +92,6 @@ struct coreaudio_stream INT32 getbuf_last; WAVEFORMATEX *fmt; BYTE *local_buffer, *cap_buffer, *wrap_buffer, *resamp_buffer, *tmp_buffer; - SIZE_T local_buffer_size, tmp_buffer_size; };
static HRESULT osstatus_to_hresult(OSStatus sc) @@ -617,6 +616,7 @@ static NTSTATUS create_stream(void *args) struct coreaudio_stream *stream = calloc(1, sizeof(*stream)); AURenderCallbackStruct input; OSStatus sc; + SIZE_T size;
if(!stream){ params->result = E_OUTOFMEMORY; @@ -679,8 +679,8 @@ static NTSTATUS create_stream(void *args) goto end; }
- stream->local_buffer_size = stream->bufsize_frames * stream->fmt->nBlockAlign; - if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->local_buffer, 0, &stream->local_buffer_size, + size = stream->bufsize_frames * stream->fmt->nBlockAlign; + if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->local_buffer, 0, &size, MEM_COMMIT, PAGE_READWRITE)){ params->result = E_OUTOFMEMORY; goto end; @@ -1337,6 +1337,7 @@ static NTSTATUS get_render_buffer(void *args) { struct get_render_buffer_params *params = args; struct coreaudio_stream *stream = params->stream; + SIZE_T size; UINT32 pad;
OSSpinLockLock(&stream->lock); @@ -1359,14 +1360,14 @@ static NTSTATUS get_render_buffer(void *args) if(stream->wri_offs_frames + params->frames > stream->bufsize_frames){ if(stream->tmp_buffer_frames < params->frames){ if(stream->tmp_buffer){ - SIZE_T size = 0; + size = 0; NtFreeVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, &size, MEM_RELEASE); stream->tmp_buffer = NULL; } - stream->tmp_buffer_size = params->frames * stream->fmt->nBlockAlign; + size = params->frames * stream->fmt->nBlockAlign; if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, 0, - &stream->tmp_buffer_size, MEM_COMMIT, PAGE_READWRITE)){ + &size, MEM_COMMIT, PAGE_READWRITE)){ stream->tmp_buffer_frames = 0; params->result = E_OUTOFMEMORY; goto end; @@ -1439,6 +1440,7 @@ static NTSTATUS get_capture_buffer(void *args) struct coreaudio_stream *stream = params->stream; UINT32 chunk_bytes, chunk_frames; LARGE_INTEGER stamp, freq; + SIZE_T size;
OSSpinLockLock(&stream->lock);
@@ -1461,9 +1463,9 @@ static NTSTATUS get_capture_buffer(void *args) if(chunk_frames < stream->period_frames){ chunk_bytes = chunk_frames * stream->fmt->nBlockAlign; if(!stream->tmp_buffer){ - stream->tmp_buffer_size = stream->period_frames * stream->fmt->nBlockAlign; + size = stream->period_frames * stream->fmt->nBlockAlign; NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, 0, - &stream->tmp_buffer_size, MEM_COMMIT, PAGE_READWRITE); + &size, MEM_COMMIT, PAGE_READWRITE); } *params->data = stream->tmp_buffer; memcpy(*params->data, stream->local_buffer + stream->lcl_offs_frames * stream->fmt->nBlockAlign,
Signed-off-by: Andrew Eikum aeikum@codeweavers.com
On Wed, Jan 26, 2022 at 01:26:13PM +0000, Huw Davies wrote:
Signed-off-by: Huw Davies huw@codeweavers.com
dlls/winecoreaudio.drv/coreaudio.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c index a2bbc3e45c9..f242ebe54a8 100644 --- a/dlls/winecoreaudio.drv/coreaudio.c +++ b/dlls/winecoreaudio.drv/coreaudio.c @@ -92,7 +92,6 @@ struct coreaudio_stream INT32 getbuf_last; WAVEFORMATEX *fmt; BYTE *local_buffer, *cap_buffer, *wrap_buffer, *resamp_buffer, *tmp_buffer;
- SIZE_T local_buffer_size, tmp_buffer_size;
};
static HRESULT osstatus_to_hresult(OSStatus sc) @@ -617,6 +616,7 @@ static NTSTATUS create_stream(void *args) struct coreaudio_stream *stream = calloc(1, sizeof(*stream)); AURenderCallbackStruct input; OSStatus sc;
SIZE_T size;
if(!stream){ params->result = E_OUTOFMEMORY;
@@ -679,8 +679,8 @@ static NTSTATUS create_stream(void *args) goto end; }
- stream->local_buffer_size = stream->bufsize_frames * stream->fmt->nBlockAlign;
- if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->local_buffer, 0, &stream->local_buffer_size,
- size = stream->bufsize_frames * stream->fmt->nBlockAlign;
- if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->local_buffer, 0, &size, MEM_COMMIT, PAGE_READWRITE)){ params->result = E_OUTOFMEMORY; goto end;
@@ -1337,6 +1337,7 @@ static NTSTATUS get_render_buffer(void *args) { struct get_render_buffer_params *params = args; struct coreaudio_stream *stream = params->stream;
SIZE_T size; UINT32 pad;
OSSpinLockLock(&stream->lock);
@@ -1359,14 +1360,14 @@ static NTSTATUS get_render_buffer(void *args) if(stream->wri_offs_frames + params->frames > stream->bufsize_frames){ if(stream->tmp_buffer_frames < params->frames){ if(stream->tmp_buffer){
SIZE_T size = 0;
size = 0; NtFreeVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, &size, MEM_RELEASE); stream->tmp_buffer = NULL; }
stream->tmp_buffer_size = params->frames * stream->fmt->nBlockAlign;
size = params->frames * stream->fmt->nBlockAlign; if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, 0,
&stream->tmp_buffer_size, MEM_COMMIT, PAGE_READWRITE)){
&size, MEM_COMMIT, PAGE_READWRITE)){ stream->tmp_buffer_frames = 0; params->result = E_OUTOFMEMORY; goto end;
@@ -1439,6 +1440,7 @@ static NTSTATUS get_capture_buffer(void *args) struct coreaudio_stream *stream = params->stream; UINT32 chunk_bytes, chunk_frames; LARGE_INTEGER stamp, freq;
SIZE_T size;
OSSpinLockLock(&stream->lock);
@@ -1461,9 +1463,9 @@ static NTSTATUS get_capture_buffer(void *args) if(chunk_frames < stream->period_frames){ chunk_bytes = chunk_frames * stream->fmt->nBlockAlign; if(!stream->tmp_buffer){
stream->tmp_buffer_size = stream->period_frames * stream->fmt->nBlockAlign;
size = stream->period_frames * stream->fmt->nBlockAlign; NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, 0,
&stream->tmp_buffer_size, MEM_COMMIT, PAGE_READWRITE);
&size, MEM_COMMIT, PAGE_READWRITE); } *params->data = stream->tmp_buffer; memcpy(*params->data, stream->local_buffer + stream->lcl_offs_frames * stream->fmt->nBlockAlign,
-- 2.23.0