PipeWire: Difference between revisions

imported>Fufexan
m Fufexan moved page Pipewire to PipeWire: Following proper name style
imported>Fufexan
Rewrite alsa-monitor configuration in module-specific option
Line 77: Line 77:
As a general rule, the values in <code>pipewire-pulse</code> should not be lower than the ones in <code>pipewire</code>.
As a general rule, the values in <code>pipewire-pulse</code> should not be lower than the ones in <code>pipewire</code>.
===Controlling the ALSA devices===
===Controlling the ALSA devices===
It is possible to configure various aspects of soundcards through <code>/etc/pipewire/media-session.d/alsa-monitor.conf</code>. Since there's no config option for it in the module, the file needs to be manually written:
It is possible to configure various aspects of soundcards through PipeWire, including format, period size and batch mode:
<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
environment.etc."pipewire/media-session.d/alsa-monitor.conf".text = ''
services.pipewire = {
  rules = [
  media-session.config.alsa-monitor = {
    {
    rules = [
      matches = [ { node.name = alsa_output.* } ]
      {
      actions = {
        matches = [ { "node.name" = "alsa_output.*" } ];
        update-props = {
        actions = {
          audio.format = "S16LE"
          update-props = {
          audio.rate = 48000
            "audio.format" = "S16LE";
          api.alsa.period-size = 160 # defaults to 1024, tweak by trial-and-error
            "audio.rate" = 48000;
          #api.alsa.disable-batch = true # generally, USB soundcards use the batch mode
            "api.alsa.period-size" = 160; # defaults to 1024, tweak by trial-and-error
         }
            #"api.alsa.disable-batch" = true; # generally, USB soundcards use the batch mode
       }
          };
     }
         };
   ];
       };
'';
     ];
   };
};
</syntaxHighlight>
</syntaxHighlight>
The <code>matches</code> attribute applies the <code>actions</code> to the devices/properties listed there. It is usually used with soundcard names, like shown in the config above. <code><alsa_device></code> can be one of the outputs of
The <code>matches</code> attribute applies the <code>actions</code> to the devices/properties listed there. It is usually used with soundcard names, like shown in the config above. <code><alsa_device></code> can be one of the outputs of