Huw Davies : winealsa: Move get_buffer_size to the unixlib.

Alexandre Julliard julliard at winehq.org
Thu Feb 24 15:33:41 CST 2022


Module: wine
Branch: master
Commit: 413b3c59e5a401797a584cd4ead127c5b697d789
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=413b3c59e5a401797a584cd4ead127c5b697d789

Author: Huw Davies <huw at codeweavers.com>
Date:   Wed Feb 23 09:08:21 2022 +0000

winealsa: Move get_buffer_size to the unixlib.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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, &params->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, &params);
 
-    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;




More information about the wine-cvs mailing list