Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add runtime configuration support for shairport / airplay #673

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
9 changes: 9 additions & 0 deletions docs/03-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,12 @@ The following variables control various aspects of each plugin behavior:
| SOUND_SPOTIFY_DISABLE_NORMALISATION | Disable volume normalization in Spotify. | Disabled if the variable exists regardless of its value. | --- |
| SOUND_SPOTIFY_ENABLE_CACHE | Enable the audio cache in Spotify. Note that over time the cache can take up large amounts of disk space. | Enabled if the variable exists regardless of its value. | --- |
| SOUND_SPOTIFY_BITRATE | Spotify playback bitrate. | Bitrate in kbps: `96`, `160` or `320` | 160 |

## AirPlay

AirPlay is based on [Shairport Sync](https://github.com/mikebrady/shairport-sync).
It supports various options that override [options provided by Shairport](https://github.com/mikebrady/shairport-sync/blob/master/scripts/shairport-sync.conf)

| Variable | Description | Options | Defaults |
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | -------- |
| SOUND_AIRPLAY_LATENCY_OFFSET | This is added to the latency requested by the player to delay or advance the output by a fixed amount. Latency adjustments should be small, not more than about ± 250 milliseconds. | Time in seconds. Example: `0.250`. Negative values are supported | 0 |
12 changes: 12 additions & 0 deletions plugins/airplay/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ SOUND_DEVICE_NAME=${SOUND_DEVICE_NAME:-"balenaSound AirPlay $(echo "$BALENA_DEVI
echo "Starting AirPlay plugin..."
echo "Device name: $SOUND_DEVICE_NAME"

# Check if LATENCY_OFFSET is set
if [[ -n "$SOUND_AIRPLAY_LATENCY_OFFSET" ]]; then
# File to modify
file="/etc/shairport-sync.conf"

# Use sed to replace the value in the specified line
sed -i "s|//[[:space:]]*audio_backend_latency_offset_in_seconds[[:space:]]*=.*;| audio_backend_latency_offset_in_seconds = $SOUND_AIRPLAY_LATENCY_OFFSET;|" "$file"

echo "Updated audio_backend_latency_offset_in_seconds to $SOUND_AIRPLAY_LATENCY_OFFSET in $file"
fi


# Start AirPlay
echo "Starting Shairport Sync"
exec shairport-sync \
Expand Down
Loading