fix pipewire stuff
This commit is contained in:
parent
7d954a61ef
commit
baf94ae575
4 changed files with 83 additions and 44 deletions
|
@ -38,7 +38,7 @@ in {
|
|||
quantum = mkOption {
|
||||
type = types.int;
|
||||
description = "Pipewire quantum in low latency mode";
|
||||
default = 64;
|
||||
default = 32;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -64,31 +64,62 @@ in {
|
|||
pulseaudio
|
||||
];
|
||||
|
||||
environment.etc."wireplumber/main.lua.d/51-alsa-config.lua" = mkIf cfg.lowLatency {
|
||||
text = ''
|
||||
alsa_monitor.properties = {
|
||||
["audio.rate"] = ${
|
||||
toString (cfg.rate
|
||||
* (
|
||||
if cfg.usbSoundcard
|
||||
then 2
|
||||
else 1
|
||||
))
|
||||
},
|
||||
["audio.format"] = "S32LE",
|
||||
["api.alsa.headroom"] = 512,
|
||||
["api.alsa.period-size"] = ${toString cfg.periodSize}
|
||||
}
|
||||
'';
|
||||
services.pipewire.extraConfig.pipewire."92-low-latency" = mkIf cfg.lowLatency {
|
||||
context.properties = {
|
||||
default.clock.rate = cfg.rate;
|
||||
default.clock.quantum = cfg.quantum;
|
||||
default.clock.min-quantum = cfg.quantum;
|
||||
default.clock.max-quantum = cfg.quantum;
|
||||
};
|
||||
};
|
||||
|
||||
environment.etc."wireplumber/bluetooth.lua.d/51-bluez-config.lua".text = ''
|
||||
bluez_monitor.properties = {
|
||||
["bluez5.enable-sbc-xq"] = true,
|
||||
["bluez5.enable-msbc"] = true,
|
||||
["bluez5.enable-hw-volume"] = true,
|
||||
["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]"
|
||||
}
|
||||
'';
|
||||
services.pipewire.extraConfig.pipewire-pulse."92-low-latency" = mkIf cfg.lowLatency {
|
||||
context.modules = [
|
||||
{
|
||||
name = "libpipewire-module-protocol-pulse";
|
||||
args = {
|
||||
pulse.min.req = qr;
|
||||
pulse.default.req = qr;
|
||||
pulse.max.req = qr;
|
||||
pulse.min.quantum = qr;
|
||||
pulse.max.quantum = qr;
|
||||
};
|
||||
}
|
||||
];
|
||||
stream.properties = {
|
||||
node.latency = qr;
|
||||
resample.quality = 1;
|
||||
};
|
||||
};
|
||||
|
||||
services.pipewire.wireplumber.configPackages =
|
||||
[
|
||||
(pkgs.writeTextDir "share/wireplumber/bluetooth.lua.d/51-bluez-config.lua" ''
|
||||
bluez_monitor.properties = {
|
||||
["bluez5.enable-sbc-xq"] = true,
|
||||
["bluez5.enable-msbc"] = true,
|
||||
["bluez5.enable-hw-volume"] = true,
|
||||
["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]"
|
||||
}
|
||||
'')
|
||||
]
|
||||
++ optional cfg.lowLatency (pkgs.writeTextDir "share/wireplumber/main.lua.d/99-alsa-lowlatency.lua" ''
|
||||
alsa_monitor.rules = {
|
||||
{
|
||||
matches = {{{ "node.name", "matches", "alsa_output.*" }}};
|
||||
apply_properties = {
|
||||
["audio.format"] = "S32LE",
|
||||
["audio.rate"] = "${toString (cfg.rate
|
||||
* (
|
||||
if cfg.usbSoundcard
|
||||
then 2
|
||||
else 1
|
||||
))}", -- for USB soundcards it should be twice your desired rate
|
||||
["api.alsa.period-size"] = ${toString cfg.periodSize}, -- defaults to 1024, tweak by trial-and-error
|
||||
-- ["api.alsa.disable-batch"] = true, -- generally, USB soundcards use the batch mode
|
||||
},
|
||||
},
|
||||
}
|
||||
'');
|
||||
};
|
||||
}
|
||||
|
|
|
@ -36,7 +36,11 @@ in {
|
|||
};
|
||||
|
||||
boot = {
|
||||
consoleLogLevel = lib.mkDefault (if cfg.fancyBoot then 0 else 3);
|
||||
consoleLogLevel = lib.mkDefault (
|
||||
if cfg.fancyBoot
|
||||
then 0
|
||||
else 3
|
||||
);
|
||||
initrd.verbose = lib.mkDefault (!cfg.fancyBoot);
|
||||
plymouth.enable = lib.mkDefault cfg.fancyBoot;
|
||||
kernelParams = lib.mkIf cfg.fancyBoot [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue