Skip to content

Commit

Permalink
[Feature] extend support for resource limitation #381 (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
GioF71 authored Feb 16, 2024
1 parent 4c0d19b commit 5f78364
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
16 changes: 13 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ ENV ZEROCONF_NAME ""

ENV HYBRID_DSD_ENABLED ""

ENV MAX_OUTPUT_BUFFER_SIZE ""
ENV AUDIO_BUFFER_SIZE ""

ENV MAX_ADDITIONAL_OUTPUTS_BY_TYPE ""

ENV RESTORE_PAUSED ""
ENV STATE_FILE_INTERVAL ""
ENV ENFORCE_PLAYER_STATE ""
ENV FORCE_REPO_BINARY ""

ENV STARTUP_DELAY_SEC ""
Expand All @@ -259,6 +259,16 @@ ENV CURL_VERIFY_PEER ""
ENV CURL_VERIFY_HOST ""
ENV CURL_CACERT ""

ENV MAX_PERMISSIONS ""

ENV MAX_ADDITIONAL_OUTPUTS_BY_TYPE ""

ENV CONNECTION_TIMEOUT ""
ENV MAX_CONNECTIONS ""
ENV MAX_PLAYLIST_LENGTH ""
ENV MAX_COMMAND_LIST_SIZE ""
ENV MAX_OUTPUT_BUFFER_SIZE ""

ENV STDERR_ENABLED ""

COPY README.md /app/doc/
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ CURL_CACERT|Parameter for CURL input plugin
ZEROCONF_ENABLED|Set to `yes` to enable, disabled by default.
ZEROCONF_NAME|Set zeroconf name, used only if `ZEROCONF_ENABLED` is set to `yes`
HYBRID_DSD_ENABLED|Hybrid dsd is enabled by default, set to `no` to disable. Disabled when at least one PulseAudio output is created.
MAX_OUTPUT_BUFFER_SIZE|The maximum size of the output buffer to a client (maximum response size). Default is 8192 (8 MiB). Value in KBytes.
AUDIO_BUFFER_SIZE|Adjust the size of the internal audio buffer. Default is `4 MB` (4 MiB).
MAX_ADDITIONAL_OUTPUTS_BY_TYPE|The maximum number of outputs by type, defaults to `20`
RESTORE_PAUSED|If set to `yes`, then MPD is put into pause mode instead of starting playback after startup. Default is `no`.
Expand All @@ -164,7 +163,12 @@ HOST_PERMISSIONS|Adds a `host_permissions`, you can add multiple (up to `MAX_PER
PASSWORD|Adds a `password`, you can add multiple (up to `MAX_PERMISSIONS`), append `_1`, `_2`, etc to the variable name for additional entries, see [here](https://mpd.readthedocs.io/en/stable/user.html#permissions-and-passwords)
MAX_PERMISSIONS|Specify the maximum number of host_permissions and passwords, defaults to `10`
STDERR_ENABLED|Print messages to the standard error, enabled by default. Set to `no` to disable
STARTUP_DELAY_SEC|Delay before starting the application in seconds, defaults to `0`.
CONNECTION_TIMEOUT|If a client does not send any new data in this time period (seconds), the connection is closed. Clients waiting in “idle” mode are excluded from this. Default is `60`
MAX_CONNECTIONS|This specifies the maximum number of clients that can be connected to MPD at the same time, default is `100`
MAX_PLAYLIST_LENGTH|The maximum number of songs that can be in the playlist, default is `16384`
MAX_COMMAND_LIST_SIZE|The maximum size a command list in KBYTES, default is `2048` (2 MiB)
MAX_OUTPUT_BUFFER_SIZE|The maximum size of the output buffer to a client (maximum response size), in KBYTES, default is 8192 (8 MiB)
STARTUP_DELAY_SEC|Delay before starting the application in seconds, defaults to `0`

#### SOXR Plugin

Expand Down
20 changes: 17 additions & 3 deletions app/bin/run-mpd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -693,14 +693,28 @@ if [ -n "${SAMPLERATE_CONVERTER}" ]; then
fi
echo "samplerate_converter \"${SAMPLERATE_CONVERTER}\"" >> $MPD_ALSA_CONFIG_FILE
fi
if [ -n "${MAX_OUTPUT_BUFFER_SIZE}" ]; then
echo "max_output_buffer_size \"${MAX_OUTPUT_BUFFER_SIZE}\"" >> $MPD_ALSA_CONFIG_FILE
fi
if [ -n "${AUDIO_BUFFER_SIZE}" ]; then
echo "audio_buffer_size \"${AUDIO_BUFFER_SIZE}\"" >> $MPD_ALSA_CONFIG_FILE
fi
echo "filesystem_charset \"UTF-8\"" >> $MPD_ALSA_CONFIG_FILE

# resource limitations
if [ -n "${CONNECTION_TIMEOUT}" ]; then
echo "connection_timeout \"${CONNECTION_TIMEOUT}\"" >> $MPD_ALSA_CONFIG_FILE
fi
if [[ -n "${MAX_CONNECTIONS}" ]]; then
echo "max_connections \"${MAX_CONNECTIONS}\"" >> $MPD_ALSA_CONFIG_FILE
fi
if [[ -n "${MAX_PLAYLIST_LENGTH}" ]]; then
echo "max_playlist_length \"${MAX_PLAYLIST_LENGTH}\"" >> $MPD_ALSA_CONFIG_FILE
fi
if [[ -n "${MAX_COMMAND_LIST_SIZE}" ]]; then
echo "max_command_list_size \"${MAX_COMMAND_LIST_SIZE}\"" >> $MPD_ALSA_CONFIG_FILE
fi
if [ -n "${MAX_OUTPUT_BUFFER_SIZE}" ]; then
echo "max_output_buffer_size \"${MAX_OUTPUT_BUFFER_SIZE}\"" >> $MPD_ALSA_CONFIG_FILE
fi

number_re="^[0-9]+$"
if [[ -n "$STARTUP_DELAY_SEC" ]]; then
if ! [[ $STARTUP_DELAY_SEC =~ $number_re ]]; then
Expand Down
1 change: 1 addition & 0 deletions doc/change-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Date|Major Changes
:---|:---
2024-02-16|Completed support for resource limitation (see issue [#381](https://github.com/GioF71/mpd-alsa-docker/issues/381))
2023-12-22|Bump to version 0.23.15 (see issue [#374](https://github.com/GioF71/mpd-alsa-docker/issues/374))
2023-12-19|Allow running in user mode (using docker `--user`) (see issue [#370](https://github.com/GioF71/mpd-alsa-docker/issues/370))
2023-12-10|Support multiple bind addresses (see issue [#357](https://github.com/GioF71/mpd-alsa-docker/issues/357))
Expand Down

0 comments on commit 5f78364

Please sign in to comment.