[PATCH 08/12] winecoreaudio: Move reset to the unixlib.

Huw Davies huw at codeweavers.com
Tue Nov 23 01:55:05 CST 2021


Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/winecoreaudio.drv/coreaudio.c | 29 ++++++++++++++++++++++++++++
 dlls/winecoreaudio.drv/mmdevdrv.c  | 31 ++++--------------------------
 dlls/winecoreaudio.drv/unixlib.h   |  7 +++++++
 3 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c
index 5a49a786f48..ee34cd29de1 100644
--- a/dlls/winecoreaudio.drv/coreaudio.c
+++ b/dlls/winecoreaudio.drv/coreaudio.c
@@ -1275,6 +1275,34 @@ static NTSTATUS stop(void *args)
     return STATUS_SUCCESS;
 }
 
+static NTSTATUS reset(void *args)
+{
+    struct reset_params *params = args;
+    struct coreaudio_stream *stream = params->stream;
+
+    OSSpinLockLock(&stream->lock);
+
+    if(stream->playing)
+        params->result = AUDCLNT_E_NOT_STOPPED;
+    else if(stream->getbuf_last)
+        params->result = AUDCLNT_E_BUFFER_OPERATION_PENDING;
+    else{
+        if(stream->flow == eRender)
+            stream->written_frames = 0;
+        else
+            stream->written_frames += stream->held_frames;
+        stream->held_frames = 0;
+        stream->lcl_offs_frames = 0;
+        stream->wri_offs_frames = 0;
+        stream->cap_offs_frames = 0;
+        stream->cap_held_frames = 0;
+        params->result = S_OK;
+    }
+
+    OSSpinLockUnlock(&stream->lock);
+    return STATUS_SUCCESS;
+}
+
 unixlib_entry_t __wine_unix_call_funcs[] =
 {
     get_endpoint_ids,
@@ -1282,6 +1310,7 @@ unixlib_entry_t __wine_unix_call_funcs[] =
     release_stream,
     start,
     stop,
+    reset,
     get_mix_format,
     is_format_supported,
     get_buffer_size,
diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c
index e214a85c0d3..cf2c23a0f40 100644
--- a/dlls/winecoreaudio.drv/mmdevdrv.c
+++ b/dlls/winecoreaudio.drv/mmdevdrv.c
@@ -1041,39 +1041,16 @@ static HRESULT WINAPI AudioClient_Stop(IAudioClient3 *iface)
 static HRESULT WINAPI AudioClient_Reset(IAudioClient3 *iface)
 {
     ACImpl *This = impl_from_IAudioClient3(iface);
+    struct reset_params params;
 
     TRACE("(%p)\n", This);
 
     if(!This->stream)
         return AUDCLNT_E_NOT_INITIALIZED;
 
-    OSSpinLockLock(&This->stream->lock);
-
-    if(This->stream->playing){
-        OSSpinLockUnlock(&This->stream->lock);
-        return AUDCLNT_E_NOT_STOPPED;
-    }
-
-    if(This->stream->getbuf_last){
-        OSSpinLockUnlock(&This->stream->lock);
-        return AUDCLNT_E_BUFFER_OPERATION_PENDING;
-    }
-
-    if(This->dataflow == eRender){
-        This->stream->written_frames = 0;
-    }else{
-        This->stream->written_frames += This->stream->held_frames;
-    }
-
-    This->stream->held_frames = 0;
-    This->stream->lcl_offs_frames = 0;
-    This->stream->wri_offs_frames = 0;
-    This->stream->cap_offs_frames = 0;
-    This->stream->cap_held_frames = 0;
-
-    OSSpinLockUnlock(&This->stream->lock);
-
-    return S_OK;
+    params.stream = This->stream;
+    UNIX_CALL(reset, &params);
+    return params.result;
 }
 
 static HRESULT WINAPI AudioClient_SetEventHandle(IAudioClient3 *iface,
diff --git a/dlls/winecoreaudio.drv/unixlib.h b/dlls/winecoreaudio.drv/unixlib.h
index c3da84c2c7a..450293052c7 100644
--- a/dlls/winecoreaudio.drv/unixlib.h
+++ b/dlls/winecoreaudio.drv/unixlib.h
@@ -87,6 +87,12 @@ struct stop_params
     HRESULT result;
 };
 
+struct reset_params
+{
+    struct coreaudio_stream *stream;
+    HRESULT result;
+};
+
 struct get_mix_format_params
 {
     EDataFlow flow;
@@ -134,6 +140,7 @@ enum unix_funcs
     unix_release_stream,
     unix_start,
     unix_stop,
+    unix_reset,
     unix_get_mix_format,
     unix_is_format_supported,
     unix_get_buffer_size,
-- 
2.23.0




More information about the wine-devel mailing list