flakes/overlays/misc/wine/0002-5.14-Latency-Fix.patch
2021-06-23 22:34:53 +07:00

59 lines
2 KiB
Diff

From 4a2c23db4eddd827ac81513af43bc92475ad7d3a Mon Sep 17 00:00:00 2001
From: Sebastian 'gonX' Jensen <gonx@gonx.dk>
Date: Sun, 20 Jun 2021 17:02:15 +0200
Subject: [PATCH 2/4] 5.14 Latency Fix
---
dlls/winepulse.drv/mmdevdrv.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 07407089ac5af65eb13d6e00b6d0969a61ec5589..3ed47e38c830987e4bcc2e9f5c59c7773fe686f1 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -68,9 +68,6 @@ enum DriverPriority {
Priority_Preferred
};
-static const REFERENCE_TIME MinimumPeriod = 30000;
-static const REFERENCE_TIME DefaultPeriod = 100000;
-
static pa_context *pulse_ctx;
static pa_mainloop *pulse_ml;
@@ -510,11 +507,12 @@ static void pulse_probe_settings(int render, WAVEFORMATEXTENSIBLE *fmt) {
if (length)
pulse_def_period[!render] = pulse_min_period[!render] = pa_bytes_to_usec(10 * length, &ss);
- if (pulse_min_period[!render] < MinimumPeriod)
- pulse_min_period[!render] = MinimumPeriod;
-
- if (pulse_def_period[!render] < DefaultPeriod)
- pulse_def_period[!render] = DefaultPeriod;
+ const char* penv = getenv("STAGING_AUDIO_PERIOD");
+ if (penv) {
+ int val = atoi(penv);
+ pulse_def_period[!render] = pulse_min_period[!render] = val;
+ printf("Staging audio period set to %d.\n", val);
+ }
wfx->wFormatTag = WAVE_FORMAT_EXTENSIBLE;
wfx->cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
@@ -1640,6 +1638,14 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient2 *iface,
if (duration <= 2 * period)
period /= 2;
}
+
+ const char* denv = getenv("STAGING_AUDIO_DURATION");
+ if (denv) {
+ int val = atoi(denv);
+ duration = val;
+ printf("Staging audio duration set to %d.\n", val);
+ }
+
period_bytes = pa_frame_size(&This->ss) * MulDiv(period, This->ss.rate, 10000000);
if (duration < 20000000)
--
2.32.0