Skip to content

Commit

Permalink
[Improvement] Create sysdefault in asound.conf, log found devices #76
Browse files Browse the repository at this point in the history
  • Loading branch information
GioF71 committed Jan 24, 2024
1 parent 3cbd83a commit 1e28b39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ An already started tidal-connect container should start working immediately, at

Date|Comment
:---|:---
2024-01-24|Always create sysdefault in asound.conf and log device names, see [#76](https://github.com/GioF71/tidal-connect/issues/76)
2024-01-23|Add support for optional card device (`CARD_DEVICE`) and format (`CARD_FORMAT`), see [#72](https://github.com/GioF71/tidal-connect/issues/72)
2023-09-12|Clarify how to install on Volumio, see issue [#29](https://github.com/GioF71/tidal-connect/issues/29)
2023-09-04|Allow default audio card selection, see issue [#22](https://github.com/GioF71/tidal-connect/issues/22)
Expand Down
18 changes: 10 additions & 8 deletions bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ write_audio_config() {
truncate -s 0 /etc/asound.conf
fi
echo "Creating sound configuration file (card_index=$CARD_INDEX)..."
echo "pcm.!default {" >> /etc/asound.conf
echo "pcm.!sysdefault {" >> /etc/asound.conf
echo " type plug" >> /etc/asound.conf
echo " slave.pcm {" >> /etc/asound.conf
echo " type hw" >> /etc/asound.conf
Expand Down Expand Up @@ -62,10 +62,10 @@ if test -f /etc/asound.conf; then
cat /etc/asound.conf
fi

PLAYBACK_DEVICE=default
if [[ -z "${card_index}" || "${card_index}" == "-1" ]] && [[ -n "${card_name}" ]]; then
# card name is set
echo "Specified CARD_NAME=[$card_name]"
found=0
aplay -l | sed 1d | \
while read i
do
Expand All @@ -78,24 +78,28 @@ if [[ -z "${card_index}" || "${card_index}" == "-1" ]] && [[ -n "${card_name}" ]
echo "Found audio device [${CARD_NAME}] as index [$curr_ndx]"
CARD_INDEX=$curr_ndx
write_audio_config
found=1
break
else
echo "Skipping audio device [${third_word}] as index [$curr_ndx]"
fi
fi
done
if [ $found -eq 0 ]; then
echo "Audio device named [${CARD_NAME}] was not found!"
fi
elif [[ -n "${card_index}" && ! "${card_index}" == "-1" ]]; then
# card index is set
echo "Specified CARD_INDEX=[$card_index]"
echo "Set card_index=[$card_index]"
write_audio_config
else
# leave default, so I delete asound.conf if found, as it is not needed
echo "Using default audio ..."
echo "No audio device is set, using default audio ..."
if [[ -f /etc/asound.conf ]]; then
echo "Removing asound.conf ..."
rm /etc/asound.conf
fi
echo "using sysdefault ..."
PLAYBACK_DEVICE=sysdefault
echo ". done."
fi

Expand All @@ -105,8 +109,6 @@ else
echo "asound.conf not found, using default audio"
fi

echo "PLAYBACK_DEVICE=[${PLAYBACK_DEVICE}]"

echo "Starting Speaker Application in Background (TMUX)"
/usr/bin/tmux new-session -d -s speaker_controller_application '/app/ifi-tidal-release/bin/speaker_controller_application'

Expand All @@ -118,7 +120,7 @@ do
echo "Starting TIDAL Connect ..."
/app/ifi-tidal-release/bin/tidal_connect_application \
--tc-certificate-path "/app/ifi-tidal-release/id_certificate/IfiAudio_ZenStream.dat" \
--playback-device ${PLAYBACK_DEVICE} \
--playback-device sysdefault \
-f "${FRIENDLY_NAME}" \
--codec-mpegh true \
--codec-mqa ${MQA_CODEC} \
Expand Down

0 comments on commit 1e28b39

Please sign in to comment.