From c2965f4750ea50a1c4918e3fc16edd58af0df4c4 Mon Sep 17 00:00:00 2001 From: Jocelyn Le Sage Date: Fri, 27 Jul 2018 12:58:06 -0400 Subject: [PATCH] Added support for sound. --- README.md | 7 +++++++ appdefs.xml | 16 +++++++++++++++- rootfs/etc/cont-init.d/check-snd.sh | 25 +++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100755 rootfs/etc/cont-init.d/check-snd.sh diff --git a/README.md b/README.md index 8b41a6b..7f1fe28 100644 --- a/README.md +++ b/README.md @@ -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 URL Path](#routing-based-on-url-path) * [Increasing Shared Memory Size](#increasing-shared-memory-size) + * [Sound Support](#sound-support) * [Troubleshooting](#troubleshooting) * [Crashes](#crashes) * [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 `-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 ### Crashes diff --git a/appdefs.xml b/appdefs.xml index f403e94..5ef9f3d 100644 --- a/appdefs.xml +++ b/appdefs.xml @@ -41,6 +41,14 @@ size of `/dev/shm` can be done via two method: `-v /dev/shm:/dev/shm` of the `docker run` command. +
+ Sound Support + +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. + +
Troubleshooting @@ -100,7 +108,13 @@ details. - + + + /dev/snd + Optional Linux device to expose to have sound. + false + + diff --git a/rootfs/etc/cont-init.d/check-snd.sh b/rootfs/etc/cont-init.d/check-snd.sh new file mode 100755 index 0000000..dcbdfb1 --- /dev/null +++ b/rootfs/etc/cont-init.d/check-snd.sh @@ -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 :