[PATCH 05/12] winecoreaudio: Move get_current_padding to the unixlib.
Andrew Eikum
aeikum at codeweavers.com
Tue Nov 23 09:22:43 CST 2021
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
On Tue, Nov 23, 2021 at 07:55:02AM +0000, Huw Davies wrote:
> Signed-off-by: Huw Davies <huw at codeweavers.com>
> ---
> 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 */
> };
> --
> 2.23.0
>
>
More information about the wine-devel
mailing list