Skip to content

Commit 17ea581

Browse files
authored
[Feature] Allow creation of Null outputs #235 (#237)
1 parent 29c9bdf commit 17ea581

File tree

5 files changed

+121
-80
lines changed

5 files changed

+121
-80
lines changed

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ VOLUME /user/config
5959

6060
# default mpd port
6161
EXPOSE 6600
62-
# default httpd port
62+
# default http port
6363
EXPOSE 8000
6464

6565
ENV DATABASE_MODE ""
@@ -152,6 +152,12 @@ ENV SHOUT_OUTPUT_PASSWORD ""
152152
ENV SHOUT_OUTPUT_PUBLIC ""
153153
ENV SHOUT_MIXER_TYPE ""
154154

155+
# NULL outputs
156+
ENV NULL_OUTPUT_CREATE ""
157+
ENV NULL_OUTPUT_ENABLED ""
158+
ENV NULL_OUTPUT_NAME ""
159+
ENV NULL_OUTPUT_SYNC ""
160+
155161
ENV INPUT_CACHE_SIZE ""
156162

157163
# Qobuz Input Plugin

README.md

Lines changed: 91 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -221,100 +221,112 @@ SCROBBLER_MPD_HOSTNAME|Set when using host mode, defaults to `localhost`
221221
SCROBBLER_MPD_PORT|Set when using host mode, defaults to `6600`
222222
PROXY|Proxy support for `mpdscribble`. Example value: `http://the.proxy.server:3128`
223223

224-
#### ALSA additional outputs
224+
#### Additional Outputs
225+
226+
You can define additional outputs of various types. Refer to the following paragraphs.
227+
For each type, that you can add up to 20 (or what is specified for the variable `MAX_ADDITIONAL_OUTPUTS_BY_TYPE`) additional outputs for each type. In order to specify distinct values, you can add `_1`, `_2` to every variable names in this set. The first output does *not* require to specify `_0`, that index is implicit.
228+
The output name of those outputs, if not explicitly set, is created by appending with `_1`, `_2`, ... to the defaut name, so in the case of PulseAudio, the names of output will be `PulseAudio_1`, `PulseAudio_2`, ...
229+
230+
##### ALSA additional outputs
225231

226232
Additional alsa outputs can be configured using the following variables:
227233

