Commit Graph
178 Commits
Author SHA1 Message Date
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 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 7848e88b81 Set the type to '96' for Classic compatibility mode. Quieten some debug messages. 2025-12-11 15:34:12 +00:00
Mike Brady 3e57f8c706 Add a flag showing the event thread had exited. Modify the ab_mutex locking and unlocking. Add get_category_string(). 2025-12-03 15:54:01 +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 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 Brady bccf0775d3 remove watchdog stuff 2024-06-29 20:05:15 +01:00
Seo Suchan d73b585c6f mbedtls: add support to mbedtls3
Signed-off-by: Seo Suchan <tjtncks@gmail.com>
2024-05-09 21:51:38 +09:00
Mike Brady 847ad7fb9c move the declaration of principal_conn_lock from player.h to rtsp.h where it should be. 2023-09-21 15:49:25 +01:00
Mike Brady 986f9587de Rebuild the locking mechanisms for safe interruption of an existing play session. 2023-09-09 10:49:32 +01:00
Mike Brady 97dd0b1eac replace some deprecated OpenSSL calls 2023-06-10 16:25:03 +01:00
Mike Brady 8201903a4e Add code to try to save your ears by handling a situation where the player volume was set very high some time ago and you have forgotten.
In that situation currenctly, when you play something, it will come out at the last volume set on the device, which will be that very high volume.
This could happen, for example, the morning after a loud party :).

The new code works as follows: If nothing has been played for a period, say a few hours, and the volume is higher than a threshold, new connections that ask
for the current volume setting will be offered the default (low) volume rather than the current (very high) one.
Most players, including the HomePod mini, iOS and iPadOS use this to set their initial volume.
The Mac Music app retains its own setting, and the Mac System Sounds preference sometimes seems to take its setting from the Music app,
but at least you can see the settings they will apply.

Existing connections are unaffected, so this facility should be unobtrusive.
2023-01-18 10:41:50 +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
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 d36decbd36 Rename and reorder some of the pairing definitions and structures. 2022-06-25 14:15:56 +01:00
Mike Brady fb151915ae Tidy up write encrypted. Explore some of the remote_control connections. Not working. 2022-06-23 09:40:30 +01:00
Mike Brady f8b91e9b25 Fix brackets around plist.h 2022-05-23 10:29:15 +01:00
Mike Brady 4fa06bed6b Change playstart to a 64-but unsigned int. Store time of start of connection (for initial muting). Remove a redundant flag. 2022-05-14 18:58:05 +10:00
Mike Brady 9ae4dee5ae Simplify a comment. 2022-03-22 18:49:58 +11:00
Mike Brady 08afa822f5 Add buffer size to statistcs information for a Buffered Audio stream. 2022-03-13 12:33:53 +11:00
Mike Brady deb11654ab Add some sanity checking of latency-affecting settings. 2022-01-24 10:17:07 +01:00
Mike Brady 04aba03b4f Stop storing the timing peer list. Clean up generation of device's timing addresses (and fix a bug). Use unique SMI interface for access to NQPTP. 2021-12-30 11:03:34 +00:00
Mike Brady e3faba141c log statsistics headers whenever verbosity goes on or off or whenever statistics are requested 2021-11-28 21:51:26 +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 c0a3dacf30 Working to check for divide / mod by 0's 2021-11-17 10:35:21 +00:00
Mike Brady 04240708a9 Try using the monotonic clock for checking output rate... 2021-11-08 10:14:42 +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 4a82745561 Allocate, deallocate and NULL the rtp_event_thread memory space so that it is only deleted once! 2021-09-18 12:22:57 +01:00
Mike Brady 2e123cf39a Fix compilation errors that accumulated with no --with-airplay-2 flag set. 2021-09-09 11:24:23 +01:00
Mike Brady 7ff6d07c83 Don't need 'had_been_cancelled'. Remoted. 2021-09-06 11:02:59 +01:00
Mike Brady 1fc00e13e9 Seems to work better with iOS / HomePod mini speaker selection. Does not recover discarded rtsp stream memory! 2021-09-06 09:11:24 +01:00
Mike Brady ae1c4f1d29 redo handle_setup to identify ptp, ntp and remote control streams, returns 400 for remote control and unrecognised stuff. 2021-09-04 15:08:44 +01:00
Mike Brady fcd57227eb clang 2021-09-01 16:53:48 +01:00
Mike Brady e2153d275d Add new type of airplasy stream 2021-09-01 16:40:43 +01:00
Mike Brady d703314c06 Move group ID store to the conn. Fix the size of the groupContainsGroupLeader plist boolean store. 2021-09-01 10:28:30 +01:00
Mike Brady 5d4d75ad4e add a place to store the groupContainsGroupLeader from SETUP 2021-08-31 17:43:56 +01:00
Mike Brady 90740694ba When an unrecognised SETUP message is received, just say okay and ignore it. Remove reduncant client_setup_plist from the conn data structure. 2021-07-28 12:58:20 +01:00
Mike Brady c5dafbd28b Remember the original anchor information so that if the master clock become equal to it in the future, it can be restored to those exact numbers and eliminate any intervening approximations. Add some diagnostics. 2021-06-01 14:51:17 +01:00
Mike Brady 1464c4ed04 Restore ability to compile without AIRPLAY-2 flag (duh). Begin to split player_play into player_prepare and player_play. 2021-05-31 17:12:20 +01:00
Mike Brady ac515bbfa3 Deal with the possibility that the anchor information can be changed suddenly at the start of a Buffered Audio play. If the anchor info changes before the local_anchor info is mature enough (5 seconds), invalidate the local anchor info to force it to be immediately updated with the new anchor info. 2021-05-31 09:49:15 +01:00
Mike Brady a109b587ec Flush seems to be working properly and reliably. Some audio glitches removed too by dropping the first two AAC blocks of any passage. Crude. Flush diagnostic linked list stuff left in place. 2021-05-30 11:17:06 +01:00
Mike Brady 2ea28c0661 Much better flushing. Delayed flushing only works for one delay. Noice artifacts removed when skipping. Pretty solid. 2021-05-29 21:24:33 +01:00
Mike Brady e258cca33a recognise two types of flush -- one with from and until information, the other with just until information. A flush with "with" information is not followed by a new set anchor, whereas a flush without the " with" information is alwasy followed by a new setanchor. 2021-05-28 19:16:37 +01:00
Mike Brady f4ba81ec5f remove redundant item 2021-05-26 19:36:31 +01:00
Mike Brady 637c8132e9 Move initial delay when using a new bus master to rtp.c and wait, if possible, whenever a new master comes along, to allow it to settle before using it. 2021-05-26 18:12:45 +01:00
Mike Brady 26ce13d511 a slightly more rational clock handling regime, I hope. Wait for 400 ms when a clock becomes master. Wait five seconds when you get a new master clock. 2021-05-26 16:48:25 +01:00
Mike Brady c645a03946 handle volume control requests in AP2 correctly. Don't reset timing peer lists when buffered audio is paused. 2021-05-15 12:18:37 +01:00