diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index 2ea3c80f3ca..a2f75d7a479 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -783,7 +783,7 @@ static HRESULT WINAPI AudioClient_GetBufferSize(IAudioClient3 *iface, UINT32 *frames) { ACImpl *This = impl_from_IAudioClient3(iface); - struct oss_stream *stream = This->stream; + struct get_buffer_size_params params; TRACE("(%p)->(%p)\n", This, frames); @@ -793,15 +793,13 @@ static HRESULT WINAPI AudioClient_GetBufferSize(IAudioClient3 *iface, if(!This->stream) return AUDCLNT_E_NOT_INITIALIZED; - oss_lock(stream); - - *frames = stream->bufsize_frames; + params.stream = This->stream; + params.size = frames; + OSS_CALL(get_buffer_size, ¶ms); TRACE("buffer size: %u\n", *frames); - oss_unlock(stream); - - return S_OK; + return params.result; } static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient3 *iface, diff --git a/dlls/wineoss.drv/oss.c b/dlls/wineoss.drv/oss.c index 628d0c5818a..fdad419abfa 100644 --- a/dlls/wineoss.drv/oss.c +++ b/dlls/wineoss.drv/oss.c @@ -70,6 +70,24 @@ static int muldiv( int a, int b, int c ) return ret; } +static void oss_lock(struct oss_stream *stream) +{ + pthread_mutex_lock(&stream->lock); +} + +static void oss_unlock(struct oss_stream *stream) +{ + pthread_mutex_unlock(&stream->lock); +} + +static NTSTATUS oss_unlock_result(struct oss_stream *stream, + HRESULT *result, HRESULT value) +{ + *result = value; + oss_unlock(stream); + return STATUS_SUCCESS; +} + static NTSTATUS test_connect(void *args) { struct test_connect_params *params = args; @@ -732,6 +750,18 @@ static NTSTATUS get_mix_format(void *args) return STATUS_SUCCESS; } +static NTSTATUS get_buffer_size(void *args) +{ + struct get_buffer_size_params *params = args; + struct oss_stream *stream = params->stream; + + oss_lock(stream); + + *params->size = stream->bufsize_frames; + + return oss_unlock_result(stream, ¶ms->result, S_OK); +} + unixlib_entry_t __wine_unix_call_funcs[] = { test_connect, @@ -740,4 +770,5 @@ unixlib_entry_t __wine_unix_call_funcs[] = release_stream, is_format_supported, get_mix_format, + get_buffer_size, }; diff --git a/dlls/wineoss.drv/unixlib.h b/dlls/wineoss.drv/unixlib.h index c0a0b25c374..b57798ef435 100644 --- a/dlls/wineoss.drv/unixlib.h +++ b/dlls/wineoss.drv/unixlib.h @@ -106,6 +106,13 @@ struct get_mix_format_params HRESULT result; }; +struct get_buffer_size_params +{ + struct oss_stream *stream; + HRESULT result; + UINT32 *size; +}; + enum oss_funcs { oss_test_connect, @@ -114,6 +121,7 @@ enum oss_funcs oss_release_stream, oss_is_format_supported, oss_get_mix_format, + oss_get_buffer_size, }; extern unixlib_handle_t oss_handle;