228-
VARIABLE|OPTIONAL|DESCRIPTION
229-
:---|:---:|:---
230-
ALSA_OUTPUT_CREATE|yes|Set to `yes` if you want to create and additional httpd output
231-
ALSA_OUTPUT_ENABLED|yes|Sets the output as enabled if set to `yes`, otherwise mpd's default behavior applies
232-
ALSA_OUTPUT_NAME|yes|The name of the httpd output, defaults to `alsa`
233-
ALSA_OUTPUT_PRESET|yes|Use an Alsa preset for easier configuration
234-
ALSA_OUTPUT_DEVICE|yes|Sets alsa device
235-
ALSA_OUTPUT_AUTO_FIND_MIXER|yes|Allows to auto-select the mixer for easy hardware volume configuration
236-
ALSA_OUTPUT_MIXER_TYPE|yes|Mixer type
237-
ALSA_OUTPUT_MIXER_DEVICE|yes|Mixer device
238-
ALSA_OUTPUT_MIXER_CONTROL|yes|Mixer Control
239-
ALSA_OUTPUT_MIXER_INDEX|yes|Mixer Index
240-
ALSA_OUTPUT_ALLOWED_FORMATS_PRESET|yes|Alternative to `ALSA_OUTPUT_ALLOWED_FORMATS`. Possible values: 8x, 4x, 2x, 8x-nodsd, 4x-nodsd, 2x-nodsd
241-
ALSA_OUTPUT_ALLOWED_FORMATS|yes|Sets allowed formats
242-
ALSA_OUTPUT_OUTPUT_FORMAT|yes|Sets output format
243-
ALSA_OUTPUT_AUTO_RESAMPLE|yes|Sets auto resample
244-
ALSA_OUTPUT_THESYCON_DSD_WORKAROUND|yes|Enables workaround
245-
ALSA_OUTPUT_INTEGER_UPSAMPLING|yes|Enables integer upsampling
246-
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`
247-
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
248-
ALSA_OUTPUT_DOP|yes|Enables Dsd-Over-Pcm. Possible values: `yes` or `no`. Empty by default: this it lets mpd handle dop setting.
249-
250-
For the meaning, refer to the corresponding values in the first list of environment variables.
251-
Note that you can add up to 20 (or what is specified for the variable `MAX_ADDITIONAL_OUTPUTS_BY_TYPE`) httpd outputs. In order to specify distinct values, you can add `_1`, `_2` to every variable names in this set. The first output does *not* require to specify `_0`, that index is implicit.
252-
253-
#### PulseAudio additional outputs
234+
VARIABLE|DESCRIPTION
235+
:---|:---
236+
ALSA_OUTPUT_CREATE|Set to `yes` if you want to create an additional alsa output
237+
ALSA_OUTPUT_ENABLED|Sets the output as enabled if set to `yes`, otherwise mpd's default behavior applies
238+
ALSA_OUTPUT_NAME|The name of the alsa output, defaults to `alsa`
239+
ALSA_OUTPUT_PRESET|Use an Alsa preset for easier configuration
240+
ALSA_OUTPUT_DEVICE|The audio device. Common examples: `hw:DAC` or `hw:x20` or `hw:X20` for usb dac based on XMOS chips. Defaults to `default`
241+
ALSA_OUTPUT_AUTO_FIND_MIXER|Allows to auto-select the mixer for easy hardware volume configuration
242+
ALSA_OUTPUT_MIXER_TYPE|Mixer type, defaults to `hardware`
243+
ALSA_OUTPUT_MIXER_DEVICE|Mixer device, defaults to `default`
244+
ALSA_OUTPUT_MIXER_CONTROL|Mixer Control, defaults to `PCM`
245+
ALSA_OUTPUT_MIXER_INDEX|Mixer Index, defaults to `0`
246+
ALSA_OUTPUT_ALLOWED_FORMATS_PRESET|Alternative to `ALSA_OUTPUT_ALLOWED_FORMATS`. Possible values: 8x, 4x, 2x, 8x-nodsd, 4x-nodsd, 2x-nodsd
247+
ALSA_OUTPUT_ALLOWED_FORMATS|Sets allowed formats
248+
ALSA_OUTPUT_OUTPUT_FORMAT|Sets output format
249+
ALSA_OUTPUT_AUTO_RESAMPLE|If set to no, then libasound will not attempt to resample. In this case, the user is responsible for ensuring that the requested sample rate can be produced natively by the device, otherwise an error will occur.
250+
ALSA_OUTPUT_THESYCON_DSD_WORKAROUND|If enabled, enables a workaround for a bug in Thesycon USB audio receivers. On these devices, playing DSD512 or PCM causes all subsequent attempts to play other DSD rates to fail, which can be fixed by briefly playing PCM at 44.1 kHz.
251+
ALSA_OUTPUT_INTEGER_UPSAMPLING|If one or more `ALSA_ALLOWED_FORMATS` are set and `INTEGER_UPSAMPLING` is set to `yes`, the formats which are evenly divided by the source sample rate are preferred. The `ALSA_ALLOWED_FORMATS` list is processed in order as provided to the container. So if you want to upsample, put higher sampling rates first. Using this feature causes a patched version of mpd to be run. Use at your own risk.
252+
ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED|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|Preset for `ALSA_OUTPUT_INTEGER_UPSAMPLING_ALLOWED`. Allowed values are `base` (for 44.1kHz and 48.0kHz) and `44` for 44.1kHz only
254+
ALSA_OUTPUT_DOP|Enables Dsd-Over-Pcm. Possible values: `yes` or `no`. Empty by default: this it lets mpd handle dop setting.
255+
256+
Refer to the MPD [documentation](https://mpd.readthedocs.io/en/stable/plugins.html#alsa-plugin) for the meaning of the variables.
257+
258+
##### PulseAudio additional outputs
254259

255260
Remember to setup [user mode](https://github.com/GioF71/mpd-alsa-docker/blob/main/doc/user-mode.md) when using PulseAudio outputs, otherwise they won't work.
256261
Additional PulseAudio outputs can be configured using the following variables:
257262

258-
VARIABLE|OPTIONAL|DESCRIPTION
259-
:---|:---:|:---
260-
PULSE_AUDIO_OUTPUT_CREATE|yes|Set to `yes` if you want to create and additional httpd output
261-
PULSE_AUDIO_OUTPUT_ENABLED|yes|Sets the output as enabled if set to `yes`, otherwise mpd's default behavior applies
262-
PULSE_AUDIO_OUTPUT_NAME|yes|The name of the httpd output, defaults to `httpd`
263-
PULSE_AUDIO_OUTPUT_SINK|yes|Specifies the name of the PulseAudio sink MPD should play on
264-
PULSE_AUDIO_OUTPUT_MEDIA_ROLE|yes|Media role for the PulseAudio output
265-
PULSE_AUDIO_OUTPUT_SCALING_FACTOR|yes|Scaling factor for the PulseAudio output
263+
VARIABLE|DESCRIPTION
264+
:---|:---
265+
PULSE_AUDIO_OUTPUT_CREATE|Set to `yes` if you want to create an additional PulseAudio output
266+
PULSE_AUDIO_OUTPUT_ENABLED|Sets the output as enabled if set to `yes`, otherwise mpd's default behavior applies
267+
PULSE_AUDIO_OUTPUT_NAME|The name of the PulseAudio output, defaults to `PulseAudio`
268+
PULSE_AUDIO_OUTPUT_SINK|Specifies the name of the PulseAudio sink MPD should play on
269+
PULSE_AUDIO_OUTPUT_MEDIA_ROLE|Media role for the PulseAudio output
270+
PULSE_AUDIO_OUTPUT_SCALING_FACTOR|Scaling factor for the PulseAudio output
266271

267272
Refer to the MPD [documentation](https://mpd.readthedocs.io/en/stable/plugins.html#pulse) for the meaning of the variables.
268-
Note that you can add up to 20 (or what is specified for the variable `MAX_ADDITIONAL_OUTPUTS_BY_TYPE`) httpd outputs. In order to specify distinct values, you can add `_1`, `_2` to every variable names in this set. The first output does *not* require to specify `_0`, that index is implicit.
269-
The port number default is calculated for each index, as well as the default output name which is appended with `_1`, `_2`, ... (so it becomes `PulseAudio_1`, `PulseAudio_2`, ...).
270273

271-
#### HTTPD additional outputs
274+
##### HTTPD additional outputs
272275

273276
Additional httpd outputs can be configured using the following variables:
274277

275-
VARIABLE|OPTIONAL|DESCRIPTION
276-
:---|:---:|:---
277-
HTTPD_OUTPUT_CREATE|yes|Set to `yes` if you want to create and additional httpd output
278-
HTTPD_OUTPUT_ENABLED|yes|Sets the output as enabled if set to `yes`, otherwise mpd's default behavior applies
279-
HTTPD_OUTPUT_NAME|yes|The name of the httpd output, defaults to `httpd`
280-
HTTPD_OUTPUT_PORT|yes|The port for the httpd output stream, defaults to `8000` if not specified
281-
HTTPD_OUTPUT_BIND_TO_ADDRESS|yes|Allows to specify the bind address
282-
HTTPD_OUTPUT_ENCODER|yes|The encoder defaults to `wave`, see [here](https://mpd.readthedocs.io/en/stable/plugins.html#encoder-plugins) for other options
283-
HTTPD_OUTPUT_ENCODER_BITRATE|yes|Encoder bitrate. Refer to the encoder [documentation](https://mpd.readthedocs.io/en/stable/plugins.html#encoder-plugins)
284-
HTTPD_OUTPUT_ENCODER_QUALITY|yes|Encoder quality. Refer to the encoder [documentation](https://mpd.readthedocs.io/en/stable/plugins.html#encoder-plugins)
285-
HTTPD_OUTPUT_MAX_CLIENTS|yes|Sets a limit, number of concurrent clients. When set to 0 no limit will apply. Defaults to `0`
286-
HTTPD_OUTPUT_ALWAYS_ON|yes|If set to `yes`, then MPD attempts to keep this audio output always open. This may be useful for streaming servers, when you don’t want to disconnect all listeners even when playback is accidentally stopped. Defaults to `yes`
287-
HTTPD_OUTPUT_TAGS|yes|If set to no, then MPD will not send tags to this output. This is only useful for output plugins that can receive tags, for example the httpd output plugin. Defaults to `yes`
288-
HTTPD_OUTPUT_FORMAT|yes|The output format, defaults to `44100:16:2`
289-
HTTPD_MIXER_TYPE|yes|Set to `software` if you want to be able to change the volume of the output stream
290-
291-
Note that you can add up to 20 (or what is specified for the variable `MAX_ADDITIONAL_OUTPUTS_BY_TYPE`) httpd outputs. In order to specify distinct values, you can add `_1`, `_2` to every variable names in this set. The first output does *not* require to specify `_0`, that index is implicit.
292-
The port number default is calculated for each index, as well as the default output name which is appended with `_1`, `_2`, ... (so it becomes `httpd_1`, `httpd_2`, ...).
278+
VARIABLE|DESCRIPTION
279+
:---|:---
280+
HTTPD_OUTPUT_CREATE|Set to `yes` if you want to create an additional httpd output
281+
HTTPD_OUTPUT_ENABLED|Sets the output as enabled if set to `yes`, otherwise mpd's default behavior applies
282+
HTTPD_OUTPUT_NAME|The name of the httpd output, defaults to `httpd`
283+
HTTPD_OUTPUT_PORT|The port for the httpd output stream, defaults to `8000` if not specified
284+
HTTPD_OUTPUT_BIND_TO_ADDRESS|Allows to specify the bind address
285+
HTTPD_OUTPUT_ENCODER|The encoder defaults to `wave`, see [here](https://mpd.readthedocs.io/en/stable/plugins.html#encoder-plugins) for other options
286+
HTTPD_OUTPUT_ENCODER_BITRATE|Encoder bitrate. Refer to the encoder [documentation](https://mpd.readthedocs.io/en/stable/plugins.html#encoder-plugins)
287+
HTTPD_OUTPUT_ENCODER_QUALITY|Encoder quality. Refer to the encoder [documentation](https://mpd.readthedocs.io/en/stable/plugins.html#encoder-plugins)
288+
HTTPD_OUTPUT_MAX_CLIENTS|Sets a limit, number of concurrent clients. When set to 0 no limit will apply. Defaults to `0`
289+
HTTPD_OUTPUT_ALWAYS_ON|If set to `yes`, then MPD attempts to keep this audio output always open. This may be useful for streaming servers, when you don’t want to disconnect all listeners even when playback is accidentally stopped. Defaults to `yes`
290+
HTTPD_OUTPUT_TAGS|If set to no, then MPD will not send tags to this output. This is only useful for output plugins that can receive tags, for example the httpd output plugin. Defaults to `yes`
291+
HTTPD_OUTPUT_FORMAT|The output format, defaults to `44100:16:2`
292+
HTTPD_MIXER_TYPE|Set to `software` if you want to be able to change the volume of the output stream
293+
294+
The port number default is calculated for each index by incrementing the default (`8000`) value.
293295
When using multiple httpd outputs, remember to open *all* the relevant ports, not only `8000`, otherwise only the first output will work.
294296

295-
#### Shout additional outputs
296-
297-
VARIABLE|OPTIONAL|DESCRIPTION
298-
:---|:---:|:---
299-
SHOUT_OUTPUT_CREATE|yes|Set to `yes` if you want to create and additional httpd output
300-
SHOUT_OUTPUT_ENABLED|yes|Sets the output as enabled if set to `yes`, otherwise mpd's default behavior applies
301-
SHOUT_OUTPUT_NAME|yes|The name of the httpd output, defaults to `shout`
302-
SHOUT_OUTPUT_PROTOCOL|yes|Specifies the protocol that wil be used to connect to the server, can be `icecast2` (default), `icecast1`, `shoutcast`
303-
SHOUT_OUTPUT_TLS|yes|Specifies what kind of TLS to use, can be `disabled` (default), `auto`, `auto_no_plain`, `rfc2818`, `rfc2817`
304-
SHOUT_OUTPUT_FORMAT|yes|The output format, defaults to `44100:16:2`
305-
SHOUT_OUTPUT_ENCODER|yes|The encoder defaults to `vorbis`, see [here](https://mpd.readthedocs.io/en/stable/plugins.html#encoder-plugins) for other options. BITRATE and QUALITY are typically alternative, so do not specify both of them.
306-
SHOUT_OUTPUT_ENCODER_BITRATE|yes|Encoder bitrate. Refer to the encoder [documentation](https://mpd.readthedocs.io/en/stable/plugins.html#encoder-plugins)
307-
SHOUT_OUTPUT_ENCODER_QUALITY|yes|Encoder quality. Refer to the encoder [documentation](https://mpd.readthedocs.io/en/stable/plugins.html#encoder-plugins)
308-
SHOUT_OUTPUT_HOST|yes|Sets the host name of the ShoutCast / IceCast server, defaults to `icecast`, this seems a sensible default in a docker environment
309-
SHOUT_OUTPUT_PORT|yes|Connect to this port number on the specified host, defaults to `8000`
310-
SHOUT_OUTPUT_MOUNT|yes|Mounts the MPD stream in the specified URI
311-
SHOUT_OUTPUT_USER|yes|Sets the user name for submitting the stream to the server, defaults to `source`
312-
SHOUT_OUTPUT_PASSWORD|yes|Sets the password for submitting the stream to the server, defaults to `hackme`
313-
SHOUT_OUTPUT_PUBLIC|yes|Specifies whether the stream should be "public", defaults to `no`
314-
SHOUT_MIXER_TYPE|yes|Set to `software` if you want to be able to change the volume of the output stream
315-
316-
Note that you can add up to 20 (or what is specified for the variable `MAX_ADDITIONAL_OUTPUTS_BY_TYPE`) httpd outputs. In order to specify distinct values, you can add `_1`, `_2` to every variable names in this set. The first output does *not* require to specify `_0`, that index is implicit.
317-
The port number default is calculated for each index, as well as the default output name which is appended with `_1`, `_2`, ... (so it becomes `shout_1`, `shout_2`, ...).
297+
##### Shout additional outputs
298+
299+
VARIABLE|DESCRIPTION
300+
:---|:---
301+
SHOUT_OUTPUT_CREATE|Set to `yes` if you want to create an additional shout output
302+
SHOUT_OUTPUT_ENABLED|Sets the output as enabled if set to `yes`, otherwise mpd's default behavior applies
303+
SHOUT_OUTPUT_NAME|The name of the shout output, defaults to `shout`
304+
SHOUT_OUTPUT_PROTOCOL|Specifies the protocol that wil be used to connect to the server, can be `icecast2` (default), `icecast1`, `shoutcast`
305+
SHOUT_OUTPUT_TLS|Specifies what kind of TLS to use, can be `disabled` (default), `auto`, `auto_no_plain`, `rfc2818`, `rfc2817`
306+
SHOUT_OUTPUT_FORMAT|The output format, defaults to `44100:16:2`
307+
SHOUT_OUTPUT_ENCODER|The encoder defaults to `vorbis`, see [here](https://mpd.readthedocs.io/en/stable/plugins.html#encoder-plugins) for other options. BITRATE and QUALITY are typically alternative, so do not specify both of them.
308+
SHOUT_OUTPUT_ENCODER_BITRATE|Encoder bitrate. Refer to the encoder [documentation](https://mpd.readthedocs.io/en/stable/plugins.html#encoder-plugins)
309+
SHOUT_OUTPUT_ENCODER_QUALITY|Encoder quality. Refer to the encoder [documentation](https://mpd.readthedocs.io/en/stable/plugins.html#encoder-plugins)
310+
SHOUT_OUTPUT_HOST|Sets the host name of the ShoutCast / IceCast server, defaults to `icecast`, this seems a sensible default in a docker environment
311+
SHOUT_OUTPUT_PORT|Connect to this port number on the specified host, defaults to `8000`
312+
SHOUT_OUTPUT_MOUNT|Mounts the MPD stream in the specified URI
313+
SHOUT_OUTPUT_USER|Sets the user name for submitting the stream to the server, defaults to `source`
314+
SHOUT_OUTPUT_PASSWORD|Sets the password for submitting the stream to the server, defaults to `hackme`
315+
SHOUT_OUTPUT_PUBLIC|Specifies whether the stream should be "public", defaults to `no`
316+
SHOUT_MIXER_TYPE|Set to `software` if you want to be able to change the volume of the output stream
317+
318+
##### Null additional outputs
319+
320+
Additional Null can be configured using the following variables:
321+
322+
VARIABLE|DESCRIPTION
323+
:---|:---
324+
NULL_OUTPUT_CREATE|Set to `yes` if you want to create an additional null output
325+
NULL_OUTPUT_ENABLED|Sets the output as enabled if set to `yes`, otherwise mpd's default behavior applies
326+
NULL_OUTPUT_NAME|The name of the Null output, defaults to `null`
327+
NULL_OUTPUT_SYNC|Sync mode for the `null` output, can be `yes` (default) or `no`
328+
329+
Refer to the MPD [documentation](https://mpd.readthedocs.io/en/stable/plugins.html#null) for the meaning of the variables.
318330

319331
### Examples
320332

app/bin/build-additional.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,19 @@ build_shout() {
313313
close_output $out_file
314314
fi
315315
}
316+
317+
build_null() {
318+
out_file=$1
319+
idx=$2
320+
create=$(get_named_env "NULL_OUTPUT_CREATE" $idx)
321+
if [[ "${create^^}" == "YES" || "${create^^}" == "Y" ]]; then
322+
echo "Creating Null output for output [$idx]"
323+
open_output $out_file
324+
set_output_type $out_file null
325+
add_output_parameter $out_file $idx NULL_OUTPUT_NAME name null str
326+
add_output_parameter $out_file $idx NULL_OUTPUT_ENABLED enabled "" none
327+
add_output_parameter $out_file $idx NULL_OUTPUT_SYNC sync yes constant
328+
close_output $out_file
329+
fi
330+
}
331+

app/bin/run-mpd.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,12 @@ do
508508
build_shout $MPD_ALSA_CONFIG_FILE $i
509509
done
510510

511+
## NULL output
512+
for i in $( eval echo {0..$output_by_type_limit} )
513+
do
514+
build_null $MPD_ALSA_CONFIG_FILE $i
515+
done
516+
511517
## additional outputs
512518
ADDITIONAL_OUTPUTS_FILE=/user/config/additional-outputs.txt
513519
if [ -f "$ADDITIONAL_OUTPUTS_FILE" ]; then

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-02-11|Support additional `NULL` outputs
56
2023-02-09|Clarified `legacy` releases
67
2023-02-04|Image name correction
78
2023-02-04|Dropped support for `PULSE` as `OUTPUT_MODE`

0 commit comments

Comments
 (0)