diff --git a/.alsa-utils.metadata b/.alsa-utils.metadata new file mode 100644 index 0000000..77195b2 --- /dev/null +++ b/.alsa-utils.metadata @@ -0,0 +1 @@ +36859b70c6b09458f9f28ae63d4fc3bf754b86b8 SOURCES/alsa-utils-1.1.8.tar.bz2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1fa7551 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/alsa-utils-1.1.8.tar.bz2 diff --git a/SOURCES/alsa-delay b/SOURCES/alsa-delay new file mode 100755 index 0000000..a412188 --- /dev/null +++ b/SOURCES/alsa-delay @@ -0,0 +1,979 @@ +#!/bin/bash + +version=0.1.0 +tmpdir=$TMPDIR +if test -z "$tmpdir"; then + tmpdir="/tmp" +fi +tmpdir=$tmpdir/alsa-delay-script + +delay= +pcard= +pdev= +ccard= +cdev= + +yes= +quiet= +clean= +remove= + +pdevice="default:%s" +pdevice_set= +cdevice="plughw:%s,%s,%s" +pctl= +cctl= +one= +arg= +mix= +pa= + +useprocfs=yes + +fuser_prg=fuser +insmod_prg=insmod +rmmod_prg=rmmod +lsmod_prg=lsmod +modprobe_prg=modprobe +chkconfig_prg=chkconfig +systemctl_prg=systemctl +pidof_prg=pidof +alsaloop_prg=alsaloop +amixer_prg=amixer +test -x /sbin/fuser && fuser_prg=/sbin/fuser +test -x /sbin/insmod && insmod_prg=/sbin/insmod +test -x /sbin/rmmod && rmmod_prg=/sbin/rmmod +test -x /sbin/lsmod && lsmod_prg=/sbin/lsmod +test -x /sbin/modprobe && modprobe_prg=/sbin/modprobe +test -x /sbin/chkconfig && chkconfig_prg=/sbin/chkconfig +test -x /bin/systemctl && systemctl_prg=/bin/systemctl +test -x /sbin/pidof && pidof_prg=/sbin/pidof +test -x /usr/bin/alsaloop && alsaloop_prg=/usr/bin/alsaloop +test -x /usr/local/bin/alsaloop && alsaloop_prg=/usr/local/bin/alsaloop +test -x /usr/bin/amixer && amixer_prg=/usr/bin/amixer + +modprobeconf=/etc/modprobe.d/alsa.conf +test -r /etc/modprobe.conf && modprobeconf=/etc/modprobe.conf && useprocfs="" +alsaloopconf=/etc/alsaloop.conf + +test -r modprobe.work && modprobeconf=modprobe.work +test -r modprobe.work && alsaloopconf=alsaloop.conf + +usage() { + echo "Usage: $0 [OPTION]... [[,]]" + cat < is ALSA card index (number) or string card identifier + is ALSA device number + +Use 'aplay -l' to list available cards and devices. + +Operation modes: + -h, --help print this help, then exit + -q, --quiet quiet mode + -y, --yes do not ask any questions - answer is always yes + -c, --clean clean temporary directory and exit + -r, --remove remove the alsa-delay config modifications and exit + --tmpdir= set temporary directory +Alsaloop options: + --pdevice= force playback device + --cdevice= force capture device + --pctl= force playback ctl device + --cctl= force capture ctl device + --one= pass this argument to last thread + --arg= pass this argument to all threads + --mix= redirect ALSA mixer controls to OSS mixer + (default is Master) + --pa Redirect PA to alsaloop + +Note: For devices, the string %s is replaced with the card index + and second string %s is replaced with the device index + and third string %s is replaced the substream index (0-7). + Example: hw:%s,%s,%s (card, device, substream) +EOF +} + +while : +do + case "$1" in + -h|--help) + usage + exit 0 + ;; + -q|--quiet) + quiet=true ;; + -y|--yes) + yes=true ;; + -c|--clean) + clean="full" ;; + -r|--remove) + remove="full" ;; + --tmpdir*) + case "$#,$1" in + *,*=*) + tmpdir=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; + 1,*) + usage ;; + *) + tmpdir="$2" + shift ;; + esac + tmpdir="$tmpdir/alsa-compile-script" + ;; + --pdevice*) + case "$#,$1" in + *,*=*) + pdevice=`expr "z$1" : 'z-[^=]*=\(.*\)'` + pdevice_set=yes ;; + 1,*) + usage ;; + *) + pdevice="$2" + pdevice_set=yes + shift ;; + esac + ;; + --cdevice*) + case "$#,$1" in + *,*=*) + cdevice=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; + 1,*) + usage ;; + *) + cdevice="$2" + shift ;; + esac + ;; + --pctl*) + case "$#,$1" in + *,*=*) + pctl=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; + 1,*) + usage ;; + *) + pctl="$2" + shift ;; + esac + ;; + --cctl*) + case "$#,$1" in + *,*=*) + cctl=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; + 1,*) + usage ;; + *) + cctl="$2" + shift ;; + esac + ;; + --one*) + case "$#,$1" in + *,*=*) + one1=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; + 1,*) + usage ;; + *) + one1="$2" + shift ;; + esac + one="$one $one1" + ;; + --arg*) + case "$#,$1" in + *,*=*) + arg1=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; + 1,*) + usage ;; + *) + arg1="$2" + shift ;; + esac + arg="$arg $arg1" + ;; + --mix*) + case "$#,$1" in + *,*=*) + mix=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; + 1,*) + usage ;; + *) + mix="$2" + shift ;; + esac + arg="$arg $arg1" + ;; + --pa) + pa=true + ;; + *) + if test -n "$1"; then + ok= + if test -z "$delay"; then + delay="$1" + if test "$delay" -lt 1000; then + delay=$[$delay * 1000] + fi + ok=true + fi + if test -z "$ok" -a -z "$pcard"; then + pcard="$1" + ok=true + fi + if test -z "$ok"; then + echo "Unknown parameter '$1'" + break + fi + else + break + fi + ;; + esac + shift +done + +test -z "$pdevice_set" -a -n "$pa" && pdevice="plug:dmix:%s" +test -z "$delay" && delay="50000" +test -z "$pcard" && pcard="1" +pdev=$(echo $pcard | cut -s -d , -f 2) +pcard=$(echo $pcard | cut -d , -f 1) +test -z "$pdev" && pdev="0" +test -z "$ccard" && ccard="Loopback,1" +cdev=$(echo $ccard | cut -s -d , -f 2) +ccard=$(echo $ccard | cut -d , -f 1) +test -z "$cdev" && cdev="0" + +# Echo "true" or "false", depending on $yes and user response to prompt +# $1 is prompt message +question_bool() { + if test "$yes" = "yes"; then + echo "true" + else + echo >&2 -n "$1 (Y/ ) " + read i + local i=${i:0:1} + if test "$i" = "Y" -o "$i" = "y"; then + echo "true" + else + echo "false" + fi + fi +} + +# Safe exit +safe_exit() { + if test -r /etc/pulse/client.conf ; then + if grep "# alsa-delay-line-to-be-removed-1234" /etc/pulse/client.conf 2> /dev/null > /dev/null ; then + grep -v alsa-delay-line-to-be-removed-1234 /etc/pulse/client.conf > /etc/pulse/client.conf.new + if test -s /etc/pulse/client.conf.new; then + mv /etc/pulse/client.conf.new /etc/pulse/client.conf + fi + fi + fi + exit $1 +} + +# Log and execute $@ and check success +do_cmd() { + if test -z "$quiet"; then + echo "> $@" + fi + $@ || safe_exit 1 +} + +# Cache or restore $protocol and $url and $package in $tmpdir +check_environment() { + if ! test -d $tmpdir ; then + mkdir -p $tmpdir + if ! test -d $tmpdir; then + echo >&2 "Unable to create directory $tmpdir." + exit 1 + fi + fi + echo "Using temporary tree: $tmpdir" + test -x /bin/depmod && depmodbin=/bin/depmod + test -x /sbin/depmod && depmodbin=/sbin/depmod + if test -z "$depmodbin"; then + echo >&2 "Unable to find depmod utility." + exit 1 + fi + test -x /bin/modinfo && modinfobin=/bin/modinfo + test -x /sbin/modinfo && modinfobin=/sbin/modinfo + if test -z "$modinfobin"; then + echo >&2 "Unable to find modinfo utility." + exit 1 + fi +} + +# Kill processes currently accessing the audio devices +kill_audio_apps() { + local pids0=$($fuser_prg /dev/snd/* 2> /dev/null) + local pids1=$($fuser_prg /dev/mixer* 2> /dev/null) + local pids2=$($fuser_prg /dev/sequencer* 2> /dev/null) + local pids= + for pid in $pids0 $pids1 $pids2; do + local pids="$pids $pid" + done + if ! test -z "$pids"; then + echo + echo "WARNING! An audio application uses ALSA driver:" + echo + for pid in $pids; do + ps --no-headers -p $pids || safe_exit 1 + done + echo + if test $(question_bool "Would you like to kill these apps?") = "true"; then + if test -w /etc/pulse/client.conf ; then + echo "autospawn = no # alsa-delay-line-to-be-removed-1234" >> /etc/pulse/client.conf + fi + for pid in $pids; do + do_cmd kill $pid + done + sleep 2 + local killed= + for pid in $pids; do + local a=$(ps --no-headers -p $pids) + if test -n "$a"; then + do_cmd kill -9 $pid + local killed="true" + fi + done + if test "$killed" = "true"; then + sleep 2 + for pid in $pids; do + local a=$(ps --no-headers -p $pids) + if test -n "$a"; then + echo >&2 "Unable to kill application:" + echo >&2 " $a" + safe_exit 1 + fi + done + fi + else + echo >&2 "Cannot continue with running audio applications." + safe_exit 1 + fi + fi +} + +# Echo the list of configured sound modules +configured_modules() { + if test -z "$useprocfs"; then + cat $modprobeconf | grep -E "^alias snd-card-" | cut -d ' ' -f 3 + else + cat /proc/asound/modules | colrm 1 3 + fi +} + +# Echo the list of loaded sound modules +current_modules() { + $lsmod_prg | cut -d ' ' -f 1 | grep -E "^(snd[_-])" +} + +# The loopback kernel driver detection +aloop_present() { + if test -r /proc/asound/card0/id; then + local id=$(cat /proc/asound/card0/id) + else + local id="" + fi + if test "$id" = "Loopback"; then + echo "yes" + fi +} + +# Remove kernel modules, using two phases +# $@ is module names +my_rmmod() { + local phase2= + while test -n "$1"; do + if ! $rmmod_prg $1 2> /dev/null > /dev/null; then + local phase2="$phase2 $1" + else + echo "> rmmod $1" + fi + shift + done + for mod in $phase2; do + echo "> rmmod $mod" + if ! $rmmod_prg $mod ; then + echo >&2 "Unable to remove kernel module $mod." + safe_exit 1 + fi + done +} + +# Reload kernel modules +kernel_modules() { + kill_audio_apps + if test "$1" = "unload"; then + local present=$(aloop_present) + if test "$present" = "yes"; then + if ! $rmmod_prg snd-aloop; then + echo >&2 "Unable to remove kernel module snd-aloop." + safe_exit 1 + fi + fi + fi + local curmods=$(current_modules) + local usermods=$(configured_modules) + my_rmmod $curmods + $modprobe_prg soundcore || safe_exit 1 + if test "$1" = "load"; then + if ! $modprobe_prg snd-aloop; then + echo >&2 "Unable to install kernel module snd-aloop." + safe_exit 1 + fi + fi + for mod in $usermods; do + if ! $modprobe_prg $mod; then + echo >&2 "Unable to install kernel module $mod." + safe_exit 1 + fi + done + echo "Kernel modules ready:" + cat /proc/asound/cards + sleep 0.5 +} + +# If $package is alsa-driver then remove current modules +kernel_modules_remove() { + local curmods=$(current_modules) + if test -z "$curmods"; then + echo "No ALSA kernel modules to remove." + safe_exit 0 + fi + kill_audio_apps + my_rmmod $curmods + echo "ALSA kernel modules removed." +} + +function clean() { + echo -n "Removing tree $tmpdir:" + if test -d "$tmpdir"; then + if ! rm -rf "$tmpdir"; then + echo " failed" + safe_exit 1 + fi + fi + echo " success" +} + +function reindex_modprobe_conf() { + if test -z "$useprocfs"; then + cat > $tmpdir/run.awk < 1) + printf(",") + printf("%i", c) + } + continue + } + printf(" %s", l[i]) + } + printf("\n") + } else if (l[1] == "remove") { + printf(l[1]) + flag = 0 + for (i = 2; i <= length(l); i++) { + if (l[i] == "/usr/sbin/alsactl" || l[i] == "store") { + flag++; + printf(" %s", l[i]); + continue; + } + if (flag == 2) { + c = int(l[i]) + 1; + printf(" %i", c); + flag = 0; + continue; + } + flag = 0; + printf(" %s", l[i]); + } + printf("\n") + } else { + print line + } +} + +BEGIN { aloop=0; } +/alias snd-card-0 snd-aloop/ { aloop=1; next; } +/options snd-card-0 index=0/ { if (aloop) next; } +/options snd-aloop/ { next; } +/alias snd-card-/ { rewrite_line(\$0); next; } +/options snd-/ { rewrite_line(\$0); next; } +/remove snd-/ { rewrite_line(\$0); next; } + { print \$0; } +EOF + cat $modprobeconf | awk -f $tmpdir/run.awk > $modprobeconf.new + rm $tmpdir/run.awk || safe_exit 1 + else + local index=1 + echo -n "" > $modprobeconf.new + declare -a modules printed + for mod in $(cat /proc/asound/modules | grep -Ev "^2[6789]" | colrm 1 3); do + if test "$mod" != "snd_aloop" -a "$mod" != "snd-aloop"; then + if test -z ${modules[$mod]}; then + modules[$mod]=$index + else + modules[$mod]="${modules[mod]},$index" + fi + echo "alias snd-card-$index $mod" >> $modprobeconf.new + echo "options snd-card-$index index=$index" >> $modprobeconf.new + fi + index=$(expr $index + 1) + done + for mod in $(cat /proc/asound/modules | grep -Ev "^2[6789]" | colrm 1 3); do + if test "$mod" != "snd_aloop" -a "$mod" != "snd-aloop"; then + if test -z ${printed[$mod]}; then + echo "options $mod index=${modules[$mod]}" >> $modprobeconf.new + printed[$mod]=yes + fi + fi + done + fi +cat >> $modprobeconf.new < /dev/null | grep -E "^alias snd-card-0 snd-aloop") + local present=$(aloop_present) + if test -n "$check"; then + echo "Module snd-aloop is already installed." + if ! test "$present" = "yes"; then + kernel_modules load + fi + else + reindex_modprobe_conf + if ! test "$present" = "yes"; then + kernel_modules load + else + kernel_modules + fi + fi +} + +function myprintf() { + local cnt=$(echo "$1" | grep -o "%" | wc -l) + if test $cnt -eq 1; then + printf "$1" "$2" + else if test $cnt -eq 2; then + printf "$1" "$2" "$3" + else + printf "$1" "$2" "$3" "$4" + fi + fi +} + +function check_ctl_name() { + $amixer_prg -D "$1" contents | grep "name='$2'" +} + +function check_oss_mixer() { + grep ": mixer" /proc/asound/oss/devices +} + +function get_card_id() { + $amixer_prg -D "$1" info | head -1 | cut -d '/' -f 1 | cut -d ' ' -f 3- | awk '{ print substr($0, 2, length($0)-2) }' +} + +function generate_alsaloop_line() { + local file="$1" + local idx="$2" + local carg=$(myprintf "$cdevice" $ccard $cdev $idx) + local parg=$(myprintf "$pdevice" $pcard $pdev $idx) + local res="-C $carg -P $parg -T $idx -t $delay" + if test -n "$cctl"; then + local carg=$(myprintf "$cctl" $pcard $cdev $idx) + local res="$res -Y $carg" + fi + if test -n "$pctl"; then + local parg=$(myprintf "$pctl" $pcard $pdev $idx) + local res="$res -X $parg" + fi + if test -n "$arg"; then + local res="$res $arg" + fi + if test $idx -eq 7; then + if test -n "$one"; then + local res="$res $one" + fi + if test -z "$pctl"; then + local res="$res -X hw:$pcard" + fi + local mymix="$mix" + if test -z "$mymix"; then + local mymix="Master" + for mymix in Master "Master Mono" Headphone Headphone2 PCM Speaker \ + "Desktop Speaker" Beep Front Rear Center LFE Side \ + Surround ; do + local check=$(check_ctl_name hw:$pcard "$mymix Playback Switch") + if test -n "$check"; then + local res="$res -m \"name='$mymix Playback Switch'\"" + fi + local check=$(check_ctl_name hw:$pcard "$mymix Playback Volume") + if test -n "$check"; then + local res="$res -m \"name='$mymix Playback Volume'\"" + fi + done + else + local check=$(check_ctl_name hw:$pcard "$mymix Playback Switch") + if test -n "$check"; then + local res="$res -m \"name='$mymix Playback Switch'\"" + fi + local check=$(check_ctl_name hw:$pcard "$mymix Playback Volume") + if test -n "$check"; then + local res="$res -m \"name='$mymix Playback Volume'\"" + fi + fi + local check=$(check_oss_mixer) + if test -n "$check"; then + local res="$res -O \"$mymix@VOLUME\"" + fi + fi + echo $res >> $file +} + +function generate_alsaloop_conf() { + local idx=0 + rm -f $alsaloopconf.new + while test $idx -lt 8; do + generate_alsaloop_line $alsaloopconf.new $idx + idx=$(expr $idx + 1) + done + mv $alsaloopconf.new $alsaloopconf || safe_exit 1 +} + +function kill_alsaloop() { + local pid=$($pidof_prg alsaloop) + if test -n "$pid"; then + echo "Killing alsaloop..." + fi + while test -n "$pid"; do + kill $pid + sleep 0.01 + pid=$($pidof_prg alsaloop) + done +} + +function restart_alsaloop() { + echo "Restarting alsaloop: delay $delay us." + if test -d /etc/systemd/system; then + systemctl start alsaloop.service + else + /etc/init.d/alsaloop start + fi + sleep 0.4 + local pid=$($pidof_prg alsaloop) + if test -z "$pid"; then + echo "ERROR: Not started, check /var/log/messages for details" + else + if test -d /etc/systemd/system; then + systemctl status alsaloop.service + else + ps -p $pid + fi + fi +} + +function create_systemd_service() { + if test -r /etc/systemd/system/alsaloop.service; then + echo "/etc/systemd/system/alsaloop.service exists" + else + cat >> /etc/systemd/system/alsaloop.service <> /etc/init.d/alsaloop < + +# For RedHat and cousins: +# chkconfig: 2345 99 01 +# description: Start alsaloop daemon +# processname: alsaloop + +### BEGIN INIT INFO +# Provides: alsaloop +# Required-Start: \$local_fs +# Required-Stop: \$local_fs +# Should-Start: +# Short-Description: ALSALOOP +# Description: ALSALOOP +### END INIT INFO + +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2, or (at your option) any later +# version. +# You should have received a copy of the GNU General Public License (for +# example COPYING); if not, write to the Free Software Foundation, Inc., 675 +# Mass Ave, Cambridge, MA 02139, USA. +# This code was originally developed as a Senior Thesis by Michael Cornwell +# at the Concurrent Systems Laboratory (now part of the Storage Systems +# Research Center), Jack Baskin School of Engineering, University of +# California, Santa Cruz. http://ssrc.soe.ucsc.edu/. + +alsaloop_opts="--daemonize --workaround serialopen --config $alsaloopconf" + +ALSALOOP_BIN=/usr/bin/alsaloop +test -x /usr/local/bin/alsaloop && ALSALOOP_BIN=/usr/local/bin/alsaloop + +# Source function library +. /etc/rc.d/init.d/functions + +RETVAL=0 +prog=alsaloop +pidfile=/var/lock/subsys/alsaloop + +start() +{ + modprobe snd-aloop + echo -n \$"Starting \$prog: " + daemon \$ALSALOOP_BIN \$alsaloop_opts + RETVAL=\$? + echo + [ \$RETVAL = 0 ] && touch \$pidfile + return \$RETVAL +} + +stop() +{ + echo -n \$"Shutting down \$prog: " + killproc \$ALSALOOP_BIN + RETVAL=\$? + echo + rm -f \$pidfile + return \$RETVAL +} + +case "\$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + try-restart) + if [ -f \$pidfile ]; then + stop + start + fi + ;; + status) + status $prog + RETVAL=$? + ;; + *) + echo \$"Usage: \$0 {start|stop|restart|try-restart}" + RETVAL=3 +esac + +exit \$RETVAL +EOF + chmod 755 /etc/init.d/alsaloop || safe_exit 1 + $chkconfig_prg --add alsaloop + $chkconfig_prg alsaloop on + fi +} + +function modify_pa_conf() { + + if grep Loopback /etc/pulse/default.pa > /dev/null; then + echo "/etc/pulse/default.pa already modified" + else + if test -f /etc/pulse/default.pa; then + local pcardid=$(get_card_id "hw:$pcard") + if ! test -f /etc/pulse/default.pa.alsa-delay.save ; then + cp /etc/pulse/default.pa /etc/pulse/default.pa.alsa-delay.save + fi + cat /etc/pulse/default.pa | \ + sed -e 's/^load-module module-udev-detect/#load-module module-udev-detect # commented by alsa-delay/' \ + -e 's/^load-module module-detect/#load-module module-detect # commented by alsa-delay/' \ + -e "s/^### Automatically load driver modules for Bluetooth hardware/load-module module-alsa-card device_id=Loopback\nload-module module-alsa-card device_id=$pcardid\n\n### Automatically load driver modules for Bluetooth hardware/" > /etc/pulse/default.pa.new + if test -s /etc/pulse/default.pa.new; then + mv /etc/pulse/default.pa.new /etc/pulse/default.pa + echo "/etc/pulse/default.pa changed" + fi + fi + fi + + local file= + local asoundconf= + if test -d /etc/alsa -a -f /etc/alsa/pulse-default.conf; then + file=/etc/alsa/alsaloop-default.conf + asoundconf=yes + fi + if test -f /usr/share/alsa/alsa.conf.d/99-pulseaudio-default.conf ; then + file=/usr/share/alsa/alsa.conf.d/A0-alsaloop-default.conf + fi + if test -z "$file"; then + echo "unknown PulseAudio setup (asound.conf)" + elif test -f $file; then + echo "$file exists" + else + cat >> $file < /etc/asound.conf.new + if test -s /etc/asound.conf.new; then + mv /etc/asound.conf.new /etc/asound.conf + fi + fi + fi +} + +function remove() { + if test -f /etc/pulse/default.pa.alsa-delay.save ; then + echo "Restoring /etc/pulse/default.pa" + mv /etc/pulse/default.pa.alsa-delay.save /etc/pulse/default.pa + fi + if test -f /etc/init.d/alsaloop ; then + echo "Removing /etc/init.d/alsaloop service" + $chkconfig_prg alsaloop off + $chkconfig_prg --del alsaloop + rm /etc/init.d/alsaloop + fi + if test -f /etc/systemd/system/alsaloop.service ; then + echo "Removing /etc/systemd/system/alsaloop.service" + $systemctl_prg disable alsaloop.service + rm /etc/systemd/system/alsaloop.service + fi + if test -f $alsaloopconf ; then + echo "Removing $alsaloopconf" + rm $alsaloopconf + fi + if test -f /etc/alsa/alsaloop-default.conf ; then + echo "Removing /etc/alsa/alsaloop-default.conf" + rm /etc/alsa/alsaloop-default.conf + fi + if test -f /usr/share/alsa/alsa.conf.d/A0-alsaloop-default.conf ; then + echo "Removing /usr/share/alsa/alsa.conf.d/A0-alsaloop-default.conf" + rm /usr/share/alsa/alsa.conf.d/A0-alsaloop-default.conf + fi + if grep "alsaloop-default.conf" /etc/asound.conf > /dev/null 2> /dev/null ; then + echo "Modifying /etc/asound.conf" + cat /etc/asound.conf | sed 's/alsaloop-default.conf/pulse-default.conf/g' > /etc/asound.conf.new + if test -s /etc/asound.conf.new; then + mv /etc/asound.conf.new /etc/asound.conf + fi + fi + if test -f $modprobeconf.alsa-delay.save ; then + echo "Restoring $modprobeconf" + if test -s $modprobeconf.alsa-delay.save ; then + mv $modprobeconf.alsa-delay.save $modprobeconf + else + rm $modprobeconf.alsa-delay.save + rm $modprobeconf + fi + fi + if test $(aloop_present) = "yes"; then + kernel_modules unload + fi +} + +rundir=$(pwd) +export LC_ALL=C +export LANGUAGE=C + +check_environment + +if test -n "$clean"; then + clean + safe_exit 0 +fi + +if test -n "$remove"; then + kill_alsaloop + remove + clean + safe_exit 0 +fi + +kill_alsaloop +if test -d /etc/systemd/system ; then + create_systemd_service +else + create_initd +fi +modify_modprobe_conf +generate_alsaloop_conf +if test -n "$pa"; then + modify_pa_conf +fi +restart_alsaloop + +clean + +safe_exit 0 diff --git a/SOURCES/alsa-delay.1 b/SOURCES/alsa-delay.1 new file mode 100644 index 0000000..eafa81f --- /dev/null +++ b/SOURCES/alsa-delay.1 @@ -0,0 +1,78 @@ +.TH ALSA-DELAY 1 "6 Jane 2016" +.SH NAME +alsadelay \- a command to (re)initialize sound hardware + +.SH SYNOPSIS +\fBalsa-delay\fP \fI[options]\fP \fIrequested_delay_in_ms\fP [\fIoutput_card\fP[,\fIdevice\fP]] + +.SH DESCRIPTION +\fBalsa-delay\fP is a command\-line utility to setup an audio +delay. The snd-aloop ALSA driver is used to send all PCM streams +back to the user space and the alsaloop utility is used to send +this stream to a real hardware. + +The parameter \fIoutput_card\fP is ALSA card index (number) or +string card identifier. The parameter \fIdevice\fP is ALSA device number. + +Use \fIaplay -l\fP to list available cards and devices. + + +.SH OPTIONS +.TP +\fI\-\-h,\-\-help\fP +Print help. +.TP +\fI\-\-q,\-\-quiet\fP +Quiet mode. +.TP +\fI\-\-y,\-\-yes\fP +Do not ask any questions - answer is always yes. +.TP +\fI\-\-c,\-\-clean\fP +Clean temporary directory. +.TP +\fI\-\-r,\-\-remove\fP +Remove the alsa-delay config modifications (modprobe, pulse-audio). +.TP +\fI\-\-tmpdir=\fP +Set temporary directory. + +.SH OPTIONS (for alsaloop daemon) +.TP +\fI\-\-pdevice=\fP +Force playback device. +.TP +\fI\-\-cdevice=\fP +Force capture device. +.TP +\fI\-\-pctl=\fP +Force playback control device. +.TP +\fI\-\-cctl=\fP +Force capture control device. +.TP +\fI\-\-one=\fP +Pass this argument to last thread. +.TP +\fI\-\-arg=\fP +Pass this argument to all threads. +.TP +\fI\-\-mix=\fP +Redirect ALSA mixer controls to OSS mixer (default is Master). +.TP +\fI\-\-pa\fP +Redirect pulse-audio to alsaloop. + +.SH NOTE + +For devices, the string %s is replaced with the card index +and second string %s is replaced with the device index +and third string %s is replaced the substream index (0-7). + +Example: hw:%s,%s,%s (card, device, substream) + +.SH SEE ALSO +\fB +alsaloop(1) +amixer(1) +alsamixer(1) diff --git a/SOURCES/alsa-restore.service b/SOURCES/alsa-restore.service new file mode 100644 index 0000000..3eb1bbd --- /dev/null +++ b/SOURCES/alsa-restore.service @@ -0,0 +1,16 @@ +# +# Note that two different ALSA card state management schemes exist and they +# can be switched using a file exist check - /etc/alsa/state-daemon.conf . +# + +[Unit] +Description=Save/Restore Sound Card State +ConditionPathExists=!/etc/alsa/state-daemon.conf +ConditionPathExistsGlob=/dev/snd/control* +ConditionPathExists=/var/lib/alsa/asound.state + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=-/sbin/alsactl -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --initfile=/lib/alsa/init/00main restore +ExecStop=/sbin/alsactl -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf store diff --git a/SOURCES/alsa-state.service b/SOURCES/alsa-state.service new file mode 100644 index 0000000..6dd312b --- /dev/null +++ b/SOURCES/alsa-state.service @@ -0,0 +1,13 @@ +# +# Note that two different ALSA card state management schemes exist and they +# can be switched using a file exist check - /etc/alsa/state-daemon.conf . +# + +[Unit] +Description=Manage Sound Card State (restore and store) +ConditionPathExists=/etc/alsa/state-daemon.conf + +[Service] +Type=simple +ExecStart=-/usr/sbin/alsactl -s -n 19 -c -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --initfile=/lib/alsa/init/00main rdaemon +ExecStop=-/usr/sbin/alsactl -s kill save_and_quit diff --git a/SOURCES/alsa-utils-1.1.8-post.patch b/SOURCES/alsa-utils-1.1.8-post.patch new file mode 100644 index 0000000..fad2415 --- /dev/null +++ b/SOURCES/alsa-utils-1.1.8-post.patch @@ -0,0 +1,1580 @@ +From 116488e5f2f1b897084bd151381ee254e1cc177d Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Fri, 18 Jan 2019 09:24:12 +0100 +Subject: [PATCH 01/20] alsamixer: define _GNU_SOURCE to get exp10 + +Fixes Master, Headphones and Speaker stuck at -8 percentage after +building with Clang 7.0.1 and getting warned about implicit declaration +of exp10, which is behind _GNU_SOURCE as a non-standard feature. Thanks +Takashi Iwai for the CFLAGS suggestion on the mailing list. GCC build is +not affected, so not adding a compiler check to the configure script. + +uClibc-ng has got exp10 since 1.0.12, so the fallback macro is no longer +needed. However, alsa-utils relies on gettext so might need further +patches to actually work on uClibc systems. + +Signed-off-by: makepost +Signed-off-by: Jaroslav Kysela +--- + alsamixer/Makefile.am | 2 +- + alsamixer/volume_mapping.c | 5 ----- + 2 files changed, 1 insertion(+), 6 deletions(-) + +diff --git a/alsamixer/Makefile.am b/alsamixer/Makefile.am +index 259b29e..249e8f8 100644 +--- a/alsamixer/Makefile.am ++++ b/alsamixer/Makefile.am +@@ -1,4 +1,4 @@ +-AM_CFLAGS = @CURSES_CFLAGS@ -DCURSESINC="@CURSESINC@" ++AM_CFLAGS = -D_GNU_SOURCE @CURSES_CFLAGS@ -DCURSESINC="@CURSESINC@" + LDADD = @CURSESLIB@ + + bin_PROGRAMS = alsamixer +diff --git a/alsamixer/volume_mapping.c b/alsamixer/volume_mapping.c +index 94bd0fe..48cfbe2 100644 +--- a/alsamixer/volume_mapping.c ++++ b/alsamixer/volume_mapping.c +@@ -36,11 +36,6 @@ + #include + #include "volume_mapping.h" + +-#ifdef __UCLIBC__ +-/* 10^x = 10^(log e^x) = (e^x)^log10 = e^(x * log 10) */ +-#define exp10(x) (exp((x) * log(10))) +-#endif /* __UCLIBC__ */ +- + #define MAX_LINEAR_DB_SCALE 24 + + static inline bool use_linear_dB_scale(long dBmin, long dBmax) +-- +2.20.1 + + +From 83bce86c26be6c04bcef584fbe00f320b3582c92 Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 14:27:11 +0900 +Subject: [PATCH 02/20] axfer: add a section about unit test + +Two unit tests are available to check internal implementation of axfer. +They perform file I/O for many times and take much time to finish. + +This commit adds a section about it. + +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + axfer/axfer-transfer.1 | 16 ++++++++++++++++ + axfer/axfer.1 | 7 +++++++ + 2 files changed, 23 insertions(+) + +diff --git a/axfer/axfer-transfer.1 b/axfer/axfer-transfer.1 +index 4ff6082..02e5b4c 100644 +--- a/axfer/axfer-transfer.1 ++++ b/axfer/axfer-transfer.1 +@@ -971,6 +971,22 @@ some scenarios below, no copying occurs between modules. + - xfer(mmap/interleaved), mapper(single), container(any) + - xfer(mmap/non\-interleaved), mapper(multiple), containers(any) + ++.SS Unit test ++ ++For each of the ++.I mapper ++and ++.I container ++module, unit test is available. To run the tests, execute below command: ++ ++.nf ++$ make test ++.fi ++ ++Each test iterates writing to file and reading to the file for many times and it ++takes long time to finish. Please take care of the execution time if running on ++any CI environment. ++ + .SH SEE ALSO + \fB + axfer(1), +diff --git a/axfer/axfer.1 b/axfer/axfer.1 +index bfcd15d..3ae9c8e 100644 +--- a/axfer/axfer.1 ++++ b/axfer/axfer.1 +@@ -75,6 +75,13 @@ Operates for playback transmission. + .I EXIT_FAILURE + (1). + ++.SH UNIT TEST ++ ++This program has unit tests for internal implementation. Please refer to the ++manual of ++.I axfer-transfer ++for details. ++ + .SH COMPATIBILITY TO APLAY + + The +-- +2.20.1 + + +From b6142611c68a380644ce34f885e2d67da084b538 Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 14:39:18 +0900 +Subject: [PATCH 03/20] axfer: fulfill section for backward compatibitity for + chmap option + +At present, axfer losts backward compatibility to aplay in a point of +'chmap' option. + +This commit filfills a section to describe lose of backward compatibility +of chmap option. + +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + axfer/axfer-transfer.1 | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/axfer/axfer-transfer.1 b/axfer/axfer-transfer.1 +index 02e5b4c..1fdfc91 100644 +--- a/axfer/axfer-transfer.1 ++++ b/axfer/axfer-transfer.1 +@@ -872,6 +872,15 @@ according to pushed enter key. However, this feature requires an additional + input handling in main loop and leave bothersome operation to maintain PCM + substream. + ++.TP ++.I \-m, \-\-chmap=CH1,CH2,... ++ALSA PCM core and control core doesn't support this feature, therefore ++remapping should be done in userspace. This brings overhead to align audio ++data frames, especially for mmap operation. Furthermore, as of alsa-lib v1.1.8, ++some plugins don't support this feature expectedly, thus this option is a lack ++of transparent operation. At present, this option is not supported yet not to ++confuse users. ++ + .TP + .I SIGTSTP, SIGCONT + This performs suspend/resume of PCM substream. In aplay(1) implementation, +-- +2.20.1 + + +From 827ed7d1933ee9a0ce052d9eb2c0b1c79770dff2 Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 14:48:33 +0900 +Subject: [PATCH 04/20] axfer: correct description about snoop mode of libffado + +The libffado library can listen to isochronous channels to which unit on +IEEE 1394 bus transfers packets as long as the unit allows software to +read the channel from its register. + +This commit corrects description about snoop mode. + +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + axfer/axfer-transfer.1 | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/axfer/axfer-transfer.1 b/axfer/axfer-transfer.1 +index 1fdfc91..89df3cc 100644 +--- a/axfer/axfer-transfer.1 ++++ b/axfer/axfer-transfer.1 +@@ -560,8 +560,9 @@ audio data frame. + .B \-\-snoop + + This option allows this program to run snoop mode. In this mode, libffado +-listens all isochronous channels. When isochronous communication starts +-by any unit on the same bus, the packets can be handled by this program. ++listens isochronous channels to which device transfers isochronous packet. When ++isochronous communication starts by any unit on the same bus, the packets can ++be handled by this program. + + .TP + .B \-\-sched\-priority +-- +2.20.1 + + +From 1848b38ca94a52e4539e27526b2c028aa487053b Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 14:49:43 +0900 +Subject: [PATCH 05/20] axfer: correct message to notice that help text is + implemented + +Now help message is available to give help option to command line. + +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + axfer/axfer-transfer.1 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/axfer/axfer-transfer.1 b/axfer/axfer-transfer.1 +index 89df3cc..d631f72 100644 +--- a/axfer/axfer-transfer.1 ++++ b/axfer/axfer-transfer.1 +@@ -100,7 +100,7 @@ is not allowed except for paths listed below: + + .TP + .B \-h, \-\-help +-Print help messages and finish run time. Not yet implemented. ++Print help messages and finish run time. + + .TP + .B \-q, \-\-quiet +-- +2.20.1 + + +From fb038252d49b31e77f56a9c62527bb108cc965ad Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Tue, 15 Jan 2019 08:49:58 +0900 +Subject: [PATCH 06/20] axfer: supplement value of options for the manual of + transfer subcommand + +This commit supplements value of options for the manual of transfer +subcommand. + +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + axfer/axfer-transfer.1 | 40 ++++++++++++++++++++-------------------- + 1 file changed, 20 insertions(+), 20 deletions(-) + +diff --git a/axfer/axfer-transfer.1 b/axfer/axfer-transfer.1 +index d631f72..a8bf9c7 100644 +--- a/axfer/axfer-transfer.1 ++++ b/axfer/axfer-transfer.1 +@@ -203,7 +203,7 @@ and + is used as a default. + + .TP +-.B \-t, \-\-file\-type=TYPES ++.B \-t, \-\-file\-type=TYPE + Indicate the type of file. This is required for capture transmission. Available + types are listed below: + - wav: Microsoft/IBM RIFF/Wave format +@@ -242,7 +242,7 @@ Select backend of transmission from a list below. The default is libasound. + .SS Backend options for libasound + + .TP +-.B \-D, \-\-device ++.B \-D, \-\-device=NODE + + This option is used to select PCM node in libasound configuration space. + Available nodes are listed by +@@ -271,7 +271,7 @@ This option implicitly uses + option as well to prevent heavy consumption of CPU time. + + .TP +-.B \-F, \-\-period\-size ++.B \-F, \-\-period\-size=# + + This option configures given value to + .I period_size +@@ -288,7 +288,7 @@ intervals of hardware interrupt, thus the same amount of audio data frame as + the value is expected to be available for one I/O operation. + + .TP +-.B \-\-period\-time ++.B \-\-period\-time=# + + This option configures given value to + .I period_time +@@ -297,7 +297,7 @@ hardware parameter of PCM substream. This option is similar to + option, however its unit is micro\-second. + + .TP +-.B \-B, \-\-buffer\-size ++.B \-B, \-\-buffer\-size=# + + This option configures given value to + .I buffer_size +@@ -311,7 +311,7 @@ the size of period. Actually, it is not, depending on implementation of the PCM + plugins, in\-kernel driver and PCM I/O plugins. + + .TP +-.B \-\-buffer\-time ++.B \-\-buffer\-time=# + + This option configures given value to + .I buffer_time +@@ -320,7 +320,7 @@ hardware parameter of PCM substream. This option is similar to + option, however its unit is micro\-second. + + .TP +-.B \-\-waiter\-type ++.B \-\-waiter\-type=TYPE + + This option indicates the type of waiter for event notification. At present, + four types are available; +@@ -355,7 +355,7 @@ Neither this option nor + is available at the same time. + + .TP +-.B \-\-sched\-model ++.B \-\-sched\-model=MODEL + + This option selects scheduling model for process of this program. One of + .I irq +@@ -368,7 +368,7 @@ When nothing specified, + model is used. + + .TP +-.B \-A, \-\-avail\-min ++.B \-A, \-\-avail\-min=# + + This option configures given value to + .I avail\-min +@@ -386,7 +386,7 @@ value of + option is used. + + .TP +-.B \-R, \-\-start\-delay ++.B \-R, \-\-start\-delay=# + + This option configures given value to + .I start_threshold +@@ -420,7 +420,7 @@ value of + option is used. + + .TP +-.B \-T, \-\-stop\-delay ++.B \-T, \-\-stop\-delay=# + + This option configures given value to + .I stop_threshold +@@ -500,7 +500,7 @@ This backend is automatically available when configure script detects + symbol in libffado shared object. + + .TP +-.B \-p, \-\-port ++.B \-p, \-\-port=# + + This option uses given value to decide which 1394 OHCI controller is used to + communicate. When Linux system has two 1394 OHCI controllers, +@@ -513,7 +513,7 @@ is available at the same time. If nothing specified, libffado performs to + communicate to units on IEEE 1394 bus managed by all of 1394 OHCI controller available in Linux system. + + .TP +-.B \-n, \-\-node ++.B \-n, \-\-node=# + + This option uses given value to decide which unit is used to communicate. This + option requires +@@ -522,7 +522,7 @@ option to indicate which 1394 OHCI controller is used to communicate to the + specified unit. + + .TP +-.B \-g, \-\-guid ++.B \-g, \-\-guid=HEXADECIMAL + + This option uses given value to decide a target unit to communicate. The value + should be prefixed with '0x' and consists of hexadecimal literal letters +@@ -533,7 +533,7 @@ communicate to units on IEEE 1394 bus managed by all of 1394 OHCI controller + available in Linux system. + + .TP +-.B \-\-frames\-per\-period ++.B \-\-frames\-per\-period=# + + This option uses given value to decide the number of audio data frame in one + read/write operation. The operation is blocked till the number of available +@@ -541,7 +541,7 @@ audio data frame exceeds the given value. As a default, 512 audio data frames + is used. + + .TP +-.B \-\-periods\-per\-buffer ++.B \-\-periods\-per\-buffer=# + + This option uses given value to decide the size of intermediate buffer between + this program and libffado. As a default, 2 periods per buffer is used. +@@ -565,7 +565,7 @@ isochronous communication starts by any unit on the same bus, the packets can + be handled by this program. + + .TP +-.B \-\-sched\-priority ++.B \-\-sched\-priority=# + + This option executes + .I pthread_setschedparam() +@@ -796,7 +796,7 @@ supports. As of 2018, PCM buffer of non\-interleaved order is hardly used by + sound devices. + + .TP +-.I \-A, \-\-avail\-min ++.I \-A, \-\-avail\-min=# + This option indicates threshold to wake up blocked process in a unit of + audio data frame. Against aplay(1) implementation, this option has no effect + with +@@ -808,7 +808,7 @@ of + option. + + .TP +-.I \-R, \-\-start\-delay ++.I \-R, \-\-start\-delay=# + This option indicates threshold to start prepared PCM substream in a unit of + audio data frame. Against aplay(1) implementation, this option has no effect + with +@@ -820,7 +820,7 @@ of + option. + + .TP +-.I \-T, \-\-stop\-delay ++.I \-T, \-\-stop\-delay=# + This option indicates threshold to stop running PCM substream in a unit of + audio data frame. Against aplay(1) implementation, this option has no effect + with +-- +2.20.1 + + +From 9ed5d7c876a1c11118f2524327c9eac65e7d66dd Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 14:56:12 +0900 +Subject: [PATCH 07/20] axfer: correct invalid usage of escape of itaric text + +A dot sign is valid for a prefix of instruction. + +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + axfer/axfer-transfer.1 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/axfer/axfer-transfer.1 b/axfer/axfer-transfer.1 +index a8bf9c7..375678e 100644 +--- a/axfer/axfer-transfer.1 ++++ b/axfer/axfer-transfer.1 +@@ -75,7 +75,7 @@ The standard input or output is used if filepath is not specified or given as + \&. + + For playback transmission, container format of given +-\I filepath ++.I filepath + is detected automatically and metadata is used for parameters of sample format, + channels, rate, duration. If nothing detected, content of given file path is + handled as raw data. In this case, the parameters should be indicated as +-- +2.20.1 + + +From 2ba2066008c0fbe98374cc22e8a2eaa4e4e1b2bd Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 18:03:11 +0900 +Subject: [PATCH 08/20] axfer: add an entry of axfer to README + +Axfer has beed added as a rework of aplay with robust design to +support recent features of Linux sound subsystem. + +This commit adds an entry to README. + +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + README.md | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/README.md b/README.md +index bee2e94..c28e2ea 100644 +--- a/README.md ++++ b/README.md +@@ -11,6 +11,7 @@ alsaconf | the ALSA driver configurator script + alsa-info | a script to gather information about ALSA subsystem + alsactl | an utility for soundcard settings management + aplay/arecord | an utility for the playback / capture of .wav,.voc,.au files ++axfer | an utility to transfer audio data frame (enhancement of aplay) + amixer | a command line mixer + alsamixer | a ncurses mixer + amidi | a utility to send/receive sysex dumps or other MIDI data +-- +2.20.1 + + +From 257be19c47e62cd0553e740599802cec9182b37c Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 17:36:22 +0900 +Subject: [PATCH 09/20] axfer: allow to be compiled with glibc-2.11 or former + +The program, axfer, was developed in userspace with glibc-2.28. This +userspace is mostly compliant to POSIX:2008 and some additional macros +for poll event are officially available. The glibc supports them as a +default since its v2.12 release. It will be failed to be compiled with +old glibc or the other libraries for C standard APIs. + +One of the purpose of axfer is an better alternative of aplay. In a +point of the purpose, it's preferable to be compiled with the old +libraries. + +This commit adds conditional macros to be compiled with libraries for +old compliance level of POSIX. + +Reported-by: Jay Foster +Fixes: fce16d9279b6 ('axfer: add an implementation of waiter for select(2)') +Signed-off-by: Takashi Sakamoto +Signed-off-by: Takashi Iwai +--- + axfer/waiter-select.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/axfer/waiter-select.c b/axfer/waiter-select.c +index a35ea85..a2776e5 100644 +--- a/axfer/waiter-select.c ++++ b/axfer/waiter-select.c +@@ -15,10 +15,19 @@ + #include + + // Except for POLLERR. +-#define POLLIN_SET (POLLRDNORM | POLLRDBAND | POLLIN | POLLHUP) +-#define POLLOUT_SET (POLLWRBAND | POLLWRNORM | POLLOUT) ++#ifdef POLLRDNORM ++// This program is for userspace compliant to POSIX 2008 (IEEE 1003.1:2008). ++// This is the default compliance level since glibc-2.12 or later. ++# define POLLIN_SET (POLLRDNORM | POLLRDBAND | POLLIN | POLLHUP) ++# define POLLOUT_SET (POLLWRBAND | POLLWRNORM | POLLOUT) ++#else ++// However it's allowed to be for old compliance levels. ++# define POLLIN_SET (POLLIN | POLLHUP) ++# define POLLOUT_SET (POLLOUT) ++#endif + #define POLLEX_SET (POLLPRI) + ++ + struct select_state { + fd_set rfds_rd; + fd_set rfds_wr; +-- +2.20.1 + + +From 6fdaa0c52412205017a9a71872169c75f3d3a542 Mon Sep 17 00:00:00 2001 +From: Takashi Sakamoto +Date: Sun, 27 Jan 2019 11:24:53 +0900 +Subject: [PATCH 10/20] axfer: add missing header file of unit test to + distribution + +The file 'axfer/test/generator.h' is missing in distribution and brings +FTBFS for unit tests of axfer. + +This commit fixes to add it. + +Reported-by: Elimar Riesebieter +Fixes: b878df1ff0b0: ('axfer: add unit test for container interface') +Fixes: 39d1ab8a0cb4: ('axfer: add a unit test for mapper interface') +Signed-off-by: Takashi Iwai +--- + axfer/test/Makefile.am | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/axfer/test/Makefile.am b/axfer/test/Makefile.am +index 76a93bf..6521134 100644 +--- a/axfer/test/Makefile.am ++++ b/axfer/test/Makefile.am +@@ -14,6 +14,7 @@ container_test_SOURCES = \ + ../container-voc.c \ + ../container-raw.c \ + generator.c \ ++ generator.h \ + container-test.c + + mapper_test_SOURCES = \ +@@ -28,4 +29,5 @@ mapper_test_SOURCES = \ + ../mapper-single.c \ + ../mapper-multiple.c \ + generator.c \ ++ generator.h \ + mapper-test.c +-- +2.20.1 + + +From 52c9cc9571659377800fea026cf31b24e2f31394 Mon Sep 17 00:00:00 2001 +From: Prashant Malani +Date: Tue, 29 Jan 2019 01:58:26 -0800 +Subject: [PATCH 11/20] seq: arecordmidi: Add num-events option + +Add a command line option to automatically exit after recording a fixed +number of MIDI events. This allows a program using arecordmidi to expect +a MIDI file to be written automatically when the specified number of +events have been received, instead of having to send a SIGINT or SIGTERM +programmatically. + +It also avoids the need to have the arecordmidi process running in the +background, and then constantly stat the output file to check if any +bytes have been written to it (this makes for less predictable and +longer-running tests). + +This functionality finds use in Chrome OS functional testing, since +having to send SIGTERM/SIGINT programmatically and then wait for the +output file adds unpredictability and delay to the tests. + +The addition of this command-line option should (hopefully) not break +any existing usage. + +Signed-off-by: Prashant Malani +Signed-off-by: Takashi Iwai +--- + seq/aplaymidi/arecordmidi.c | 47 ++++++++++++++++++++++++++++++++++--- + 1 file changed, 44 insertions(+), 3 deletions(-) + +diff --git a/seq/aplaymidi/arecordmidi.c b/seq/aplaymidi/arecordmidi.c +index 19dbb7d..c0d0569 100644 +--- a/seq/aplaymidi/arecordmidi.c ++++ b/seq/aplaymidi/arecordmidi.c +@@ -86,6 +86,25 @@ static int ts_num = 4; /* time signature: numerator */ + static int ts_div = 4; /* time signature: denominator */ + static int ts_dd = 2; /* time signature: denominator as a power of two */ + ++/* Parse a decimal number from a command line argument. */ ++static long arg_parse_decimal_num(const char *str, int *err) ++{ ++ long val; ++ char *endptr; ++ ++ errno = 0; ++ val = strtol(str, &endptr, 0); ++ if (errno > 0) { ++ *err = -errno; ++ return 0; ++ } ++ if (*endptr != '\0') { ++ *err = -EINVAL; ++ return 0; ++ } ++ ++ return val; ++} + + /* prints an error message to stderr, and dies */ + static void fatal(const char *msg, ...) +@@ -690,7 +709,8 @@ static void help(const char *argv0) + " -t,--ticks=ticks resolution in ticks per beat or frame\n" + " -s,--split-channels create a track for each channel\n" + " -m,--metronome=client:port play a metronome signal\n" +- " -i,--timesig=nn:dd time signature\n", ++ " -i,--timesig=nn:dd time signature\n" ++ " -n,--num-events=events fixed number of events to record, then exit\n", + argv0); + } + +@@ -706,7 +726,7 @@ static void sighandler(int sig) + + int main(int argc, char *argv[]) + { +- static const char short_options[] = "hVlp:b:f:t:sdm:i:"; ++ static const char short_options[] = "hVlp:b:f:t:sdm:i:n:"; + static const struct option long_options[] = { + {"help", 0, NULL, 'h'}, + {"version", 0, NULL, 'V'}, +@@ -719,6 +739,7 @@ int main(int argc, char *argv[]) + {"dump", 0, NULL, 'd'}, + {"metronome", 1, NULL, 'm'}, + {"timesig", 1, NULL, 'i'}, ++ {"num-events", 1, NULL, 'n'}, + { } + }; + +@@ -727,6 +748,9 @@ int main(int argc, char *argv[]) + struct pollfd *pfds; + int npfds; + int c, err; ++ /* If |num_events| isn't specified, leave it at 0. */ ++ long num_events = 0; ++ long events_received = 0; + + init_seq(); + +@@ -775,6 +799,16 @@ int main(int argc, char *argv[]) + case 'i': + time_signature(optarg); + break; ++ case 'n': ++ err = 0; ++ num_events = arg_parse_decimal_num(optarg, &err); ++ if (err != 0) { ++ fatal("Couldn't parse num_events argument: %s\n", ++ strerror(-err)); ++ } ++ if (num_events <= 0) ++ fatal("num_events must be greater than 0"); ++ break; + default: + help(argv[0]); + return 1; +@@ -864,13 +898,20 @@ int main(int argc, char *argv[]) + err = snd_seq_event_input(seq, &event); + if (err < 0) + break; +- if (event) ++ if (event) { + record_event(event); ++ events_received++; ++ } + } while (err > 0); + if (stop) + break; ++ if (num_events && (events_received == num_events)) ++ break; + } + ++ if (num_events && events_received < num_events) ++ fputs("Warning: Received signal before num_events\n", stdout); ++ + finish_tracks(); + write_file(); + +-- +2.20.1 + + +From a558b71e63a50c045731e032dc35623674848c6c Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Tue, 12 Mar 2019 15:52:49 +0100 +Subject: [PATCH 12/20] alsa-info.sh: cleanups + +- fix awk arguments +- backticks/gravemarks removal +- some cosmetic and indentation changes +- add REQUIRES to check the basic tools + +Signed-off-by: Jaroslav Kysela +--- + alsa-info/alsa-info.sh | 169 +++++++++++++++++++++-------------------- + 1 file changed, 85 insertions(+), 84 deletions(-) + +diff --git a/alsa-info/alsa-info.sh b/alsa-info/alsa-info.sh +index cda4125..cf7ad89 100755 +--- a/alsa-info/alsa-info.sh ++++ b/alsa-info/alsa-info.sh +@@ -22,22 +22,26 @@ CHANGELOG="http://www.alsa-project.org/alsa-info.sh.changelog" + + ################################################################################## + +-#The script was written for 2 main reasons: +-# 1. Remove the need for the devs/helpers to ask several questions before we can easily help the user. +-# 2. Allow newer/inexperienced ALSA users to give us all the info we need to help them. ++# The script was written for 2 main reasons: ++# 1. Remove the need for the devs/helpers to ask several questions before we can easily help the user. ++# 2. Allow newer/inexperienced ALSA users to give us all the info we need to help them. + + #Set the locale (this may or may not be a good idea.. let me know) + export LC_ALL=C + +-#Change the PATH variable, so we can run lspci (needed for some distros) ++# Change the PATH variable, so we can run lspci (needed for some distros) + PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin + BGTITLE="ALSA-Info v $SCRIPT_VERSION" + PASTEBINKEY="C9cRIO8m/9y8Cs0nVs0FraRx7U0pHsuc" +-#Define some simple functions + +-WGET=$(which wget 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null) ++WGET=$(which wget 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null) ++REQUIRES="mktemp grep pgrep whereis ping awk date uname cat dmesg amixer alsactl" + +-pbcheck(){ ++# ++# Define some simple functions ++# ++ ++pbcheck() { + [[ $UPLOAD = "no" ]] && return + + if [[ -z $PASTEBIN ]]; then +@@ -50,9 +54,9 @@ pbcheck(){ + update() { + test -z "$WGET" -o ! -x "$WGET" && return + +- SHFILE=`mktemp -t alsa-info.XXXXXXXXXX` || exit 1 ++ SHFILE=$(mktemp -t alsa-info.XXXXXXXXXX) || exit 1 + wget -O $SHFILE "http://www.alsa-project.org/alsa-info.sh" >/dev/null 2>&1 +- REMOTE_VERSION=`grep SCRIPT_VERSION $SHFILE |head -n1 |sed 's/.*=//'` ++ REMOTE_VERSION=$(grep SCRIPT_VERSION $SHFILE | head -n1 | sed 's/.*=//') + if [ -s "$SHFILE" -a "$REMOTE_VERSION" != "$SCRIPT_VERSION" ]; then + if [[ -n $DIALOG ]] + then +@@ -131,7 +135,7 @@ withlsmod() { + echo "!!All Loaded Modules" >> $FILE + echo "!!------------------" >> $FILE + echo "" >> $FILE +- lsmod |awk {'print $1'} >> $FILE ++ lsmod | awk '{print $1}' >> $FILE + echo "" >> $FILE + echo "" >> $FILE + } +@@ -140,13 +144,13 @@ withamixer() { + echo "!!Amixer output" >> $FILE + echo "!!-------------" >> $FILE + echo "" >> $FILE +- for i in `grep "]: " /proc/asound/cards | awk -F ' ' '{ print $1} '` ; do +- CARD_NAME=`grep "^ *$i " $TEMPDIR/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 ++ for i in $(grep "]: " /proc/asound/cards | awk -F ' ' '{ print $1 }') ; do ++ CARD_NAME=$(grep "^ *$i " $TEMPDIR/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 + echo "" >> $FILE + } +@@ -155,17 +159,7 @@ withalsactl() { + echo "!!Alsactl output" >> $FILE + echo "!!--------------" >> $FILE + echo "" >> $FILE +- exe="" +- if [ -x /usr/sbin/alsactl ]; then +- exe="/usr/sbin/alsactl" +- fi +- if [ -x /usr/local/sbin/alsactl ]; then +- exe="/usr/local/sbin/alsactl" +- fi +- if [ -z "$exe" ]; then +- exe=`whereis alsactl | cut -d ' ' -f 2` +- fi +- $exe -f $TEMPDIR/alsactl.tmp store ++ alsactl -f $TEMPDIR/alsactl.tmp store + echo "--startcollapse--" >> $FILE + cat $TEMPDIR/alsactl.tmp >> $FILE + echo "--endcollapse--" >> $FILE +@@ -183,8 +177,7 @@ withdevices() { + } + + withconfigs() { +-if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]] || [[ -e $HOME/.asoundrc.asoundconf ]] +-then ++if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]] || [[ -e $HOME/.asoundrc.asoundconf ]]; then + echo "!!ALSA configuration files" >> $FILE + echo "!!------------------------" >> $FILE + echo "" >> $FILE +@@ -268,7 +261,7 @@ withall() { + } + + get_alsa_library_version() { +- ALSA_LIB_VERSION=`grep VERSION_STR /usr/include/alsa/version.h 2>/dev/null|awk {'print $3'}|sed 's/"//g'` ++ ALSA_LIB_VERSION=$(grep VERSION_STR /usr/include/alsa/version.h 2>/dev/null | awk '{ print $3 }' | sed 's/"//g') + + if [ -z "$ALSA_LIB_VERSION" ]; then + if [ -f /etc/lsb-release ]; then +@@ -276,7 +269,7 @@ get_alsa_library_version() { + case "$DISTRIB_ID" in + Ubuntu) + if which dpkg > /dev/null ; then +- ALSA_LIB_VERSION=`dpkg -l libasound2 | tail -1 | awk '{print $3}' | cut -f 1 -d -` ++ ALSA_LIB_VERSION=$(dpkg -l libasound2 | tail -1 | awk '{ print $3 }' | cut -f 1 -d -) + fi + + if [ "$ALSA_LIB_VERSION" = "" ]; then +@@ -290,7 +283,7 @@ get_alsa_library_version() { + esac + elif [ -f /etc/debian_version ]; then + if which dpkg > /dev/null ; then +- ALSA_LIB_VERSION=`dpkg -l libasound2 | tail -1 | awk '{print $3}' | cut -f 1 -d -` ++ ALSA_LIB_VERSION=$(dpkg -l libasound2 | tail -1 | awk '{ print $3 }' | cut -f 1 -d -) + fi + + if [ "$ALSA_LIB_VERSION" = "" ]; then +@@ -301,16 +294,24 @@ get_alsa_library_version() { + fi + } + ++# Basic requires ++for prg in $REQUIRES; do ++ t=$(which $prg 2> /dev/null) ++ if test -z "$t"; then ++ echo "This script requires $prg utility to continue." ++ exit 1 ++ fi ++done + +-#Run checks to make sure the programs we need are installed. +-LSPCI=$(which lspci 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null); +-TPUT=$(which tput 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null); ++# Run checks to make sure the programs we need are installed. ++LSPCI=$(which lspci 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null); ++TPUT=$(which tput 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null); + DIALOG=$(which dialog 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null); + +-#Check to see if sysfs is enabled in the kernel. We'll need this later on +-SYSFS=$(mount |grep sysfs|awk {'print $3'}); ++# Check to see if sysfs is enabled in the kernel. We'll need this later on ++SYSFS=$(mount | grep sysfs | awk '{ print $3 }'); + +-#Check modprobe config files for sound related options ++# Check modprobe config files for sound related options + SNDOPTIONS=$(modprobe -c|sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p') + + KEEP_OUTPUT= +@@ -386,11 +387,11 @@ else + fi # dialog + fi # WELCOME + +-#Set the output file +-TEMPDIR=`mktemp -t -d alsa-info.XXXXXXXXXX` || exit 1 ++# Set the output file ++TEMPDIR=$(mktemp -t -d alsa-info.XXXXXXXXXX) || exit 1 + FILE="$TEMPDIR/alsa-info.txt" + if [ -z "$NFILE" ]; then +- NFILE=`mktemp -t alsa-info.txt.XXXXXXXXXX` || exit 1 ++ NFILE=$(mktemp -t alsa-info.txt.XXXXXXXXXX) || exit 1 + fi + + trap cleanup 0 +@@ -404,17 +405,17 @@ if [ -z "$LSPCI" ]; then + fi + fi + +-#Fetch the info and store in temp files/variables +-DISTRO=`grep -ihs "buntu\|SUSE\|Fedora\|PCLinuxOS\|MEPIS\|Mandriva\|Debian\|Damn\|Sabayon\|Slackware\|KNOPPIX\|Gentoo\|Zenwalk\|Mint\|Kubuntu\|FreeBSD\|Puppy\|Freespire\|Vector\|Dreamlinux\|CentOS\|Arch\|Xandros\|Elive\|SLAX\|Red\|BSD\|KANOTIX\|Nexenta\|Foresight\|GeeXboX\|Frugalware\|64\|SystemRescue\|Novell\|Solaris\|BackTrack\|KateOS\|Pardus" /etc/{issue,*release,*version}` +-KERNEL_VERSION=`uname -r` +-KERNEL_PROCESSOR=`uname -p` +-KERNEL_MACHINE=`uname -m` +-KERNEL_OS=`uname -o` +-[[ `uname -v | grep SMP` ]] && KERNEL_SMP="Yes" || KERNEL_SMP="No" +-ALSA_DRIVER_VERSION=`cat /proc/asound/version |head -n1|awk {'print $7'} |sed 's/\.$//'` ++# Fetch the info and store in temp files/variables ++TSTAMP=$(LANG=C TZ=UTC date) ++DISTRO=$(grep -ihs "buntu\|SUSE\|Fedora\|PCLinuxOS\|MEPIS\|Mandriva\|Debian\|Damn\|Sabayon\|Slackware\|KNOPPIX\|Gentoo\|Zenwalk\|Mint\|Kubuntu\|FreeBSD\|Puppy\|Freespire\|Vector\|Dreamlinux\|CentOS\|Arch\|Xandros\|Elive\|SLAX\|Red\|BSD\|KANOTIX\|Nexenta\|Foresight\|GeeXboX\|Frugalware\|64\|SystemRescue\|Novell\|Solaris\|BackTrack\|KateOS\|Pardus" /etc/{issue,*release,*version}) ++KERNEL_VERSION=$(uname -r) ++KERNEL_PROCESSOR=$(uname -p) ++KERNEL_MACHINE=$(uname -m) ++KERNEL_OS=$(uname -o) ++[[ $(uname -v | grep SMP) ]] && KERNEL_SMP="Yes" || KERNEL_SMP="No" ++ALSA_DRIVER_VERSION=$(cat /proc/asound/version | head -n1 | awk '{ print $7 }' | sed 's/\.$//') + get_alsa_library_version +-ALSA_UTILS_VERSION=`amixer -v |awk {'print $3'}` +-LAST_CARD=$((`grep "]: " /proc/asound/cards | wc -l` - 1 )) ++ALSA_UTILS_VERSION=$(amixer -v | awk '{ print $3 }') + + ESDINST=$(which esd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null) + PAINST=$(which pulseaudio 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null) +@@ -451,10 +452,10 @@ if [ -d /sys/bus/acpi/devices ]; then + done + fi + +-cat /proc/asound/modules 2>/dev/null|awk {'print $2'}>$TEMPDIR/alsamodules.tmp +-cat /proc/asound/cards >$TEMPDIR/alsacards.tmp ++cat /proc/asound/modules 2>/dev/null | awk '{ print $2 }' > $TEMPDIR/alsamodules.tmp ++cat /proc/asound/cards > $TEMPDIR/alsacards.tmp + if [[ ! -z "$LSPCI" ]]; then +-lspci |grep -i "multi\|audio">$TEMPDIR/lspci.tmp ++ lspci | grep -i "multi\|audio">$TEMPDIR/lspci.tmp + fi + + #Check for HDA-Intel cards codec#* +@@ -477,7 +478,7 @@ echo "!!################################" >> $FILE + echo "!!ALSA Information Script v $SCRIPT_VERSION" >> $FILE + echo "!!################################" >> $FILE + echo "" >> $FILE +-echo "!!Script ran on: `LANG=C TZ=UTC date`" >> $FILE ++echo "!!Script ran on: $TSTAMP" >> $FILE + echo "" >> $FILE + echo "" >> $FILE + echo "!!Linux Distribution" >> $FILE +@@ -531,35 +532,35 @@ echo "!!Sound Servers on this system" >> $FILE + echo "!!----------------------------" >> $FILE + echo "" >> $FILE + if [[ -n $PAINST ]];then +-[[ `pgrep '^(.*/)?pulseaudio$'` ]] && PARUNNING="Yes" || PARUNNING="No" ++[[ $(pgrep '^(.*/)?pulseaudio$') ]] && PARUNNING="Yes" || PARUNNING="No" + echo "Pulseaudio:" >> $FILE + echo " Installed - Yes ($PAINST)" >> $FILE + echo " Running - $PARUNNING" >> $FILE + echo "" >> $FILE + fi + if [[ -n $ESDINST ]];then +-[[ `pgrep '^(.*/)?esd$'` ]] && ESDRUNNING="Yes" || ESDRUNNING="No" ++[[ $(pgrep '^(.*/)?esd$') ]] && ESDRUNNING="Yes" || ESDRUNNING="No" + echo "ESound Daemon:" >> $FILE + echo " Installed - Yes ($ESDINST)" >> $FILE + echo " Running - $ESDRUNNING" >> $FILE + echo "" >> $FILE + fi + if [[ -n $ARTSINST ]];then +-[[ `pgrep '^(.*/)?artsd$'` ]] && ARTSRUNNING="Yes" || ARTSRUNNING="No" ++[[ $(pgrep '^(.*/)?artsd$') ]] && ARTSRUNNING="Yes" || ARTSRUNNING="No" + echo "aRts:" >> $FILE + echo " Installed - Yes ($ARTSINST)" >> $FILE + echo " Running - $ARTSRUNNING" >> $FILE + echo "" >> $FILE + fi + if [[ -n $JACKINST ]];then +-[[ `pgrep '^(.*/)?jackd$'` ]] && JACKRUNNING="Yes" || JACKRUNNING="No" ++[[ $(pgrep '^(.*/)?jackd$') ]] && JACKRUNNING="Yes" || JACKRUNNING="No" + echo "Jack:" >> $FILE + echo " Installed - Yes ($JACKINST)" >> $FILE + echo " Running - $JACKRUNNING" >> $FILE + echo "" >> $FILE + fi + if [[ -n $ROARINST ]];then +-[[ `pgrep '^(.*/)?roard$'` ]] && ROARRUNNING="Yes" || ROARRUNNING="No" ++[[ $(pgrep '^(.*/)?roard$') ]] && ROARRUNNING="Yes" || ROARRUNNING="No" + echo "RoarAudio:" >> $FILE + echo " Installed - Yes ($ROARINST)" >> $FILE + echo " Running - $ROARRUNNING" >> $FILE +@@ -602,20 +603,20 @@ echo "" >> $FILE + echo "" >> $FILE + fi + +-if [ -d "$SYSFS" ] +-then +-echo "!!Loaded sound module options" >> $FILE +-echo "!!---------------------------" >> $FILE +-echo "" >> $FILE +-for mod in `cat /proc/asound/modules|awk {'print $2'}`;do +-echo "!!Module: $mod" >> $FILE +-for params in `echo $SYSFS/module/$mod/parameters/*`; do +- echo -ne "\t"; +- echo "$params : `cat $params`" | sed 's:.*/::'; +-done >> $FILE +-echo "" >> $FILE +-done +-echo "" >> $FILE ++if [ -d "$SYSFS" ]; then ++ echo "!!Loaded sound module options" >> $FILE ++ echo "!!---------------------------" >> $FILE ++ echo "" >> $FILE ++ for mod in $(cat /proc/asound/modules | awk '{ print $2 }'); do ++ echo "!!Module: $mod" >> $FILE ++ for params in $(echo $SYSFS/module/$mod/parameters/*); do ++ echo -ne "\t" ++ value=$(cat $params) ++ echo "$params : $value" | sed 's:.*/::' ++ done >> $FILE ++ echo "" >> $FILE ++ done ++ echo "" >> $FILE + fi + + if [ -s "$TEMPDIR/alsa-hda-intel.tmp" ]; then +@@ -856,8 +857,8 @@ if [ "$UPLOAD" = "no" ]; then + + fi # UPLOAD + +-#Test that wget is installed, and supports --post-file. Upload $FILE if it does, and prompt user to upload file if it doesnt. +-if [[ -n "${WGET}" ]] && [[ -x "${WGET}" ]] && [[ `wget --help |grep post-file` ]] ++# Test that wget is installed, and supports --post-file. Upload $FILE if it does, and prompt user to upload file if it does not. ++if [[ -n "${WGET}" ]] && [[ -x "${WGET}" ]] && [[ $(wget --help | grep post-file) ]] + then + + if [[ -n $DIALOG ]] +@@ -882,7 +883,7 @@ fi + dialog --backtitle "$BGTITLE" --title "Information uploaded" --yesno "Would you like to see the uploaded information?" 5 100 + DIALOG_EXIT_CODE=$? + if [ $DIALOG_EXIT_CODE = 0 ]; then +- grep -v "alsa-info.txt" $FILE >$TEMPDIR/uploaded.txt ++ grep -v "alsa-info.txt" $FILE > $TEMPDIR/uploaded.txt + dialog --backtitle "$BGTITLE" --textbox $TEMPDIR/uploaded.txt 0 0 + fi + +@@ -911,20 +912,20 @@ done + echo -e "\b Done!" + echo "" + +-fi #dialog ++fi # dialog + +-#See if tput is available, and use it if it is. ++# See if tput is available, and use it if it is. + if [ -n "$TPUT" ]; then + if [[ -z $PASTEBIN ]]; then +- FINAL_URL=`tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2 ; tput sgr0` ++ FINAL_URL=$(tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2 ; tput sgr0) + else +- FINAL_URL=`tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p';tput sgr0` ++ FINAL_URL=$(tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'; tput sgr0) + fi + else + if [[ -z $PASTEBIN ]]; then +- FINAL_URL=`grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2` ++ FINAL_URL=$(grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2) + else +- FINAL_URL=`grep "SUCCESS:" $TEMPDIR/wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'` ++ FINAL_URL=$(grep "SUCCESS:" $TEMPDIR/wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p') + fi + fi + +-- +2.20.1 + + +From cf2cc375020a2cd5038332f923d428c8e642b70a Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Tue, 12 Mar 2019 16:05:23 +0100 +Subject: [PATCH 13/20] alsactl: simple coverity fix + +Signed-off-by: Jaroslav Kysela +--- + alsactl/init_parse.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/alsactl/init_parse.c b/alsactl/init_parse.c +index f39d80e..562e674 100644 +--- a/alsactl/init_parse.c ++++ b/alsactl/init_parse.c +@@ -1675,8 +1675,10 @@ static int parse(struct space *space, const char *filename) + linenum = 0; + linesize = 128; + line = malloc(linesize); +- if (line == NULL) ++ if (line == NULL) { ++ file_unmap(buf, bufsize); + return -ENOMEM; ++ } + space->filename = filename; + while (!err && pos < bufsize && !space->quit) { + count = line_width(buf, bufsize, pos); +-- +2.20.1 + + +From 6dc4b1eab578bd4b6608a0118f170cf2f84e0680 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Tue, 12 Mar 2019 16:06:03 +0100 +Subject: [PATCH 14/20] arecordmidi: simple coverity fix + +Signed-off-by: Jaroslav Kysela +--- + seq/aplaymidi/arecordmidi.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/seq/aplaymidi/arecordmidi.c b/seq/aplaymidi/arecordmidi.c +index c0d0569..f3db65e 100644 +--- a/seq/aplaymidi/arecordmidi.c ++++ b/seq/aplaymidi/arecordmidi.c +@@ -631,7 +631,7 @@ static void write_file(void) + fwrite("MThd\0\0\0\6", 1, 8, file); + /* type 0 or 1 */ + fputc(0, file); +- fputc(used_tracks > 1, file); ++ fputc(used_tracks > 1 ? 1 : 0, file); + /* number of tracks */ + fputc((used_tracks >> 8) & 0xff, file); + fputc(used_tracks & 0xff, file); +-- +2.20.1 + + +From bc42704c96c02b138849be4af6c90b4755659b56 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Tue, 12 Mar 2019 16:14:50 +0100 +Subject: [PATCH 15/20] aplay: fix the multiple open file descriptors for the + raw capture + +Signed-off-by: Jaroslav Kysela +--- + aplay/aplay.c | 18 +++++++----------- + 1 file changed, 7 insertions(+), 11 deletions(-) + +diff --git a/aplay/aplay.c b/aplay/aplay.c +index efc1eb4..8bdf45b 100644 +--- a/aplay/aplay.c ++++ b/aplay/aplay.c +@@ -2690,8 +2690,6 @@ static void end_voc(int fd) + bt.datalen_h = (u_char) ((cnt & 0xFF0000) >> 16); + if (lseek64(fd, length_seek, SEEK_SET) == length_seek) + xwrite(fd, &bt, sizeof(VocBlockType)); +- if (fd != 1) +- close(fd); + } + + static void end_wave(int fd) +@@ -2712,8 +2710,6 @@ static void end_wave(int fd) + xwrite(fd, &rifflen, 4); + if (lseek64(fd, length_seek, SEEK_SET) == length_seek) + xwrite(fd, &cd, sizeof(WaveChunkHeader)); +- if (fd != 1) +- close(fd); + } + + static void end_au(int fd) +@@ -2725,8 +2721,6 @@ static void end_au(int fd) + ah.data_size = fdcount > 0xffffffff ? 0xffffffff : BE_INT(fdcount); + if (lseek64(fd, length_seek, SEEK_SET) == length_seek) + xwrite(fd, &ah.data_size, sizeof(ah.data_size)); +- if (fd != 1) +- close(fd); + } + + static void header(int rtype, char *name) +@@ -2938,7 +2932,7 @@ static void playback(char *name) + break; + } + +- if (fd != 0) ++ if (fd != fileno(stdin)) + close(fd); + } + +@@ -3151,7 +3145,7 @@ static void capture(char *orig_name) + if (!name || !strcmp(name, "-")) { + fd = fileno(stdout); + name = "stdout"; +- tostdout=1; ++ tostdout = 1; + if (count > fmt_rec_table[file_type].max_filesize) + count = fmt_rec_table[file_type].max_filesize; + } +@@ -3159,7 +3153,7 @@ static void capture(char *orig_name) + + do { + /* open a file to write */ +- if(!tostdout) { ++ if (!tostdout) { + /* upon the second file we start the numbering scheme */ + if (filecount || use_strftime) { + filecount = new_capture_file(orig_name, namebuf, +@@ -3218,8 +3212,10 @@ static void capture(char *orig_name) + } + + /* finish sample container */ +- if (fmt_rec_table[file_type].end && !tostdout) { +- fmt_rec_table[file_type].end(fd); ++ if (!tostdout) { ++ if (fmt_rec_table[file_type].end) ++ fmt_rec_table[file_type].end(fd); ++ close(fd); + fd = -1; + } + +-- +2.20.1 + + +From 819e04c7a1958a1c4378d914b38bddaf248d9fc0 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Wed, 13 Mar 2019 14:19:12 +0100 +Subject: [PATCH 16/20] axfer: coverity fixes + +- container-voc.c - out of array access +- container-voc.c - handle correctly eof +- frame_cache.c - correct memory allocation +- container.c - byte_count might be used uninitialized +- xfer-libasound-irq-mmap.c - fix avail signess +- xfer-options.c - fix potential 32-bit wrap for duration + +Signed-off-by: Jaroslav Kysela +--- + axfer/container-voc.c | 32 +++++++++++++----------- + axfer/container.c | 2 +- + axfer/frame-cache.c | 44 +++++++++++++++++---------------- + axfer/xfer-libasound-irq-mmap.c | 2 +- + axfer/xfer-options.c | 2 +- + 5 files changed, 43 insertions(+), 39 deletions(-) + +diff --git a/axfer/container-voc.c b/axfer/container-voc.c +index 92e9c83..6fa59c3 100644 +--- a/axfer/container-voc.c ++++ b/axfer/container-voc.c +@@ -234,7 +234,7 @@ static int build_time_constant(unsigned int frames_per_second, + frames_per_second) + break; + } +- if (i < ARRAY_SIZE(ex_v110_time_consts) || ++ if (i < ARRAY_SIZE(ex_v110_time_consts) && + frames_per_second <= 192000) { + *code = ex_v110_time_consts[i].code; + } else { +@@ -520,29 +520,31 @@ static int detect_format_block(struct container_context *cntr) + { + struct parser_state *state = cntr->private_data; + struct block_header header; +- void *buf = NULL; ++ void *buf; + int err; + + again: ++ buf = NULL; + err = cache_data_block(cntr, &header, &buf); + if (err < 0) + return err; ++ if (buf) { ++ if (header.type == BLOCK_TYPE_EXTENDED_V110_FORMAT) { ++ err = parse_extended_v110_format(state, buf); ++ } else if (header.type == BLOCK_TYPE_V120_DATA) { ++ err = parse_v120_format_block(state, buf); ++ } else if (header.type == BLOCK_TYPE_V110_DATA) { ++ err = parse_v110_data(state, buf); ++ } else { ++ free(buf); ++ goto again; ++ } + +- if (header.type == BLOCK_TYPE_EXTENDED_V110_FORMAT) { +- err = parse_extended_v110_format(state, buf); +- } else if (header.type == BLOCK_TYPE_V120_DATA) { +- err = parse_v120_format_block(state, buf); +- } else if (header.type == BLOCK_TYPE_V110_DATA) { +- err = parse_v110_data(state, buf); +- } else { + free(buf); +- goto again; +- } +- +- free(buf); + +- if (err < 0) +- return err; ++ if (err < 0) ++ return err; ++ } + + // Expect to detect block_v110_data. + if (header.type == BLOCK_TYPE_EXTENDED_V110_FORMAT) +diff --git a/axfer/container.c b/axfer/container.c +index 6b0e42e..7da97c6 100644 +--- a/axfer/container.c ++++ b/axfer/container.c +@@ -296,7 +296,7 @@ int container_context_pre_process(struct container_context *cntr, + unsigned int *frames_per_second, + uint64_t *frame_count) + { +- uint64_t byte_count; ++ uint64_t byte_count = 0; + unsigned int bytes_per_frame; + int err; + +diff --git a/axfer/frame-cache.c b/axfer/frame-cache.c +index 882568f..417c1e6 100644 +--- a/axfer/frame-cache.c ++++ b/axfer/frame-cache.c +@@ -50,13 +50,18 @@ int frame_cache_init(struct frame_cache *cache, snd_pcm_access_t access, + unsigned int samples_per_frame, + unsigned int frames_per_cache) + { ++ cache->access = access; ++ cache->remained_count = 0; ++ cache->bytes_per_sample = bytes_per_sample; ++ cache->samples_per_frame = samples_per_frame; ++ cache->frames_per_cache = frames_per_cache; ++ + if (access == SND_PCM_ACCESS_RW_INTERLEAVED) + cache->align_frames = align_frames_in_i; + else if (access == SND_PCM_ACCESS_RW_NONINTERLEAVED) + cache->align_frames = align_frames_in_n; + else + return -EINVAL; +- cache->access = access; + + if (access == SND_PCM_ACCESS_RW_INTERLEAVED) { + char *buf; +@@ -64,45 +69,42 @@ int frame_cache_init(struct frame_cache *cache, snd_pcm_access_t access, + buf = calloc(frames_per_cache, + bytes_per_sample * samples_per_frame); + if (buf == NULL) +- return -ENOMEM; ++ goto nomem; + cache->buf = buf; + cache->buf_ptr = buf; + } else { +- char **bufs; +- char **buf_ptrs; ++ char **bufs = calloc(samples_per_frame, sizeof(*bufs)); ++ char **buf_ptrs = calloc(samples_per_frame, sizeof(*buf_ptrs)); + int i; + +- bufs = calloc(samples_per_frame, sizeof(*bufs)); +- if (bufs == NULL) +- return -ENOMEM; +- buf_ptrs = calloc(samples_per_frame, sizeof(*buf_ptrs)); +- if (buf_ptrs == NULL) +- return -ENOMEM; ++ cache->buf = bufs; ++ cache->buf_ptr = buf_ptrs; ++ if (bufs == NULL || buf_ptrs == NULL) ++ goto nomem; + for (i = 0; i < samples_per_frame; ++i) { + bufs[i] = calloc(frames_per_cache, bytes_per_sample); + if (bufs[i] == NULL) +- return -ENOMEM; ++ goto nomem; + buf_ptrs[i] = bufs[i]; + } +- cache->buf = bufs; +- cache->buf_ptr = buf_ptrs; + } + +- cache->remained_count = 0; +- cache->bytes_per_sample = bytes_per_sample; +- cache->samples_per_frame = samples_per_frame; +- cache->frames_per_cache = frames_per_cache; + + return 0; ++ ++nomem: ++ frame_cache_destroy(cache); ++ return -ENOMEM; + } + + void frame_cache_destroy(struct frame_cache *cache) + { + if (cache->access == SND_PCM_ACCESS_RW_NONINTERLEAVED) { +- int i; +- for (i = 0; i < cache->samples_per_frame; ++i) { +- char **bufs = cache->buf; +- free(bufs[i]); ++ char **bufs = cache->buf; ++ if (bufs) { ++ int i; ++ for (i = 0; i < cache->samples_per_frame; ++i) ++ free(bufs[i]); + } + free(cache->buf_ptr); + } +diff --git a/axfer/xfer-libasound-irq-mmap.c b/axfer/xfer-libasound-irq-mmap.c +index 0c96ee5..0fbbcc6 100644 +--- a/axfer/xfer-libasound-irq-mmap.c ++++ b/axfer/xfer-libasound-irq-mmap.c +@@ -75,7 +75,7 @@ static int irq_mmap_process_frames(struct libasound_state *state, + struct map_layout *layout = state->private_data; + const snd_pcm_channel_area_t *areas; + snd_pcm_uframes_t frame_offset; +- snd_pcm_uframes_t avail; ++ snd_pcm_sframes_t avail; + unsigned int avail_count; + void *frame_buf; + snd_pcm_sframes_t consumed_count; +diff --git a/axfer/xfer-options.c b/axfer/xfer-options.c +index 8394d8a..2713027 100644 +--- a/axfer/xfer-options.c ++++ b/axfer/xfer-options.c +@@ -395,7 +395,7 @@ void xfer_options_calculate_duration(struct xfer_context *xfer, + uint64_t frame_count; + + if (xfer->duration_seconds > 0) { +- frame_count = xfer->duration_seconds * xfer->frames_per_second; ++ frame_count = (uint64_t)xfer->duration_seconds * (uint64_t)xfer->frames_per_second; + if (frame_count < *total_frame_count) + *total_frame_count = frame_count; + } +-- +2.20.1 + + +From 9b6c5e2d5c3119dbb79fc70ac8355424a8893ed0 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Wed, 13 Mar 2019 14:22:22 +0100 +Subject: [PATCH 17/20] aplay: check the return value for + snd_pcm_sw_params_current() (coverity) + +Signed-off-by: Jaroslav Kysela +--- + aplay/aplay.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/aplay/aplay.c b/aplay/aplay.c +index 8bdf45b..5b3a766 100644 +--- a/aplay/aplay.c ++++ b/aplay/aplay.c +@@ -1411,7 +1411,11 @@ static void set_params(void) + chunk_size, buffer_size); + prg_exit(EXIT_FAILURE); + } +- snd_pcm_sw_params_current(handle, swparams); ++ err = snd_pcm_sw_params_current(handle, swparams); ++ if (err < 0) { ++ error(_("Unable to get current sw params.")); ++ prg_exit(EXIT_FAILURE); ++ } + if (avail_min < 0) + n = chunk_size; + else +-- +2.20.1 + + +From 8c026b9562dbdfc222bcd637dfb85b85f4e95412 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Wed, 13 Mar 2019 14:31:57 +0100 +Subject: [PATCH 18/20] alsactl: monitor - remove dead code in run_dispatcher() + (coverity) + +Signed-off-by: Jaroslav Kysela +--- + alsactl/monitor.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/alsactl/monitor.c b/alsactl/monitor.c +index 282fb1c..6b090e4 100644 +--- a/alsactl/monitor.c ++++ b/alsactl/monitor.c +@@ -369,8 +369,6 @@ static int run_dispatcher(int epfd, int sigfd, int infd, struct list_head *srcs, + remove_source_entry(entry); + } + } +- if (err < 0) +- break; + } + end: + free(epev); +-- +2.20.1 + + +From 8dcc3a1391ade9f714143038cf6f816fad1cc2df Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Wed, 13 Mar 2019 14:47:23 +0100 +Subject: [PATCH 19/20] alsaloop: remove unused assignment warning (coverity) + +Signed-off-by: Jaroslav Kysela +--- + alsaloop/pcmjob.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/alsaloop/pcmjob.c b/alsaloop/pcmjob.c +index 4c9517b..29d1aba 100644 +--- a/alsaloop/pcmjob.c ++++ b/alsaloop/pcmjob.c +@@ -293,7 +293,7 @@ static int increase_playback_avail_min(struct loopback_handle *lhandle) + /* avoid 100% CPU usage for broken plugins */ + ts.tv_sec = 0; + ts.tv_nsec = 10000; +- err = nanosleep(&ts, NULL); ++ nanosleep(&ts, NULL); + return 0; + } + snd_pcm_sw_params_alloca(&swparams); +-- +2.20.1 + + +From 30f9a14a7964c650fb6b2b559d6fc879844b21b4 Mon Sep 17 00:00:00 2001 +From: Jaroslav Kysela +Date: Wed, 13 Mar 2019 14:51:12 +0100 +Subject: [PATCH 20/20] axfer: return back unsigned avail variable, do proper + retype in xfer-libasound-irq-mmap.c + +Signed-off-by: Jaroslav Kysela +--- + axfer/xfer-libasound-irq-mmap.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/axfer/xfer-libasound-irq-mmap.c b/axfer/xfer-libasound-irq-mmap.c +index 0fbbcc6..71ee79f 100644 +--- a/axfer/xfer-libasound-irq-mmap.c ++++ b/axfer/xfer-libasound-irq-mmap.c +@@ -75,7 +75,7 @@ static int irq_mmap_process_frames(struct libasound_state *state, + struct map_layout *layout = state->private_data; + const snd_pcm_channel_area_t *areas; + snd_pcm_uframes_t frame_offset; +- snd_pcm_sframes_t avail; ++ snd_pcm_uframes_t avail; + unsigned int avail_count; + void *frame_buf; + snd_pcm_sframes_t consumed_count; +@@ -110,7 +110,7 @@ static int irq_mmap_process_frames(struct libasound_state *state, + // MEMO: either snd_pcm_avail_update() and snd_pcm_mmap_begin() can + // return the same number of available frames. + avail = snd_pcm_avail_update(state->handle); +- if (avail < 0) ++ if ((snd_pcm_sframes_t)avail < 0) + return (int)avail; + if (*frame_count < avail) + avail = *frame_count; +-- +2.20.1 + diff --git a/SOURCES/alsa.rules b/SOURCES/alsa.rules new file mode 100644 index 0000000..6a4a0c3 --- /dev/null +++ b/SOURCES/alsa.rules @@ -0,0 +1,8 @@ +ACTION=="add", SUBSYSTEM=="sound", KERNEL=="controlC*", KERNELS!="card*", GOTO="alsa_restore_go" +GOTO="alsa_restore_end" + +LABEL="alsa_restore_go" +TEST!="/etc/alsa/state-daemon.conf", RUN+="/sbin/alsactl -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --initfile=/lib/alsa/init/00main restore /dev/$name" +TEST=="/etc/alsa/state-daemon.conf", RUN+="/sbin/alsactl -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --initfile=/lib/alsa/init/00main nrestore /dev/$name" + +LABEL="alsa_restore_end" diff --git a/SOURCES/alsactl.conf b/SOURCES/alsactl.conf new file mode 100644 index 0000000..71f0d80 --- /dev/null +++ b/SOURCES/alsactl.conf @@ -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 +} diff --git a/SOURCES/alsaunmute b/SOURCES/alsaunmute new file mode 100755 index 0000000..3f772ea --- /dev/null +++ b/SOURCES/alsaunmute @@ -0,0 +1,6 @@ +#!/bin/sh + +exec /sbin/alsactl \ + -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf \ + --initfile=/lib/alsa/init/00main \ + init diff --git a/SOURCES/alsaunmute.1 b/SOURCES/alsaunmute.1 new file mode 100644 index 0000000..057ae50 --- /dev/null +++ b/SOURCES/alsaunmute.1 @@ -0,0 +1,28 @@ +.TH ALSAUNMUTE 1 "21 April 2010" +.SH NAME +alsaunmute \- a simple script to initialize ALSA sound devices + +.SH DESCRIPTION +\fBalsaunmute\fP is a shell script which runs the \fBalsactl(1)\fP +utility with \fIinit\fP argument (see the script for details). + +.SH OPTIONS +None + +.SS +Example: +\fBalsaunmute\fR + +.SH SEE ALSO +\fB +alsactl(1), +alsamixer(1), +amixer(1) +\fP + +.SH BUGS +None known. + +.SH AUTHOR +\fBalsaunmute\fP is by Jaroslav Kysela + diff --git a/SPECS/alsa-utils.spec b/SPECS/alsa-utils.spec new file mode 100644 index 0000000..bd4d08f --- /dev/null +++ b/SPECS/alsa-utils.spec @@ -0,0 +1,527 @@ +%define baseversion 1.1.8 +#define fixversion .1 + +Summary: Advanced Linux Sound Architecture (ALSA) utilities +Name: alsa-utils +Version: %{baseversion}%{?fixversion} +Release: 2%{?dist} +License: GPLv2+ +Group: Applications/Multimedia +URL: http://www.alsa-project.org/ +Source: ftp://ftp.alsa-project.org/pub/utils/alsa-utils-%{version}.tar.bz2 +Source4: alsaunmute +Source5: alsaunmute.1 +Source7: alsa-delay +Source8: alsa-delay.1 +Source10: alsa.rules +Source11: alsactl.conf +Source20: alsa-restore.service +Source22: alsa-state.service +Patch0: alsa-utils-1.1.8-post.patch +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildRequires: alsa-lib-devel >= %{baseversion} +BuildRequires: libsamplerate-devel +BuildRequires: ncurses-devel +BuildRequires: gettext-devel +BuildRequires: xmlto python-docutils +BuildRequires: systemd-units >= 39-2 +Conflicts: udev <= 179-2 +# use latest alsa-lib - the executables in this package requires latest API +Requires: alsa-lib%{?_isa} >= %{baseversion}, systemd-units >= 39-2 +Conflicts: filesystem < 3 + +%description +This package contains command line utilities for the Advanced Linux Sound +Architecture (ALSA). + +%prep +%setup -q -n %{name}-%{version} +%patch0 -p1 -b .post + +%build +%configure CFLAGS="$RPM_OPT_FLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" --disable-alsaconf \ + --with-udev-rules-dir=%{_prefix}/lib/udev/rules.d \ + --with-systemdsystemunitdir=%{_unitdir} +%{__make} %{?_smp_mflags} +%{__cp} %{SOURCE4} . + +%install +make install DESTDIR=$RPM_BUILD_ROOT +%find_lang %{name} + +# Install ALSA udev rules +mkdir -p $RPM_BUILD_ROOT/%{_prefix}/lib/udev/rules.d +install -p -m 644 %{SOURCE10} $RPM_BUILD_ROOT/%{_prefix}/lib/udev/rules.d/90-alsa-restore.rules +mkdir -p $RPM_BUILD_ROOT/%{_unitdir} +install -p -m 644 %{SOURCE20} $RPM_BUILD_ROOT/%{_unitdir}/alsa-restore.service +install -p -m 644 %{SOURCE22} $RPM_BUILD_ROOT/%{_unitdir}/alsa-state.service + +# Install support utilities +mkdir -p -m755 $RPM_BUILD_ROOT/%{_bindir} +install -p -m 755 alsaunmute %{buildroot}/%{_bindir} +mkdir -p -m755 $RPM_BUILD_ROOT/%{_mandir}/man1 +install -p -m 644 %{SOURCE5} %{buildroot}/%{_mandir}/man1/alsaunmute.1 + +# Move /usr/share/alsa/init to /usr/lib/alsa/init +mkdir -p -m 755 %{buildroot}/%{_prefix}/lib/alsa +mv %{buildroot}%{_datadir}/alsa/init %{buildroot}/%{_prefix}/lib/alsa + +# Link /usr/lib/alsa/init to /usr/share/alsa/init back +ln -s ../../lib/alsa/init %{buildroot}%{_datadir}/alsa/init + +# Create a place for global configuration +mkdir -p -m 755 %{buildroot}/etc/alsa +install -p -m 644 %{SOURCE11} %{buildroot}/etc/alsa + +# Create /var/lib/alsa tree +mkdir -p -m 755 %{buildroot}/var/lib/alsa + +# Install alsa-info.sh script +rm -f %{buildroot}/usr/sbin/alsa-info.sh +install -p -m 755 $RPM_BUILD_DIR/%{name}-%{version}/alsa-info/alsa-info.sh %{buildroot}/usr/sbin/alsa-info +ln -s alsa-info %{buildroot}/usr/sbin/alsa-info.sh + +# Install alsa-delay script +install -p -m 755 %{SOURCE7} %{buildroot}/usr/bin/alsa-delay +install -p -m 644 %{SOURCE8} %{buildroot}/%{_mandir}/man1/alsa-delay.1 + +%files -f %{name}.lang +%defattr(-,root,root,-) +%doc COPYING ChangeLog README.md TODO +%config /etc/alsa/* +%{_prefix}/lib/udev/rules.d/* +%{_unitdir}/* +%{_unitdir}/sound.target.wants/* +%{_prefix}/lib/alsa/init/* +%{_bindir}/* +%{_sbindir}/* +%{_datadir}/alsa/ +%{_datadir}/sounds/* +%{_mandir}/man?/* +%dir /etc/alsa/ +%dir %{_prefix}/lib/alsa/ +%dir %{_prefix}/lib/alsa/init/ +%dir /var/lib/alsa/ + +%pre +if [ ! -r /lib/systemd/system/alsa-state.service ]; then + [ -d /etc/alsa ] || mkdir -m 0755 /etc/alsa + echo "# Remove this file to disable the alsactl daemon mode" > \ + /etc/alsa/state-daemon.conf +fi + +%post +if [ -s /etc/alsa/asound.state -a ! -s /etc/asound.state ] ; then + mv /etc/alsa/asound.state /etc/asound.state +fi +if [ -s /etc/asound.state -a ! -s /var/lib/alsa/asound.state ] ; then + mv /etc/asound.state /var/lib/alsa/asound.state +fi + +%changelog +* Wed Mar 13 2019 Jaroslav Kysela - 1.1.8-2 +- Updated to 1.1.8 +- Resolves: rhbz#1658086 + +* Tue May 22 2018 Jaroslav Kysela - 1.1.6-1 +- Updated to 1.1.6 +- Resolves: rhbz#1578685 + +* Fri Mar 24 2017 Jaroslav Kysela - 1.1.3-2 +- Updated to 1.1.3 +- Resolves: rhbz#1399509 + +* Mon Jun 6 2016 Jaroslav Kysela - 1.1.1-1 +- Updated to 1.1.1 +- Add alsa-delay man page +- Resolves: rhbz#1264129 + +* Fri Dec 12 2014 Jaroslav Kysela - 1.0.28-4 +- Fixed aplay -d regression +- Resolves: rhbz#1172189 + +* Wed Sep 24 2014 Jaroslav Kysela - 1.0.28-3 +- alsactl locking fixes, coverity fixes + +* Tue Sep 23 2014 Jaroslav Kysela - 1.0.28-2 +- Fixes for alsa-info.sh + +* Mon Sep 15 2014 Jaroslav Kysela - 1.0.28-1 +- Updated to 1.0.28 +- Resolves: rhbz#1112206 + +* Fri Jan 24 2014 Daniel Mach - 1.0.27.2-5 +- Mass rebuild 2014-01-24 + +* Fri Dec 27 2013 Daniel Mach - 1.0.27.2-4 +- Mass rebuild 2013-12-27 + +* Tue Jul 30 2013 Jaroslav Kysela - 1.0.27.2-3 +- Added an updated alsa-delay script from RHEL 6 + +* Fri Jul 19 2013 Jaroslav Kysela - 1.0.27.2-2 +- Fix alsa-state.service (rkill -> kill) - rhbz#986141 + +* Wed Jul 10 2013 Jaroslav Kysela - 1.0.27.2-1 +- Updated to 1.0.27.2 + +* Tue May 21 2013 Jaroslav Kysela - 1.0.27.1-1 +- Updated to 1.0.27.1 +- Updated alsa-info.sh to 0.4.61 +- Remove dependency on the dialog package (it is optional for alsa-info.sh) + +* Mon Apr 15 2013 Jaroslav Kysela - 1.0.27-2 +- Fix the new udev rules (missing GOTO) - bug#951750 +- Fix the string size in alsactl (underflow) + +* Fri Apr 12 2013 Jaroslav Kysela - 1.0.27-1 +- Updated to 1.0.27, activated the alsactl daemon mode +- Updated alsa-info.sh to 0.4.61 + +* Wed Feb 13 2013 Fedora Release Engineering - 1.0.26-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Thu Sep 6 2012 Jaroslav Kysela - 1.0.26-1 +- Updated to 1.0.26 + +* Wed Jul 18 2012 Fedora Release Engineering - 1.0.25-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Tue Apr 3 2012 Peter Robinson - 1.0.25-8 +- bump Release to be larger than F-16 + +* Tue Jan 31 2012 Jaroslav Kysela 1.0.25-1 +- update to 1.0.25 final + +* Wed Jan 25 2012 Harald Hoyer 1.0.24.1-8 +- install everything in /usr + https://fedoraproject.org/wiki/Features/UsrMove + +* Thu Jan 12 2012 Fedora Release Engineering - 1.0.24.1-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Fri Jan 6 2012 Lennart Poettering - 1.0.24.1-6 +- Always build with systemd support + +* Fri Jan 6 2012 Lennart Poettering - 1.0.24.1-5 +- When installing the Fedora service files make sure to override the + actual service files with them instead of the symlinks to them +- Drop StandardOutput=syslog since that is the default now and we + don't want to needlessly override the default + +* Mon Oct 31 2011 Bastien Nocera 1.0.24.1-4 +- Add patch to unmute MacBookAir4,1 speakers + +* Mon Feb 07 2011 Fedora Release Engineering - 1.0.24.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Fri Jan 28 2011 Jaroslav Kysela 1.0.24.1-2 +- add missing systemd files, add dependency on systemd-units +- use own udev rule file for /lib/udev/rules.d +- create /var/lib/alsa directory for asound.state + +* Fri Jan 28 2011 Jaroslav Kysela 1.0.24.1-1 +- updated to 1.0.24.1 final (new automake/autoconf) + +* Fri Jan 28 2011 Jaroslav Kysela 1.0.24-1 +- updated to 1.0.24 final +- updated alsa-info.sh script to 0.4.60 + +* Thu Jan 13 2011 Ville Skyttä - 1.0.23-4 +- Fix alsaunmute man page permissions, let rpmbuild compress it. + +* Mon Jun 28 2010 Jaroslav Kysela 1.0.23-3 +- add requires line (bug#526492) for specific alsa-lib package +- add requires line for dialog package (bug#561988) +- added man page for alsaunmute (bug#526174) +- updated alsa-info.sh script to 0.4.59 + +* Mon Jun 28 2010 Jaroslav Kysela 1.0.23-1 +- updated to 1.0.23 final + +* Sun Apr 18 2010 Thomas Spura 1.0.22-2 +- don't own %%{_datadir}/sounds (#569425) + +* Fri Jan 1 2010 Jaroslav Kysela 1.0.22-1 +- updated to 1.0.22 final + +* Thu Sep 3 2009 Jaroslav Kysela 1.0.21-2 +- added missing patch file + +* Thu Sep 3 2009 Jaroslav Kysela 1.0.21-1 +- updated to 1.0.21 final +- updated alsa-info.sh script to 0.4.58 + +* Fri Jul 24 2009 Fedora Release Engineering - 1.0.20-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Fri May 15 2009 Jaroslav Kysela 1.0.20-3 +- added missing Headphone Volume patch + +* Fri May 15 2009 Jaroslav Kysela 1.0.20-2 +- fixed Headphone Volume issue (bz#500956) + +* Wed May 06 2009 Jaroslav Kysela 1.0.20-1 +- updated to 1.0.20 final +- updated alsa-info.sh script to 0.4.56 + +* Mon Feb 23 2009 Fedora Release Engineering - 1.0.19-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Mon Feb 09 2009 Jaroslav Kysela 1.0.19-3 +- fixed volume initialization for some HDA codecs +- updated alsa-info.sh to 0.4.54 + +* Wed Feb 04 2009 Jaroslav Kysela 1.0.19-2 +- add dir directive for /lib/alsa and /lib/alsa/init directories (bz#483324) + +* Tue Jan 20 2009 Jaroslav Kysela 1.0.19-1 +- updated to 1.0.19 final + +* Tue Nov 04 2008 Jaroslav Kysela 1.0.18-5 +- fixed building + +* Tue Nov 04 2008 Jaroslav Kysela 1.0.18-4 +- updated to 1.0.18 final +- updated alsa-info.sh script + +* Thu Sep 18 2008 Jaroslav Kysela 1.0.18-3.rc3 +- fixed alsa-info.sh link + +* Thu Sep 18 2008 Jaroslav Kysela 1.0.18-2.rc3 +- fixed /lib/alsa/init path for x86_64 (was /lib64/alsa/init) +- added /etc/alsa/asound.state -> /etc/asound.state shift to post section +- fix udev rules (ommited /dev/ prefix for the alsactl utility) +- added --ignore option for alsactl (added also to upstream) + +* Thu Sep 11 2008 Jaroslav Kysela 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 1.0.17-1 +- updated to 1.0.17 final +- updated alsa-info.sh script to 0.4.48 + +* Mon Apr 28 2008 Martin Stransky 1.0.16-3 +- Added alsa-info.sh script to /usr/bin/alsa-info + +* Tue Feb 19 2008 Fedora Release Engineering - 1.0.16-2 +- Autorebuild for GCC 4.3 + +* Mon Feb 18 2008 Martin Stransky 1.0.16-1 +- updated to 1.0.16 final + +* Tue Jan 15 2008 Mikel Ward +- add salsa man page + +* Mon Oct 29 2007 Martin Stransky 1.0.15-1 +- updated to 1.0.15 final + +* Mon Oct 1 2007 Martin Stransky 1.0.15-0.4.rc1 +- moved saved volume settings back to /etc/alsa + (per discussion at #293301) + +* Mon Sep 24 2007 Martin Stransky 1.0.15-0.3.rc1 +- fixed #303151 - wrong salsa dir in /etc/udev/rules.d/90-alsa.rules + +* Thu Sep 20 2007 Matthias Saou 1.0.15-0.2.rc1 +- Update License field. +- Mark udev rule as config. +- Use find_lang macro again to include translations (why was it removed?). + +* Wed Sep 19 2007 Martin Stransky 1.0.15-0.1.rc1 +- new upstream +- moved saved volume settings to /var/lib (#293301) +- patched alsactl for that (#255421) + +* Thu Aug 16 2007 Martin Stransky 1.0.14-2 +- added an entry to alsaunmute for HP xw4550 (#252171) + +* Wed Jul 25 2007 Martin Stransky 1.0.14-1 +- release bump + +* Thu Jun 7 2007 Martin Stransky 1.0.14-0.8 +- new upstream + +* Wed May 30 2007 Martin Stransky 1.0.14-0.7.rc2 +- updated alsanumute for Siemens Lifebook S7020 (#241639) +- unmute Master Mono for all drivers + +* Wed May 2 2007 Martin Stransky 1.0.14-0.6.rc2 +- added fix for #238442 (unmute Mono channel for w4550, + xw4600, xw6600, and xw8600) + +* Wed Apr 18 2007 Martin Stransky 1.0.14-0.5.rc2 +- added more funcionality to salsa (save/load sound settings), + moved volume settings to /etc/alsa/ + +* Tue Apr 10 2007 Martin Stransky 1.0.14-0.4.rc2 +- added support for large files +- minor fix in alsaunmute +- fixed #209239 - alsaconf: Stale language-dependent files +- fixed #233765 - alsa-utils : unowned directories + +* Fri Jan 19 2007 Martin Stransky 1.0.14-0.3.rc2 +- new upstream + +* Wed Jan 10 2007 Martin Stransky 1.0.14-0.2.rc1 +- added a config line for hda-intel driver + +* Mon Dec 11 2006 Martin Stransky 1.0.14-0.1.rc1 +- new upstream + +* Mon Oct 2 2006 Martin Stransky 1.0.12-3 +- fix for #207384 - Audio test fails during firstboot + +* Fri Aug 25 2006 Martin Stransky 1.0.12-2 +- new upstream + +* Mon Aug 07 2006 Martin Stransky 1.0.12-1.rc2 +- new upstream + +* Thu Jul 20 2006 Martin Stransky 1.0.12-1.rc1 +- new upstream + +* Wed Jul 12 2006 Jesse Keating - sh: line 0: fg: no job control +- rebuild + +* Tue May 30 2006 Martin Stransky 1.0.11-7 +- new upstream + +* Wed May 3 2006 Martin Stransky 1.0.11-6.rc2 +- removed HW specific switch - it should be set by driver + +* Thu Apr 6 2006 Martin Stransky 1.0.11-5.rc2 +- fixed rules file (#186494) +- fixed Audigi mixer switch (#187807) + +* Mon Feb 20 2006 Martin Stransky 1.0.11-3.rc2 +- removed autoreconf + +* Fri Feb 10 2006 Jesse Keating - 1.0.11-2.rc2.2 +- bump again for double-long bug on ppc(64) + +* Tue Feb 07 2006 Jesse Keating - 1.0.11-2.rc2.1 +- rebuilt for new gcc4.1 snapshot and glibc changes + +* Wed Jan 25 2006 Martin Stransky 1.0.11-2.rc2 +- added volume option to alsaunmute utility (for s-c-s) + +* Thu Jan 12 2006 Martin Stransky 1.0.11-1.rc2 +- new upstream + +* Fri Dec 09 2005 Jesse Keating +- rebuilt + +* Thu Nov 24 2005 Martin Stransky 1.0.10rf-1 +- new upstream version +- added alias for snd-azx + +* Wed Nov 9 2005 Martin Stransky 1.0.10rc1-2 +- fix for #169292 - RHEL4U2 xw4300 IntelHD internal speakers muted by default + +* Tue Sep 27 2005 Martin Stransky 1.0.10rc1-1 +- new upstream version + +* Tue Aug 23 2005 Martin Stransky 1.0.9-5 +- unmute External Amplifier by default (#166153) + +* Wed Jul 13 2005 Bill Nottingham 1.0.9-4 +- migrate the alsa restore program to a udev rule, not a dev.d program +- conflict with appropriate udev +- move alsaunmute, alsacard to /bin + +* Mon Jul 11 2005 Martin Stransky 1.0.9-3 +- New alsaunmute utility +- Add autoconf to BuildRequires (#162483) + +* Thu Jun 16 2005 Martin Stransky 1.0.9-2 +- New upstream version + +* Mon May 30 2005 Martin Stransky 1.0.9-1 +- New upstream version. +- moved alsacard utility from alsa-lib to alsa-tools + +* Mon May 16 2005 Bill Nottingham 1.0.9rc2-2 +- make sure 'Wave' playback channel isn't muted (#157850) + +* Mon Apr 25 2005 Martin Stransky 1.0.9rc2-1 +- New upstream version +- add %%find_lang macro (#155719) + +* Fri Apr 1 2005 Bill Nottingham 1.0.8-4 +- replace the dev.d script with a program that calls alsactl to + restore the volume if there is a saved config, and just unmutes + the playback channels if there isn't one (#132575) + +* Mon Mar 7 2005 Martin Stransky +- rebuilt + +* Wed Feb 16 2005 Martin Stransky 1.0.8-2 +- fix #148011 (add gettext-devel to BuildRequires) +- add $RPM_OPT_FLAGS to CFLAGS + +* Wed Jan 26 2005 Martin Stransky 1.0.8-1 +- update to 1.0.8 +- temporarily removed alsa-lauch.patch + +* Sat Jan 08 2005 Colin Walters 1.0.7-2 +- New patch alsa-utils-1.0.7-alsa-launch.patch, adds the + alsa-launch command. +- New source file xinit-alsa-launch.sh, integrates alsa-launch + into X startup +- BR xorg-x11-devel + +* Thu Jan 06 2005 Colin Walters 1.0.7-1 +- New upstream version + +* Tue Oct 19 2004 Bill Nottingham 1.0.6-3 +- tweak dev.d sound restore script (#133535, revisited) + +* Thu Oct 14 2004 Bill Nottingham 1.0.6-2 +- move alsactl to /sbin +- include a dev.d script for mixer restoring (#133535) + +* Mon Aug 30 2004 Bill Nottingham 1.0.6-1 +- update to 1.0.6 + +* Fri Jul 2 2004 Bill Nottingham 1.0.5-1 +- update to 1.0.5 + +* Tue Jun 15 2004 Elliot Lee +- rebuilt + +* Thu Mar 11 2004 Bill Nottingham 1.0.3-1 +- update to 1.0.3 + +* Fri Feb 13 2004 Elliot Lee +- rebuilt + +* Wed Jan 28 2004 Bill Nottingham 1.0.2-1 +- update to 1.0.2 + +* Wed Dec 17 2003 Bill Nottingham 1.0.0-0.rc2 +- import fedora.us RPM, take out save-alsamixer & alsaconf for now + +* Thu Dec 11 2003 Thorsten Leemhuis 1.0.0-0.fdr.0.4.rc2 +- rename alsamixer-saver save-alsamixer + +* Mon Dec 8 2003 Thorsten Leemhuis 1.0.0-0.fdr.0.3.rc2 +- Integrate Michael Schwendt's script alsamixer-saver; Still not quite sure if + this script is the right way -- but mine didn't work... + +* Sat Dec 6 2003 Thorsten Leemhuis 1.0.0-0.fdr.0.2.rc2 +- Update to 1.0.0rc2 +- added alsamixer Script -- stores settings on shutdown, does nothing on startup +- some minor corrections in spec-file style + +* Wed Dec 3 2003 Thorsten Leemhuis 1.0.0-0.fdr.0.1.rc1 +- Update to 1.0.0rc1 + +* Wed Aug 6 2003 Dams 0:utils-0.fdr.1 +- Initial build.