Commit Graph
131 Commits
Author SHA1 Message Date
Mike Brady 83ae1d286b Add a new exit handler to enable Shairport Sync to exit cleanly — that is, on exit, to clean up everything, e.g. open files, ports, sockets, devices, threads, it has been using.
If cleanup isn’t finished after one second, exit will occur unconditionally.
Use the new exit handler for normal exit, for SIGINT and SIGTERM handling, for abnormal exit after fatal errors, and for handling quit requests from the D-Bus and MPRIS interfaces.

When an unfixable error occurs without an installed unfixable error handler, unlock the mutex protecting Shairport Sync’s alsa backend to permit a clean exit.

Fix a very low-level mutex-locking error that interfered with debugging.

Simplify much mutex lock handling.
Remove lots of old and unused code, variables and definitions.

Update audio_sndio.c to remove some harmless compiler warnings.

Undo adding two seconds for messages to be output before _Exit() on die() to allow messages to be output...
Undo making die() exit unconditionally.
2026-07-16 14:51:06 +01:00
Mike Brady f30dd7aee6 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.
2026-05-18 09:57:12 +01:00
Mike Brady 11052b7896 Lot of changes here.
1. check_classic_mac_basic.yml — update to latest macOS-latest
2. docker-on-push-tag-or-pr — dependant updates
3. FFTConvolver — fix a compilation warning when the DEBUG flag is turned off
4. Reorganise some source files — e.g. move most of the metadata stuff into a subdirectory
5. Remove unused special-purpose AirPlay 2 RC event handler.
6. Reorganise source files and source code relating to the standard event handler.
7. Check configuration settings a little more carefully to offer more meaningful diagnostics.
8. Add password to AirPlay 2 and reorganise initialisation to set AirPlay 2 flags accordingly.  Also, remove redundant airplay_pin.
9. Remove redundant debug facility definitions from common.h
10. Make it possible to omit all the dacp stuff from a build.
11. Make it possible to omit metadata multicast from a build.
12. Add AP2-native metadata by setting bit 50 of features to true.
13. Improve stability when pre-empting an existing play session.
14. Fix a few compiler warnings in the pair_ap library.
15. Ensure that the audio format is known before starting synchronisation.
16. Improve handle_configure to set/clear a new config setting. Doesn’t seem to do anything…
17. Experimentally turn off bit 46 of AirPlay 2 features — seems to stop failing pair-verify attempts.
2026-04-26 10:23:18 +01:00
Mike Brady daa985e4e4 Turn off many currently-irrelevant debug messages by setting their level to 4, meaning they will never be displayed. 2026-03-01 13:43:11 +00:00
Mike Brady d32d5cb9d5 Fix warning of dropping 'const' signifier. 2026-02-15 08:13:44 +00:00
Mike Brady 16b6534ad3 further changes to remove compilation warnings on 32-bit builds 2025-12-31 19:02:16 +00:00
Mike Brady 691d71f356 More fixes due to tightening the checks on debug/die/inform/warn varadic arguments. 2025-12-30 16:56:30 +00:00
Mike Brady e12a3ed7b2 Do a long-overdue rebuild of the buffered audio processor and, with everything we have figured out, implement a cleaner method to handle both immediate and deferred flush requests. Remove lots of old flags and redundant code. Leave in a few debug messages. 2025-11-16 16:58:34 +00:00
Mike Brady 60143518c2 This squashed commit comprises a long series of improvements, bug fixes, optimizations, and new feature additions:
- 48,000 frames per second operation,
 - 48k lossless stereo, 5.1 and 7.1 surround sound
 - Multichannel and multi rate operation on ALSA, PipeWire, PulseAudio, FreeBSD, stdout and unix pipe output backends.

Automatic, flexible and controllable output format (rate, sample format and channel count) selection.

Full FFmpeg integration to support transcoding, resampling, and new audio formats.

Better operation on lower powered devices down to e.g. Raspberry Pi B.

Reduced Docker image sizes with a slimmed-down FFmpeg library.

Enhanced timestamp handling for better synchronization.

Improved the sync error calculation.

A new "vernier" resampling and interpolation method for low-power CPUs.

Bug fixes and minor enhancements.

