all repos — nixfiles @ 7e8fa95c6665515fc30422782ab0525aabd0ad7c

System and user configuration, managed by nix and home-manager

gaming: fix low-latency audio setup
Alan Pearce alan@alanpearce.eu
Mon, 10 Oct 2022 23:15:41 +0200
commit

7e8fa95c6665515fc30422782ab0525aabd0ad7c

parent

b33437969b10090ff0749367d8e7306013f8c887

1 files changed, 40 insertions(+), 11 deletions(-)

jump to
M system/settings/gaming.nixsystem/settings/gaming.nix
@@ -25,6 +25,7 @@ "context.properties" = {       "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"; }
@@ -74,6 +64,45 @@ { name = "libpipewire-module-session-manager"; }     ];
     "stream.properties" = {
       "node.latency" = "32/44100";
+      "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;
     };
   };