From 7a2431213ad7bd3debb662dfac567eecc58b0ed6 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Tue, 11 Mar 2008 16:15:55 +0000 Subject: (is_5_1_in_pulseaudio_enabled,set_5_1_in_pulseaudio,switch) enable to set 5.1 channels (#38796) --- perl-install/NEWS | 3 +++ perl-install/harddrake/sound.pm | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'perl-install') diff --git a/perl-install/NEWS b/perl-install/NEWS index c09138f49..75b4e2525 100644 --- a/perl-install/NEWS +++ b/perl-install/NEWS @@ -1,3 +1,6 @@ +- draksound: + o enable to set 5.1 channels (#38796) + Version 10.11 - 11 March 2008 - diskdrake: 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 = ( @@ -309,6 +333,10 @@ sub switch { text => N("Automatic routing from ALSA to PulseAudio"), 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"); -- cgit v1.2.1