Skip to content

[Problem]: Shairport-sync crashes with memory error while using bluealsa #2033

@Neelu2904

Description

@Neelu2904

What happened?

I am trying to build an iPhone -> Shairport-sync -> Bluetooth speaker system using a pi zero 2 w.

I had done it in the past and it worked well then. I stopped my project then and started back now.

My procedure included like this

Install Bluealsa from source. (with only debug and systemd enabled)
Go to bluetoothctl
Pair, trust and connect speaker
Run a test "aplay -D bluealsa /usr/share/sounds/alsa/Front_Center.wav"
Get Front Center audio from speaker, perfect.
Install shairport-sync and NQPTP (with standard configs from source).
Go to shairport-sync config file
Change output device to bluealsa
sudo nano ~/.asoundrc

pcm.!default {
        type asym
        playback.pcm {
                type plug
                slave.pcm "output"
        }
        capture.pcm {
                type plug
                slave.pcm "softcard"
        }
}
pcm.softcard {
       type softvol
       slave.pcm "hw:2,0"
       control.name "Pre-Amp"
       control.card 2
       min_dB -5.0
       max_dB 20.0
       resolution 5
}

pcm.output {
       type bluealsa
       device "xx:xx:xx:xx:xx:xx"
       profile "a2dp"
}

ctl.!default {
        type bluealsa
}

Use the above asoundrc config

And voila, it used to work.

But now it doesnt.

It now leads into two scenarios.

1.) iPhone shows playing but no sound from the speaker

2.) iPhone connects to the Pi's airplay but whenever I hit play it crashes saying "Unable to connect to Raspberrypi"

running "sudo systemctl status shairport-sync.service" shows a fatal error as shown in log output. (only in case 2)

I have tried everything. Using all the different asoundrc configs that finally solved people's issues, trying different locations for asoundrc as ~/.asoundrc ; /etc/.asoundrc ; /etc/asound.conf . I also tried the legacy Raspbian that had the /boot/config.txt rather than boot/firmware/config.txt.

I have no idea what to do now. Any help would be appreciated, thanks.

Relevant log output

● shairport-sync.service - Shairport Sync - AirPlay Audio Receiver
     Loaded: loaded (/lib/systemd/system/shairport-sync.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Fri 2025-06-13 23:34:47 IST; 3s ago
    Process: 756 ExecStart=/usr/local/bin/shairport-sync --log-to-syslog (code=exited, status=1/FAILURE)
   Main PID: 756 (code=exited, status=1/FAILURE)
        CPU: 1.891s
● shairport-sync.service - Shairport Sync - AirPlay Audio Receiver
     Loaded: loaded (/lib/systemd/system/shairport-sync.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Fri 2025-06-13 23:34:47 IST; 3s ago
    Process: 756 ExecStart=/usr/local/bin/shairport-sync --log-to-syslog (code=exited, status=1/FAILURE)
   Main PID: 756 (code=exited, status=1/FAILURE)
        CPU: 1.891s

Jun 13 23:34:39 raspberrypi systemd[1]: Started Shairport Sync - AirPlay Audio Receiver.
Jun 13 23:34:47 raspberrypi shairport-sync[756]: [762] D: ../../../src/asound/bluealsa-pcm.c:1671: Getting BlueALSA PCM: PLAYBACK 00:00:00:00:00:00 a2dp
Jun 13 23:34:47 raspberrypi shairport-sync[756]: [762] D: ../../../src/asound/bluealsa-pcm.c:1426: /org/bluealsa/hci0/dev_30_21_0B_F0_83_EC/a2dpsrc/sink: Setting co>
Jun 13 23:34:47 raspberrypi shairport-sync[756]: [762] D: ../../../src/asound/bluealsa-pcm.c:593: /org/bluealsa/hci0/dev_30_21_0B_F0_83_EC/a2dpsrc/sink: Initializin>
Jun 13 23:34:47 raspberrypi shairport-sync[756]: [762] D: ../../../src/asound/bluealsa-pcm.c:542: /org/bluealsa/hci0/dev_30_21_0B_F0_83_EC/a2dpsrc/sink: Attempting >
Jun 13 23:34:47 raspberrypi shairport-sync[756]: fatal error: audio_alsa: Unable to set hw parameters for device "bluealsa": Cannot allocate memory.
Jun 13 23:34:47 raspberrypi systemd[1]: shairport-sync.service: Main process exited, code=exited, status=1/FAILURE
Jun 13 23:34:47 raspberrypi systemd[1]: shairport-sync.service: Failed with result 'exit-code'.
Jun 13 23:34:47 raspberrypi systemd[1]: shairport-sync.service: Consumed 1.891s CPU time.

System Information.

RPi Zero 2 W

Configuration Information.

>> Display Config Start.

From "uname -a":
 Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux

From /etc/os-release:
 Debian GNU/Linux 11 (bullseye)

From /sys/firmware/devicetree/base/model:
 Raspberry Pi Zero 2 W Rev 1.0

Shairport Sync Version String:
 4.3.7-4-g188aa527-AirPlay2-smi10-OpenSSL-Avahi-ALSA-soxr-sysconfdir:/etc

Command Line:
 shairport-sync --displayConfig

Configuration File:
 /etc/shairport-sync.conf

Configuration File Settings:
 alsa :
 {
   output_device = "bluealsa";
 };
 pw :
 {
 };

>> Display Config End.
>> Goodbye!

PulseAudio or PipeWire installed?

  • Check if your system uses a Sound Server.

How did you install Shairport Sync?

Built from source

Check previous issues

  • Confirm

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions