Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/wineoss.drv/mmdevdrv.c | 55 ++++--------------------------------- dlls/wineoss.drv/oss.c | 49 +++++++++++++++++++++++++++++++++ dlls/wineoss.drv/unixlib.h | 9 ++++++ 3 files changed, 64 insertions(+), 49 deletions(-)
diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index 921253b62c2..491e4fc5d16 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -1251,9 +1251,7 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface, UINT32 frames, BYTE **data) { ACImpl *This = impl_from_IAudioRenderClient(iface); - struct oss_stream *stream = This->stream; - UINT32 write_pos; - SIZE_T size; + struct get_render_buffer_params params;
TRACE("(%p)->(%u, %p)\n", This, frames, data);
@@ -1262,53 +1260,12 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
*data = NULL;
- oss_lock(stream); - - if(stream->getbuf_last){ - oss_unlock(stream); - return AUDCLNT_E_OUT_OF_ORDER; - } - - if(!frames){ - oss_unlock(stream); - return S_OK; - } - - if(stream->held_frames + frames > stream->bufsize_frames){ - oss_unlock(stream); - return AUDCLNT_E_BUFFER_TOO_LARGE; - } - - write_pos = - (stream->lcl_offs_frames + stream->held_frames) % stream->bufsize_frames; - if(write_pos + frames > stream->bufsize_frames){ - if(stream->tmp_buffer_frames < frames){ - if(stream->tmp_buffer){ - size = 0; - NtFreeVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, &size, MEM_RELEASE); - stream->tmp_buffer = NULL; - } - size = frames * stream->fmt->nBlockAlign; - if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, 0, &size, - MEM_COMMIT, PAGE_READWRITE)){ - stream->tmp_buffer_frames = 0; - oss_unlock(stream); - return E_OUTOFMEMORY; - } - stream->tmp_buffer_frames = frames; - } - *data = stream->tmp_buffer; - stream->getbuf_last = -frames; - }else{ - *data = stream->local_buffer + write_pos * stream->fmt->nBlockAlign; - stream->getbuf_last = frames; - } - - silence_buffer(stream, *data, frames); - - oss_unlock(stream); + params.stream = This->stream; + params.frames = frames; + params.data = data; + OSS_CALL(get_render_buffer, ¶ms);
- return S_OK; + return params.result; }
static void oss_wrap_buffer(struct oss_stream *stream, BYTE *buffer, UINT32 written_frames) diff --git a/dlls/wineoss.drv/oss.c b/dlls/wineoss.drv/oss.c index 3ea0ab42e3e..9c45aa082b4 100644 --- a/dlls/wineoss.drv/oss.c +++ b/dlls/wineoss.drv/oss.c @@ -876,6 +876,54 @@ static NTSTATUS timer_loop(void *args) return STATUS_SUCCESS; }
+static NTSTATUS get_render_buffer(void *args) +{ + struct get_render_buffer_params *params = args; + struct oss_stream *stream = params->stream; + UINT32 write_pos, frames = params->frames; + BYTE **data = params->data; + SIZE_T size; + + oss_lock(stream); + + if(stream->getbuf_last) + return oss_unlock_result(stream, ¶ms->result, AUDCLNT_E_OUT_OF_ORDER); + + if(!frames) + return oss_unlock_result(stream, ¶ms->result, S_OK); + + if(stream->held_frames + frames > stream->bufsize_frames) + return oss_unlock_result(stream, ¶ms->result, AUDCLNT_E_BUFFER_TOO_LARGE); + + write_pos = + (stream->lcl_offs_frames + stream->held_frames) % stream->bufsize_frames; + if(write_pos + frames > stream->bufsize_frames){ + if(stream->tmp_buffer_frames < frames){ + if(stream->tmp_buffer){ + size = 0; + NtFreeVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, &size, MEM_RELEASE); + stream->tmp_buffer = NULL; + } + size = frames * stream->fmt->nBlockAlign; + if(NtAllocateVirtualMemory(GetCurrentProcess(), (void **)&stream->tmp_buffer, 0, &size, + MEM_COMMIT, PAGE_READWRITE)){ + stream->tmp_buffer_frames = 0; + return oss_unlock_result(stream, ¶ms->result, E_OUTOFMEMORY); + } + stream->tmp_buffer_frames = frames; + } + *data = stream->tmp_buffer; + stream->getbuf_last = -frames; + }else{ + *data = stream->local_buffer + write_pos * stream->fmt->nBlockAlign; + stream->getbuf_last = frames; + } + + silence_buffer(stream, *data, frames); + + return oss_unlock_result(stream, ¶ms->result, S_OK); +} + static NTSTATUS is_format_supported(void *args) { struct is_format_supported_params *params = args; @@ -1073,6 +1121,7 @@ unixlib_entry_t __wine_unix_call_funcs[] = stop, reset, timer_loop, + get_render_buffer, is_format_supported, get_mix_format, get_buffer_size, diff --git a/dlls/wineoss.drv/unixlib.h b/dlls/wineoss.drv/unixlib.h index 73963b1871b..0d83a03d64f 100644 --- a/dlls/wineoss.drv/unixlib.h +++ b/dlls/wineoss.drv/unixlib.h @@ -113,6 +113,14 @@ struct timer_loop_params struct oss_stream *stream; };
+struct get_render_buffer_params +{ + struct oss_stream *stream; + UINT32 frames; + HRESULT result; + BYTE **data; +}; + struct is_format_supported_params { const char *device; @@ -169,6 +177,7 @@ enum oss_funcs oss_stop, oss_reset, oss_timer_loop, + oss_get_render_buffer, oss_is_format_supported, oss_get_mix_format, oss_get_buffer_size,