What happened?
Hi, thanks all for all the awesome work.
I’m testing convolution support on a Raspberry Pi 4 plugged into a Yamaha amp. With AirPlay 2 Buffered playback from macOS (and iOS), Shairport repeatedly logs the same convolver being initialized during one playback session. I generated the FIR impulse response WAVs with the HouseCurve app on an iPhone.
With a unity FIR whose impulse is at sample 0, audio still plays. With a 0.5s centered FIR from HouseCurve, playback was silent or nearly silent.
I found a workaround, but I’m not sure it is the right fix.
The workaround was in player.c, inside player_thread_func around the convolver setup check. I tried removing inframe->length from the conditions that trigger convolver reinitialization
diff --git a/player.c b/player.c
@@ -4626,7 +4626,6 @@ void *player_thread_func(void *arg) {
// First, have we got the right convolution setup?
static int convolver_is_valid = 0;
- static size_t current_convolver_block_size = 0;
static unsigned int current_convolver_rate = 0;
static unsigned int current_convolver_channels = 0;
static double current_convolver_maximum_length_in_seconds = 0;
@@ -4635,7 +4634,6 @@ void *player_thread_func(void *arg) {
if (
// if any of these are true, we need to create a new convolver
// (conn->convolver_is_valid == 0) ||
- (current_convolver_block_size != inframe->length) ||
(current_convolver_rate != conn->input_rate) ||
!((current_convolver_channels == 1) ||
(current_convolver_channels == conn->input_num_channels)) ||
@@ -4646,7 +4644,6 @@ void *player_thread_func(void *arg) {
// look for a convolution ir file with a matching rate and channel count
convolver_is_valid = 0; // declare any current convolver as invalid
- current_convolver_block_size = inframe->length;
current_convolver_rate = conn->input_rate;
current_convolver_channels = conn->input_num_channels;
FFTConvolver.h says that after initialization, subsequent data portions of arbitrary length can be convolved.
Relevant log output
Before workaround:
Connection 1: AirPlay 2 Buffered playback. Source: "Christopher’s MacBook Pro". Input format: AAC/48000/F24/2. Output format: 44100/S32_LE/2.
player.c:4705 convolver: "/etc/shairport-sync/filters/unity-48000.wav".
player.c:4705 convolver: "/etc/shairport-sync/filters/unity-48000.wav".
player.c:4705 convolver: "/etc/shairport-sync/filters/unity-48000.wav".
... repeated continuously during playback ...
After workaround:
Connection 1: AirPlay 2 Buffered playback. Source: "Christopher’s MacBook Pro". Input format: AAC/48000/F24/2. Output format: 44100/S32_LE/2.
player.c:4702 convolver: "/etc/shairport-sync/filters/q100-cutsonly-48.wav".
Playback stopped. Total playing time 00:00:37. Output: 44099.49 (raw), 44099.75 (corrected) frames per second.
System Information.
Raspberry Pi 4, Debian 12 bookworm, Yamaha USB DAC via ALSA
Configuration Information.
0.006827863 "shairport.c:1730" config.service_type is: "auto".
0.000930701 "shairport.c:1778" NQPTP service found.
0.000074666 "shairport.c:2523" >> Display Config Start.
0.003175896 "shairport.c:2523"
0.000058685 "shairport.c:2523" From "uname -a":
0.000011555 "shairport.c:2523" Linux nad3020streamer 6.6.70-v8+ #1837 SMP PREEMPT Fri Jan 10 12:02:51 GMT 2025 aarch64 GNU/Linux
0.007090104 "shairport.c:2523"
0.000394258 "shairport.c:2523" From /etc/os-release:
0.000171036 "shairport.c:2523" Debian GNU/Linux 12 (bookworm)
0.003575024 "shairport.c:2523"
0.000310943 "shairport.c:2523" From /sys/firmware/devicetree/base/model:
0.000044963 "shairport.c:2523" Raspberry Pi 4 Model B Rev 1.4
0.000173055 "shairport.c:2523"
0.000035481 "shairport.c:2523" Shairport Sync Version String:
0.000031111 "shairport.c:2523" 5.1-dirty-AirPlay2-smi10-OpenSSL-Avahi-ALSA-soxr-convolution-sysconfdir:/etc
0.000224944 "shairport.c:2523"
0.000038963 "shairport.c:2523" Command Line:
0.000082185 "shairport.c:2523" shairport-sync --displayConfig
0.000074518 "shairport.c:2523"
0.000034389 "shairport.c:2523" Configuration File:
0.000030277 "shairport.c:2523" /etc/shairport-sync.conf
0.000029871 "shairport.c:2523"
0.000467331 "shairport.c:2523" Configuration File Settings:
0.000046352 "shairport.c:2523" general :
0.000031296 "shairport.c:2523" {
0.000029352 "shairport.c:2523" name = "Office Receiver";
0.000029296 "shairport.c:2523" volume_range_db = 35;
0.000030000 "shairport.c:2523" volume_control_profile = "standard";
0.000029629 "shairport.c:2523" };
0.000028834 "shairport.c:2523" alsa :
0.000203073 "shairport.c:2523" {
0.000091926 "shairport.c:2523" output_device = "hw:DAC";
0.000033888 "shairport.c:2523" output_rate = 44100;
0.000029926 "shairport.c:2523" };
0.000024389 "shairport.c:2523" pa :
0.000010778 "shairport.c:2523" {
0.000008240 "shairport.c:2523" };
0.000008056 "shairport.c:2523" dsp :
0.000007963 "shairport.c:2523" {
0.000007907 "shairport.c:2523" convolution_enabled = "yes";
0.000008278 "shairport.c:2523" convolution_thread_pool_size = 1;
0.000008611 "shairport.c:2523" convolution_ir_files = "/etc/shairport-sync/filters/q100-cutsonly-44.wav, /etc/shairport-sync/filters/q100-cutsonly-48.wav";
0.000009482 "shairport.c:2523" convolution_gain = -4.0;
0.000008759 "shairport.c:2523" convolution_max_length_in_seconds = 0.5;
0.000008500 "shairport.c:2523" loudness_enabled = "no";
0.000007907 "shairport.c:2523" };
0.000007870 "shairport.c:2523" diagnostics :
0.000007982 "shairport.c:2523" {
0.000007833 "shairport.c:2523" statistics = "yes";
0.000008056 "shairport.c:2523" log_verbosity = 1;
0.000008222 "shairport.c:2523" log_show_time_since_last_message = "no";
0.000008815 "shairport.c:2523" };
0.000008222 "shairport.c:2523"
0.000007926 "shairport.c:2523" >> Display Config End.
0.000008611 "shairport.c:2525" >> Goodbye!
PulseAudio or PipeWire installed?
How did you install Shairport Sync?
Built from source
Check previous issues
What happened?
Hi, thanks all for all the awesome work.
I’m testing convolution support on a Raspberry Pi 4 plugged into a Yamaha amp. With AirPlay 2 Buffered playback from macOS (and iOS), Shairport repeatedly logs the same convolver being initialized during one playback session. I generated the FIR impulse response WAVs with the HouseCurve app on an iPhone.
With a unity FIR whose impulse is at sample 0, audio still plays. With a 0.5s centered FIR from HouseCurve, playback was silent or nearly silent.
I found a workaround, but I’m not sure it is the right fix.
The workaround was in
player.c, insideplayer_thread_funcaround the convolver setup check. I tried removinginframe->lengthfrom the conditions that trigger convolver reinitializationFFTConvolver.hsays that after initialization, subsequent data portions of arbitrary length can be convolved.Relevant log output
System Information.
Raspberry Pi 4, Debian 12 bookworm, Yamaha USB DAC via ALSA
Configuration Information.
PulseAudio or PipeWire installed?
How did you install Shairport Sync?
Built from source
Check previous issues