diff --git a/docs/03-customization.md b/docs/03-customization.md index c7235ef1..12c7ed64 100644 --- a/docs/03-customization.md +++ b/docs/03-customization.md @@ -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 | diff --git a/plugins/airplay/start.sh b/plugins/airplay/start.sh index 9d586385..9f389c90 100644 --- a/plugins/airplay/start.sh +++ b/plugins/airplay/start.sh @@ -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 \