Created
November 12, 2022 00:12
-
-
Save smortex/d4f2385ae3e404381f636322f241e6ae to your computer and use it in GitHub Desktop.
freebsd-devd-pulseaudio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# /usr/local/bin/pulseaudio-pcm | |
set -x | |
/usr/bin/logger "$0 $*" | |
action=$1 | |
case $action in | |
attach) | |
pcm=$2 dsp=dsp${2#pcm} uaudio=$3 | |
/usr/local/bin/sudo -u romain /usr/local/bin/pacmd load-module module-oss device=/dev/$dsp | |
ugen=$(devinfo -v | awk '$1 == "'$uaudio'" { split($NF, r, "="); print r[2] }') | |
echo $dsp > /tmp/uaudio-$ugen | |
;; | |
detach) | |
ugen=$2 | |
if [ -f "/tmp/uaudio-$ugen" ]; then | |
dsp=$(cat /tmp/uaudio-$ugen) | |
i=$(/usr/local/bin/sudo -u romain /usr/local/bin/pacmd list-modules | /usr/bin/awk '$1 == "index:" { last_index = $2 } $1 == "argument:" && $2 == "<device=/dev/'$dsp'>" { i = last_index } END { print i }') | |
/usr/local/bin/sudo -u romain /usr/local/bin/pacmd unload-module $i && rm -f "/tmp/uaudio-$ugen" | |
fi | |
;; | |
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /usr/local/etc/devd/uaudio.conf | |
attach 10 { | |
device-name "pcm[0-9]+"; | |
action "/usr/local/bin/pulseaudio-pcm attach $device-name $bus"; | |
}; | |
notify 10 { | |
match "system" "USB"; | |
match "subsystem" "DEVICE"; | |
match "type" "DETACH"; | |
match "ugen" "ugen[0-9]+.[0-9]+"; | |
action "/usr/local/bin/pulseaudio-pcm detach $ugen"; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment