Added support for sound.

This commit is contained in:
Jocelyn Le Sage 2018-07-27 12:58:06 -04:00
parent ef916e2aa5
commit c2965f4750
3 changed files with 47 additions and 1 deletions

View File

@ -37,6 +37,7 @@ Mozilla Firefox is a free and open-source web browser developed by Mozilla Found
* [Routing Based on Hostname](#routing-based-on-hostname) * [Routing Based on Hostname](#routing-based-on-hostname)
* [Routing Based on URL Path](#routing-based-on-url-path) * [Routing Based on URL Path](#routing-based-on-url-path)
* [Increasing Shared Memory Size](#increasing-shared-memory-size) * [Increasing Shared Memory Size](#increasing-shared-memory-size)
* [Sound Support](#sound-support)
* [Troubleshooting](#troubleshooting) * [Troubleshooting](#troubleshooting)
* [Crashes](#crashes) * [Crashes](#crashes)
* [Support or Contact](#support-or-contact) * [Support or Contact](#support-or-contact)
@ -434,6 +435,12 @@ size of `/dev/shm` can be done via two method:
- By using shared memory of the host, by mapping `/dev/shm` via the parameter - By using shared memory of the host, by mapping `/dev/shm` via the parameter
`-v /dev/shm:/dev/shm` of the `docker run` command. `-v /dev/shm:/dev/shm` of the `docker run` command.
## Sound Support
For Firefox to be able to use the audio device available on
the host, `/dev/snd` must be exposed to the container by adding the
`--device /dev/snd` parameter to the `docker run` command.
## Troubleshooting ## Troubleshooting
### Crashes ### Crashes

View File

@ -41,6 +41,14 @@ size of `/dev/shm` can be done via two method:
`-v /dev/shm:/dev/shm` of the `docker run` command. `-v /dev/shm:/dev/shm` of the `docker run` command.
</content> </content>
</section> </section>
<section>
<title level="2">Sound Support</title>
<content>
For {{ defs.app.friendly_name }} to be able to use the audio device available on
the host, `/dev/snd` must be exposed to the container by adding the
`--device /dev/snd` parameter to the `docker run` command.
</content>
</section>
<section> <section>
<title level="2">Troubleshooting</title> <title level="2">Troubleshooting</title>
<content/> <content/>
@ -100,7 +108,13 @@ details.
<!-- Network ports --> <!-- Network ports -->
<ports/> <ports/>
<!-- Devices --> <!-- Devices -->
<devices/> <devices>
<device>
<path>/dev/snd</path>
<description>Optional Linux device to expose to have sound.</description>
<include_in_quick_start>false</include_in_quick_start>
</device>
</devices>
<!-- Extra parameters --> <!-- Extra parameters -->
<extra_params> <extra_params>
<extra_param> <extra_param>

View File

@ -0,0 +1,25 @@
#!/usr/bin/with-contenv sh
set -e # Exit immediately if a command exits with a non-zero status.
set -u # Treat unset variables as an error.
log() {
echo "[cont-init.d] $(basename $0): $*"
}
SND_DEV="/dev/snd"
if [ ! -d "$SND_DEV" ]; then
log "sound not supported: device $SND_DEV not exposed to the container."
exit 0
fi
# Save the associated group.
SND_GRP="$(find "$SND_DEV" -maxdepth 1 -not -type d -exec stat -c "%g" {} \; | sort -u | tail -n1)"
log "sound device group $SND_GRP."
if [ -f /var/run/s6/container_environment/SUP_GROUP_IDS ]; then
echo -n "," >> /var/run/s6/container_environment/SUP_GROUP_IDS
fi
echo -n "$SND_GRP" >> /var/run/s6/container_environment/SUP_GROUP_IDS
# vim: set ft=sh :