Commit Graph
229 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 37fff1ac39 Add Jack deprecation note to the configuration file. [skip ci] 2026-06-22 18:52:42 +01:00
Mike Brady 1008f918c9 Add note about new --with-metadata-pipe and --with-metadata-multicast configuration flags. 2026-06-22 18:48:02 +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
lululombard bd9008e4f7 Add MQTT retain flag support 2026-02-08 12:43:53 +01:00
Hugo VilleneuveandHugo Villeneuve 6a94eeb926 Use common service file for avahi
Use variable substitution to simplify service file for optional avahi.

This will also help to simplify adding future service dependencies.

Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
2026-01-26 10:24:22 -05:00
Mike Brady 07b60e7112 1. Add the ability to work back through queued buffers to find the first buffer that’s older than the given one. This is to enable the replacement of deciphered buffers with buffers that arrive later but are timed earlier.
Added functions that relate to this are: get_revised_seqno() to wind back through the queued buffers and clear_buffers_from() to free buffers that are already occupied.
2. Clean up get_audio_buffer_size_and_occupancy() and replace it with get_audio_buffer_occupancy().
3. Add a new general setting: audio_decoded_buffer_desired_length_in_seconds for managing the size of the player buffer queue when the source is buffered audio. Default is 0.75 seconds so that we can step back up to that time if older buffers appear.
2025-12-14 10:17:38 +00:00
Mike Brady d043f98330 Update the convolution code:
(1) to be multithreaded,
    (2) to work on multichannel audio and
    (3) to work on 48k and 44.1k audio.

    Allow multiple impulse response (IR) files with a new setting: "convolution_ir_files"
    When convolution starts, Shairport Sync will look for an IR file with a sample rate
    matching the input (44.1k or 48k) and channel count.
    If one can't be found, it will look for a single-channel IR file with the same rate.
    It will always choose the first match in the file list supplied "convolution_ir_files".

    Allow multithreading -- use the "convolution_thread_pool_size" to set the number of threads to use.

    Deprecate "convolution" -- use "convolution_enabled" instead.
    Deprecate "convolution_max_length" -- use "convolution_max_length_in_seconds" instead.
    Deprecate "convolution_ir_file" -- use "convolution_ir_files" instead.
    Update corresponding D-Bus methods and properties.

Update the loudness code to work on 48k and well as 44.1k audio and with multichannel audio.

    Deprecate "loudness" -- use "loudness_enabled" instead.
    Update corresponding D-Bus methods and properties.

Fix a deprecated FFmpeg warning.

