[PATCH 1/3] winealsa: Move get_buffer_size to the unixlib.
Andrew Eikum
aeikum at codeweavers.com
Thu Feb 24 08:52:47 CST 2022
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
On Wed, Feb 23, 2022 at 09:08:21AM +0000, Huw Davies wrote:
> Signed-off-by: Huw Davies <huw at codeweavers.com>
> ---
> dlls/winealsa.drv/alsa.c | 31 +++++++++++++++++++++++++++++++
> dlls/winealsa.drv/mmdevdrv.c | 11 +++++------
> dlls/winealsa.drv/unixlib.h | 8 ++++++++
> 3 files changed, 44 insertions(+), 6 deletions(-)
>
> diff --git a/dlls/winealsa.drv/alsa.c b/dlls/winealsa.drv/alsa.c
> index f79a655780c..cc0f9166d1a 100644
> --- a/dlls/winealsa.drv/alsa.c
> +++ b/dlls/winealsa.drv/alsa.c
> @@ -160,6 +160,24 @@ static int muldiv( int a, int b, int c )
> return ret;
> }
>
> +static void alsa_lock(struct alsa_stream *stream)
> +{
> + pthread_mutex_lock(&stream->lock);
> +}
> +
> +static void alsa_unlock(struct alsa_stream *stream)
> +{
> + pthread_mutex_unlock(&stream->lock);
> +}
> +
> +static NTSTATUS alsa_unlock_result(struct alsa_stream *stream,
> + HRESULT *result, HRESULT value)
> +{
> + *result = value;
> + alsa_unlock(stream);
> + return STATUS_SUCCESS;
> +}
> +
> static BOOL alsa_try_open(const char *devnode, EDataFlow flow)
> {
> snd_pcm_t *handle;
> @@ -1220,6 +1238,18 @@ exit:
> return STATUS_SUCCESS;
> }
>
> +static NTSTATUS get_buffer_size(void *args)
> +{
> + struct get_buffer_size_params *params = args;
> + struct alsa_stream *stream = params->stream;
> +
> + alsa_lock(stream);
> +
> + *params->size = stream->bufsize_frames;
> +
> + return alsa_unlock_result(stream, ¶ms->result, S_OK);
> +}
> +
> unixlib_entry_t __wine_unix_call_funcs[] =
> {
> get_endpoint_ids,
> @@ -1227,4 +1257,5 @@ unixlib_entry_t __wine_unix_call_funcs[] =
> release_stream,
> is_format_supported,
> get_mix_format,
> + get_buffer_size,
> };
> diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c
> index a1477dbe850..46fd2b3aef5 100644
> --- a/dlls/winealsa.drv/mmdevdrv.c
> +++ b/dlls/winealsa.drv/mmdevdrv.c
> @@ -827,7 +827,7 @@ static HRESULT WINAPI AudioClient_GetBufferSize(IAudioClient3 *iface,
> UINT32 *out)
> {
> ACImpl *This = impl_from_IAudioClient3(iface);
> - struct alsa_stream *stream = This->stream;
> + struct get_buffer_size_params params;
>
> TRACE("(%p)->(%p)\n", This, out);
>
> @@ -837,13 +837,12 @@ static HRESULT WINAPI AudioClient_GetBufferSize(IAudioClient3 *iface,
> if(!This->stream)
> return AUDCLNT_E_NOT_INITIALIZED;
>
> - alsa_lock(stream);
> -
> - *out = stream->bufsize_frames;
> + params.stream = This->stream;
> + params.size = out;
>
> - alsa_unlock(stream);
> + ALSA_CALL(get_buffer_size, ¶ms);
>
> - return S_OK;
> + return params.result;
> }
>
> static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient3 *iface,
> diff --git a/dlls/winealsa.drv/unixlib.h b/dlls/winealsa.drv/unixlib.h
> index 771f189bca4..e079b88cbde 100644
> --- a/dlls/winealsa.drv/unixlib.h
> +++ b/dlls/winealsa.drv/unixlib.h
> @@ -108,6 +108,13 @@ struct get_mix_format_params
> HRESULT result;
> };
>
> +struct get_buffer_size_params
> +{
> + struct alsa_stream *stream;
> + HRESULT result;
> + UINT32 *size;
> +};
> +
> enum alsa_funcs
> {
> alsa_get_endpoint_ids,
> @@ -115,6 +122,7 @@ enum alsa_funcs
> alsa_release_stream,
> alsa_is_format_supported,
> alsa_get_mix_format,
> + alsa_get_buffer_size,
> };
>
> extern unixlib_handle_t alsa_handle;
> --
> 2.25.1
>
>
More information about the wine-devel
mailing list