Enhancements

Enable the AirPlay 2 build to operate an optional classic-AirPlay-only service or to gracefully degrade to classic AirPlay, as follows:
  1. Add a new command-line option '-—service-type=<type>' and an equivalent configuration entry 'service_type = "<type>"' in the 'general' section of the configuration file,
     where <type> can be "auto", "classic" or "airplay2":
      1. "auto" (default) means that the service will be AirPlay 2 if NQPTP is running. If NQPTP is not running, classic AirPlay service will be provided instead, and in that case,
      "(Classic)" will be appended to the default AirPlay service name visible to AirPlay clients like Apple Music, for example "RaspberryPi3B (Classic)".
      2. "classic" means the service will be classic AirPlay (aka AirPlay 1).
      3. "airplay2" means the service will be the modern AirPlay 2. In this case, as distinct from "auto", if NQPTP is not running, Shairport Sync will log an error and terminate.
  2. In the systemd service file, NQPTP is now a "Want" rather than a "Require". If it's present, then it will be launched before Shairport Sync. If it's absent, Shairport Sync will launch anyway.
  3. Improve the delivery of input format changes and emit 'sdsc' metadata when changes occur.
  4. Emit new format information in the log if statistics is enabled.

Docker Changes
  1. Support for linux/arm/v6 has been dropped, as Docker is no longer supported.
  2. NQPTP is not started in the AirPlay 2 Docker image if '--service-type=classic' or '--service-type=airplay1' is in the command line options at the end of the docker run command.
     The purpose is to ensure that ports 319 and 320 are left alone when the AirPlay 2 image is set to provide Classic service only.
     Note that setting the configuration file 'service_type' to 'classic' will not prevent NQPTP from starting up -- you must use the command line option.
  3. A new "dev" target has been added. It is a large image containing the custom-built FFmpeg library, NQPTP, Avahi and D-Bus along with the Shairport Sync source and
     all necessary development tools. When started, Avahi, D-Bus and NQPTP are all installed and running. The bash shell has also been added and is entered.

Stability Improvements
  Reorganise session preemption to fully terminate the existing session before starting a new one.
  Don't delay closing the event port to wait for it to be closed at the client end.
  Add a safe_socket_close() function to ensure sockets are fully closed. Use -1 to designate closed rather than 0, to prevent attempts to reclose sockets, causing mayhem.
  Re-order FFmpeg decommissioning during teardown.
