diff --git a/dlls/winealsa.drv/alsa.c b/dlls/winealsa.drv/alsa.c index f79a655780c878021a94dc2ee5743e10da67af03..cc0f9166d1a616c64833070f41f46f6deb3f50b3 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 a1477dbe850de7c38e703ba6021b3d7e3666a320..46fd2b3aef56116579703abe83bf01364e5c064b 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 771f189bca4271a8ce6d0e1f2c6421d2c780aa35..e079b88cbdeab1b025bccbe679cd3da027aa6af0 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;