]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Allow the airplay_device_id to be varied either by adding an offset or by replacing...
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Fri, 24 Dec 2021 11:03:19 +0000 (11:03 +0000)
committerMike Brady <4265913+mikebrady@users.noreply.github.com>
Fri, 24 Dec 2021 11:03:19 +0000 (11:03 +0000)
scripts/shairport-sync.conf
shairport.c

index f377c22179c2d5d6cb0194c1028f95cdda13e766..f0176a3fd482b844196bacc351c690181df934f3 100644 (file)
@@ -14,15 +14,17 @@ general =
 //                             %v for the version number, e.g. 3.0 and
 //                             %V for the full version string, e.g. 3.3-OpenSSL-Avahi-ALSA-soxr-metadata-sysconfdir:/etc
 //             Overall length can not exceed 50 characters. Example: "Shairport Sync %v on %H".
-//     password = "secret"; // leave this commented out if you don't want to require a password
+//     password = "secret"; // (AirPlay 1 only) leave this commented out if you don't want to require a password
 //     interpolation = "auto"; // aka "stuffing". Default is "auto". Alternatives are "basic" or "soxr". Choose "soxr" only if you have a reasonably fast processor and Shairport Sync has been built with "soxr" support.
 //     output_backend = "alsa"; // Run "shairport-sync -h" to get a list of all output_backends, e.g. "alsa", "pipe", "stdout". The default is the first one.
 //     mdns_backend = "avahi"; // Run "shairport-sync -h" to get a list of all mdns_backends. The default is the first one.
 //     interface = "name"; // Use this advanced setting to specify the interface on which Shairport Sync should provide its service. Leave it commented out to get the default, which is to select the interface(s) automatically.
-//     port = 5000; // Listen for service requests on this port
-//     udp_port_base = 6001; // start allocating UDP ports from this port number when needed
-//     udp_port_range = 10; // look for free ports in this number of places, starting at the UDP port base. Allow at least 10, though only three are needed in a steady state.
-//     regtype = "_raop._tcp"; // Use this advanced setting to set the service type and transport to be advertised by Zeroconf/Bonjour. Default is "_raop._tcp".
+//     port = <number>; // Listen for service requests on this port. 5000 for AirPlay 1, 7000 for AirPlay 2
+//     udp_port_base = 6001; // (AirPlay 1 only) start allocating UDP ports from this port number when needed 
+//     udp_port_range = 10; // (AirPlay 1 only) look for free ports in this number of places, starting at the UDP port base. Allow at least 10, though only three are needed in a steady state.
+//     airplay_device_id_offset = 0; // (AirPlay 2 only) add this to the default airplay_device_id calculated from one of the device's MAC address
+//     airplay_device_id = <6-byte_hexadecimal_number>; // (AirPlay 2 only) use this as the airplay_device_id
+//     regtype = "<string>"; // Use this advanced setting to set the service type and transport to be advertised by Zeroconf/Bonjour. Default is "_raop._tcp" for AirPlay 1, "_airplay._tcp" for AirPlay 2.
 
 //     drift_tolerance_in_seconds = 0.002; // allow a timing error of this number of seconds of drift away from exact synchronisation before attempting to correct it
 //     resync_threshold_in_seconds = 0.050; // a synchronisation error greater than this number of seconds will cause resynchronisation; 0 disables it
index d866f46a5b893df898ea5e526c3a536bc397b75d..88db792477cdaaaeb22c682bda17841b0440dde8 100644 (file)
@@ -1830,10 +1830,22 @@ int main(int argc, char **argv) {
   // Set to NULL to work with transient pairing
   config.airplay_pin = NULL;
 
-  // use the start of the config.hw_addr and the PID to generate the airplay_device_id
+  // use the start of the config.hw_addr and the PID to generate the default airplay_device_id
   uint64_t apid = nctoh64(config.hw_addr);
   apid = apid >> 16; // we only use the first 6 bytes but have imported 8.
-  // apid = apid + pid;
+  
+  int64_t aid;
+  // add the airplay_device_id_offset if provided
+  if (config_lookup_int64(config.cfg, "general.airplay_device_id_offset", &aid)) {
+    apid += aid;
+  } 
+  
+  // replace the airplay_device_id with this, if provided
+  if (config_lookup_int64(config.cfg, "general.airplay_device_id", &aid)) {
+    apid = aid;
+  }
+  
   char apids[6*2+5+1]; // six pairs of digits, 5 colons and a NUL
   apids[6*2+5] = 0; // NUL termination
   int i;
@@ -1846,6 +1858,7 @@ int main(int argc, char **argv) {
     if (i != 0)
       apids[i*3-1] = ':';
   }
+  
   config.airplay_device_id = strdup(apids);
 
   // now generate a UUID