Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

1.2 KB
Raw Blame
diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c
index e5791534..52019d48 100644
--- a/dlls/winecoreaudio.drv/coreaudio.c
+++ b/dlls/winecoreaudio.drv/coreaudio.c
@@ -829,7 +829,12 @@ static NTSTATUS unix_create_stream(void *args)
 
     stream->period_frames = max(min_period_frames, min(stream->period_frames, max_period_frames));
     stream->period = muldiv(stream->period_frames, 10000000, stream->fmt->nSamplesPerSec);
-    if (FAILED(params->result = set_device_period_frame_size(stream->dev_id, stream->flow, stream->period_frames)))
+    /* NotProton: with the device buffer as long as Wine's 10 ms period, a render callback
+     * regularly asks for more frames than the client has written yet, and ca_render_cb
+     * pads the shortfall with silence, which is heard as crackling (Deadlock, CS2). A
+     * device buffer of half a period keeps each pull within what is already queued. */
+    if (FAILED(params->result = set_device_period_frame_size(stream->dev_id, stream->flow,
+            stream->flow == eRender ? max(min_period_frames, stream->period_frames / 2) : stream->period_frames)))
         goto end;
 
     stream->bufsize_frames = muldiv(params->duration, stream->fmt->nSamplesPerSec, 10000000);