Skip to content

Commit 7a3fcaf

Browse files
authored
[Feature] Support for ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED #221 (#222)
1 parent 86e47dd commit 7a3fcaf

File tree

7 files changed

+36
-4
lines changed

7 files changed

+36
-4
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ ENV ALSA_OUTPUT_OUTPUT_FORMAT ""
112112
ENV ALSA_OUTPUT_AUTO_RESAMPLE ""
113113
ENV ALSA_OUTPUT_THESYCON_DSD_WORKAROUND ""
114114
ENV ALSA_OUTPUT_INTEGER_UPSAMPLING ""
115+
ENV ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED ""
116+
ENV ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED_PRESET ""
115117
ENV ALSA_OUTPUT_DOP ""
116118

117119
ENV PULSE_AUDIO_OUTPUT_CREATE ""
@@ -222,6 +224,7 @@ COPY app/bin/get-value.sh /app/bin/
222224
COPY app/bin/read-file.sh /app/bin/
223225
COPY app/bin/build-soxr-presets.sh /app/bin/
224226
COPY app/bin/build-allowed-formats-presets.sh /app/bin/
227+
COPY app/bin/build-integer-upsampling-allowed-presets.sh /app/bin/
225228
COPY app/bin/load-alsa-presets.sh /app/bin/
226229
COPY app/bin/build-additional.sh /app/bin/
227230
COPY app/bin/user-management.sh /app/bin/

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ Images: [DockerHub](https://hub.docker.com/r/giof71/mpd-alsa)
2727
## MPD Source code
2828

2929
The source code is in this GitHub [repo](https://github.com/GioF71/MPD).
30-
The `v0.23.x` branch is kept in-line with the GitHub [upstream repo](https://github.com/MusicPlayerDaemon/MPD).
31-
The `v0.23.x-ups` branch contains a patch which is used when `INTEGER_UPSAMPLING` is set to `yes`. Use at your own risk.
30+
The `version-0.23.12` tag is in-line with the GitHub [upstream repo](https://github.com/MusicPlayerDaemon/MPD) at version 0.23.12.
31+
The `version-0.23.12-ups` tag contains a patch which is used when `INTEGER_UPSAMPLING` is set to `yes`. Use at your own risk.
3232
Two binaries are available in the container image:
3333

3434
- /app/bin/compiled/mpd (stable version)
3535
- /app/bin/compiled/mpd-ups (patched version)
3636

37-
The current mpd version is `v0.23.11`.
37+
The current mpd version is `v0.23.12`.
3838

3939
## Why
4040

@@ -249,6 +249,8 @@ ALSA_OUTPUT_OUTPUT_FORMAT|yes|Sets output format
249249
ALSA_OUTPUT_AUTO_RESAMPLE|yes|Sets auto resample
250250
ALSA_OUTPUT_THESYCON_DSD_WORKAROUND|yes|Enables workaround
251251
ALSA_OUTPUT_INTEGER_UPSAMPLING|yes|Enables integer upsampling
252+
ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED|yes|Allows selection of sample rates to be upsampled. If set, only specified values are allowed. The values should respect the same format user for `ALSA_OUTPUT_ALLOWED_FORMATS`
253+
ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED_PRESET|yes|Preset for `ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED`. Allowed values are `base` (for 44.1kHz and 48.0kHz) and `44` for 44.1kHz only
252254
ALSA_OUTPUT_DOP|yes|Enables Dsd-Over-Pcm. Possible values: `yes` or `no`. Empty by default: this it lets mpd handle dop setting.
253255

254256
For the meaning, refer to the corresponding values in the first list of environment variables.

app/bin/build-additional.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,19 @@ build_alsa() {
202202
alsa_out_set_values[$alsa_set_key]="${c_allowed_formats}"
203203
fi
204204
fi
205+
206+
# integer upsampling allowed presets
207+
c_integer_upsampling_allowed_preset=$(get_named_env ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED_PRESET $idx)
208+
if [ -n "${c_integer_upsampling_allowed_preset}" ]; then
209+
echo "Integer Upsampling Allowed set for alsa output [$idx] -> [${c_integer_upsampling_allowed_preset}]"
210+
c_integer_upsampling_allowed="${integer_upsampling_allowed_presets[${c_integer_upsampling_allowed_preset}]}"
211+
echo " translates to [${c_integer_upsampling_allowed}]"
212+
if [[ -n "${c_integer_upsampling_allowed}" ]]; then
213+
alsa_set_key="integer_upsampling_allowed.${idx}"
214+
alsa_out_set_values[$alsa_set_key]="${c_integer_upsampling_allowed}"
215+
fi
216+
fi
217+
205218
# debug dump values
206219
## sz=`echo "${#alsa_out_set_values[@]}"`
207220
## echo "There are [$sz] available alsa_presets"
@@ -220,6 +233,7 @@ build_alsa() {
220233
add_output_parameter $out_file $idx ALSA_OUTPUT_AUTO_RESAMPLE auto_resample "" none
221234
add_output_parameter $out_file $idx ALSA_OUTPUT_THESYCON_DSD_WORKAROUND thesycon_dsd_workaround "" none
222235
add_output_parameter $out_file $idx ALSA_OUTPUT_INTEGER_UPSAMPLING integer_upsampling "" none
236+
add_alsa_output_parameter $out_file $idx ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED integer_upsampling_allowed "" none "integer_upsampling_allowed"
223237
add_output_parameter $out_file $idx ALSA_OUTPUT_DOP dop "" none
224238
close_output $out_file
225239
# see if the ups version must be enforced
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
declare -A integer_upsampling_allowed_presets
4+
5+
integer_upsampling_allowed_44=44
6+
integer_upsampling_allowed_base=base
7+
8+
integer_upsampling_allowed_presets[$integer_upsampling_allowed_44]="44100:*:*"
9+
integer_upsampling_allowed_presets[$integer_upsampling_allowed_base]="44100:*:* 48000:*:*"
10+

app/bin/run-mpd.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ declare -A file_dict
3737

3838
source build-soxr-presets.sh
3939
source build-allowed-formats-presets.sh
40+
source build-integer-upsampling-allowed-presets.sh
4041
source read-file.sh
4142
source get-value.sh
4243
source load-alsa-presets.sh

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ echo "Base Image Tag: ["$selected_image_tag"]"
6464
echo "Build Tag: ["$tag"]"
6565
echo "Proxy: ["$proxy"]"
6666

67-
docker build . --no-cache \
67+
docker build . \
6868
--build-arg BASE_IMAGE_TAG=${selected_image_tag} \
6969
--build-arg USE_APT_PROXY=${proxy} \
7070
-t giof71/mpd-alsa:$tag

doc/change-history.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Date|Major Changes
44
:---|:---
5+
2023-02-03|Add support for `ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED`
6+
2023-02-03|Bump to mpd version `v0.23.12`
57
2023-01-30|Add support for `AUDIO_BUFFER_SIZE`
68
2023-01-20|Player state enforced by default
79
2023-01-17|`HTTPD_OUTPUT_TAGS` had typo in name

0 commit comments

Comments
 (0)