Open janprzy opened 7 months ago
Thanks for the post. It looks like an error is coming back from the FreeBSD sndio
library and Shairport Sync is responding to it. We don't know what the cause of the error is -- maybe it is not serious. Let me take a look and perhaps allow Shairport Sync to ignore that sndio
error.
Hmm, if the error occurs, it must be considered serious: "Once an error occurs, all functions taking a sio_hdl
argument, except sio_close()
and sio_eof()
, stop working (i.e. always return 0)."
So, modifying the flush code (as follows) so that is does nothing might be an interesting experiment. The code, in audio_sndio.c
is:
static void flush() {
// pthread_mutex_lock(&sndio_mutex);
pthread_cleanup_debug_mutex_lock(&sndio_mutex, 1000, 1);
if (!sio_stop(hdl) || !sio_start(hdl))
die("sndio: unable to flush");
written = played = 0;
// pthread_mutex_unlock(&sndio_mutex);
pthread_cleanup_pop(1); // unlock the mutex
}
Replacing it with:
static void flush() {
}
Would make it do nothing.
I just tried that, but it didn't work unfortunately. Now I get sndio: unable to stop
:
0.000062025 "ptp-utilities.c:223" Send control message to NQPTP: "/nqptp P"
0.000117066 "rtsp.c:2017" Connection 1: Pause playing.
0.000062304 "rtp.c:1322" Connection 1: Clear anchor information.
0.000081303 "rtsp.c:2025" Connection 1: Stop the output backend.
0.000050850 "audio_sndio.c:249" *fatal error: sndio: unable to stop
0.000191384 "shairport.c:1728" emergency exit
0.000355387 "rtsp.c:5415" rtsp_listen_loop_cleanup_handler called.
0.000070128 "rtsp.c:531" Connection 1: cancelled.
I will try to investigate what's causing the error in sndio
.
I saw sndio: unable to flush/stop
once or twice with 4.3.2 on OpenBSD/amd64 7.4-current as well, haven't looked into it (yet).
I can confirm that this happens to me on FreeBSD 14.0-RELEASE too, and also happens when changing tracks or fast-forwarding/backwarding (essentially any time the buffer is flushed, it seems). The problem disappears if I switch to AirPlay 1.
I can confirm that this happens to me on FreeBSD 14.0-RELEASE too, and also happens when changing tracks or fast-forwarding/backwarding (essentially any time the buffer is flushed, it seems). The problem disappears if I switch to AirPlay 1.
Thanks @amandasystems -- this is interesting. The same audio backend is used for AirPlay 2 and AirPlay 1. However, I think AirPlay 2 starts and stops audio streams much more frequently than AirPlay 1, possibly giving rise to the circumstances that cause the sndio
problem more often.
Interesting! I’ll try to provoke it on AirPlay 1 too.
Update: I tried my damnedest but I couldn't trigger it.
Thanks for your efforts and for the update. I'll keep trying to figure out if something is happening inadvertently in Shairport Sync.
My intuition says race condition of some kind, or possibly bad cleanup, but I have no familiarity with any of this so it's 100% gut feeling.
This issue has been inactive for 28 days so will be closed 7 days from now. To prevent this, please remove the "stale" label or post a comment.
The issue seems to appear less frequently than it used to, but it's still there.
I did some further investigating, but I couldn't find anything new unfortunately. It can be provoked by pressing the play/pause button repeatedly. The error message is sometimes unable to stop
and sometimes unable to flush
.
I gave up and bought an AirPlay speaker instead, but someone should try the latest FreeBSD 14.1, which does list improved audio drivers. Who knows, something may have been shaken up to avoid the bug.
Fair enough. As a matter of interest, did you think of using a Linux, by any chance?
Yes, but this was a multipurpose machine that I wanted to use mostly as a NAS, so FreeBSD made sense (and still does).
Thanks!
What happened?
Hi,
I'm running shairport-sync 4.3.2 on Freebsd 13.
Often when pausing the audio, or when the next song starts, shairport-sync will crash and the error message
sndio: unable to flush
is written to the log. It doesn't happen every time, but it is reproducible by pressing play/pause repeatedly.Log verbosity is set to 2. I hope I captured all the relevant parts of the log.
Relevant log output
System Information.
Odroid H2
Configuration Information.
PulseAudio or PipeWire installed?
How did you install Shairport Sync?
A package manager (apt, apt install, yum, pkg, etc.)
Check previous issues