Commit Graph
35 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 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 3aa34cd712 fix lots of errors calling debug() with incorrect argument patterns. 2025-12-30 14:59:27 +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 a9000de666 Try again to ensure an active_end metadata item is emitted if the player exits while playing. 2023-08-27 15:54:16 +01:00
Mike Brady 46a215b630 activity monitor should send an active_end on shutdown, provided it was in the active state. 2023-06-21 19:24:18 +01:00
Mike Brady e8b8c6edb7 Clang cleanup 2022-11-18 18:14:50 +00:00
Mike Brady fdc9531a3b Remove strange calls to the D-Bus system. 2022-10-05 12:39:57 +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 4d6082161e Fix a couple of race conditions in the activity monitor and allow the hooked procedures to run without the activity_monitor_lock mutex in the locked state. 2022-06-20 15:10:14 +01:00
Mike Brady a382ac6672 Clang Format 2022-03-14 11:56:43 +11:00
Mike Brady 6b6d5986d7 Handle keep_dac_busy correctly if disable_standby_mode is disable_standby_auto. 2022-03-10 17:43:12 +11:00
Mike Brady d8bad42b64 FIx a misspelled comment 2022-03-02 09:29:09 +11: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 c0a3dacf30 Working to check for divide / mod by 0's 2021-11-17 10:35:21 +00:00
Mike Brady d33de05ae9 change some debug messages 2021-06-04 09:40:24 +01:00
Mike Brady b3cec5c690 move over to clock_realtime from clock_monotonic. Seems to work. 2021-04-30 10:12:59 +01:00
minix1234andGitHub 70f60fcd8a Updated activity_monitor.c - metadata publishing wrong codes
Found that MQTT activity_start: abeg and activity_end: aend topics where never being published. instead immediately after a play session started a play_end: pend topic was sent.  Also after the activity_timout a duplicate play_end was received.

This commit fixes those bugs.
2020-06-12 09:03:30 -04:00
Mike Brady 67e9b1b6cd partial move to using a nanosecond-based system timer. More to come. 2020-02-24 19:40:44 +00:00
Chris Boot b9cf91b2bb More typo fixes across the tree
Previously I have made spelling changes as caught by Debian's lintian
tool, which has a short list of common misspellings that it tests for.
This time I decided to run codespell against the source and fix all the
obvious problems it came up with. It also uses a list of misspellings
but it's much larger than lintian's, but also has some false positives
so I went over the list by hand.

The command I used to do check the source was:
git ls-tree -rz --name-only HEAD | xargs -0 codespell -L minimise,errorstring
2019-07-27 00:05:38 -03: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 83c0405d03 Add automatic bit depth and speed selection for alsa devices. Set rate and format to "auto" by default. Always look for the greatest bit depth, but the lowest multiple of 44,100.
Improve support for big-endian CPUs by adding support for explicit -endian formats, i.e. S16_LE, S16_BE, S24_LE, S24_BE, S32_LE, S32_BE.

For the "disable_standby_mode" setting, change "while_active" to "auto".
2019-05-07 10:19:04 +01:00
Mike Brady 20967812ad Fix a bug in the activity_monitor software that could lock up a player thread so that it couln't be cancelled. If a player was cancelled while performing an activity script, the activity_monitor_mutex would remain locked. 2019-02-26 15:23:11 +00:00
Mike Brady 405a028f33 quieten some exiting debug messages 2019-02-16 19:44:25 +00:00
Mike Brady 5af6179875 use the term'state' rather than 'mode' when taling about the active state. Use 'while_active' rather than 'while active' 2019-02-12 15:47:10 +00:00
Mike Brady 54bb627eff Fix some errors and warnings from OpenBSD 2019-02-12 10:55:04 +00:00
Mike Brady 97a4766e93 Add call to check if the dbus service is started. 2019-02-08 22:31:50 +00:00
Mike Brady 58acd161cd make including of reference to dbus-service conditional on CONFIG_DBUS_INTERFACE 2019-02-08 20:48:29 +00:00
Mike Brady 34351a99cb Continue hooking up active mode and disable standby stuff 2019-02-08 16:57:39 +00:00
Mike Brady c86823c343 Starting to connect active mode with disable standby. 2019-02-08 09:04:33 +00:00
Mike Brady 79e22063ef check that the systems are started before trying to stop them, duh. 2019-02-05 15:51:16 +00:00
Mike Brady 2e4428538d Add an "active" mode that can time out after a period -- 10 seconds by default -- after play ends. 2019-01-21 21:43:55 +00:00
Mike Brady 604ca8dee4 Hook up active mode stuff to metadata, add two four-char codes, improve external command calling. 2019-01-21 21:18:40 +00:00
Mike Brady 2e181f937f add initial script-execution functionality to active mode. Make is possible to wait for start and stop scripts. 2019-01-21 18:20:39 +00:00
Mike Brady a8639f6c40 Add an activity monitor -- can set an activity idle timeout. 2019-01-20 22:15:02 +00:00