Skip to content

Commit

Permalink
Convert to s6 style and remove Pulseaudio restart (#153)
Browse files Browse the repository at this point in the history
* Convert overlay to new s6 style

This fixes an issue where restarting Pulseaudio on new hardware didn't
work. With this, we restart the pulseaudio service and wait for
readiness.

* Restart Pulseaudio on add and remove

Restart Pulseaudio in both cases, when adding and removing devices. Also
drop the unnecessary sleep.

* Drop rescue streams as it is deprecated

* Don't reload Pulseaudio

The necessary modules get reloaded by Supervisor now.
  • Loading branch information
agners committed Oct 30, 2023
1 parent da87a83 commit b4bbab8
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 19 deletions.
4 changes: 0 additions & 4 deletions rootfs/etc/pulse/system.pa
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ load-module module-native-protocol-unix auth-anonymous=1 auth-cookie-enabled=0 s
### that look up the default sink/source get the right value
load-module module-default-device-restore

### Automatically move streams to the default sink if the sink they are
### connected to dies, similar for sources
load-module module-rescue-streams

### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,15 @@ declare control
while read -r line; do

# Check if new ALSA mixer connecting
if [[ ! "${line}" =~ add.*(controlC[0-9]) ]]; then
if [[ "${line}" =~ add.*(controlC[0-9]) ]]; then
control=${BASH_REMATCH[1]}
bashio::log.info "Add ALSA mixer: ${control}"

# Run our soundconfig
soundconfig "${control}"
else
bashio::log.debug "Skip ${line}"
continue
else
control=${BASH_REMATCH[1]}
fi

# Wait until new mixer is setup
bashio::log.info "New ALSA mixer: ${control}"
sleep 5

# Run our soundconfig
soundconfig "${control}"

# Restart PulseAudio
s6-svc -wD -d -T2500 "/var/run/s6/services/pulseaudio"
s6-svc -wU -u -T2500 "/var/run/s6/services/pulseaudio"

done < <(udevadm monitor --subsystem-match=sound)
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/alsa/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
5 changes: 5 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/pulseaudio/data/check
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# Check if pulseaudio socket exists
test -S /data/external/pulse.sock
exit
File renamed without changes.
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/pulseaudio/notification-fd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ fi
export PULSE_STATE_PATH="/data/states"
export LD_PRELOAD="/usr/local/lib/libjemalloc.so.2"

exec pulseaudio --system --disallow-exit --exit-idle-time=-1 --disable-shm "${pulse_args[@]}"
exec s6-notifyoncheck -d -s 300 -w 300 -n 0 \
pulseaudio --system --disallow-exit --exit-idle-time=-1 \
--disable-shm "${pulse_args[@]}"
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/pulseaudio/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.

0 comments on commit b4bbab8

Please sign in to comment.