summaryrefslogtreecommitdiffstats
path: root/perl-install/harddrake/sound.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/harddrake/sound.pm')
-rw-r--r--perl-install/harddrake/sound.pm30
1 files changed, 30 insertions, 0 deletions
diff --git a/perl-install/harddrake/sound.pm b/perl-install/harddrake/sound.pm
index 5e706c486..71bcb1e61 100644
--- a/perl-install/harddrake/sound.pm
+++ b/perl-install/harddrake/sound.pm
@@ -241,6 +241,29 @@ sub set_pulseaudio_routing {
}
+
+my $pulse_config_file = '/etc/pulse/daemon.conf';
+
+sub is_5_1_in_pulseaudio_enabled() {
+ my ($val) = (cat_($pulse_config_file) =~ /^default-sample-channels\s*=\s*(\d+)/m); #^
+ $val ||= 2;
+ $val == 6;
+}
+
+sub set_5_1_in_pulseaudio {
+ my ($val) = @_;
+ $val = 'default-sample-channels = ' . ($val ? 6 : 2) . "\n";
+ my $done;
+ substInFile {
+ if (/^default-sample-channels\s*=/) {
+ $_ = $val;
+ $done = 1;
+ }
+ } $pulse_config_file;
+ append_to_file($pulse_config_file, $val) if !$done;
+}
+
+
sub rooted { run_program::rooted($::prefix, @_) }
sub unload { modules::unload(@_) if $::isStandalone || $blacklisted }
@@ -297,6 +320,7 @@ sub switch {
my $is_pulseaudio_enabled = is_pulseaudio_enabled();
my $is_pulseaudio_routing_enabled = is_pulseaudio_routing_enabled();
+ my $is_5_1_in_pulseaudio_enabled = is_5_1_in_pulseaudio_enabled();
my $is_user_switching = is_user_switching_enabled();
my @common = (
@@ -310,6 +334,10 @@ sub switch {
type => 'bool', val => \$is_pulseaudio_routing_enabled,
},
{
+ text => N("Enable 5.1 sound with Pulse Audio"),
+ type => 'bool', val => \$is_5_1_in_pulseaudio_enabled,
+ },
+ {
text => N("Enable user switching for audio applications"),
type => 'bool', val => \$is_user_switching,
},
@@ -335,6 +363,7 @@ sub switch {
)) {
set_pulseaudio($is_pulseaudio_enabled);
set_pulseaudio_routing($is_pulseaudio_routing_enabled);
+ set_5_1_in_pulseaudio($is_5_1_in_pulseaudio_enabled);
set_user_switching($is_user_switching);
}
} elsif ($in->ask_from_({ title => N("Sound configuration"),
@@ -373,6 +402,7 @@ To use alsa, one can either use:
{
set_pulseaudio($is_pulseaudio_enabled);
set_pulseaudio_routing($is_pulseaudio_routing_enabled);
+ set_5_1_in_pulseaudio($is_5_1_in_pulseaudio_enabled);
set_user_switching($is_user_switching);
return if $new_driver eq $device->{current_driver};
log::explanations("switching audio driver from '" . $device->{current_driver} . "' to '$new_driver'\n");