Note -- there are many breaking changes from previous versions of Shairport Sync!
2025-02-23 13:31:17 +00:00
Mike Brady b7d9c22de9 format adjustments 2023-09-11 16:01:38 +01:00
Mike Brady 6acd73da57 Make the change to short DACP polling (semi-)permanent. Maye look at this again in the future. 2023-07-04 19:28:05 +01:00
Mike Brady b29e92b8cd Always use revision number 1 when looking for status updates on the DACP remote control port. This is ia hacky change to try out a (good) suggestion in Issue #1658. 2023-06-22 09:53:09 +01:00
Mike Brady e8b8c6edb7 Clang cleanup 2022-11-18 18:14:50 +00:00
Mike Brady 03d291f464 Second attempt. Modify the generation of the 12-digit classic AirPlay service name prefix so that it depends on the service name as well as the hardware address. 2022-11-17 10:31:51 +00:00
Mike Brady d67909b837 Add new metadata item: sps:songdatakind, derived from the asdk metadata token. It seems to indicate a timed item (0) or an untimed stream (1). Add output format, output frame rate, stream type (Realtime/Buffered/Classic) properties. Update MQTT appropriately. 2022-11-12 16:42:25 +00:00
Mike Brady fd880056fb Squashed commit of the following:
Add three parameters to the backend play() function call -- (1) a flag indicating whether the samples are timed or not. If timed, (2) the timestamp and (3) the local time at which the first frame should be heard.
    Update missing pipewire library message.
    Makefile.am fix.
    Update the SHM version and fix the SHM name so that it works with FreeBSD.
    Remove redundant (?) AC_HEADER_STDC check.
    Fix compilation and installation under FreeBSD -- changes to allow building in a separate directory broke the FreeBSD build process.
    Add AC_CHECK_LIB for gcrypt in case PKG_CHECK_MODULES fails to find it.
    Find gcrypt using pkg-config
    Add code to detect when the RTSP channel goes idle for a period, and use it to reset clocks and timings, etc. so that SPS resumes correctly where the source has gone to sleep while playing a realtime stream and has subsequently woken up.
    Don't exit if a UDP Clock Control packet is empty. Also check minimum packet size.
    Remove some very experimental code which may cause memory and port leaks.
    Strip file path from the filename used in debug messages, information messages, warnings and fatal error messages.
    BB fix to Makefile.am -- overwriting the DBUS stuff with MPRIS definitions, duh.
    Fix some problems building on FreeBSD and tidy up the use of the "sed" editor.
    Fix some problems building on picore.
    Fix an uninitialised variable
    start using the "nqptp" SMI
