Fixed a bug with connecting with alsa.

This commit is contained in:
Storm Dragon 2023-12-16 00:07:56 -05:00
parent 11e4a4d183
commit e034c518ee

22
tojam
View File

@ -147,7 +147,7 @@ configure_ninjam() {
--no-tags \ --no-tags \
--menu "Select the sound card Ninjam should use" -1 -1 -1 "${soundcards[@]}" --stdout)" --menu "Select the sound card Ninjam should use" -1 -1 -1 "${soundcards[@]}" --stdout)"
menuCode=$? menuCode=$?
if [ ${menuCode} -eq 1 -o ${menuCode} -eq 255]; then if [ ${menuCode} -eq 1 -o ${menuCode} -eq 255 ]; then
continue continue
fi fi
soundDriver="$(dialog --backtitle "Tojam" --title "Alsa Configuration" \ soundDriver="$(dialog --backtitle "Tojam" --title "Alsa Configuration" \
@ -159,7 +159,7 @@ configure_ninjam() {
"nch:" 6 1 "2" 6 25 6 6 \ "nch:" 6 1 "2" 6 25 6 6 \
"in:" 7 1 "${soundcard}" 7 25 25 25 \ "in:" 7 1 "${soundcard}" 7 25 25 25 \
"out:" 8 1 "${soundcard}" 8 25 25 25 --stdout)" "out:" 8 1 "${soundcard}" 8 25 25 25 --stdout)"
if [ ${menuCode} -eq 1 -o ${menuCode} -eq 255]; then if [ ${menuCode} -eq 1 -o ${menuCode} -eq 255 ]; then
continue continue
fi fi
mapfile -t alsaParameters < <(echo "${soundDriver}") mapfile -t alsaParameters < <(echo "${soundDriver}")
@ -168,10 +168,11 @@ configure_ninjam() {
alsaParameters[2]="bps ${alsaParameters[2]}" alsaParameters[2]="bps ${alsaParameters[2]}"
alsaParameters[3]="srate ${alsaParameters[3]}" alsaParameters[3]="srate ${alsaParameters[3]}"
alsaParameters[4]="nch ${alsaParameters[4]}" alsaParameters[4]="nch ${alsaParameters[4]}"
alsaParameters[5]="in ${alsaParameters[5]}" alsaParameters[5]="in hw:${alsaParameters[5]}"
alsaParameters[6]="out ${alsaParameters[6]}" alsaParameters[6]="out hw:${alsaParameters[6]}"
soundDriver="alsaconfig '${alsaParameters[*]}'" soundDriver="alsa"
sed -i "s/^soundDriver=.*/soundDriver=\"${soundDriver}\"/" "${config}/config" && alsaParameters="${alsaParameters[*]}"
sed -i -e "s/^soundDriver=.*/soundDriver=\"${soundDriver}\"/" -e "s/^alsaParameters=.*/alsaParameters=\"${alsaParameters}\"/" "${config}/config" &&
dialog --msgbox "Sound driver set to alsa." -1 -1 dialog --msgbox "Sound driver set to alsa." -1 -1
;; ;;
"username") "username")
@ -195,7 +196,8 @@ mkdir -p "${config}"
if ! [[ -r "${config}/config" ]]; then if ! [[ -r "${config}/config" ]]; then
# Write initial config file # Write initial config file
{ echo 'anonymous="true"'; { echo 'alsaParameters=""';
echo 'anonymous="true"';
echo 'saveSourceFiles="false"'; echo 'saveSourceFiles="false"';
echo 'soundDriver="jack"'; echo 'soundDriver="jack"';
echo "userName='Tojam$(date '+%S')'"; } >> "${config}/config" echo "userName='Tojam$(date '+%S')'"; } >> "${config}/config"
@ -276,4 +278,8 @@ esac
ninjam="$(command -v cninjam 2> /dev/null)" ninjam="$(command -v cninjam 2> /dev/null)"
[[ ${#ninjam} -le 3 ]] && { echo "Could not find cninjam."; exit 1; } [[ ${#ninjam} -le 3 ]] && { echo "Could not find cninjam."; exit 1; }
$ninjam "${server}" -user "${userName}" -${soundDriver} -sessiondir "${sessiondir}" ${saveSourceFiles} if [[ "${soundDriver}" == "jack" ]]; then
$ninjam "${server}" -user "${userName}" -jack -sessiondir "${sessiondir}" ${saveSourceFiles}
else
$ninjam "${server}" -user "${userName}" -alsaconfig "${alsaParameters}" -sessiondir "${sessiondir}" ${saveSourceFiles}
fi