Commit Graph
363 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 2ba3b1163a Make die() exit unconditionally. Clean up some more redundant code. Revert unfixable error to use die() rather than warn() and _Exit(). 2026-07-12 17:07:11 +01:00
Mike Brady 8b76d1c559 Exit immediately when an unfixable error is detected. Don't try to clean up before exit. 2026-07-12 16:18:31 +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 fb7de841b7 Silence some currently-irrelevant debug messages. 2026-03-02 19:00:31 +00: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 16b6534ad3 further changes to remove compilation warnings on 32-bit builds 2025-12-31 19:02:16 +00:00
Mike Brady 3aa34cd712 fix lots of errors calling debug() with incorrect argument patterns. 2025-12-30 14:59:27 +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 e05448aecc Check for configuration strings that are given but turn out to be empty, issue a warning and ignore them. 2025-04-14 10:40:26 +01: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 5f64722a70 Merge branch 'development' of github.com:mikebrady/shairport-sync into development
forgot online update
2024-06-03 09:37:11 +01:00
Mike Brady eaf923614a Give access to mixers in a HDMI device by attaching the mixer to the device's name but replacing the header hdmi: with hw: 2024-06-03 09:36:37 +01:00
Mike Brady 238e4bbfa3 Modify the alsa help to use the hdmi: prefix for the HDMI devices it finds. 2024-06-01 22:08:41 +01:00
Mike Brady c0f5112b8d Remove some almost-never-used and therefore untested code, and remove a potentially misleading comment from the ALSA backend. 2024-04-24 10:31:10 +01:00
Mike Brady b7d9c22de9 format adjustments 2023-09-11 16:01:38 +01:00
Mike Brady b5bb2fef38 Capture where the device was never there (ENOENT), as opposed to when it was there but disappeared (ENODEV). 2022-12-31 17:57:25 +00:00
Mike Brady 76387f8291 Be more careful checking for ENODEV conditions in audio_alsa.c. Still a few places where it is not done... 2022-12-31 17:16:02 +00:00
Mike Brady ae5910e2e7 make the error message one single identifier by linking the error number to the message with an underscore. 2022-12-30 19:31:01 +00:00
Mike Brady d6536a8e79 Call the unfixable error if the output device can't be opened or disappears. Clang-format. 2022-12-30 18:36:33 +00:00
= 0b03f23795 Fix a bug in audio_alsa.c when there is no hardware device name. 2022-11-19 09:05:26 +00:00
Mike Brady 2bc62c7dd9 Close the DAC when the keep_dac_busy flag is changed (by the activity monitor) from true to false. Wait a little longer for the DAC to drop all frames. 2022-09-30 10:18:51 +01: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 30510e72f1 Remove a very noisy and redundant debug message. 2022-08-16 09:25:53 +01:00
Mike Brady 449e024c95 If the default device is inaccessible with EHOSTDOWN, try hw:0 instead. Works for Fedora 36 Workstation. Might need to make it a bit smarter. 2022-07-22 15:52:16 +01:00
Mike Brady 129343c165 Don't quit if the ALSA output device is or becomes busy and resume when it becomes available again. 2022-07-20 18:04:42 +01:00
Mike Brady 850fda1055 Fix a typo. 2022-05-19 18:07:32 +01:00
Mike Brady 00bc837bef quieten some debug messages. 2022-05-17 17:50:46 +01:00
Mike Brady 3b4a21f002 Quieten some debug messages. Remove some redundant code. 2022-05-17 15:49:01 +01:00
Mike Brady a295c2a291 Improve the logic for supressing clicks when the alsa disable_standby_mode is active. 2022-04-03 10:35:48 +01:00
Mike Brady 8490c4c1c1 Always record frames successfully sent to DAC even if they are less than requested. 2022-03-16 10:19:15 +11:00
Mike Brady a382ac6672 Clang Format 2022-03-14 11:56:43 +11:00
Mike Brady 3d96f79ddc Quieten a few debug messages. 2022-03-11 17:03:49 +11:00
Mike Brady 0b4b4a73fc make close() a separate function and make flush do a close if we don't have to keep the dac active. 2022-03-10 17:41:53 +11:00
Mike Brady 713492a709 Check to see if the alsa_handle is NULL in standard_delay_and_status. Don't see how it could happen though. 2022-03-07 16:23:59 +11:00
Mike Brady 8476e5efac Check to see if the alsa_handle is NULL in precision_delay_and_status. Don't see how it could happen though. 2022-03-07 13:32:16 +11:00
Mike Brady 9bac04e2d7 Check for NULL pointers before deferencing delay and state variable pointers in audio_alsa.c's delay and delay_and_status functions. 2022-03-04 10:02:40 +11:00
Mike Brady 70ef99e924 Add a special-purpose flush routine called sub_flush. It doesn't close the device ever. 2022-02-26 08:33:19 +00:00
Mike Brady 6ced6bc67d Add a "mixer_control_index" setting to the "alsa" part of ther configuration file. A mixer is fully identified by a name and index, duh. Change some debug messages and add an entry to the sample configuration file. 2022-01-21 18:18:13 +01: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 dc5b8f1a11 Clang format 2021-11-26 18:02:23 +00:00
Mike Brady 136071a621 change stats to report non-zero if output has just opened or if there has been any discontinuity in play from previous time. 2021-11-26 15:17:27 +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 cd9da86fc3 Add a 'stats' function to the audio back ends to replace the 'rate_info' function. Zero all except the alsa back end. 2021-11-20 13:59:16 +00:00
Mike Brady 5f8e6e3989 attempt to increase the precision of the FPS timing 2021-11-20 12:14:23 +00:00
Mike Brady c0a3dacf30 Working to check for divide / mod by 0's 2021-11-17 10:35:21 +00:00
Mike Brady 99c6638573 Ensure the frame rate calculator allows for silent frames added to disable standby. Clean up outmoded and unused stuff in audio_alsa.c. More to do. 2021-11-06 18:32:26 +00:00
Mike Brady 366eb27afc Stop a message from repeating endlessly. 2021-09-09 11:23:25 +01:00
Mike Brady f058d118c1 Quieten a really noise message on verbosity 3. 2021-09-03 15:38:28 +01:00