Commit Graph
592 Commits
Author SHA1 Message Date
Mike Brady 16b6534ad3 further changes to remove compilation warnings on 32-bit builds 2025-12-31 19:02:16 +00:00
Mike Brady 3d148f026a Move to -Wformat=2 checking in Linux 2025-12-30 18:52:01 +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 3aa34cd712 fix lots of errors calling debug() with incorrect argument patterns. 2025-12-30 14:59:27 +00:00
Mike Brady 60278863ce Add some checks on cancelled deferred flushes and over-running immediate flushes. Quieten some other messages. 2025-12-15 12:50:10 +00:00
Mike Brady fb5b434f55 Quieten some debug messages. 2025-12-14 15:27:12 +00: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 ee56f778fd Remove redundant (?) calls to 'prepare_decoding_chain()'. 2025-12-11 16:44:16 +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 bc384466e0 Set the AirPlay type to ap_1 and the timing type to ts_ntp when you get an ANNOUNCE to signify a Classic AirPlay session has been started. 2025-12-11 11:03:18 +00:00
Mike Brady 489bfd7862 Add a check for EINTR to accept() calls. 2025-12-09 17:13:18 +00:00
Mike Brady e9f60c89d2 Cleaned up the get_play_lock and release_play_lock stuff and placed them in the right (?) places for AP2, AP1 compatibiity and Classic AP. Fixed the setting of flags and GID in Bonjour. 2025-12-09 12:10:05 +00:00
Mike Brady f2de7fadef Start using get_play_lock and release_play_lock and enable them to turn on and off the appropriate bonjour flags. 2025-12-08 09:50:54 +00:00
Mike Brady 5969896612 release principal conn when terminating a listener loop, set the airplay_stream_type for a classic airplay session. 2025-12-06 15:05:58 +00:00
Mike Brady 21e7d628ef Make cancel_all_RTSP_threads be specific about what kind of listeners it will kill, if needed. Quieten a few more messages. 2025-12-05 13:29:35 +00:00
Mike Brady a755a26e92 Move clock setup and start from Setup Phase 1 to Setup Phase 2. clear_all_conns now clears every type of connection, not just airplay. Clean up, rename and remove some old stuff and quieten yet more debug messages. 2025-12-05 12:10:15 +00:00
Mike Brady b82ae79852 Quieten a few more debug messages 2025-12-05 10:05:57 +00:00
Mike Brady a062f83abe Quieten lots of debug messages. 2025-12-05 08:49:22 +00:00
Mike Brady aac6913681 Stop the player thread from resetting the NTPTP client clock when it finishes. 2025-12-05 08:33:18 +00:00
Mike Brady 0e274eb760 Balking when connecting to HPM. 2025-12-04 11:35:00 +00:00
Mike Brady 009a13dfe5 Separate out the buffered audio processor, the buffered reader and the mod 2^23 aritemetic. 2025-12-03 17:44:50 +00:00
Mike Brady 341a1f8d5d Move a function so that it can be build without the FFmpeg library, duh. 2025-12-03 16:13:38 +00:00
Mike Brady 93bafe304a Modify/simplify the TEARDOWN handling in AP2 mode. Allow the threads to natrually terminate when ports are closed by the client. 2025-12-03 15:56:38 +00:00
Mike Brady 54445ee8f5 Separate out the debug facilities into their own files. Clean up and add a few associated methods. 2025-11-27 12:37:16 +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 e4d3c6f7e8 Fix a potential bug by checking that a buffer is not zero before attempting to deallocate it. 2024-12-04 16:06:22 +00:00
Mike Brady da1c20c672 Quieten some debug messages. 2024-12-02 10:59:29 +00:00
Mike Brady ab6225c1ac Add some extra diagnostics to investigate a read of zero bytes. 2024-11-02 14:44:12 +00:00
Mike Brady aa3af3b368 Add a check for when a read() returns zero. 2024-10-31 17:28:12 +00:00
Mike Brady 419ff394f5 Remove watchdog stuff. USe the session timeout to set the TCP keep intervals and stuff. Change response to ETIMEDOUT to rtsp_read_request_response_immediate_shutdown_requested. 2024-06-29 20:04:29 +01:00
Mike Brady c064b8bae5 Change order of some include file to facilitiate old Mac OS X builds. Check existence of TCP_KEEPINTVL before trying to use it. Fix a race condition with initial messages to the metadata queues. The race was that the queues and mutexes were definied in a thread, so could be delayed to after when the main process was using them. 2024-06-15 14:31:14 +01:00
Mike Brady e0b13829cd Reverse changes made in PR 1831 (https://github.com/mikebrady/shairport-sync/pull/1831/files) -- issue identified in Issue 1856 (https://github.com/mikebrady/shairport-sync/issues/1856). 2024-05-23 14:24:30 +01:00
= 5fb152a5f5 fix inversion of number and size arguments in a calloc 2024-04-26 11:20:03 +01:00
Mike BradyandGitHub 6eba4fd83e Merge pull request #1831 from kuzhylol/master
This patch introduces modification to AirPlay attributes allowing AirPlay clients seeing only appropriate Endpoints of specific version of AirPlay protocol.

[Test]
Run two instances of shairport-sync - built for version 1 and for version 2.

TuneBlade recognizes only AirPlay version 1 instance running.
MacOS/iOS recognizes only AirPlay version 2 instance running.

Without that patch, both MacOS/iOS detect two endpoints at the same time. The TuneBlade detects only AirPlay version 1 since it doesn't support AirPlay version 2.
2024-04-01 13:02:20 +01:00
Mike BradyandGitHub 5922f9d1b4 Merge pull request #1813 from rmounce/fix-ptp-net-iface
Limit PTP addresses to configured network interface.
2024-04-01 10:38:58 +01:00
Oleh Kuzhylnyi 3dc5926243 Add version-based visibility of shairport-sync endpoints
This patch introduces modification to AirPlay attributes allowing AirPlay clients
seeing only appropriate Endpoints of specific version of AirPlay protocol.

[Test]
Run two instances of shairport-sync - built for version 1 and for version 2.

TuneBlade recognizes only AirPlay version 1 instance running.
MacOS/iOS recognizes only AirPlay version 2 instance running.

Without that patch, both MacOS/iOS detect two endpoints at the same time.
The TuneBlade detects only AirPlay version 1 since it doesn't support AirPlay version 2.
2024-03-26 19:48:42 -03:00
Mike Brady 0f07107c36 Look for DACP-ID and Active-Remote in the GET /info request, where it sometimes appears from AirPlay from an intel Mac. 2024-03-25 20:28:11 +00:00
Ryan Mounce b6a3835d45 Limit PTP addresses to configured network interface
Otherwise every address on the system is advertised and AirPlay 2
sources will send PTP announce + signalling messages to all of them in
parallel.
2024-02-27 22:20:27 +10:30
Klemens Nanni 783d600a10 Fix crash on double pthread_cancel(3) on exit
On OpenBSD 7.4-current, failure to listen on the RTSP socket(s) results
the `rtsp_listener_thread` being pthread_cancel(3)'ed twice, once through
`rtsp_listen_loop()` and again via atexit(3) handler `exit_rtsp_listener()`:

```
$ nc -4l 5000 &
$ nc -6l 5000 &
$ shairport-sync -c/dev/null
warning: could not establish a service on port 5000 -- program terminating. Is another instance of Shairport Sync running on this device?
Segmentation fault (core dumped)
```
```
Program terminated with signal SIGSEGV, Segmentation fault.
433             if (tib->tib_canceled == 0 && tid != 0 &&
[Current thread is 1 (process 290061)]
```

`die()` -> `exit(EXIT_FAILURE)` normally in this case, thus forgoing the
first cancel and relying on the atexit handler alone.

With Mike Brady.
2024-02-01 18:35:35 +01:00
Klemens Nanni 62abb0465c fix [-Wunused-variable] for keep* variables 2024-01-30 02:52:49 +01:00
Klemens NanniandKlemens Nanni dc235275ac No per-socket TCP keepidle on OpenBSD
A system-wide sysctl(2) net.inet.tcp.keepidle exists, but there is no
setsockopt(2) equivalent.
2024-01-27 19:15:07 +01:00
Mike Brady e36ec5c45d Quieten some debug messages. 2023-11-12 11:50:21 +00:00
Mike Brady 5f9a88fb74 Use pthread_rwlock_wrlock instead of the incorrect use of pthread_rdlock_wrlock when tearing down a connection. 2023-10-31 09:01:24 +00:00
Mike Brady b70dd4633f Change response to a /feedback message in a Classic AirPlay session to 501 Not Implmemented instead of 200 OK. 2023-10-13 07:52:51 +01:00
Mike Brady 4cd3c1da4b Return code 200 for a POST of type /feedback, and continue to return 500 for everything else. 2023-10-08 17:43:02 +01:00
Mike Brady 29a5589be6 Quieten a debug message. 2023-10-02 10:05:21 +01:00
Mike Brady c4975d5c3b Add missing arguments to some debug messages. They could potentially cause crashes just when you need them to work properly, sigh! 2023-09-25 09:37:47 +01:00
Mike Brady a3f12d685a When a connection termiates abruptly while is it the principal_conn, make sure it sets the principal_conn
to NULL and cleans up the bonjour flags, if appropriate.

Simplify the TEARDOWN handlers and the thress teardown functions by incporporating
the above code in the teardown_phase_two (for AP2) and teardown (fpr AP1) functions.

It means that closing a connection will block on the principal_conn_lock, so if
you have the principal_conn_lock, closing will not complete until you release it.

Maybe we need a principal_conn_acquisition_lock for that...
2023-09-24 17:23:04 +01:00