From 1e28b39a4b0f6f04b569c5c621df93466641ec69 Mon Sep 17 00:00:00 2001 From: Giovanni Fulco Date: Wed, 24 Jan 2024 17:06:39 +0100 Subject: [PATCH] [Improvement] Create sysdefault in asound.conf, log found devices #76 --- README.md | 1 + bin/entrypoint.sh | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 902e1a1..fe53473 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/bin/entrypoint.sh b/bin/entrypoint.sh index ca04368..02b5580 100755 --- a/bin/entrypoint.sh +++ b/bin/entrypoint.sh @@ -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 @@ -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 @@ -78,10 +78,16 @@ 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]" @@ -89,13 +95,11 @@ elif [[ -n "${card_index}" && ! "${card_index}" == "-1" ]]; then 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 @@ -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' @@ -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} \