2022-09-12 15:19:52 +01:00
Mike Brady ea4eafbfed Remove a redundant subexpression that was always true. 2022-06-09 07:57:26 -07:00
Mike Brady 2dc6af2daf Partially clean up some mutex diagnostic stuff. 2022-05-18 19:37:18 +01:00
Mike Brady dbebdca84d quieten a debug message 2021-12-07 15:08:16 +00:00
Mike Brady 56bef8e7dd Use CLOCK_MONOLITHIC_RAW to avoid NTP effects, report raw and corrected timing from audio_alsa. Clean up statistics. Stop watchdog timing out AP2 sessions. CLean up some debug messages. 2021-11-28 16:08:48 +00:00
Mike Brady 14bfba2724 Add code to check divisions and mods for a potrntial divide by zero problem. MAy cause SPS to terminate but leave a log message. 2021-11-21 21:47:32 +00:00
Mike Brady e925e196c8 Changes to allow it to compile in FreeBSD and fix a few issues that were picked up by clang 10. 2021-06-22 13:49:11 +01:00
Mike Brady 91b85a0207 Working for Realtime Audio Streams 2021-04-30 14:55:11 +01:00
Mike Brady b3cec5c690 move over to clock_realtime from clock_monotonic. Seems to work. 2021-04-30 10:12:59 +01:00
Mike Brady 18c9e13a02 Clean up with clang-format 2021-01-24 21:32:57 +00:00
Mike Brady c27fb1c9b5 Fix a crash that occurred if metadata support is enabled during compilation but turned off in the configuration file.
Fix a crash that occurred playing from AirPower on Android.
2020-12-23 16:11:12 +00:00
Mike Brady 3fc9570489 Clang Format 2020-09-27 10:45:22 +01:00
Mike Brady 6857d06bd6 Handle active_remote_id as a string rather than an unsigned 32-bit number. It seems ROON uses a longer character sequence. Tidy up some error messages aboout which backend is selected. 2020-09-27 10:44:12 +01:00
Mike Brady c5b47427f2 Tighten up memory allocatons in DACP.c but shorten the wait time for a response. 2020-09-20 16:51:07 +01:00
Mike Brady d3365f8bdc Quieten a debug message 2020-07-13 11:52:52 +01:00
Mike Brady 77a5cf1e80 Ensure metadata and cover art are enabled if metadata support is included at compilation. Reword some misleading error messages, set convolution defaults even if no configuration file is found. 2020-07-13 10:47:10 +01:00
Mike Brady 4fad3d24b1 remove the cause of a FreeBSD warning 2020-06-22 12:01:26 +01:00
Mike Brady 4e1f74db87 Quieten some debug messages. 2020-06-21 13:16:08 +01:00
Mike Brady 54d761ff7d Clean up some of the wording and layout of the configuration file
Clean up and improve the way lead-in sillence is used to give a more accurate sync time to the first packet of audio.
Allow very good sync to occur with 0.3 seconds of lead-in silence.
Improve the use of the buffer offset.
Format some other files.
2020-05-18 16:55:09 +01:00
Mike Brady 72d7153529 Fix calculation of latency -- honour the signs of the offset and account for the DAC buffer size. 2020-05-14 19:51:32 +01:00
Mike Brady a6acb6062a If the DACP port is zero, do a zeroconf re-broswe every two seconds in case it has been missed. 2020-03-25 10:16:21 +00:00
Mike Brady 67e9b1b6cd partial move to using a nanosecond-based system timer. More to come. 2020-02-24 19:40:44 +00:00
Mike Brady 27e42a666a Store the UserAgent so as to recognise forked-daapd so as to always send a revision_number of 1 when asking for playerstatus of forked-daapd. 2020-01-10 17:20:25 +00:00
Mike Brady 85b17cdaef Remove timeout on reception of DACP responses to allow for long poll behaviour of some players, e.g. Forked Daapd. Add some examples to the dbus client. 2020-01-10 08:31:13 +00:00
Mike Brady fe8198a23b Add SetAirplayVolume to the D-Bus RemoteControl interface.
Add SetVolume to the MPRIS interface.
Hook up the Volume property in the MPRIS interface.
Modify RemoteCommand in the D-Bus interface to return the HTTP status and response.
Change the type of airplay_volume from int to double in the metadata hub.
Add a few sample commands in the D-Bus document.
2019-12-20 17:17:21 +00:00
Mike Brady d734b7e71d add volume-up and volume-down to the dbus test client. Quieten a debug message. 2019-09-08 17:43:07 +01:00
Mike Brady 2b980ff2a8 make dbus interface set more quickly an AdvancedRemoteControlAvailable to false when going from an iTunes to an AirPlay service. 2019-09-08 17:26:06 +01:00
Mike Brady daab7a634c Clean up the scanning code for detecting either a standard DACP server or an advanced DACP server. 2019-09-04 20:24:34 +01:00
Mike Brady 86b6d7bfff Squashed commit of the following:
Fix Issue #890 -- https://github.com/mikebrady/shairport-sync/issues/890
    Recognise situation where a track has no artwork properly.
    Less likely to drop the 'availabile' property.
    Always output the full metadata whenever any part of it has changed.
    Metadata coming from dacp is now incorporated,
2019-08-29 11:47:49 +01:00
Mike Brady c8b0be30b4 find . \( -name \*.cpp -or -name \*.h -or -name \*.c \) -exec clang-format -i -style='{BasedOnStyle: llvm, IndentWidth: 2, ColumnLimit: 100}' '{}' \; 2019-06-19 19:06:54 +01:00
Mike Brady 413df6d063 Correct a compilation error in Alpine Linux 2019-06-07 17:48:45 +01:00
Mike Brady d9168f4aa7 remove a strncpy truncation warning
update a timing setting in the settings file
list the alsa hardware devices in the -h message
2019-05-17 10:43:54 +01:00
Mike Brady 57bcea52c7 Tidy up the exit() arguments. 2019-04-10 21:32:08 +01:00
Mike Brady cc0ff56ab7 Create the dbus/system.d directory if it doesn't already exist. 2019-03-18 19:37:09 +00:00
Mike Brady 405a028f33 quieten some exiting debug messages 2019-02-16 19:44:25 +00:00