Update HiFi-LoFi FFT convolver to latest available.
2025-10-13 13:26:20 +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 BradyandGitHub 39781ece71 Update shairport-sync.conf
Fix a typo. Thanks to OptimoSupreme (https://github.com/OptimoSupreme) for finding it.
2025-01-03 15:08:47 +00:00
aaronk6 cda315b6aa Add support for MQTT autodiscovery 2024-09-24 20:32:08 +02:00
Mike Brady 597aba0ca6 Use an explicit 'is_running' flag in the sndio back end. Correct/improve some sndio documentation. 2024-07-22 10:28:30 +01:00
Mike Brady 0099831cb7 Revert the session timeout from one munite back to two minutes (120 seconds) 2024-06-30 09:53:41 +01:00
Mike Brady 6be34b7f2b set the session timeout to one minute by default. 2024-06-29 20:01:39 +01:00
Mike Brady 7aaaf0c96d Move the PipeWire stanza up in the configuration file. 2023-10-06 11:13:30 +01:00
Mike Brady 98679bbb54 Add PipeWire sink target setting. Fix PipeWire node name code, duh, remove code that was double-deallocating settings strings. 2023-10-06 10:51:49 +01:00
Mike Brady 288e5eb695 Change node_name default to "Shairport Sync", parameterise a few settings. 2023-10-05 16:40:42 +01:00
Mike Brady 3763b321b8 Add two PipeWire backend ("pw") settings -- application_name (default: "Shairport Sync") and node_name (default: "shairport-sync"). 2023-10-05 09:41:21 +01:00
Mike Brady 8821ec2861 Update some slightly outdated comments in common.h and shairport-sync.conf 2023-07-23 13:18:52 +02:00
dasl- ebe1ca17f2 rename to dasl_tapered 2023-07-13 21:43:25 -04:00
dasl- baf51cf2a7 Add logarithmic volume_control_profile mode 2023-07-02 09:27:53 -04:00
Mike BradyandGitHub 8c607e2d61 Update shairport-sync.conf
default volume typo in configuration file
2023-01-19 17:46:30 +00:00
Mike Brady 72f1554cbb Continuing to check the high-volume limiter. Add configuration file settings for default and threshold volume settings and timeout. Include in diagnostics, set tentative defaults. 2023-01-19 12:44:26 +00:00
Mike Brady 28f54af281 Add a new setting: resync_recovery_time to give the systems a little time to restart.
Clean up the tolerance and resync threshold times.
2023-01-14 12:48:18 +00:00
Mike Brady 5bc072eb9f small layout edit to shairport-sync.conf 2022-12-30 19:21:16 +00:00
Mike Brady 5bf379f780 Add detail about the new 'progress_interval' metadata setting. 2022-11-30 16:23:26 +00:00
Mike Brady 0dc34a4617 Get rid of the -u option -- too confusing -- and instead add a --log-to-syslog option for use when starting as a daemon. Modify the startup scripts accordingly. 2022-05-25 15:56:17 +01:00
Mike Brady b246c88fd9 Stop using libdaemon and use FreeBSD's daemon utility to deamonise and control shairport sync. 2022-05-20 12:30:08 +01:00
Mike Brady 38bbad6f63 Remove the requirement for Avahi in the systemd startup file unless Avahi is included in the build. 2022-04-05 07:22:34 +01:00
Mike Brady fbe0565a68 Remove the illegal "Provides" entry. 2022-03-11 09:38:59 +11:00
Mike Brady afc82b1800 Declare the service provided. 2022-02-28 18:04:55 +11:00
Mike Brady 0aea810735 experiment with different startup regimes 2022-02-28 10:59:41 +11:00
Mike Brady 3d720d65bf MQTT -- add code to deal with empty payloads by adding a dummy payload to empty messages by default. 2022-02-07 12:36:08 +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 5617f40edd Update the documentation a little. 2021-12-24 11:22:27 +00:00
Mike Brady 1997f16fba Allow the airplay_device_id to be varied either by adding an offset or by replacing it completely. 2021-12-24 11:03:19 +00:00
Mike Brady 953ad8ac14 Move AP2 player termination code from handle_teardown into the player cleanup function so that cancelling the player thread cleans up properly. 2021-05-08 17:46:13 +01:00
Mike Brady 8de7f34611 fix typo 2021-03-27 14:20:22 +00:00
Mike BradyandGitHub 91adfedfd2 Update shairport-sync.conf 2021-03-07 11:18:56 +00:00
Mike BradyandGitHub c5a3b438ff Update shairport-sync.conf 2021-03-07 11:17:06 +00:00
Mike Brady 485e18db17 Add a default name for the pipe backend: /tmp/shairport-sync-audio 2020-09-11 17:31:55 +01:00
Mike Brady f266e4c08b Allow Shairport Sync native D-Bus and MPRIS services to be owned by root as well as user "shairport-sync" 2020-06-21 09:57:05 +01:00
Mike Brady c0e5d0473e Add the ability to direct logs etc. to a file or pipe. 2020-05-28 12:19:59 +01:00
Mike Brady 6406c296f5 Add setting to direct logs to syslog, STDERR or STDOUT 2020-05-27 16:21:35 +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 012dd26c77 Add the ability to set the silent lead-in parameters initial_period, minimum number of adjustments and adjustment interval, and give them sensible defaults. 2020-05-17 12:48:25 +01:00
Mike Brady 18749bc315 Add brief message about finding ALSA devices. 2020-05-16 12:49:00 +01:00
Mike Brady a4edc649f8 Add code to do calculations involving the audio_backend_latency_offset_in_seconds and audio_backend_silent_lead_in_time settings correctly. Clean up the audio_backend_silent_lead_in_time setting by adding an "auto" setting. 2020-05-16 12:23:08 +01:00
Guillaume Revaillot aacc4e802b Allow to specify pulseaudio server instead of using default one.
Add "server" entry to pa config section, allowing to connect to a remote or a local system
pulseaudio instance instead of letting pulseaudio choose.
2020-03-27 09:39:11 +01:00