Skip to content

Commit

Permalink
[Feature] Support for ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED #221 (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
GioF71 authored Feb 3, 2023
1 parent 86e47dd commit 7a3fcaf
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ ENV ALSA_OUTPUT_OUTPUT_FORMAT ""
ENV ALSA_OUTPUT_AUTO_RESAMPLE ""
ENV ALSA_OUTPUT_THESYCON_DSD_WORKAROUND ""
ENV ALSA_OUTPUT_INTEGER_UPSAMPLING ""
ENV ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED ""
ENV ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED_PRESET ""
ENV ALSA_OUTPUT_DOP ""

ENV PULSE_AUDIO_OUTPUT_CREATE ""
Expand Down Expand Up @@ -222,6 +224,7 @@ COPY app/bin/get-value.sh /app/bin/
COPY app/bin/read-file.sh /app/bin/
COPY app/bin/build-soxr-presets.sh /app/bin/
COPY app/bin/build-allowed-formats-presets.sh /app/bin/
COPY app/bin/build-integer-upsampling-allowed-presets.sh /app/bin/
COPY app/bin/load-alsa-presets.sh /app/bin/
COPY app/bin/build-additional.sh /app/bin/
COPY app/bin/user-management.sh /app/bin/
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ Images: [DockerHub](https://hub.docker.com/r/giof71/mpd-alsa)
## MPD Source code

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

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

The current mpd version is `v0.23.11`.
The current mpd version is `v0.23.12`.

## Why

Expand Down Expand Up @@ -249,6 +249,8 @@ ALSA_OUTPUT_OUTPUT_FORMAT|yes|Sets output format
ALSA_OUTPUT_AUTO_RESAMPLE|yes|Sets auto resample
ALSA_OUTPUT_THESYCON_DSD_WORKAROUND|yes|Enables workaround
ALSA_OUTPUT_INTEGER_UPSAMPLING|yes|Enables integer upsampling
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`
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
ALSA_OUTPUT_DOP|yes|Enables Dsd-Over-Pcm. Possible values: `yes` or `no`. Empty by default: this it lets mpd handle dop setting.

For the meaning, refer to the corresponding values in the first list of environment variables.
Expand Down
14 changes: 14 additions & 0 deletions app/bin/build-additional.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ build_alsa() {
alsa_out_set_values[$alsa_set_key]="${c_allowed_formats}"
fi
fi

# integer upsampling allowed presets
c_integer_upsampling_allowed_preset=$(get_named_env ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED_PRESET $idx)
if [ -n "${c_integer_upsampling_allowed_preset}" ]; then
echo "Integer Upsampling Allowed set for alsa output [$idx] -> [${c_integer_upsampling_allowed_preset}]"
c_integer_upsampling_allowed="${integer_upsampling_allowed_presets[${c_integer_upsampling_allowed_preset}]}"
echo " translates to [${c_integer_upsampling_allowed}]"
if [[ -n "${c_integer_upsampling_allowed}" ]]; then
alsa_set_key="integer_upsampling_allowed.${idx}"
alsa_out_set_values[$alsa_set_key]="${c_integer_upsampling_allowed}"
fi
fi

# debug dump values
## sz=`echo "${#alsa_out_set_values[@]}"`
## echo "There are [$sz] available alsa_presets"
Expand All @@ -220,6 +233,7 @@ build_alsa() {
add_output_parameter $out_file $idx ALSA_OUTPUT_AUTO_RESAMPLE auto_resample "" none
add_output_parameter $out_file $idx ALSA_OUTPUT_THESYCON_DSD_WORKAROUND thesycon_dsd_workaround "" none
add_output_parameter $out_file $idx ALSA_OUTPUT_INTEGER_UPSAMPLING integer_upsampling "" none
add_alsa_output_parameter $out_file $idx ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED integer_upsampling_allowed "" none "integer_upsampling_allowed"
add_output_parameter $out_file $idx ALSA_OUTPUT_DOP dop "" none
close_output $out_file
# see if the ups version must be enforced
Expand Down
10 changes: 10 additions & 0 deletions app/bin/build-integer-upsampling-allowed-presets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

declare -A integer_upsampling_allowed_presets

integer_upsampling_allowed_44=44
integer_upsampling_allowed_base=base

integer_upsampling_allowed_presets[$integer_upsampling_allowed_44]="44100:*:*"
integer_upsampling_allowed_presets[$integer_upsampling_allowed_base]="44100:*:* 48000:*:*"

1 change: 1 addition & 0 deletions app/bin/run-mpd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ declare -A file_dict

source build-soxr-presets.sh
source build-allowed-formats-presets.sh
source build-integer-upsampling-allowed-presets.sh
source read-file.sh
source get-value.sh
source load-alsa-presets.sh
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ echo "Base Image Tag: ["$selected_image_tag"]"
echo "Build Tag: ["$tag"]"
echo "Proxy: ["$proxy"]"

docker build . --no-cache \
docker build . \
--build-arg BASE_IMAGE_TAG=${selected_image_tag} \
--build-arg USE_APT_PROXY=${proxy} \
-t giof71/mpd-alsa:$tag
2 changes: 2 additions & 0 deletions doc/change-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Date|Major Changes
:---|:---
2023-02-03|Add support for `ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED`
2023-02-03|Bump to mpd version `v0.23.12`
2023-01-30|Add support for `AUDIO_BUFFER_SIZE`
2023-01-20|Player state enforced by default
2023-01-17|`HTTPD_OUTPUT_TAGS` had typo in name
Expand Down

0 comments on commit 7a3fcaf

Please sign in to comment.