Skip to content

Commit dc06c2c

Browse files
authored
[Feature] Improve binary selection #267 (#270)
1 parent 9c971d2 commit dc06c2c

File tree

5 files changed

+73
-7
lines changed

5 files changed

+73
-7
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ ENV AUDIO_BUFFER_SIZE ""
211211

212212
ENV MAX_ADDITIONAL_OUTPUTS_BY_TYPE ""
213213

214+
ENV FORCE_REPO_BINARY ""
215+
214216
ENV STARTUP_DELAY_SEC ""
215217

216218
COPY app/assets/pulse-client-template.conf /app/assets/pulse-client-template.conf

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ MAX_ADDITIONAL_OUTPUTS_BY_TYPE|The maximum number of outputs by type, defaults t
142142
RESTORE_PAUSED|If set to `yes`, then MPD is put into pause mode instead of starting playback after startup. Default is `no`.
143143
STATE_FILE_INTERVAL|Auto-save the state file this number of seconds after each state change, defaults to `10` seconds
144144
ENFORCE_PLAYER_STATE|If set to `yes`, it will remove player state information from the state file, so the player state will only depend on the environment variables. Defaults to `yes`
145+
FORCE_REPO_BINARY|If set to `yes`, the binary from the distro repository will be used
145146
STARTUP_DELAY_SEC|Delay before starting the application in seconds, defaults to `0`.
146147

147148
#### SOXR Plugin

app/bin/build-additional.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,17 @@ build_alsa() {
239239
# see if the ups version must be enforced
240240
c_integer_upsampling=$(get_named_env "ALSA_OUTPUT_INTEGER_UPSAMPLING" $idx)
241241
echo "ALSA OUTPUT [$idx] requires INTEGER_UPSAMPLING [${c_integer_upsampling}]"
242-
if [[ "${c_integer_upsampling^^}" == "YES" || "${c_integer_upsampling^^}" == "Y" ]]; then
243-
echo "Setting mpd_binary to [${UPSAMPLING_MPD_BINARY}]"
244-
mpd_binary=$UPSAMPLING_MPD_BINARY
242+
if [ ! "${FORCE_REPO_BINARY^^}" == "YES" ]; then
243+
if [ -n "${UPSAMPLING_MPD_BINARY}" ]; then
244+
if [[ "${c_integer_upsampling^^}" == "YES" || "${c_integer_upsampling^^}" == "Y" ]]; then
245+
echo "Setting mpd_binary to [${UPSAMPLING_MPD_BINARY}]"
246+
mpd_binary=$UPSAMPLING_MPD_BINARY
247+
fi
248+
else
249+
echo "MPD binary with integer upsampling support is not available"
250+
fi
251+
else
252+
echo "MPD binary forced to repo binary"
245253
fi
246254
fi
247255
}

app/bin/run-mpd.sh

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,48 @@
1010
# 8 Invalid default type
1111
# 9 Invalid parameter
1212
# 10 Missing mandatory parameter
13+
# 11 Missing binaries
14+
15+
CONF_INTEGER_UPSAMPLING_SUPPORT_FILE="/app/conf/integer_upsampling_support.txt"
16+
COMPILED_MPD_PATH="/app/conf/mpd-compiled-path.txt"
17+
COMPILED_UPS_MPD_PATH="/app/conf/mpd-compiled-ups-path.txt"
18+
INTEGER_UPSAMPLING_SUPPORTED="no"
19+
20+
REPO_MPD_BINARY="/usr/bin/mpd"
21+
REPO_MPD_BINARY_AVAILABLE="no"
22+
COMPILED_MPD_BINARY=""
23+
COMPILED_UPS_MPD_BINARY=""
24+
25+
if [ -f "$CONF_INTEGER_UPSAMPLING_SUPPORT_FILE" ]; then
26+
INTEGER_UPSAMPLING_SUPPORTED=`cat $CONF_INTEGER_UPSAMPLING_SUPPORT_FILE`
27+
if [ -f "$COMPILED_MPD_PATH" ]; then
28+
COMPILED_MPD_BINARY=`cat $COMPILED_MPD_PATH`
29+
fi
30+
if [[ "${INTEGER_UPSAMPLING_SUPPORTED^^}" == "YES" ]]; then
31+
if [ -f "$COMPILED_UPS_MPD_PATH" ]; then
32+
COMPILED_UPS_MPD_BINARY=`cat $COMPILED_UPS_MPD_PATH`
33+
fi
34+
fi
35+
fi
36+
37+
if [ -f "${REPO_MPD_BINARY}" ]; then
38+
echo "MPD from repo is available at [${REPO_MPD_BINARY}]"
39+
REPO_MPD_BINARY_AVAILABLE="yes"
40+
else
41+
echo "MPD from repo is not available"
42+
fi
43+
44+
echo "Integer upsampling supported: [${INTEGER_UPSAMPLING_SUPPORTED}]"
45+
echo "Compiled mpd binary: [${COMPILED_MPD_BINARY}]"
46+
echo "Compiled mpd ups binary: [${COMPILED_UPS_MPD_BINARY}]"
47+
48+
if [[ -z "${REPO_MPD_BINARY}" && -z "${COMPILED_MPD_BINARY}" ]]; then
49+
echo "NO BINARIES AVAILABLE, exiting"
50+
exit 11
51+
fi
1352

14-
STABLE_MPD_BINARY=/app/bin/compiled/mpd
15-
UPSAMPLING_MPD_BINARY=/app/bin/compiled/mpd-ups
16-
REPO_MPD_BINARY=/usr/bin/mpd
53+
STABLE_MPD_BINARY=${COMPILED_MPD_BINARY}
54+
UPSAMPLING_MPD_BINARY=${COMPILED_UPS_MPD_BINARY}
1755

1856
DEFAULT_MAX_OUTPUTS_BY_TYPE=20
1957
DEFAULT_OUTPUT_MODE=alsa
@@ -27,7 +65,23 @@ else
2765
fi
2866
echo "MAX_OUTPUTS=[$max_outputs_by_type]"
2967

30-
mpd_binary=$STABLE_MPD_BINARY
68+
if [[ ! "${FORCE_REPO_BINARY^^}" == "YES" ]]; then
69+
if [ -n "${STABLE_MPD_BINARY}" ]; then
70+
mpd_binary=$STABLE_MPD_BINARY
71+
else
72+
mpd_binary=$REPO_MPD_BINARY
73+
fi
74+
else
75+
# binary repo must be available
76+
if [ "${REPO_MPD_BINARY_AVAILABLE^^}" == "YES" ]; then
77+
mpd_binary=$REPO_MPD_BINARY
78+
else
79+
echo "Repo binary forced but not available!"
80+
exit 11
81+
fi
82+
fi
83+
84+
echo "Selected binary: [${mpd_binary}]"
3185

3286
declare -A file_dict
3387

doc/change-history.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
Date|Major Changes
44
:---|:---
5+
2023-03-25|Add support for selection of repo binary (`FORCE_REPO_BINARY`)
56
2023-03-24|Add armv6 support on debian-based images (see issue [#258](https://github.com/GioF71/mpd-alsa-docker/issues/258))
67
2023-03-20|Missing libaudiofile-dev (see issue [#253](https://github.com/GioF71/mpd-alsa-docker/issues/253) issue)
78
2023-03-20|Fixed build base image (see issue [#251](https://github.com/GioF71/mpd-alsa-docker/issues/251) issue)

0 commit comments

Comments
 (0)