Skip to content

Commit

Permalink
Pulseaudio direct connection
Browse files Browse the repository at this point in the history
Set Ghaf audio apps to directly connect to audiovm with pulseaudio
With this change we can also remove the pulseaudio don't move patch

Signed-off-by: Jon Sahlberg <[email protected]>
  • Loading branch information
josa41 authored and brianmcgillion committed Oct 23, 2024
1 parent 46c621a commit 5d5ae6d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion modules/microvm/virtualization/microvm/appvm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ let

ghaf-audio = {
inherit (vm.ghafAudio) enable;
inherit (vm.ghafAudio) useTunneling;
name = "${vm.name}";
};

Expand Down Expand Up @@ -270,7 +271,10 @@ in
type = types.nullOr types.str;
default = null;
};
ghafAudio.enable = lib.mkEnableOption "Ghaf application audio support";
ghafAudio = {
enable = lib.mkEnableOption "Ghaf application audio support";
useTunneling = lib.mkEnableOption "Use Pulseaudio tunneling";
};
vtpm.enable = lib.mkEnableOption "vTPM support in the virtual machine";
};
}
Expand Down
15 changes: 12 additions & 3 deletions modules/microvm/virtualization/microvm/common/ghaf-audio.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,31 @@ in
'';
type = types.str;
};

useTunneling = mkEnableOption "Enable local pulseaudio with tunneling";
};

config = lib.mkIf cfg.enable {
security.rtkit.enable = true;
users.extraUsers.ghaf.extraGroups = [
security.rtkit.enable = cfg.useTunneling;
users.extraUsers.ghaf.extraGroups = lib.mkIf cfg.useTunneling [
"audio"
"video"
];

hardware.pulseaudio = {
hardware.pulseaudio = lib.mkIf cfg.useTunneling {
enable = true;
extraConfig = ''
load-module module-tunnel-sink-new sink_name=${cfg.name}.speaker server=${address} reconnect_interval_ms=${toString reconnectMs}
load-module module-tunnel-source-new source_name=${cfg.name}.mic server=${address} reconnect_interval_ms=${toString reconnectMs}
'';
package = pkgs.pulseaudio-ghaf;
};

environment = lib.mkIf (!cfg.useTunneling) {
systemPackages = [ pkgs.pulseaudio ];
sessionVariables = rec {
PULSE_SERVER = "${address}";
};
};
};
}

0 comments on commit 5d5ae6d

Please sign in to comment.