From 2bb465fca1fdbeb91f6e44718102a83d4f8478bb Mon Sep 17 00:00:00 2001 From: Huw Davies <huw@codeweavers.com> Date: Fri, 15 Apr 2022 07:59:58 +0100 Subject: [PATCH] wineoss: Move release_capture_buffer to the unixlib. Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> --- dlls/wineoss.drv/mmdevdrv.c | 32 +++++--------------------------- dlls/wineoss.drv/oss.c | 29 +++++++++++++++++++++++++++++ dlls/wineoss.drv/unixlib.h | 8 ++++++++ 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index cc9d22d21d0..80bac1d9ceb 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -1349,37 +1349,15 @@ static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer( IAudioCaptureClient *iface, UINT32 done) { ACImpl *This = impl_from_IAudioCaptureClient(iface); - struct oss_stream *stream = This->stream; + struct release_capture_buffer_params params; TRACE("(%p)->(%u)\n", This, done); - oss_lock(stream); + params.stream = This->stream; + params.done = done; + OSS_CALL(release_capture_buffer, ¶ms); - if(!done){ - stream->getbuf_last = 0; - oss_unlock(stream); - return S_OK; - } - - if(!stream->getbuf_last){ - oss_unlock(stream); - return AUDCLNT_E_OUT_OF_ORDER; - } - - if(stream->getbuf_last != done){ - oss_unlock(stream); - return AUDCLNT_E_INVALID_SIZE; - } - - stream->written_frames += done; - stream->held_frames -= done; - stream->lcl_offs_frames += done; - stream->lcl_offs_frames %= stream->bufsize_frames; - stream->getbuf_last = 0; - - oss_unlock(stream); - - return S_OK; + return params.result; } static HRESULT WINAPI AudioCaptureClient_GetNextPacketSize( diff --git a/dlls/wineoss.drv/oss.c b/dlls/wineoss.drv/oss.c index 2e811f9b424..f1994295618 100644 --- a/dlls/wineoss.drv/oss.c +++ b/dlls/wineoss.drv/oss.c @@ -1048,6 +1048,34 @@ static NTSTATUS get_capture_buffer(void *args) return oss_unlock_result(stream, ¶ms->result, *frames ? S_OK : AUDCLNT_S_BUFFER_EMPTY); } +static NTSTATUS release_capture_buffer(void *args) +{ + struct release_capture_buffer_params *params = args; + struct oss_stream *stream = params->stream; + UINT32 done = params->done; + + oss_lock(stream); + + if(!done){ + stream->getbuf_last = 0; + return oss_unlock_result(stream, ¶ms->result, S_OK); + } + + if(!stream->getbuf_last) + return oss_unlock_result(stream, ¶ms->result, AUDCLNT_E_OUT_OF_ORDER); + + if(stream->getbuf_last != done) + return oss_unlock_result(stream, ¶ms->result, AUDCLNT_E_INVALID_SIZE); + + stream->written_frames += done; + stream->held_frames -= done; + stream->lcl_offs_frames += done; + stream->lcl_offs_frames %= stream->bufsize_frames; + stream->getbuf_last = 0; + + return oss_unlock_result(stream, ¶ms->result, S_OK); +} + static NTSTATUS is_format_supported(void *args) { struct is_format_supported_params *params = args; @@ -1248,6 +1276,7 @@ unixlib_entry_t __wine_unix_call_funcs[] = get_render_buffer, release_render_buffer, get_capture_buffer, + release_capture_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 ca6d1d69de3..2f0884b9ac5 100644 --- a/dlls/wineoss.drv/unixlib.h +++ b/dlls/wineoss.drv/unixlib.h @@ -140,6 +140,13 @@ struct get_capture_buffer_params UINT64 *qpcpos; }; +struct release_capture_buffer_params +{ + struct oss_stream *stream; + UINT32 done; + HRESULT result; +}; + struct is_format_supported_params { const char *device; @@ -199,6 +206,7 @@ enum oss_funcs oss_get_render_buffer, oss_release_render_buffer, oss_get_capture_buffer, + oss_release_capture_buffer, oss_is_format_supported, oss_get_mix_format, oss_get_buffer_size,