summaryrefslogtreecommitdiff
path: root/modules/multimedia/audio/pipewire.nix
blob: 282417628f4f978bc2ae140b51d118a8d4252276 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# { lib, ... }:
# let
#   inherit (lib.modules) mkBefore;
#   inherit (lib.lists) singleton;
#   inherit (builtins) toString;
#   mapOptionDefault = lib.attrsets.mapAttrs (_: lib.modules.mkOptionDefault);
#   quantum = toString 64;
#   rate = toString 48000;
#   qr = "${quantum}/${rate}";
# in
{
  services.pipewire = {
    enable = true;
    wireplumber.enable = true;
    jack.enable = true;
    pulse.enable = true;
    audio.enable = true;

    alsa = {
      enable = true;
      support32Bit = true;
    };

    extraConfig = {
      pipewire = {
        "10-logging" = {
          "context.properties"."log.level" = 3;
        };

        # "10-defaults" = {
        #   "context.properties" = mapOptionDefault {
        #     "clock.power-of-two-quantum" = true;
        #     "core.daemon" = true;
        #     "core.name" = "pipewire-0";
        #     "link.max-buffers" = 16;
        #     "settings.check-quantum" = true;
        #   };

        #   "context.spa-libs" = mapOptionDefault {
        #     "audio.convert.*" = "audioconvert/libspa-audioconvert";
        #     "avb.*" = "avb/libspa-avb";
        #     "api.alsa.*" = "alsa/libspa-alsa";
        #     "api.v4l2.*" = "v4l2/libspa-v4l2";
        #     "api.libcamera.*" = "libcamera/libspa-libcamera";
        #     "api.bluez5.*" = "bluez5/libspa-bluez5";
        #     "api.vulkan.*" = "vulkan/libspa-vulkan";
        #     "api.jack.*" = "jack/libspa-jack";
        #     "support.*" = "support/libspa-support";
        #     "video.convert.*" = "videoconvert/libspa-videoconvert";
        #   };
        # };
      };

      # pipewire-pulse = {
      #   "10-defaults" = {
      #     "context.spa-libs" = mapOptionDefault {
      #       "audio.convert.*" = "audioconvert/libspa-audioconvert";
      #       "support.*" = "support/libspa-support";
      #     };

      #     "pulse.cmd" = mkBefore [
      #       {
      #         cmd = "load-module";
      #         args = "module-always-sink";
      #         flags = [ ];
      #       }
      #     ];

      #     "pulse.properties" = {
      #       "server.address" = mkBefore [ "unix:native" ];
      #     };

      #     "pulse.rules" = mkBefore [
      #       {
      #         matches = [
      #           { "application.process.binary" = "teams"; }
      #           { "application.process.binary" = "teams-insiders"; }
      #           { "application.process.binary" = "skypeforlinux"; }
      #         ];

      #         actions.quirks = [ "force-s16-info" ];
      #       }
      #       {
      #         matches = singleton { "application.process.binary" = "firefox"; };
      #         actions.quirks = [ "remove-capture-dont-move" ];
      #       }
      #       {
      #         matches = singleton { "application.name" = "~speech-dispatcher*"; };

      #         actions = {
      #           update-props = {
      #             "pulse.min.req" = "1024/48000"; # 21 milliseconds
      #             "pulse.min.quantum " = "1024/48000"; # 21 milliseconds
      #           };
      #         };
      #       }
      #     ];
      #   };
      # };

      # pipewire."92-low-latency" = {
      #   "context.properties" = {
      #     "default.clock.rate" = rate;
      #     "default.clock.quantum" = quantum;
      #     "default.clock.min-quantum" = quantum;
      #     "default.clock.max-quantum" = quantum;
      #     "default.clock.allowed-rates" = [ rate ];
      #   };

      #   # "context.modules" = [
      #   #   {
      #   #     name = "libpipewire-module-rtkit";

      #   #     flags = [
      #   #       "ifexists"
      #   #       "nofail"
      #   #     ];

      #   #     args = {
      #   #       "nice.level" = -15;
      #   #       "rt.prio" = 90;
      #   #       "rt.time.soft" = 200000;
      #   #       "rt.time.hard" = 200000;
      #   #     };
      #   #   }
      #   #   {
      #   #     name = "libpipewire-module-protocol-pulse";

      #   #     args = {
      #   #       "server.address" = [ "unix:native" ];
      #   #       "pulse.min.quantum" = qr;
      #   #       "pulse.min.req" = qr;
      #   #       "pulse.min.frag" = qr;
      #   #     };
      #   #   }
      #   # ];

      #   "stream.properties" = {
      #     "node.latency" = qr;
      #     "resample.quality" = 1;
      #   };
      # };

      # pipewire-pulse."92-low-latency" = {
      #   "context.modules" = singleton {
      #     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" = 4;
      #   };
      # };
    };
  };
}