This commit is contained in:
Mike Brady
2026-05-18 09:57:12 +01:00
parent 0bd9271ea9
commit f30dd7aee6
69 changed files with 2897 additions and 2716 deletions
+16 -21
View File
@@ -25,15 +25,14 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "core.h"
#include "pc_queue.h"
#include <stdlib.h>
#include <inttypes.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#ifdef CONFIG_METADATA_PIPE
#include "pipe.h"
@@ -51,7 +50,6 @@
#include "mqtt.h"
#endif
// Metadata is not used by shairport-sync.
// Instead we send all metadata to a fifo pipe, so that other apps can listen to
// the pipe and use the metadata.
@@ -167,14 +165,14 @@ void metadata_init(void) {
#ifdef CONFIG_METADATA_PIPE
metadata_pipe_queue_init();
#endif
#endif
#ifdef CONFIG_METADATA_MULTICAST
metadata_multicast_queue_init();
metadata_multicast_queue_init();
#endif
#ifdef CONFIG_METADATA_HUB
metadata_hub_queue_init();
metadata_hub_queue_init();
#endif
#ifdef CONFIG_MQTT
@@ -195,14 +193,13 @@ void metadata_stop(void) {
metadata_hub_queue_stop();
#endif
#ifdef CONFIG_METADATA_MULTICAST
#ifdef CONFIG_METADATA_MULTICAST
metadata_multicast_queue_stop();
#endif
#ifdef CONFIG_METADATA_PIPE
#ifdef CONFIG_METADATA_PIPE
metadata_pipe_queue_stop();
#endif
}
}
@@ -259,17 +256,18 @@ int send_metadata_to_queue(pc_queue *queue, const uint32_t type, const uint32_t
if (pack.carrier) {
if (rc == EWOULDBLOCK)
debug(2,
"metadata queue \"%s\" full, dropping message item: type %x, code %x, data %" PRIxPTR ", "
"metadata queue \"%s\" full, dropping message item: type %x, code %x, data %" PRIxPTR
", "
"length %u, message %d.",
queue->name, pack.type, pack.code, (uintptr_t)pack.data, pack.length,
pack.carrier->index_number);
msg_free(&pack.carrier);
} else {
if (rc == EWOULDBLOCK)
debug(
2,
"metadata queue \"%s\" full, dropping data item: type %x, code %x, data %" PRIxPTR ", length %u.",
queue->name, pack.type, pack.code, (uintptr_t)pack.data, pack.length);
debug(2,
"metadata queue \"%s\" full, dropping data item: type %x, code %x, data %" PRIxPTR
", length %u.",
queue->name, pack.type, pack.code, (uintptr_t)pack.data, pack.length);
if (pack.data)
free(pack.data);
}
@@ -287,8 +285,7 @@ int send_metadata(const uint32_t type, const uint32_t code, const char *data, co
#endif
#ifdef CONFIG_METADATA_MULTICAST
rc =
send_metadata_to_multicast_queue(type, code, data, length, carrier, block);
rc = send_metadata_to_multicast_queue(type, code, data, length, carrier, block);
#endif
#ifdef CONFIG_METADATA_HUB
@@ -298,7 +295,6 @@ int send_metadata(const uint32_t type, const uint32_t code, const char *data, co
#ifdef CONFIG_MQTT
rc = send_metadata_to_mqtt_queue(type, code, data, length, carrier, block);
#endif
}
return rc;
}
@@ -307,4 +303,3 @@ int send_ssnc_metadata(const uint32_t code, const char *data, const uint32_t len
const int block) {
return send_metadata('ssnc', code, data, length, NULL, block);
}
+1 -2
View File
@@ -1,8 +1,8 @@
#pragma once
#include "../rtsp.h"
#include "common.h"
#include "config.h"
#include "../rtsp.h"
#include "pc_queue.h"
#include <pthread.h>
@@ -21,7 +21,6 @@ void metadata_pack_cleanup_function(void *arg);
void metadata_init(void);
void metadata_stop(void);
int send_metadata_to_queue(pc_queue *queue, const uint32_t type, const uint32_t code,
const char *data, const uint32_t length, rtsp_message *carrier,
int block);
+9 -10
View File
@@ -43,10 +43,10 @@
#include "config.h"
#include "common.h"
#include "core.h"
#include "dacp.h"
#include "hub.h"
#include "pc_queue.h"
#include "core.h"
#ifdef CONFIG_MBEDTLS
#include <mbedtls/md5.h>
@@ -759,15 +759,14 @@ void metadata_hub_queue_init() {
}
void metadata_hub_queue_stop() {
// debug(2, "metadata stop hub thread.");
pthread_cancel(metadata_hub_thread);
pthread_join(metadata_hub_thread, NULL);
pc_queue_delete(&metadata_hub_queue);
// debug(2, "metadata stop hub done.");
// debug(2, "metadata stop hub thread.");
pthread_cancel(metadata_hub_thread);
pthread_join(metadata_hub_thread, NULL);
pc_queue_delete(&metadata_hub_queue);
// debug(2, "metadata stop hub done.");
}
int send_metadata_to_hub_queue(const uint32_t type, const uint32_t code,
const char *data, const uint32_t length, rtsp_message *carrier,
int block) {
return send_metadata_to_queue(&metadata_hub_queue, type, code, data, length, carrier, block);
int send_metadata_to_hub_queue(const uint32_t type, const uint32_t code, const char *data,
const uint32_t length, rtsp_message *carrier, int block) {
return send_metadata_to_queue(&metadata_hub_queue, type, code, data, length, carrier, block);
}
+2 -4
View File
@@ -194,7 +194,5 @@ void _metadata_hub_read_epilog(const char *filename, const int linenumber);
// metadata queue stuff
void metadata_hub_queue_init();
void metadata_hub_queue_stop();
int send_metadata_to_hub_queue(const uint32_t type, const uint32_t code,
const char *data, const uint32_t length, rtsp_message *carrier,
int block);
int send_metadata_to_hub_queue(const uint32_t type, const uint32_t code, const char *data,
const uint32_t length, rtsp_message *carrier, int block);
+18 -19
View File
@@ -1,16 +1,15 @@
#include "multicast.h"
#include "core.h"
#include "pc_queue.h"
#include <stdlib.h>
#include <string.h>
#include "multicast.h"
#include "core.h"
#include "pc_queue.h"
#include <stdlib.h>
#include <string.h>
// A special sub-protocol is used for sending large data items over UDP
// If the payload exceeded 4 MB, it is chunked using the following format:
// "ssnc", "chnk", packet_ix, packet_counts, packet_tag, packet_type, chunked_data.
// Notice that the number of items is different to the standard
#define METADATA_SNDBUF (4 * 1024 * 1024)
static int metadata_sock = -1;
static struct sockaddr_in metadata_sockaddr;
@@ -20,10 +19,10 @@ pc_queue metadata_multicast_queue;
metadata_package metadata_multicast_queue_items[metadata_multicast_queue_size];
pthread_t metadata_multicast_thread;
int send_metadata_to_multicast_queue(const uint32_t type, const uint32_t code,
const char *data, const uint32_t length, rtsp_message *carrier,
int block) {
return send_metadata_to_queue(&metadata_multicast_queue, type, code, data, length, carrier, block);
int send_metadata_to_multicast_queue(const uint32_t type, const uint32_t code, const char *data,
const uint32_t length, rtsp_message *carrier, int block) {
return send_metadata_to_queue(&metadata_multicast_queue, type, code, data, length, carrier,
block);
}
void metadata_create_multicast_socket(void) {
@@ -162,12 +161,12 @@ void *metadata_multicast_thread_function(__attribute__((unused)) void *ignore) {
}
void metadata_multicast_queue_init() {
// create a pc_queue for the metadata_multicast_queue
pc_queue_init(&metadata_multicast_queue, (char *)&metadata_multicast_queue_items,
sizeof(metadata_package), metadata_multicast_queue_size, "multicast");
if (named_pthread_create(&metadata_multicast_thread, NULL, metadata_multicast_thread_function,
NULL, "metadata mcst") != 0)
debug(1, "Failed to create metadata multicast thread!");
// create a pc_queue for the metadata_multicast_queue
pc_queue_init(&metadata_multicast_queue, (char *)&metadata_multicast_queue_items,
sizeof(metadata_package), metadata_multicast_queue_size, "multicast");
if (named_pthread_create(&metadata_multicast_thread, NULL, metadata_multicast_thread_function,
NULL, "metadata mcst") != 0)
debug(1, "Failed to create metadata multicast thread!");
}
void metadata_multicast_queue_stop() {
+3 -4
View File
@@ -1,10 +1,9 @@
#pragma once
#include <inttypes.h>
#include "rtsp.h"
#include <inttypes.h>
void metadata_multicast_queue_init();
void metadata_multicast_queue_stop();
int send_metadata_to_multicast_queue(const uint32_t type, const uint32_t code,
const char *data, const uint32_t length, rtsp_message *carrier,
int block);
int send_metadata_to_multicast_queue(const uint32_t type, const uint32_t code, const char *data,
const uint32_t length, rtsp_message *carrier, int block);
+1 -2
View File
@@ -27,9 +27,9 @@
#include "pc_queue.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
void pc_queue_init(pc_queue *the_queue, char *items, size_t item_size, uint32_t number_of_items,
const char *name) {
@@ -169,4 +169,3 @@ int pc_queue_get_item(pc_queue *the_queue, void *the_stuff) {
}
return 0;
}
+14 -15
View File
@@ -1,14 +1,14 @@
#include "pipe.h"
#include "core.h"
#include "pc_queue.h"
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include "pipe.h"
#include "core.h"
#include "pc_queue.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
static int fd = -1; // the pipe file descriptor
pc_queue metadata_queue;
#define metadata_queue_size 500
metadata_package metadata_queue_items[metadata_queue_size];
@@ -152,8 +152,8 @@ void metadata_pipe_queue_init() {
if ((fd == -1) && (errno != ENXIO)) {
char errorstring[1024];
strerror_r(errno, (char *)errorstring, sizeof(errorstring));
debug(1, "metadata_init -- error %d (\"%s\") opening pipe: \"%s\".", errno,
(char *)errorstring, path);
debug(1, "metadata_init -- error %d (\"%s\") opening pipe: \"%s\".", errno, (char *)errorstring,
path);
warn("can not open metadata pipe -- error %d (\"%s\") opening pipe: \"%s\".", errno,
(char *)errorstring, path);
}
@@ -179,8 +179,7 @@ void metadata_pipe_queue_stop() {
}
}
int send_metadata_to_pipe_queue(const uint32_t type, const uint32_t code,
const char *data, const uint32_t length, rtsp_message *carrier,
int block) {
return send_metadata_to_queue(&metadata_queue, type, code, data, length, carrier, block);
int send_metadata_to_pipe_queue(const uint32_t type, const uint32_t code, const char *data,
const uint32_t length, rtsp_message *carrier, int block) {
return send_metadata_to_queue(&metadata_queue, type, code, data, length, carrier, block);
}
+3 -4
View File
@@ -1,10 +1,9 @@
#pragma once
#include <inttypes.h>
#include "rtsp.h"
#include <inttypes.h>
void metadata_pipe_queue_init();
void metadata_pipe_queue_stop();
int send_metadata_to_pipe_queue(const uint32_t type, const uint32_t code,
const char *data, const uint32_t length, rtsp_message *carrier,
int block);
int send_metadata_to_pipe_queue(const uint32_t type, const uint32_t code, const char *data,
const uint32_t length, rtsp_message *carrier, int block);