Skip to content

Commit e5c5363

Browse files
committed
Refactor AirPlay receiver entrypoint for improved audio setup and debugging
1 parent 11ae20b commit e5c5363

1 file changed

Lines changed: 35 additions & 34 deletions

File tree

docker-compose.yml

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -53,60 +53,61 @@ services:
5353
restart: unless-stopped
5454
network_mode: host
5555
hostname: kitchen-homespeaker # Set a specific hostname for this container
56+
devices:
57+
- /dev/snd:/dev/snd # Add direct ALSA device access
5658
volumes:
5759
- ./shairport-sync.conf:/tmp/shairport-sync-template.conf:ro
5860
- airplay-shared:/tmp/airplay-shared # Shared volume for state files
61+
- /run/user/1000/pulse:/run/user/1000/pulse:rw # PulseAudio socket
5962
environment:
6063
- PULSE_SERVER=unix:/run/user/1000/pulse/native
64+
- PULSE_RUNTIME_PATH=/run/user/1000/pulse
6165
- AIRPLAY_NAME=${AIRPLAY_NAME:-HomeSpeaker}
66+
entrypoint: ["/bin/bash"]
6267
command:
63-
- sh
6468
- -c
6569
- |
66-
# Debug: Show what name we're using
70+
set -e
71+
echo "=== Bypassing s6 init and starting manually ==="
6772
echo "Using AirPlay name: $${AIRPLAY_NAME}"
73+
echo "Hostname: $(hostname)"
6874
69-
# Set hostname for this session
70-
hostname "$${AIRPLAY_NAME// /-}" || true
71-
72-
# Create state management scripts inside container
73-
cat > /usr/local/bin/airplay-start.sh << 'EOF'
74-
#!/bin/sh
75-
echo 'ACTIVE' > /tmp/airplay-shared/state
76-
echo 'AirPlay session started' > /tmp/airplay-shared/log
77-
EOF
78-
79-
cat > /usr/local/bin/airplay-stop.sh << 'EOF'
80-
#!/bin/sh
81-
echo 'INACTIVE' > /tmp/airplay-shared/state
82-
echo 'AirPlay session ended' > /tmp/airplay-shared/log
83-
EOF
84-
85-
chmod +x /usr/local/bin/airplay-start.sh
86-
chmod +x /usr/local/bin/airplay-stop.sh
75+
# Kill any existing s6 processes to ensure clean start
76+
pkill -f s6 || true
8777
8878
# Copy template and replace placeholder with actual name
8979
cp /tmp/shairport-sync-template.conf /etc/shairport-sync.conf
9080
sed -i "s/AIRPLAY_NAME_PLACEHOLDER/$${AIRPLAY_NAME}/g" /etc/shairport-sync.conf
9181
92-
# Debug: Show the updated config
93-
echo "Updated config:"
94-
grep 'name =' /etc/shairport-sync.conf
82+
echo "=== Config file generated ==="
83+
cat /etc/shairport-sync.conf
84+
85+
echo ""
86+
echo "=== Starting required services manually ==="
87+
88+
# Start D-Bus system daemon
89+
echo "Starting D-Bus..."
90+
mkdir -p /var/run/dbus
91+
dbus-daemon --system --fork --print-pid > /var/run/dbus.pid || true
92+
sleep 2
9593
96-
# Debug: Check PulseAudio access
97-
echo "Checking PulseAudio connection..."
98-
export PULSE_SERVER=$${PULSE_SERVER}
99-
echo "PULSE_SERVER is: $${PULSE_SERVER}"
94+
# Start Avahi daemon for mDNS
95+
echo "Starting Avahi daemon..."
96+
avahi-daemon --daemonize --no-drop-root || true
97+
sleep 3
10098
101-
# Test if we can connect to pulse
102-
pactl info || echo "Warning: Could not connect to PulseAudio"
99+
echo ""
100+
echo "=== Audio setup debugging ==="
101+
echo "PULSE_SERVER: $${PULSE_SERVER}"
102+
echo "PULSE_RUNTIME_PATH: $${PULSE_RUNTIME_PATH}"
103+
ls -la /run/user/1000/pulse/ || echo "PulseAudio socket not found"
103104
104-
# Wait a moment for system to be ready
105-
sleep 5
105+
# Test PulseAudio connection
106+
which pactl && pactl info || echo "PulseAudio not accessible, will fall back to ALSA"
106107
107-
# Start shairport-sync directly with verbose output
108-
echo "Starting shairport-sync..."
109-
exec shairport-sync -c /etc/shairport-sync.conf -v
108+
echo ""
109+
echo "=== Starting shairport-sync ==="
110+
exec /usr/local/bin/shairport-sync -c /etc/shairport-sync.conf -v
110111
depends_on:
111112
- homespeaker.server2
112113

0 commit comments

Comments
 (0)