From 7e8fa95c6665515fc30422782ab0525aabd0ad7c Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 10 Oct 2022 23:15:41 +0200 Subject: gaming: fix low-latency audio setup --- system/settings/gaming.nix | 51 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/system/settings/gaming.nix b/system/settings/gaming.nix index 1ad07470..493a201e 100644 --- a/system/settings/gaming.nix +++ b/system/settings/gaming.nix @@ -25,6 +25,7 @@ "link.max-buffers" = 16; "log.level" = 2; "default.clock.rate" = 44100; + "default.clock.allowed_rates" = [ 44100 48000 88200 96000 ]; "default.clock.quantum" = 32; "default.clock.min-quantum" = 32; "default.clock.max-quantum" = 32; @@ -45,17 +46,6 @@ { name = "libpipewire-module-protocol-native"; } { name = "libpipewire-module-profiler"; } { name = "libpipewire-module-metadata"; } - { - name = "libpipewire-module-protocol-pulse"; - args = { - "pulse.min.req" = "32/44100"; - "pulse.default.req" = "32/44100"; - "pulse.max.req" = "32/44100"; - "pulse.min.quantum" = "32/44100"; - "pulse.max.quantum" = "32/44100"; - "server.address" = [ "unix:native" ]; - }; - } { name = "libpipewire-module-spa-device-factory"; } { name = "libpipewire-module-spa-node-factory"; } { name = "libpipewire-module-client-node"; } @@ -77,6 +67,45 @@ "resample.quality" = 1; }; }; + services.pipewire.config.pipewire-pulse = { + "context.properties" = { + "log.level" = 2; + }; + "context.modules" = [ + { + name = "libpipewire-module-rtkit"; + args = { + "nice.level" = -15; + "rt.prio" = 88; + "rt.time.soft" = 200000; + "rt.time.hard" = 200000; + }; + flags = [ "ifexists" "nofail" ]; + } + { name = "libpipewire-module-protocol-native"; } + { name = "libpipewire-module-client-node"; } + { name = "libpipewire-module-adapter"; } + { name = "libpipewire-module-metadata"; } + { + name = "libpipewire-module-protocol-pulse"; + args = { + "pulse.min.req" = "32/48000"; + "pulse.default.req" = "32/48000"; + "pulse.max.req" = "32/48000"; + "pulse.min.quantum" = "32/48000"; + "pulse.max.quantum" = "32/48000"; + "server.address" = [ + "unix:native" + "tcp:[::1]:4713" + ]; + }; + } + ]; + "stream.properties" = { + "node.latency" = "32/48000"; + "resample.quality" = 1; + }; + }; systemd = { extraConfig = '' -- cgit 1.4.1