porg [Thu, 7 Mar 2024 09:31:27 +0000 (10:31 +0100)]
Update AIRPLAY2.md - Version introduced + Supported devices
The introduction paragraph now more clearly mentions the hard facts/requirements with "as of v4.1 and newer" and the supported devices are displayed in bullet list format for better readabilty.
Mike Brady [Mon, 4 Mar 2024 11:13:56 +0000 (11:13 +0000)]
Build scripts/shairport-sync.service, scripts/shairport-sync.service-avahi and scripts/shairport-sync unconditionally for Linux to facilitate different installation methods.
Klemens Nanni [Wed, 31 Jan 2024 04:01:55 +0000 (05:01 +0100)]
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.
Klemens Nanni [Tue, 30 Jan 2024 02:43:44 +0000 (03:43 +0100)]
Exit on config read error to avoid crash on EACCES
Failure to read does not exit despite
` /* Read the file. If there is an error, report it and exit. */`
EACCES (e.g. insufficient filesystem permissions) is enough to crash
on access through later `config_*()` such as those when either of
either of D-Bus, MPRIS or MQTT is used.
Seen `--with-mpris-interface` and
```
$ ls -l /etc/shairport-sync.conf
-rw-r----- 1 root _shairport 28114 Jan 25 01:53 /etc/shairport-sync.conf
$ shairport-sync
Segmentation fault (core dumped)
```
Klemens Nanni [Tue, 30 Jan 2024 02:14:52 +0000 (03:14 +0100)]
clarify root privilege requirements
NQPTP works and runs as _shairport user on OpenBSD.
Linux capabilities(7) allow starting as unprivileged user in the first
place, otherwise programs only need to start and perform privileged
actions such as bind(2)ing sockets as root, after that they can and
should! drop privileges.
Instead of updating/repeating supported systems, drop listings.
Adds a "install-config-files" Makefile target that installs the config
files and dbus policies to DESTDIR=, regardless of whether
--with{,out}-configfiles is specified.
Klemens Nanni [Sat, 27 Jan 2024 18:40:04 +0000 (19:40 +0100)]
Move shairport-sync manual from section 7 to 1
From mandoc man(1) [-s] section:
1 General commands (tools and utilities).
[...]
7 Miscellaneous information.
From GNU man(1) DESCRIPTION:
1 Executable programs or shell commands
[...]
7 Miscellaneous (including macro packages and conventions), e.g.
man(7), groff(7)
shairport-sync is an executable, shairport-sync(1) ought to be its
documentation, not merely miscellaneous information.
OpenBSD adjusts this in its audio/shairport-sync port/package ever since.
Klemens Nanni [Sat, 27 Jan 2024 07:27:46 +0000 (08:27 +0100)]
Connect to NQPTP control socket on localhost
nqptp.c listens on "localhost", but shairport-sync connectes to the wildcard
address 0/0. This apparently works on Linux and FreeBSD, but OpenBSD fails:
Resolve and connect to "localhost" just like NQPTP does, resulting in
127.0.0.1 or ::1 as socket addresses.
This is required to run when configured `--with-airplay-2`.
Tested on OpenBSD/amd64 7.4-current with shairport-sync 2.4.3 and nqptp
1.2.5-dev cfa8315 (plus OpenBSD fixes).
I expect Linux and FreeBSD to work as before, but have not tested it.
Mike Brady [Sun, 15 Oct 2023 17:20:18 +0000 (18:20 +0100)]
Merge branch 'development'
Update to 4.3.2
**Enhancements**
* A totally new PipeWire backend featuring full synchronisation.
**Bug Fixes**
* Stability improvements for the PulseAudio backend.
* Fix a crash when the Avahi subsystem became disconnected. This is normally a rare occurrence, but Shairport Sync was not dereferencing obsolete data correctly when it happened.
* Set and reset Bonjour flags correctly when it's a Classic Airplay session in AirPlay 2 operation.
* Fix a number of FreeBSD compilation errors and warnings.
* Fix various errors when breaking into an existing session to terminate it. Thanks again to [aaronk6](https://github.com/aaronk6).
* Fix some debug message errors, sigh. Thanks to [Nathan Gray](https://github.com/n8gray).
Mike Brady [Sat, 30 Sep 2023 14:45:41 +0000 (15:45 +0100)]
Replace the pipewire backend completely. Play writes to a buffer. The on_process() function reads from the buffer and updates timing information for the delay() function. Barebones -- can't set the app name or the volume. Assumes no further delays and no buffers when on_process is called. But it works!
Mike Brady [Wed, 27 Sep 2023 09:36:28 +0000 (10:36 +0100)]
Very very rarely, the avahi client becomes disconnected.
This usually means there are problems in the system as a whole rahter than with Shairport Sync.
However, Shairport Sync was not cleaning up properly before deleting the now-disconnected avahi client and
creating a new one in an attempt to reconnect. That caused Shairport Sync to crash even if the new avahi client
was created successfully.
So this commit has code to delete the avahi group and broswer callback before deleting the disconnected avahi client.
Mike Brady [Sun, 24 Sep 2023 16:22:22 +0000 (17:22 +0100)]
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...
Mike Brady [Thu, 21 Sep 2023 15:04:23 +0000 (16:04 +0100)]
Change principal_conn_lock from a regular mutex to a read-write mutex, so it can be used to check and hold the current principal_conn unless it's being altered in get_play_lock or a release_play_lock.
Only allow access to the config.airplay_statusflags, build_bonjour_strings(NULL), mdns_update(NULL, secondary_txt_records) when read_lock is acquired on the principal_conn_lock.
Only allow changes to config.airplay_statusflags and only allow access to mdns_update if you are the principal conn.
The bonjour status flags and the info response plist calculations are still a dirty rotten hack.