From e7fc62c950a3d9e268e90489c51e279c3781e7c5 Mon Sep 17 00:00:00 2001 From: Andrey Arapov Date: Wed, 23 Mar 2016 21:42:58 +0100 Subject: [PATCH] first commit --- Dockerfile | 35 +++++++++++++++++++++++++++++++++++ README.md | 28 ++++++++++++++++++++++++++++ client.conf | 2 ++ daemon.conf | 4 ++++ default.pa | 37 +++++++++++++++++++++++++++++++++++++ docker-compose.yml | 21 +++++++++++++++++++++ 6 files changed, 127 insertions(+) create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 client.conf create mode 100644 daemon.conf create mode 100644 default.pa create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..157a94c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# Run pulseaudio server in a container +# +# TODO +# - reset volume to 80% and keep it enabled when the container runs +# + +FROM debian:jessie +MAINTAINER Andrey Arapov +# Inspired by Jessica Frazelle + +# To avoid problems with Dialog and curses wizards +ENV DEBIAN_FRONTEND noninteractive + +# Define a user under which the pulseaudio server will be running +ENV USER pulseaudio +ENV UID 1000 +ENV GROUPS audio +ENV HOME /home/$USER + +RUN apt-get update \ + && apt-get install -yq pulseaudio pulseaudio-module-x11 \ + && rm -rf /var/lib/apt/lists + +COPY [ "default.pa", "client.conf", "daemon.conf", "/etc/pulse/" ] + +RUN useradd -u $UID -m -d $HOME -s /usr/sbin/nologin $USER \ + && usermod -aG $GROUPS $USER \ + && chmod 0644 -- /etc/pulse/* \ + && mkdir -p $HOME/.config/pulse \ + && chown -Rh $USER:$USER -- $HOME + +WORKDIR $HOME +USER $USER +VOLUME [ "/tmp", "$HOME/.config/pulse" ] +ENTRYPOINT [ "/usr/bin/pulseaudio" ] diff --git a/README.md b/README.md new file mode 100644 index 0000000..826c964 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +Readme +====== + +Launching pulseaudio +``` +echo "autospawn = no" > ~/.config/pulse/client.conf +pulseaudio --kill +rm -rf ~/.config/pulse/ +docker-compose up -d +``` + +If you wish your host system to use your docker pulseaudio server, e.g. +accepting Fn volume Up/Down and On/Off keys, issue the following command +``` +xprop -root -f PULSE_SERVER 8s -set PULSE_SERVER "tcp:localhost:4713" +``` + +To remove pulseaudio properties from environment variables +``` +pax11publish -e +``` + +To test whether pulseaudio is working +``` +PULSE_SERVER="tcp:localhost:4713" pactl list +PULSE_SERVER="tcp:localhost:4713" alsamixer +PULSE_SERVER="tcp:localhost:4713" mplayer some.avi +``` diff --git a/client.conf b/client.conf new file mode 100644 index 0000000..4e423ed --- /dev/null +++ b/client.conf @@ -0,0 +1,2 @@ +autospawn = no +daemon-binary = /bin/true diff --git a/daemon.conf b/daemon.conf new file mode 100644 index 0000000..092fcb4 --- /dev/null +++ b/daemon.conf @@ -0,0 +1,4 @@ +exit-idle-time = 180 +flat-volumes = yes +log-target = stderr +log-level = 4 diff --git a/default.pa b/default.pa new file mode 100644 index 0000000..acd1fae --- /dev/null +++ b/default.pa @@ -0,0 +1,37 @@ +.nofail + # Set tsched=0 here if you experience glitchy playback. This will + # revert back to interrupt-based scheduling and should fix it. + # + # Replace the device= part if you want pulse to use a specific device + # such as "dmix" and "dsnoop" so it doesn't lock an hw: device. + # use aplay -l to find your device + # test with: speaker-test -D plughw:PCH -l 3 -t sine -c 1 + + # INPUT/RECORD + # load-module module-alsa-source device="default" tsched=1 + load-module module-alsa-source device="plughw:PCH" tsched=1 + + # OUTPUT/PLAYBACK + # load-module module-alsa-sink device="default" tsched=1 + load-module module-alsa-sink device="plughw:PCH" tsched=1 + + # TODO: the below block has not been fully testsd yet (in this Docker container) + ### Automatically load driver modules depending on the hardware available + #.ifexists module-udev-detect.so + #load-module module-udev-detect + #.else + ### Use the static hardware detection module (for systems that lack udev support) + #load-module module-detect + #.endif + + # Accept clients -- very important! + load-module module-native-protocol-unix + load-module module-native-protocol-tcp auth-ip-acl=127.0.0.0/8;172.0.0.0/8 auth-anonymous=1 + +.ifexists module-x11-publish.so + # Publish to X11 so the clients know how to connect to Pulse. + # Will clear itself on unload. + load-module module-x11-publish +.endif + +.fail diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1bc723c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +version: '2' + +services: + pulseaudio: + build: ./ + read_only: true + hostname: localhost + networks: + - net + ports: + - "4713:4713" + devices: + - /dev/snd + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix + - /var/run/dbus:/var/run/dbus + environment: + DISPLAY: unix$DISPLAY + +networks: + net: {}