Hello All,
First, we want to thank you for your response.
We made some progress on the project. By the suggestion of tmigone, we first tried fixing the kiosk container and make it work on the raspberry pi audio jack. When running the command aplay -L
we should see the pulse device and ALSA output as default. This was not the case, even if we put the docker command:
RUN curl -sL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh | sh
In the end we just built the functionality of the debian-setup.sh script into the dockerfile of kiosk:
(pulse-alsa.conf and 99-pulse.conf are placed locally and copied into the container when building it.)
# build tohora from source
FROM balenalib/raspberrypi3-golang as builder
RUN go get -d -v github.com/mozz100/tohora/...
WORKDIR /go/src/github.com/mozz100/tohora
RUN go build
FROM balenablocks/browser:%%BALENA_MACHINE_NAME%%
RUN install_packages cec-utils
COPY --from=builder /go/src/github.com/mozz100/tohora /home/chromium/tohora
COPY launch.sh /home/chromium/
# adding ALSA bridge
# https://sound.balenalabs.io/contributing/architecture/
#RUN curl -sL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh | sh
RUN apt-get update
RUN apt-get install libasound2-plugins -y
RUN mkdir -p /usr/share/alsa/
COPY pulse-alsa.conf /usr/share/alsa/pulse-alsa.conf
COPY pulse-alsa.conf /etc/asound.conf
RUN mkdir -p /etc/alsa/conf.d/
COPY 99-pulse.conf /etc/alsa/conf.d/99-pulse.conf
ENV PULSE_SERVER=tcp:audio:4317
ENV AUDIO_OUTPUT=balena-sound.input
#COPY debian-setup.sh /home/chromium
#RUN /home/chromium/debian-setup.sh
#RUN curl -sL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh | sh
RUN apt-get install alsa-utils -y
#RUN apt-get install pulseaudio
#RUN apt-get install pulseaudio-utils
#RUN pulseaudio -D --system
# replace command that runs in start script
COPY alt_start.sh /usr/src/app/
RUN sed -i '$d' /usr/src/app/start.sh
RUN echo ". alt_start.sh" >> /usr/src/app/start.sh
That seemed to have done the trick, except the default was not ALSA Output. For that we needed also an asound.conf COPY pulse-alsa.conf /etc/asound.conf
(We also removed the network_mode: host and put ENV PULSE_SERVER=tcp:audio:4317
)
Then we could see this:
root@44ff7f0:/usr/src# aplay -L
default
Playback/recording through the PulseAudio sound server
null
Discard all samples (playback) or generate zero samples (capture)
lavrate
Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
Rate Converter Plugin Using Samplerate Library
speexrate
Rate Converter Plugin Using Speex Resampler
jack
JACK Audio Connection Kit
oss
Open Sound System
pulse
PulseAudio Sound Server
upmix
Plugin for channel upmix (4,6,8)
vdownmix
Plugin for channel downmix (stereo) with a simple spacialization
sysdefault:CARD=bcm2835-jack
bcm2835 Headphones, bcm2835 Headphones
Default Audio Device
dmix:CARD=bcm2835-jack,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct sample mixing device
dsnoop:CARD=bcm2835-jack,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct sample snooping device
hw:CARD=bcm2835-jack,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Direct hardware device without any conversions
plughw:CARD=bcm2835-jack,DEV=0
bcm2835 Headphones, bcm2835 Headphones
Hardware device with all software conversions
usbstream:CARD=bcm2835-jack
bcm2835 Headphones
USB Stream Output
However there was still no audio playing ( via aplay /usr/share/sounds/alsa/Front_Center.wav
or a web radio station via kiosk)
First, the audio container was trying to connect to the sound supervisor server (<host_ip>:3000), but was not succeding. It turns out the audio container was connecting to the wrong IP. We fixed it in start.sh by replacing:
#SOUND_SUPERVISOR="$(ip route | awk '/default / { print $3 }'):3000"
(This just took the gateway for the subnet instead of the IP address of the ‘on board’ sound-supervisor.)
with:
SOUND_SUPERVISOR=$BALENA_SUPERVISOR_ADDRESS
For this we also added label io.balena.features.supervisor-api: 1
to the audio container in the docer-compose.yml
Next, we saw this in the logs of the audio container:
29.11.20 21:35:55 (+0100) audio
29.11.20 21:35:55 (+0100) audio --- Audio ---
29.11.20 21:35:55 (+0100) audio Starting audio service with settings:
29.11.20 21:35:55 (+0100) audio - Pulse log level: NOTICE
29.11.20 21:35:55 (+0100) audio - Default output: AUTO
29.11.20 21:35:55 (+0100) audio
29.11.20 21:35:55 (+0100) audio Detected audio cards:
29.11.20 21:35:55 (+0100) audio 0 bcm2835-jack bcm2835_headphonbcm2835Headphones-bcm2835Headphones
29.11.20 21:35:55 (+0100) audio
29.11.20 21:35:55 (+0100) audio
29.11.20 21:36:27 (+0100) audio Setting audio routing rules. Note that this can be changed after startup.
29.11.20 21:36:28 (+0100) audio Routing 'balena-sound.input' to 'snapcast'.
29.11.20 21:36:28 (+0100) audio Routing 'balena-sound.output' to 'alsa_output.bcm2835-jack.stereo-fallback'.
29.11.20 21:36:29 (+0100) audio W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).
29.11.20 21:36:31 (+0100) audio W: [pulseaudio] module-loopback.c: Cannot set requested sink latency of 66.67 ms, adjusting to 23.22 ms
29.11.20 21:36:31 (+0100) audio W: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
29.11.20 21:36:31 (+0100) audio W: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
And the sound-supervisor doing this:
29.11.20 21:35:44 (+0100) sound-supervisor Error connecting to audio block - Retry failed: connect ECONNREFUSED 192.168.1.112:4317
29.11.20 21:36:04 (+0100) sound-supervisor Error connecting to audio block - Retry failed: connect ECONNREFUSED 192.168.1.112:4317
29.11.20 21:36:29 (+0100) sound-supervisor Error connecting to audio block - Retry failed: connect ECONNREFUSED 192.168.1.112:4317
29.11.20 21:37:00 (+0100) sound-supervisor Connected to PulseAudio at 192.168.1.112:4317
29.11.20 21:37:00 (+0100) sound-supervisor Server protocol version: 33
29.11.20 21:37:00 (+0100) sound-supervisor Client protocol version: 33
29.11.20 21:37:05 (+0100) sound-supervisor Joining the fleet, requesting master info with fleet-sync...
29.11.20 21:57:01 (+0100) sound-supervisor Playback started, announcing 192.168.1.112 as multi-room master!
29.11.20 21:58:46 (+0100) sound-supervisor Playback started, announcing 192.168.1.112 as multi-room master!
29.11.20 21:59:05 (+0100) sound-supervisor Playback started, announcing 192.168.1.112 as multi-room master!
The Routing 'balena-sound.input' to 'snapcast'.
and Routing 'balena-sound.output' to alsa_output.bcm2835-jack.stereo-fallback'.
looks ok.
What worries us is this:
29.11.20 21:36:31 (+0100) audio W: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
29.11.20 21:36:31 (+0100) audio W: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
We found a couple of posts discussing this issue (albeit for the raspberry pi 3). The workaround to make it 32-bit:
Remove the vc4-kms-v3d dtoverlay setting from the Device Configuration section of your device.
This does not seem to have an effect.
We tried to set DBUS_SYSTEM_BUS_ADDRESS
for the audio container:
environment:
- DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
Adding the label io.balena.features.kernel-modules: '1'
, does not help.
Also trying out SOUND_MODE
STANDALONE
doesn’t have an effect.
The sound-supervisor does seem to react to audio being played. When we run: aplay /usr/share/sounds/alsa/Front_Center.wav
the log shows:
sound-supervisor Playback started, announcing 192.168.1.112 as multi-room master!
Next thing on the list is to fix the [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
error.
Sugestions are always welcome.
EDIT: Maybe also interesting to know, we use the “balenaOS 2.58.6+rev1” OS on a Raspberry Pi 4
Kind regards,
Woody