[PATCH 1/6] winecoreaudio: Pass a ptr to receive the stream in create_stream.

Huw Davies huw at codeweavers.com
Mon Apr 25 01:58:33 CDT 2022


This matches the other drivers.

Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/winecoreaudio.drv/coreaudio.c |  2 +-
 dlls/winecoreaudio.drv/mmdevdrv.c  | 16 +++++++++-------
 dlls/winecoreaudio.drv/unixlib.h   |  2 +-
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c
index f242ebe54a8..5892a0e44f4 100644
--- a/dlls/winecoreaudio.drv/coreaudio.c
+++ b/dlls/winecoreaudio.drv/coreaudio.c
@@ -700,7 +700,7 @@ end:
         free(stream->fmt);
         free(stream);
     } else
-        params->stream = stream;
+        *params->stream = stream;
 
     return STATUS_SUCCESS;
 }
diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c
index 128396fbe29..2ba4e7ee028 100644
--- a/dlls/winecoreaudio.drv/mmdevdrv.c
+++ b/dlls/winecoreaudio.drv/mmdevdrv.c
@@ -666,6 +666,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
     ACImpl *This = impl_from_IAudioClient3(iface);
     struct release_stream_params release_params;
     struct create_stream_params params;
+    struct coreaudio_stream *stream;
     UINT32 i;
 
     TRACE("(%p)->(%x, %x, %s, %s, %p, %s)\n", This, mode, flags,
@@ -734,10 +735,13 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
     params.duration = duration;
     params.period = period;
     params.fmt = fmt;
-    params.stream = NULL;
+    params.stream = &stream;
 
     UNIX_CALL(create_stream, &params);
-    if(FAILED(params.result)) goto end;
+    if(FAILED(params.result)){
+        LeaveCriticalSection(&g_sessions_lock);
+        return params.result;
+    }
 
     This->flags = flags;
     This->channel_count = fmt->nChannels;
@@ -759,14 +763,12 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
 
 end:
     if(FAILED(params.result)){
-        if(params.stream){
-            release_params.stream = params.stream;
-            UNIX_CALL(release_stream, &release_params);
-        }
+        release_params.stream = stream;
+        UNIX_CALL(release_stream, &release_params);
         HeapFree(GetProcessHeap(), 0, This->vols);
         This->vols = NULL;
     }else{
-        This->stream = params.stream;
+        This->stream = stream;
         set_stream_volumes(This, -1);
     }
 
diff --git a/dlls/winecoreaudio.drv/unixlib.h b/dlls/winecoreaudio.drv/unixlib.h
index bd9a5ce03bd..e48670ab2f0 100644
--- a/dlls/winecoreaudio.drv/unixlib.h
+++ b/dlls/winecoreaudio.drv/unixlib.h
@@ -46,7 +46,7 @@ struct create_stream_params
     REFERENCE_TIME period;
     const WAVEFORMATEX *fmt;
     HRESULT result;
-    struct coreaudio_stream *stream;
+    struct coreaudio_stream **stream;
 };
 
 struct release_stream_params
-- 
2.23.0




More information about the wine-devel mailing list