first commit

This commit is contained in:
Andy 2016-03-23 21:42:58 +01:00
parent f08be84b3f
commit e7fc62c950
Signed by: arno
GPG Key ID: 368DDA2E9A471EAC
6 changed files with 127 additions and 0 deletions

35
Dockerfile Normal file
View File

@ -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 <andrey.arapov@nixaid.com>
# Inspired by Jessica Frazelle <jess@docker.com>
# 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" ]

28
README.md Normal file
View File

@ -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
```

2
client.conf Normal file
View File

@ -0,0 +1,2 @@
autospawn = no
daemon-binary = /bin/true

4
daemon.conf Normal file
View File

@ -0,0 +1,4 @@
exit-idle-time = 180
flat-volumes = yes
log-target = stderr
log-level = 4

37
default.pa Normal file
View File

@ -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

21
docker-compose.yml Normal file
View File

@ -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: {}