From c924387aacdfa82597d750f0e4e41afc6ae76038 Mon Sep 17 00:00:00 2001 From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Tue, 7 Feb 2023 14:51:14 +0000 Subject: [PATCH] Make sure that the AirPlay 1 hex prefix to the service name matches the AirPlay 2 device ID in AirPlay2 mode. In AirPlaty 1 mode, the prefix is a hash of the service name. --- shairport.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/shairport.c b/shairport.c index 4829c616..db54c8c6 100644 --- a/shairport.c +++ b/shairport.c @@ -1411,6 +1411,9 @@ int parse_options(int argc, char **argv) { int i; char hexchar[] = "0123456789abcdef"; for (i = 5; i >= 0; i--) { + // In AirPlay 2 mode, the AP1 name prefix must be + // the same as the AirPlay 2 device id less the colons. + config.ap1_prefix[i] = temporary_airplay_id & 0xFF; apids[i * 3 + 1] = hexchar[temporary_airplay_id & 0xF]; temporary_airplay_id = temporary_airplay_id >> 4; apids[i * 3] = hexchar[temporary_airplay_id & 0xF]; @@ -2513,7 +2516,11 @@ int main(int argc, char **argv) { soxr_time_check_thread_started = 1; #endif - // calculate the 12-hex-digit prefix by hashing the service name. + + // In AirPlay 2 mode, the AP1 prefix is the same as the device ID less the colons + // In AirPlay 1 mode, the AP1 prefix is calculated by hashing the service name. +#ifndef CONFIG_AIRPLAY_2 + uint8_t ap_md5[16]; // debug(1, "size of hw_addr is %u.", sizeof(config.hw_addr)); @@ -2550,6 +2557,7 @@ int main(int argc, char **argv) { #endif memcpy(config.ap1_prefix, ap_md5, sizeof(config.ap1_prefix)); +#endif #ifdef CONFIG_METADATA metadata_init(); // create the metadata pipe if necessary