From 2dd83eed7b75b10984088894c18e2d8392b876f0 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Tue, 23 Nov 2021 07:55:02 +0000 Subject: [PATCH] winecoreaudio: Move get_current_padding to the unixlib. Signed-off-by: Huw Davies Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- dlls/winecoreaudio.drv/coreaudio.c | 19 +++++++++++++++++++ dlls/winecoreaudio.drv/mmdevdrv.c | 27 +++++++++++++-------------- dlls/winecoreaudio.drv/unixlib.h | 9 +++++++++ 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c index 2d5aa29555a..76febf1eb91 100644 --- a/dlls/winecoreaudio.drv/coreaudio.c +++ b/dlls/winecoreaudio.drv/coreaudio.c @@ -1219,6 +1219,24 @@ static NTSTATUS get_latency(void *args) return STATUS_SUCCESS; } +static UINT32 get_current_padding_nolock(struct coreaudio_stream *stream) +{ + if(stream->flow == eCapture) capture_resample(stream); + return stream->held_frames; +} + +static NTSTATUS get_current_padding(void *args) +{ + struct get_current_padding_params *params = args; + struct coreaudio_stream *stream = params->stream; + + if(params->lock) OSSpinLockLock(&stream->lock); + *params->padding = get_current_padding_nolock(stream); + if(params->lock) OSSpinLockUnlock(&stream->lock); + params->result = S_OK; + return STATUS_SUCCESS; +} + unixlib_entry_t __wine_unix_call_funcs[] = { get_endpoint_ids, @@ -1228,6 +1246,7 @@ unixlib_entry_t __wine_unix_call_funcs[] = is_format_supported, get_buffer_size, get_latency, + get_current_padding, capture_resample /* temporary */ }; diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index 63deb458f1a..5d140665a83 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -874,22 +874,23 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient3 *iface, static HRESULT AudioClient_GetCurrentPadding_nolock(ACImpl *This, UINT32 *numpad) { + struct get_current_padding_params params; + if(!This->stream) return AUDCLNT_E_NOT_INITIALIZED; - if(This->dataflow == eCapture) - capture_resample(This); - - *numpad = This->stream->held_frames; - - return S_OK; + params.stream = This->stream; + params.padding = numpad; + params.lock = FALSE; + UNIX_CALL(get_current_padding, ¶ms); + return params.result; } static HRESULT WINAPI AudioClient_GetCurrentPadding(IAudioClient3 *iface, UINT32 *numpad) { ACImpl *This = impl_from_IAudioClient3(iface); - HRESULT hr; + struct get_current_padding_params params; TRACE("(%p)->(%p)\n", This, numpad); @@ -899,13 +900,11 @@ static HRESULT WINAPI AudioClient_GetCurrentPadding(IAudioClient3 *iface, if(!This->stream) return AUDCLNT_E_NOT_INITIALIZED; - OSSpinLockLock(&This->stream->lock); - - hr = AudioClient_GetCurrentPadding_nolock(This, numpad); - - OSSpinLockUnlock(&This->stream->lock); - - return hr; + params.stream = This->stream; + params.padding = numpad; + params.lock = TRUE; + UNIX_CALL(get_current_padding, ¶ms); + return params.result; } static HRESULT WINAPI AudioClient_IsFormatSupported(IAudioClient3 *iface, diff --git a/dlls/winecoreaudio.drv/unixlib.h b/dlls/winecoreaudio.drv/unixlib.h index dd86cd81973..072ffd233c3 100644 --- a/dlls/winecoreaudio.drv/unixlib.h +++ b/dlls/winecoreaudio.drv/unixlib.h @@ -107,6 +107,14 @@ struct get_latency_params REFERENCE_TIME *latency; }; +struct get_current_padding_params +{ + struct coreaudio_stream *stream; + BOOL lock; /* temporary */ + HRESULT result; + UINT32 *padding; +}; + enum unix_funcs { unix_get_endpoint_ids, @@ -116,6 +124,7 @@ enum unix_funcs unix_is_format_supported, unix_get_buffer_size, unix_get_latency, + unix_get_current_padding, unix_capture_resample /* temporary */ };