alsa-utils: updated 1.0.18rc3 and removed RH specific udev helpers
This commit is contained in:
parent
78088923b3
commit
1e0bef8f50
@ -17,3 +17,4 @@ alsa-utils-1.0.14.tar.bz2
|
||||
alsa-utils-1.0.15rc1.tar.bz2
|
||||
alsa-utils-1.0.16.tar.bz2
|
||||
alsa-utils-1.0.17.tar.bz2
|
||||
alsa-utils-1.0.18rc3.tar.bz2
|
||||
|
103
alsa-info.sh
103
alsa-info.sh
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_VERSION=0.4.48
|
||||
SCRIPT_VERSION=0.4.51
|
||||
CHANGELOG="http://www.alsa-project.org/alsa-info.sh.changelog"
|
||||
|
||||
#################################################################################
|
||||
@ -33,7 +33,11 @@ PASTEBINKEY="C9cRIO8m/9y8Cs0nVs0FraRx7U0pHsuc"
|
||||
#Define some simple functions
|
||||
|
||||
pbcheck(){
|
||||
[[ $(ping -c1 www.pastebin.ca) ]] || KEEP_FILES="yes" NOUPLOAD="yes" PBERROR="yes"
|
||||
if [[ -z $PASTEBIN ]]; then
|
||||
[[ $(ping -c1 www.alsa-project.org) ]] || KEEP_FILES="yes" NOUPLOAD="yes" PBERROR="yes"
|
||||
else
|
||||
[[ $(ping -c1 www.pastebin.ca) ]] || KEEP_FILES="yes" NOUPLOAD="yes" PBERROR="yes"
|
||||
fi
|
||||
}
|
||||
|
||||
update() {
|
||||
@ -69,12 +73,6 @@ cleanup() {
|
||||
}
|
||||
|
||||
|
||||
#### FIX ME
|
||||
withsecure() {
|
||||
POST_URL="http://alsa-info.pastebin.ca"
|
||||
}
|
||||
###########
|
||||
|
||||
withaplay() {
|
||||
echo "!!Aplay/Arecord output" >> $FILE
|
||||
echo "!!------------" >> $FILE
|
||||
@ -106,6 +104,7 @@ withamixer() {
|
||||
CARD_NAME=`grep "^ *$i " /tmp/alsainfo/alsacards.tmp|awk {'print $2'}`
|
||||
echo "!!-------Mixer controls for card $i $CARD_NAME]" >> $FILE
|
||||
echo "" >>$FILE
|
||||
amixer -c$i info>> $FILE 2>&1
|
||||
amixer -c$i>> $FILE 2>&1
|
||||
echo "" >> $FILE
|
||||
done
|
||||
@ -192,6 +191,8 @@ SYSFS=$(mount |grep sysfs|awk {'print $3'});
|
||||
#Check modprobe config files for sound related options
|
||||
SNDOPTIONS=$(modprobe -c|sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p')
|
||||
|
||||
PASTEBIN=""
|
||||
WWWSERVICE="www.alsa-project.org"
|
||||
QUESTION="yes"
|
||||
PROCEED="yes"
|
||||
REPEAT=""
|
||||
@ -205,6 +206,10 @@ case "$1" in
|
||||
--no-upload)
|
||||
NOUPLOAD="yes"
|
||||
;;
|
||||
--pastebin)
|
||||
PASTEBIN="yes"
|
||||
WWWSERVICE="pastebin"
|
||||
;;
|
||||
--no-dialog)
|
||||
DIALOG=""
|
||||
REPEAT=""
|
||||
@ -219,7 +224,7 @@ if [ "$QUESTION" = "yes" ]; then
|
||||
if [[ -n "$DIALOG" ]]
|
||||
then
|
||||
if [ -z "$NOUPLOAD" ]; then
|
||||
dialog --backtitle "$BGTITLE" --title "ALSA-Info script v $SCRIPT_VERSION" --yesno "\nThis script will collect information about your ALSA installation and sound related hardware, to help diagnose your problem\n\nBy default, this script will AUTOMATICALLY UPLOAD your information to a pastebin site.\n\nSee $0 --help for options\n\nDo you want to run this script?" 0 0
|
||||
dialog --backtitle "$BGTITLE" --title "ALSA-Info script v $SCRIPT_VERSION" --yesno "\nThis script will collect information about your ALSA installation and sound related hardware, to help diagnose your problem\n\nBy default, this script will AUTOMATICALLY UPLOAD your information to a $WWWSERVICE site.\n\nSee $0 --help for options\n\nDo you want to run this script?" 0 0
|
||||
else
|
||||
dialog --backtitle "$BGTITLE" --title "ALSA-Info script v $SCRIPT_VERSION" --yesno "\nThis script will collect information about your ALSA installation and sound related hardware, to help diagnose your problem\n\nSee $0 --help for options\n\nDo you want to run this script?" 0 0
|
||||
fi
|
||||
@ -238,11 +243,11 @@ echo ""
|
||||
if [ -z "$NOUPLOAD" ]; then
|
||||
if [[ -n "$TPUT" ]]; then
|
||||
tput bold
|
||||
echo "By default, the collected information will be AUTOMATICALLY uploaded to a pastebin site."
|
||||
echo "By default, the collected information will be AUTOMATICALLY uploaded to a $WWWSERVICE site."
|
||||
echo "If you do not wish for this to occur, run the script with the --no-upload argument"
|
||||
tput sgr0
|
||||
else
|
||||
echo "By default, the collected information will be AUTOMATICALLY uploaded to a pastebin site."
|
||||
echo "By default, the collected information will be AUTOMATICALLY uploaded to a $WWWSERVICE site."
|
||||
echo "If you do not wish for this to occur, run the script with the --no-upload argument"
|
||||
fi
|
||||
echo ""
|
||||
@ -297,7 +302,11 @@ cat /proc/asound/card*/codec97\#0/ac97\#0-0 > /tmp/alsainfo/alsa-ac97.tmp 2> /de
|
||||
cat /proc/asound/card*/codec97\#0/ac97\#0-0+regs > /tmp/alsainfo/alsa-ac97-regs.tmp 2> /dev/null
|
||||
|
||||
#Fetch the info, and put it in $FILE in a nice readable format.
|
||||
if [[ -z $PASTEBIN ]]; then
|
||||
echo "upload=true&script=true&cardinfo=" > $FILE
|
||||
else
|
||||
echo "name=$USER&type=33&description=/tmp/alsa-info.txt&expiry=&s=Submit+Post&content=" > $FILE
|
||||
fi
|
||||
echo "!!################################" >> $FILE
|
||||
echo "!!ALSA Information Script v $SCRIPT_VERSION" >> $FILE
|
||||
echo "!!################################" >> $FILE
|
||||
@ -425,6 +434,16 @@ then
|
||||
until [ -z "$1" ]
|
||||
do
|
||||
case "$1" in
|
||||
--pastebin)
|
||||
update
|
||||
withdevices
|
||||
withconfigs
|
||||
withaplay
|
||||
withamixer
|
||||
withalsactl
|
||||
withlsmod
|
||||
pbcheck
|
||||
;;
|
||||
--update)
|
||||
update
|
||||
exit
|
||||
@ -510,18 +529,23 @@ then
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "alsa-info.sh version $SCRIPT_VERSION"
|
||||
echo ""
|
||||
echo "Available options:"
|
||||
echo " --with-aplay (includes the output of aplay -l)"
|
||||
echo " --with-amixer (includes the output of amixer)"
|
||||
echo " --with-alsactl (includes the output of alsactl)"
|
||||
echo " --with-configs (includes the output of ~/.asoundrc and /etc/asound.conf if they exist)"
|
||||
echo " --with-configs (includes the output of ~/.asoundrc and"
|
||||
echo " /etc/asound.conf if they exist)"
|
||||
echo " --with-devices (shows the device nodes in /dev/snd/)"
|
||||
echo ""
|
||||
echo " --update (check server for script updates)"
|
||||
echo " --no-upload (do not upload contents to remote server)"
|
||||
echo " --pastebin (use http://pastebin.ca) as remote server"
|
||||
echo " instead www.alsa-project.org"
|
||||
echo " --about (show some information about the script)"
|
||||
echo " --debug (will run the script as normal, but will not delete $FILE)"
|
||||
echo " --debug (will run the script as normal, but will not"
|
||||
echo " delete $FILE)"
|
||||
cleanup
|
||||
exit 0
|
||||
;;
|
||||
@ -539,6 +563,14 @@ then
|
||||
if [[ -n "$DIALOG" ]]
|
||||
then
|
||||
if [[ -z $NOUPLOAD ]]; then
|
||||
if [[ -z $PASTEBIN ]]; then
|
||||
wget -O - --tries=5 --timeout=60 --post-file=/tmp/alsa-info.txt "http://www.alsa-project.org/cardinfo-db/" &>/tmp/alsainfo/wget.tmp || echo "Upload failed; exit"
|
||||
{ for i in 10 20 30 40 50 60 70 80 90; do
|
||||
echo $i
|
||||
sleep 0.2
|
||||
done
|
||||
echo; } |dialog --backtitle "$BGTITLE" --guage "Uploading information to www.alsa-project.org ..." 6 70 0
|
||||
else
|
||||
wget -O - --tries=5 --timeout=60 --post-file=/tmp/alsa-info.txt "http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY&encrypt=t&encryptpw=blahblah" &>/tmp/alsainfo/wget.tmp || echo "Upload failed; exit"
|
||||
{ for i in 10 20 30 40 50 60 70 80 90; do
|
||||
echo $i
|
||||
@ -546,12 +578,18 @@ then
|
||||
done
|
||||
echo; } |dialog --backtitle "$BGTITLE" --guage "Uploading information to www.pastebin.ca ..." 6 70 0
|
||||
fi
|
||||
fi
|
||||
else
|
||||
|
||||
if [[ -z $NOUPLOAD ]]; then
|
||||
if [[ -z $PASTEBIN ]]; then
|
||||
echo -n "Uploading information to www.alsa-project.org ... "
|
||||
wget -O - --tries=5 --timeout=60 --post-file=/tmp/alsa-info.txt http://www.alsa-project.org/cardinfo-db/ &>/tmp/alsainfo/wget.tmp &
|
||||
else
|
||||
echo -n "Uploading information to www.pastebin.ca ... "
|
||||
wget -O - --tries=5 --timeout=60 --post-file=/tmp/alsa-info.txt http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY &>/tmp/alsainfo/wget.tmp &
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
#Progess spinner for wget transfer.
|
||||
if [[ -z "$DIALOG" ]]
|
||||
@ -569,9 +607,17 @@ fi
|
||||
if [[ -z $NOUPLOAD ]]; then
|
||||
if [[ -n "$TPUT" ]]
|
||||
then
|
||||
FINAL_URL=`tput setaf 1; grep "SUCCESS:" /tmp/alsainfo/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p';tput sgr0`
|
||||
if [[ -z $PASTEBIN ]]; then
|
||||
FINAL_URL=`tput setaf 1; grep "SUCCESS:" /tmp/alsainfo/wget.tmp | cut -d ' ' -f 2 ; tput sgr0`
|
||||
else
|
||||
FINAL_URL=`tput setaf 1; grep "SUCCESS:" /tmp/alsainfo/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p';tput sgr0`
|
||||
fi
|
||||
else
|
||||
FINAL_URL=`grep "SUCCESS:" /tmp/alsainfo/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'`
|
||||
if [[ -z $PASTEBIN ]]; then
|
||||
FINAL_URL=`grep "SUCCESS:" /tmp/alsainfo/wget.tmp | cut -d ' ' -f 2`
|
||||
else
|
||||
FINAL_URL=`grep "SUCCESS:" /tmp/alsainfo/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'`
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
#Output the URL of the uploaded file.
|
||||
@ -589,9 +635,9 @@ if [[ -n $DIALOG ]]
|
||||
then
|
||||
if [[ -n $NOUPLOAD ]]; then
|
||||
if [[ -n $PBERROR ]]; then
|
||||
dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "An error occured while contacting the pastebin. Your information was NOT automatically uploaded.\n\nYour ALSA information can be seen by looking in $FILE" 10 100
|
||||
dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "An error occured while contacting the $WWWSERVICE. Your information was NOT automatically uploaded.\n\nYour ALSA information can be seen by looking in $FILE" 10 100
|
||||
else
|
||||
dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "You requested that your information was NOT automatically uploaded to the pastebin\n\nYour ALSA information can be seen by looking in $FILE" 10 100
|
||||
dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "You requested that your information was NOT automatically uploaded to the $WWWSERVICE\n\nYour ALSA information can be seen by looking in $FILE" 10 100
|
||||
fi
|
||||
else
|
||||
dialog --backtitle "$BGTITLE" --title "Information uploaded" --yesno "Would you like to see the uploaded information?" 5 100
|
||||
@ -605,12 +651,12 @@ fi
|
||||
clear
|
||||
if [[ -n $NOUPLOAD ]]; then
|
||||
if [[ -n $PBERROR ]]; then
|
||||
echo "An error occured while contacting the pastebin. Your information was NOT automatically uploaded."
|
||||
echo "An error occured while contacting the $WWWSERVICE. Your information was NOT automatically uploaded."
|
||||
echo ""
|
||||
echo "Your ALSA information can be seen by looking in $FILE"
|
||||
echo ""
|
||||
else
|
||||
echo "You requested that your information was NOT automatically uploaded to the pastebin"
|
||||
echo "You requested that your information was NOT automatically uploaded to the $WWWSERVICE"
|
||||
echo ""
|
||||
echo "Your ALSA information can be seen by looking in $FILE"
|
||||
echo ""
|
||||
@ -621,7 +667,7 @@ echo "Your ALSA information is located at $FINAL_URL"
|
||||
echo "Please inform the person helping you."
|
||||
echo ""
|
||||
fi
|
||||
#We posted the file to pastebin.ca , so we dont need it anymore. delete it.
|
||||
#We posted the file , so we dont need it anymore. delete it.
|
||||
if [ -z $KEEP_FILES ]
|
||||
then
|
||||
rm $FILE
|
||||
@ -631,6 +677,16 @@ fi
|
||||
else
|
||||
if [[ -z $DIALOG ]]
|
||||
then
|
||||
if [[ -z $PASTEBIN ]]; then
|
||||
echo ""
|
||||
echo "Could not automatically upload output to http://www.alsa-project.org"
|
||||
echo "Possible reasons are:"
|
||||
echo " 1. Couldnt find 'wget' in your PATH"
|
||||
echo " 2. Your version of wget is less than 1.8.2"
|
||||
echo ""
|
||||
echo "Please manually upload $FILE to http://www.alsa-project.org/cardinfo-db/ and submit your post."
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
echo "Could not automatically upload output to http://www.pastebin.ca"
|
||||
echo "Possible reasons are:"
|
||||
@ -639,10 +695,15 @@ else
|
||||
echo ""
|
||||
echo "Please manually upload $FILE to http://www.pastebin.ca/upload.php and submit your post."
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
if [[ -n $DIALOG ]]
|
||||
then
|
||||
dialog --backtitle "$BGTITLE" --msgbox "Could not automatically upload output to http://www.pastebin.ca.\nPossible reasons are:\n\n 1. Couldn't find 'wget' in your PATH\n 2. Your version of wget is less than 1.8.2\n\nPlease manually upload $FILE to http://www.pastebin.ca/upload.php and submit your post." 25 100
|
||||
if [[ -z $PASTEBIN ]]; then
|
||||
dialog --backtitle "$BGTITLE" --msgbox "Could not automatically upload output to http://www.alsa-project.org.\nPossible reasons are:\n\n 1. Couldn't find 'wget' in your PATH\n 2. Your version of wget is less than 1.8.2\n\nPlease manually upload $FILE to http://www.alsa-project,org/cardinfo-db/ and submit your post." 25 100
|
||||
else
|
||||
dialog --backtitle "$BGTITLE" --msgbox "Could not automatically upload output to http://www.pastebin.ca.\nPossible reasons are:\n\n 1. Couldn't find 'wget' in your PATH\n 2. Your version of wget is less than 1.8.2\n\nPlease manually upload $FILE to http://www.pastebin.ca/upload.php and submit your post." 25 100
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
#Clean up the temp files
|
||||
|
@ -1,70 +0,0 @@
|
||||
--- alsa-utils-1.0.14/alsaconf/alsaconf.in~ 2007-05-31 11:07:21.000000000 +0300
|
||||
+++ alsa-utils-1.0.14/alsaconf/alsaconf.in 2007-08-26 22:40:21.000000000 +0300
|
||||
@@ -938,8 +938,8 @@ If you have a big amplifier, lower your
|
||||
aplay -N $TESTSOUND
|
||||
fi
|
||||
fi
|
||||
- if [ ! -r /etc/asound.state ]; then
|
||||
- xecho "Saving the mixer setup used for this in /etc/asound.state."
|
||||
+ if [ ! -r /etc/alsa/asound.state ]; then
|
||||
+ xecho "Saving the mixer setup used for this in /etc/alsa/asound.state."
|
||||
$sbindir/alsactl store
|
||||
fi
|
||||
clear
|
||||
--- alsa-utils-1.0.14/alsaconf/po/ja.po~ 2007-05-31 11:07:21.000000000 +0300
|
||||
+++ alsa-utils-1.0.14/alsaconf/po/ja.po 2007-08-26 22:40:43.000000000 +0300
|
||||
@@ -203,8 +203,8 @@ msgstr ""
|
||||
" テスト音が聞こえるかどうか確認してください。\n"
|
||||
|
||||
#: ../alsaconf.in:932
|
||||
-msgid "Saving the mixer setup used for this in /etc/asound.state."
|
||||
-msgstr "ミキサーの設定を /etc/asound.state に保存します"
|
||||
+msgid "Saving the mixer setup used for this in /etc/alsa/asound.state."
|
||||
+msgstr "ミキサーの設定を /etc/alsa/asound.state に保存します"
|
||||
|
||||
#: ../alsaconf.in:936
|
||||
msgid ""
|
||||
--- alsa-utils-1.0.14/alsaconf/po/ru.po~ 2007-05-31 11:07:21.000000000 +0300
|
||||
+++ alsa-utils-1.0.14/alsaconf/po/ru.po 2007-08-26 22:40:34.000000000 +0300
|
||||
@@ -211,8 +211,8 @@ msgstr ""
|
||||
" и удостоверьтесь что вы слышите тестовый пример.\n"
|
||||
|
||||
#: ../alsaconf.in:932
|
||||
-msgid "Saving the mixer setup used for this in /etc/asound.state."
|
||||
-msgstr "Сохраняем настройки микшера в /etc/asound.state."
|
||||
+msgid "Saving the mixer setup used for this in /etc/alsa/asound.state."
|
||||
+msgstr "Сохраняем настройки микшера в /etc/alsa/asound.state."
|
||||
|
||||
#: ../alsaconf.in:936
|
||||
msgid ""
|
||||
--- alsa-utils-1.0.14/alsactl/alsactl.1~ 2007-05-31 11:07:21.000000000 +0300
|
||||
+++ alsa-utils-1.0.14/alsactl/alsactl.1 2007-08-26 22:40:03.000000000 +0300
|
||||
@@ -35,7 +35,7 @@ Help: show available flags and commands.
|
||||
|
||||
.TP
|
||||
\fI\-f, \-\-file\fP
|
||||
-Select the configuration file to use. The default is /etc/asound.state or
|
||||
+Select the configuration file to use. The default is /etc/alsa/asound.state or
|
||||
/etc/asound.names (for the \fInames\fP command).
|
||||
|
||||
.TP
|
||||
@@ -52,7 +52,7 @@ Use debug mode: a bit more verbose.
|
||||
Print alsactl version number.
|
||||
|
||||
.SH FILES
|
||||
-\fI/etc/asound.state\fP (or whatever file you specify with the
|
||||
+\fI/etc/alsa/asound.state\fP (or whatever file you specify with the
|
||||
\fB\-f\fP flag) is used to store current settings for your
|
||||
soundcards. The settings include all the usual soundcard mixer
|
||||
settings. More importantly, alsactl is
|
||||
--- alsa-utils-1.0.14/alsactl/alsactl.c~ 2007-05-31 11:07:21.000000000 +0300
|
||||
+++ alsa-utils-1.0.14/alsactl/alsactl.c 2007-08-26 22:40:10.000000000 +0300
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <alsa/asoundlib.h>
|
||||
#include "alsactl.h"
|
||||
|
||||
-#define SYS_ASOUNDRC "/etc/asound.state"
|
||||
+#define SYS_ASOUNDRC "/etc/alsa/asound.state"
|
||||
#define SYS_ASOUNDNAMES "/etc/asound.names"
|
||||
|
||||
int debugflag = 0;
|
@ -1,22 +1,19 @@
|
||||
#define prever rc1
|
||||
#define prever_dot .rc1
|
||||
%define prever rc3
|
||||
%define prever_dot .rc3
|
||||
|
||||
Summary: Advanced Linux Sound Architecture (ALSA) utilities
|
||||
Name: alsa-utils
|
||||
Version: 1.0.17
|
||||
Version: 1.0.18
|
||||
Release: 1%{?prever_dot}%{?dist}
|
||||
License: GPLv2+
|
||||
Group: Applications/Multimedia
|
||||
URL: http://www.alsa-project.org/
|
||||
Source: ftp://ftp.alsa-project.org/pub/utils/alsa-utils-%{version}%{?prever}.tar.bz2
|
||||
Source2: salsa.c
|
||||
Source3: alsacard.c
|
||||
Source4: alsaunmute.c
|
||||
Source5: salsa.1
|
||||
Source4: alsaunmute
|
||||
Source6: alsa-info.sh
|
||||
Source10: alsa.rules
|
||||
Source11: alsactl.conf
|
||||
Patch0: alsa-utils-1.0.17-alsaconf.patch
|
||||
Patch1: alsa-utils-1.0.14-statedir.patch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: alsa-lib-devel >= %{version}
|
||||
BuildRequires: ncurses-devel
|
||||
@ -30,14 +27,10 @@ Architecture (ALSA).
|
||||
%prep
|
||||
%setup -q -n %{name}-%{version}%{?prever}
|
||||
%patch0 -p1
|
||||
%patch1 -p1 -b .statedir
|
||||
|
||||
%build
|
||||
%configure CFLAGS="$RPM_OPT_FLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" --sbindir=/sbin
|
||||
%{__make} %{?_smp_mflags}
|
||||
%{__cc} $RPM_OPT_FLAGS -o salsa %{SOURCE2} -lasound
|
||||
%{__cc} $RPM_OPT_FLAGS -o alsacard %{SOURCE3} -lasound
|
||||
%{__cc} $RPM_OPT_FLAGS -o alsaunmute %{SOURCE4} -lasound
|
||||
%{__cp} %{SOURCE5} .
|
||||
|
||||
%install
|
||||
@ -51,20 +44,16 @@ install -p -m 644 %{SOURCE10} $RPM_BUILD_ROOT/etc/udev/rules.d/90-alsa.rules
|
||||
|
||||
# Install support utilities
|
||||
mkdir -p -m755 $RPM_BUILD_ROOT/bin
|
||||
install -p -m 755 alsacard alsaunmute %{buildroot}/bin/
|
||||
install -p -m 755 salsa %{buildroot}/sbin/
|
||||
install -p -m 755 alsaunmute %{buildroot}/bin/
|
||||
|
||||
# Link alsactl to /usr/sbin
|
||||
mkdir -p $RPM_BUILD_ROOT/%{_sbindir}
|
||||
ln -s ../../sbin/alsactl $RPM_BUILD_ROOT/%{_sbindir}/alsactl
|
||||
|
||||
# Create a place for volume configuration
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/alsa
|
||||
touch $RPM_BUILD_ROOT/etc/alsa/asound.state
|
||||
|
||||
# Install salsa man page
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1
|
||||
install -p -m 644 salsa.1 %{buildroot}/usr/share/man/man1
|
||||
# Create a place for global configuration
|
||||
mkdir -p -m 755 $RPM_BUILD_ROOT/etc/alsa
|
||||
install -p -m 644 alsactl.conf %{buildroot}/etc/alsa
|
||||
touch $RPM_BUILD_ROOT/etc/asound.state
|
||||
|
||||
# Install alsa-info.sh script
|
||||
install -p -m 755 %{SOURCE6} $RPM_BUILD_ROOT/usr/bin/alsa-info
|
||||
@ -76,6 +65,7 @@ install -p -m 755 %{SOURCE6} $RPM_BUILD_ROOT/usr/bin/alsa-info
|
||||
%defattr(-,root,root,-)
|
||||
%doc COPYING ChangeLog README TODO
|
||||
%config /etc/udev/rules.d/*
|
||||
%config /etc/alsa/*
|
||||
/bin/*
|
||||
/sbin/*
|
||||
%{_bindir}/*
|
||||
@ -84,10 +74,19 @@ install -p -m 755 %{SOURCE6} $RPM_BUILD_ROOT/usr/bin/alsa-info
|
||||
%{_datadir}/sounds/
|
||||
%{_mandir}/man?/*
|
||||
%dir /etc/alsa/
|
||||
%ghost /etc/alsa/asound.state
|
||||
%ghost /etc/asound.state
|
||||
|
||||
|
||||
%changelog
|
||||
* Thu Sep 11 2008 Jaroslav Kysela <jkysela@redhat.com> 1.0.18-1.rc3
|
||||
- updated to 1.0.18rc3
|
||||
- updated alsa-info.sh script to 0.4.51
|
||||
- removed alsacard utility
|
||||
- removed salsa utility
|
||||
- changed alsaunmute to use 'alsactl init' now
|
||||
- updated ALSA udevd rules to use alsactl
|
||||
- moved /etc/alsa/asound.state back to /etc/asound.state
|
||||
|
||||
* Mon Jul 21 2008 Jaroslav Kysela <jkysela@redhat.com> 1.0.17-1
|
||||
- updated to 1.0.17 final
|
||||
- updated alsa-info.sh script to 0.4.48
|
||||
|
@ -1,2 +1,4 @@
|
||||
SUBSYSTEM=="sound", KERNEL=="controlC*" RUN+="/sbin/salsa"
|
||||
SUBSYSTEM=="sound", KERNEL=="pcm*" RUN+="/sbin/salsa"
|
||||
ACTION=="add", SUBSYSTEM=="sound", KERNEL=="controlC*", \
|
||||
ENV{ALSA_CONFIG_PATH}="/etc/alsa/alsactl.conf", RUN+="/sbin/alsactl restore $name"
|
||||
ACTION=="remove", SUBSYSTEM=="sound", KERNEL=="controlC*", \
|
||||
ENV{ALSA_CONFIG_PATH}="/etc/alsa/alsactl.conf", RUN+="/sbin/alsactl store $name"
|
||||
|
46
alsacard.c
46
alsacard.c
@ -1,46 +0,0 @@
|
||||
/* Copyright 2005 Red Hat, Inc.
|
||||
*
|
||||
* This software may be freely redistributed under the terms of the GNU
|
||||
* public license.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
int get_card_device(const char *p_device)
|
||||
{
|
||||
int err;
|
||||
snd_ctl_t *handle;
|
||||
snd_ctl_card_info_t *info;
|
||||
|
||||
snd_ctl_card_info_alloca(&info);
|
||||
|
||||
if ((err = snd_ctl_open(&handle, "default", 0)) < 0) {
|
||||
fprintf(stderr,"Open error: %s\n", snd_strerror(err));
|
||||
return(0);
|
||||
}
|
||||
if ((err = snd_ctl_card_info(handle, info)) < 0) {
|
||||
fprintf(stderr,"HW info error: %s\n", snd_strerror(err));
|
||||
return(0);
|
||||
}
|
||||
|
||||
return (snd_ctl_card_info_get_card(info));
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *p_device = "default";
|
||||
int card;
|
||||
|
||||
if (argc > 1 && argv[1])
|
||||
p_device = argv[1];
|
||||
|
||||
card = get_card_device(p_device);
|
||||
printf("%d",card);
|
||||
return (card);
|
||||
}
|
14
alsactl.conf
Normal file
14
alsactl.conf
Normal file
@ -0,0 +1,14 @@
|
||||
#
|
||||
# ALSA library configuration file for alsactl tool
|
||||
# (/usr/share/alsa tree is not necessary for alsactl)
|
||||
#
|
||||
|
||||
ctl.hw {
|
||||
@args [ CARD ]
|
||||
@args.CARD {
|
||||
type string
|
||||
default "0"
|
||||
}
|
||||
type hw
|
||||
card $CARD
|
||||
}
|
5
alsaunmute
Executable file
5
alsaunmute
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
export ALSA_CONFIG_PATH="/etc/alsa/alsactl.conf"
|
||||
exec /sbin/alsactl init
|
||||
|
407
alsaunmute.c
407
alsaunmute.c
@ -1,407 +0,0 @@
|
||||
/* Copyright 2005 Red Hat, Inc.
|
||||
*
|
||||
* Portions extraced from various ALSA code:
|
||||
* Copyright (c) by Abramo Bagnara <abramo@alsa-project.org>
|
||||
* Jaroslav Kysela <perex@suse.cz>
|
||||
* Takashi Iwai <tiwai@suse.de>
|
||||
* Bernd Kaindl <bk@suse.de>
|
||||
* Jan ONDREJ (SAL) <ondrejj@salstar.sk>
|
||||
*
|
||||
* This software may be freely redistributed under the terms of the GNU
|
||||
* public license.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
TODO
|
||||
-> external unmute table
|
||||
*/
|
||||
|
||||
#define VERSION "0.3"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
#define TRUE (1==1)
|
||||
#define FALSE (1!=1)
|
||||
|
||||
int verbose = 0;
|
||||
int help = 0;
|
||||
|
||||
typedef struct _CHANNEL {
|
||||
|
||||
char name[100];
|
||||
int play_volume;
|
||||
int play_switch;
|
||||
int rec_volume;
|
||||
int rec_switch;
|
||||
char driver[100];
|
||||
|
||||
} CHANNEL;
|
||||
|
||||
CHANNEL channels[] = {
|
||||
|
||||
// channel pl vol pl swt rec vol rec swt driver
|
||||
|
||||
{"Master", 75, 1, 0, 0, ""},
|
||||
{"Front", 75, 1, 0, 0, ""},
|
||||
{"PCM", 75, 1, 0, 0, ""},
|
||||
{"PCM-2", 75, 1, 0, 0, ""},
|
||||
{"Synth", 75, 1, 0, 0, ""},
|
||||
{"CD", 75, 1, 90, 1, ""},
|
||||
{"Mono", 75, 1, 0, 0, ""},
|
||||
{"Master Mono", 75, 1, 0, 0, ""},
|
||||
{"Speaker", 75, 1, 0, 0, ""},
|
||||
|
||||
// mute mic
|
||||
{"Mic", 0, 0, 0, 0, ""},
|
||||
|
||||
// Trident/YMFPCI/emu10k1
|
||||
{"Wave", 100, 1, 0, 0, ""},
|
||||
{"Music", 100, 1, 0, 0, ""},
|
||||
{"AC97", 100, 1, 0, 0, ""},
|
||||
|
||||
// CS4237B chipset
|
||||
{"Master Digital", 75, 1, 0, 0, ""},
|
||||
|
||||
// Envy24 chips with analog outs
|
||||
{"DAC", 75, 1, 0, 0, ""},
|
||||
|
||||
// Powermacs
|
||||
{"DRC Range", 75, 1, 0, 0, ""},
|
||||
|
||||
// some notebooks use headphone instead of master
|
||||
{"Headphone", 75, 1, 0, 0, ""},
|
||||
{"Playback", 100, 1, 0, 0, ""},
|
||||
|
||||
// turn off digital switches
|
||||
{"SB Live Analog/Digital Output Jack", 0, 0, 0, 0, ""},
|
||||
// removed - should by set by driver
|
||||
// {"Audigy Analog/Digital Output Jack", 0, 0, 0, 0, ""},
|
||||
|
||||
// Specific config for ca0106
|
||||
{"Analog Front", 75, 1, 0, 0, "snd-ca0106"},
|
||||
{"Analog Rear", 75, 1, 0, 0, "snd-ca0106"},
|
||||
{"SPDIF Out", 0, 0, 0, 0, "snd-ca0106"},
|
||||
|
||||
// Specific config for snd-emu10k1
|
||||
// Removed (#187807)
|
||||
// {"Audigy Analog/Digital Output Jack", 0,1,0, 0, "snd-emu10k1"},
|
||||
{"IEC958 Optical Raw", 0, 0, 0, 0, "snd-emu10k1"},
|
||||
{"Tone", 0, 0, 0, 0, "snd-emu10k1"},
|
||||
|
||||
// Specific config for AC97/HDA
|
||||
{"External Amplifier", 1, 1, 0, 0, "snd-intel8x0"},
|
||||
{"iSpeaker", 75, 1, 0, 0, "snd-hda-intel"},
|
||||
{"Internal Speaker", 75, 1, 0, 0, "snd-hda-intel"},
|
||||
|
||||
// Specific config for snd-ens1371
|
||||
{"IEC958", 0, 0, 0, 0, "snd-ens1371"}
|
||||
};
|
||||
|
||||
char * strlwr(char *a)
|
||||
{
|
||||
char *ret = a;
|
||||
|
||||
while (*a != '\0') {
|
||||
if (isupper (*a))
|
||||
*a = tolower (*a);
|
||||
a++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
CHANNEL * channel_find(const char *p_name, const char *p_driver) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(channels) / sizeof(channels[0]); i++)
|
||||
if (!strcmp(channels[i].driver, p_driver) && !strcmp(channels[i].name, p_name))
|
||||
return (channels + i);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int calc_volume(long min, long max, int percent)
|
||||
{
|
||||
return ((int)(min + ((max - min) / 100.0f) * percent));
|
||||
}
|
||||
|
||||
int unmute_card(int index, const char *p_driver)
|
||||
{
|
||||
CHANNEL *p_chan;
|
||||
long pmin, pmax;
|
||||
long rmin, rmax;
|
||||
int rc = 0;
|
||||
char card[32];
|
||||
char channel_name[500];
|
||||
int c,vol;
|
||||
|
||||
snd_mixer_t *handle;
|
||||
snd_mixer_selem_id_t *sid;
|
||||
snd_mixer_elem_t *elem;
|
||||
snd_mixer_selem_id_alloca(&sid);
|
||||
|
||||
if(verbose) {
|
||||
fprintf(stderr,"Unmuting %s...\n",p_driver ? p_driver : "");
|
||||
}
|
||||
|
||||
sprintf(card, "hw:%d", index);
|
||||
if ((rc = snd_mixer_open(&handle, 0)) < 0) {
|
||||
if(verbose) {
|
||||
fprintf(stderr,"%s: error file %s, line %d...\n",__FUNCTION__,__FILE__,__LINE__);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
if ((rc = snd_mixer_attach(handle, card)) < 0) {
|
||||
if(verbose) {
|
||||
fprintf(stderr,"%s: error file %s, line %d...\n",__FUNCTION__,__FILE__,__LINE__);
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
if ((rc = snd_mixer_selem_register(handle, NULL, NULL)) < 0) {
|
||||
if(verbose) {
|
||||
fprintf(stderr,"%s: error file %s, line %d...\n",__FUNCTION__,__FILE__,__LINE__);
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
rc = snd_mixer_load(handle);
|
||||
if (rc < 0) {
|
||||
if(verbose) {
|
||||
fprintf(stderr,"%s: error file %s, line %d...\n",__FUNCTION__,__FILE__,__LINE__);
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (elem = snd_mixer_first_elem(handle); elem;
|
||||
elem = snd_mixer_elem_next(elem)) {
|
||||
|
||||
snd_mixer_selem_get_id(elem, sid);
|
||||
strncpy(channel_name,snd_mixer_selem_id_get_name(sid),500);
|
||||
channel_name[499] = '\0';
|
||||
p_chan = channel_find(strlwr(channel_name),p_driver);
|
||||
if (!p_chan)
|
||||
continue;
|
||||
|
||||
for (c = 0; c < SND_MIXER_SCHN_LAST; c++) {
|
||||
|
||||
if (snd_mixer_selem_has_capture_channel(elem, c)) {
|
||||
if (snd_mixer_selem_has_capture_switch(elem)) {
|
||||
snd_mixer_selem_set_capture_switch(elem, c, p_chan->rec_switch);
|
||||
if(verbose) {
|
||||
fprintf(stderr,"Cap. Switch %s(%d) to %d\n",p_chan->name,c,p_chan->rec_switch);
|
||||
}
|
||||
}
|
||||
if (snd_mixer_selem_has_capture_volume(elem)) {
|
||||
snd_mixer_selem_get_capture_volume_range(elem, &rmin, &rmax);
|
||||
vol = calc_volume(rmin, rmax,p_chan->rec_volume);
|
||||
snd_mixer_selem_set_capture_volume(elem, c, vol);
|
||||
if(verbose) {
|
||||
fprintf(stderr,"Cap. Volume %s(%d) to %d\n",p_chan->name,c,vol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (snd_mixer_selem_has_playback_channel(elem, c)) {
|
||||
if (snd_mixer_selem_has_playback_switch(elem)) {
|
||||
snd_mixer_selem_set_playback_switch(elem, c, p_chan->play_switch);
|
||||
if(verbose) {
|
||||
fprintf(stderr,"Play. Switch %s(%d) to %d\n",p_chan->name,c,p_chan->play_switch);
|
||||
}
|
||||
}
|
||||
if (snd_mixer_selem_has_playback_volume(elem)) {
|
||||
snd_mixer_selem_get_playback_volume_range(elem, &pmin, &pmax);
|
||||
vol = calc_volume(pmin, pmax,p_chan->play_volume);
|
||||
snd_mixer_selem_set_playback_volume(elem, c, vol);
|
||||
if(verbose) {
|
||||
fprintf(stderr,"Play. Volume %s(%d) to %d\n",p_chan->name,c,vol);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
|
||||
out:
|
||||
snd_mixer_close(handle);
|
||||
return rc;
|
||||
}
|
||||
|
||||
char * check_driver_name(char *p_name)
|
||||
{
|
||||
char *p_tmp = strchr(p_name,'-');
|
||||
if(p_tmp) {
|
||||
*p_tmp = '_';
|
||||
}
|
||||
return(p_name);
|
||||
}
|
||||
|
||||
#define PROC_MODULES "/proc/asound/modules"
|
||||
|
||||
static char driver_name[100];
|
||||
|
||||
const char * get_card_driver(int index)
|
||||
{
|
||||
FILE *f = fopen(PROC_MODULES,"r");
|
||||
char tmp[100];
|
||||
int id;
|
||||
|
||||
if(!f)
|
||||
return(NULL);
|
||||
|
||||
while(fgets(tmp,100,f)) {
|
||||
sscanf(tmp," %d %s",&id,driver_name);
|
||||
if(id == index) {
|
||||
return(check_driver_name(driver_name));
|
||||
}
|
||||
}
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
void set_volume(int volume)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(channels) / sizeof(channels[0]); i++) {
|
||||
if (channels[i].play_volume > 1)
|
||||
channels[i].play_volume = volume;
|
||||
}
|
||||
}
|
||||
|
||||
void check_data(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(channels) / sizeof(channels[0]); i++) {
|
||||
strlwr(channels[i].name);
|
||||
check_driver_name(channels[i].driver);
|
||||
}
|
||||
}
|
||||
|
||||
int get_card_device(const char *p_device)
|
||||
{
|
||||
int err;
|
||||
snd_ctl_t *handle;
|
||||
snd_ctl_card_info_t *info;
|
||||
int card = 0;
|
||||
|
||||
snd_ctl_card_info_alloca(&info);
|
||||
|
||||
if ((err = snd_ctl_open(&handle, "default", 0)) < 0) {
|
||||
fprintf(stderr,"Open error: %s\n", snd_strerror(err));
|
||||
return(0);
|
||||
}
|
||||
if ((err = snd_ctl_card_info(handle, info)) < 0) {
|
||||
fprintf(stderr,"HW info error: %s\n", snd_strerror(err));
|
||||
return(0);
|
||||
}
|
||||
|
||||
card = snd_ctl_card_info_get_card(info);
|
||||
|
||||
snd_ctl_close(handle);
|
||||
|
||||
return(card);
|
||||
}
|
||||
|
||||
void usage(void)
|
||||
{
|
||||
printf("Alsa Unmute utility, Version %s, Copyright 2005 Red Hat, Inc.\n",VERSION);
|
||||
printf("This software may be freely redistributed under the terms of the GNU\n");
|
||||
printf("public license.\n\n");
|
||||
|
||||
printf("Usage: alsaunmute [options]\n\n");
|
||||
printf(" [card_number] - sound card number. If this parameter is not given,\n");
|
||||
printf(" the \"default\" sound device is unmuted.\n");
|
||||
printf(" [-D device] - unmute specified alsa device (like \"default\")\n");
|
||||
printf(" [-v] - verbose mode\n");
|
||||
printf(" [-s volume] - set this volume level instead of the default (75%%)\n");
|
||||
printf(" the volume is number from 0 to 100\n");
|
||||
printf(" [-h] - this help\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
Unmute specified card
|
||||
alsaunmute 0
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *p_driver;
|
||||
char *p_device = "default";
|
||||
int index = -1;
|
||||
int volume = 75;
|
||||
int param;
|
||||
|
||||
for(param = 1; param < argc; param++) {
|
||||
if (argv[param][0] >= '0' && argv[param][0] <= '9') {
|
||||
index = atoi(argv[param]);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[param],"-v")) {
|
||||
verbose = TRUE;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[param],"-h") || !strcmp(argv[param],"--help")) {
|
||||
help = TRUE;
|
||||
continue;
|
||||
}
|
||||
if (param+1 < argc && !strcmp(argv[param],"-s")) {
|
||||
param++;
|
||||
volume = atoi(argv[param]);
|
||||
continue;
|
||||
}
|
||||
if (param+1 < argc && !strcmp(argv[param],"-D")) {
|
||||
param++;
|
||||
p_device = argv[param];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(help) {
|
||||
usage();
|
||||
}
|
||||
|
||||
|
||||
if(index == -1) {
|
||||
if(verbose) {
|
||||
fprintf(stderr,"Unmuting ALSA device '%s'...\n",p_device);
|
||||
}
|
||||
index = get_card_device(p_device);
|
||||
}
|
||||
else {
|
||||
if(verbose) {
|
||||
fprintf(stderr,"Unmuting ALSA card %d...\n",index);
|
||||
}
|
||||
}
|
||||
|
||||
p_driver = get_card_driver(index);
|
||||
if(!p_driver) {
|
||||
fprintf(stderr,"Wrong card index %d...\n",index);
|
||||
return(1);
|
||||
}
|
||||
|
||||
if(verbose) {
|
||||
fprintf(stderr,"Card %d Driver %s Volume %d%%...\n",index,p_driver,volume);
|
||||
}
|
||||
|
||||
check_data();
|
||||
|
||||
// setting volume
|
||||
set_volume(volume);
|
||||
|
||||
// default settings for all cards
|
||||
unmute_card(index,"");
|
||||
|
||||
// specific setting for selected card_number
|
||||
unmute_card(index,p_driver);
|
||||
|
||||
return (0);
|
||||
}
|
23
salsa.1
23
salsa.1
@ -1,23 +0,0 @@
|
||||
.TH SALSA "1" "January 2008" "alsa-utils" "User Commands"
|
||||
.SH NAME
|
||||
salsa \- ALSA sound card volume settings handler
|
||||
.SH SYNOPSIS
|
||||
.B salsa
|
||||
[\fB-ls\fR] [\fIcard number\fR]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
salsa is used to save or load the volume settings for sound cards.
|
||||
.PP
|
||||
The card number is optional. If you don't specify one, all
|
||||
installed sound cards will be configured.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-l\fR
|
||||
Load volume settings
|
||||
.TP
|
||||
\fB\-s\fR
|
||||
Save volume settings
|
||||
.SH FILES
|
||||
/etc/alsa/asound.state
|
||||
.SH "SEE ALSO"
|
||||
alsactl(1)
|
166
salsa.c
166
salsa.c
@ -1,166 +0,0 @@
|
||||
/* Copyright 2007 Red Hat, Inc.
|
||||
*
|
||||
* Portions extraced from various ALSA code:
|
||||
* Copyright (c) by Abramo Bagnara <abramo@alsa-project.org>
|
||||
* Jaroslav Kysela <perex@suse.cz>
|
||||
*
|
||||
* This software may be freely redistributed under the terms of the GNU
|
||||
* public license.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
#define ALSA_CONFIG_PATH "/etc/alsa/asound.state"
|
||||
#define ALL_CARDS (-1)
|
||||
|
||||
|
||||
int get_card_number()
|
||||
{
|
||||
char *devname, *action;
|
||||
|
||||
action = getenv("ACTION");
|
||||
if (!action || strcmp(action, "add"))
|
||||
return -1;
|
||||
devname = getenv("DEVNAME");
|
||||
if (!devname)
|
||||
return -1;
|
||||
if (!strncmp(devname, "/dev/snd/controlC", 17))
|
||||
return atoi(devname + 17);
|
||||
if (!strncmp(devname, "/dev/snd/pcmC", 13))
|
||||
return atoi(devname + 13);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int has_config(int index)
|
||||
{
|
||||
int rc = 0;
|
||||
snd_config_t *config, *control;
|
||||
snd_input_t *in;
|
||||
snd_ctl_t *handle;
|
||||
snd_ctl_card_info_t *info;
|
||||
const char *id;
|
||||
char path[32];
|
||||
|
||||
rc = snd_config_top(&config);
|
||||
if (rc < 0)
|
||||
goto out;
|
||||
rc = snd_input_stdio_open(&in, ALSA_CONFIG_PATH, "r");
|
||||
if (rc >= 0) {
|
||||
rc = snd_config_load(config, in);
|
||||
snd_input_close(in);
|
||||
if (rc < 0)
|
||||
goto out;
|
||||
}
|
||||
sprintf(path, "hw:%d", index);
|
||||
rc = snd_ctl_open(&handle, path, 0);
|
||||
if (rc < 0)
|
||||
goto out;
|
||||
snd_ctl_card_info_alloca(&info);
|
||||
rc = snd_ctl_card_info(handle, info);
|
||||
if (rc < 0)
|
||||
goto out_close;
|
||||
id = snd_ctl_card_info_get_id(info);
|
||||
rc = snd_config_searchv(config, &control, "state", id, "control", 0);
|
||||
out_close:
|
||||
snd_ctl_close(handle);
|
||||
out:
|
||||
return !rc;
|
||||
|
||||
}
|
||||
|
||||
void load_volume_settings(int index)
|
||||
{
|
||||
char *args[] = { "/sbin/alsactl", "-f", ALSA_CONFIG_PATH, "restore", NULL, NULL };
|
||||
char num[10];
|
||||
|
||||
if(index != ALL_CARDS) {
|
||||
snprintf(num, 10, "%d", index);
|
||||
args[4] = num;
|
||||
}
|
||||
|
||||
execv(args[0], args);
|
||||
}
|
||||
|
||||
void save_volume_settings(int index)
|
||||
{
|
||||
char *args[] = { "/sbin/alsactl", "-f", ALSA_CONFIG_PATH, "store", NULL, NULL };
|
||||
char num[10];
|
||||
|
||||
if(index != ALL_CARDS) {
|
||||
snprintf(num, 10, "%d", index);
|
||||
args[4] = num;
|
||||
}
|
||||
|
||||
execv(args[0], args);
|
||||
}
|
||||
|
||||
void frob_mixer(int index)
|
||||
{
|
||||
char tmp[100];
|
||||
snprintf(tmp, 100, "%d", index);
|
||||
tmp[99] = '\0';
|
||||
execl("/bin/alsaunmute","/bin/alsaunmute", tmp, "-v", NULL);
|
||||
}
|
||||
|
||||
void banner(void)
|
||||
{
|
||||
printf("ALSA volume settings handler, Copyright 2007 Red Hat, Inc.\n");
|
||||
printf("This software may be freely redistributed under\nthe terms of the GNU public license.\n\n");
|
||||
|
||||
printf("Usage: salsa [options] [card number]\n\n");
|
||||
printf(" Options:\n");
|
||||
printf(" -l - Load volume settings\n");
|
||||
printf(" -s - Save volume settings\n\n");
|
||||
printf(" Card number:\n");
|
||||
printf(" ## - An affected card. If it isn't specified,\n");
|
||||
printf(" configure all installed sound cards.\n\n");
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(argc == 1) {
|
||||
i = get_card_number();
|
||||
if (i < 0) {
|
||||
return 0;
|
||||
}
|
||||
if (has_config(i)) {
|
||||
load_volume_settings(i);
|
||||
}
|
||||
else {
|
||||
frob_mixer(i);
|
||||
}
|
||||
}
|
||||
else if(argc >= 2) {
|
||||
|
||||
int card_number = ALL_CARDS;
|
||||
if(argc == 3) {
|
||||
card_number = atoi(argv[2]);
|
||||
}
|
||||
|
||||
if(argv[1][1] == 'l') {
|
||||
load_volume_settings(card_number);
|
||||
}
|
||||
else if(argv[1][1] == 's') {
|
||||
save_volume_settings(card_number);
|
||||
}
|
||||
else {
|
||||
banner();
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user