Hello all,
Trying to set everything up so that I can AirPlay to the Pi, which then plays to the speaker over Bluetooth.
I found an earlier issue and tried one solution (https://github.com/mikebrady/shairport-sync/issues/200#issuecomment-520574102) but when I tried, I got no audio to my speaker.
The test command they provided to test if sound would play over Bluetooth (aplay -D marshall file_example_WAV_1MG.wav) worked, but when I tried using shairport, nothing played on the speaker.
Any guidance would be much appreciated!
I’m afraid I don’t have any experience of trying to use Bluetooth. Perhaps some other users may be able to offer some advice.
The test command they provided to test if sound would play over Bluetooth (
aplay -D marshall file_example_WAV_1MG.wav) worked, but when I tried using shairport, nothing played on the speaker.
It works for me. What do you have in your shairport-sync.conf ?
The only thing I changed in shairport-sync.conf was the following:
alsa =
{
output_device = "bt_speaker";
};
And here is my /etc/asound.conf:
pcm.bt_speaker {
type plug
slave {
pcm {
type bluealsa
device 00:42:79:7D:82:A9
profile "a2dp"
}
}
hint {
show on
description "BT Speaker"
}
}
Looks fine. If aplay -D bt_speaker works for you I guess you should check shairport-sync logs
I have the exact same issue as OP.
systemd[1]: Started Shairport Sync - AirPlay Audio Receiver.
This is all I see in syslog.
I don't understand what is going on, but I don't even know how to diagnose better. Please help.
I have some more info.
When you do
aplay -l
the Bluetooth device does not show up in that list at all:
* List of PLAYBACK Hardware Devices *
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 7/7
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 IEC958/HDMI [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: ALSA [bcm2835 ALSA], device 2: bcm2835 IEC958/HDMI1 [bcm2835 IEC958/HDMI1]
Subdevices: 1/1
Subdevice #0: subdevice #0
Now if I do aplay -L it shows at the top:
null
Discard all samples (playback) or generate zero samples (capture)
harmony
Harmony speaker
default:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA... etc
My BT speaker is called " Harmony"
I defined it in '/etc/asound.conf' like this:
pcm.harmony {
type plug
slave {
pcm {
type bluealsa
device 0A:F2:E7:05:14:E4
profile "a2dp"
}
}
hint {
show on
description "Harmony speaker"
}
}
I believe the problem comes from this being a virtual device and not an actual device. I have no idea how the people who got it running did so but it does not work in this way at least. Any idea how to fix this to make it work?
One more thing, even though I can play an audio file with aplay, I cannto make any soundgo to the speaker with speaker-test, it gives no error but I hear nothing. Maybe there's a mixer issue? But I don't see how to make alsamixer show this virtual device.
Also for completeness I just added a ctl.harmony entry to /etc/asound.conf
@kikendo if it helps, here's the output of same commands on my machine
aplay -l
pi@raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 7/7
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 IEC958/HDMI [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: ALSA [bcm2835 ALSA], device 2: bcm2835 IEC958/HDMI1 [bcm2835 IEC958/HDMI1]
Subdevices: 1/1
Subdevice #0: subdevice #0
aplay -L
pi@raspberrypi:~ $ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
jack
JACK Audio Connection Kit
pulse
PulseAudio Sound Server
marshall
Marshall speaker
default:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
sysdefault:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
dmix:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Direct sample mixing device
dmix:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Direct sample mixing device
dmix:CARD=ALSA,DEV=2
bcm2835 ALSA, bcm2835 IEC958/HDMI1
Direct sample mixing device
dsnoop:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Direct sample snooping device
dsnoop:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Direct sample snooping device
dsnoop:CARD=ALSA,DEV=2
bcm2835 ALSA, bcm2835 IEC958/HDMI1
Direct sample snooping device
hw:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Direct hardware device without any conversions
hw:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Direct hardware device without any conversions
hw:CARD=ALSA,DEV=2
bcm2835 ALSA, bcm2835 IEC958/HDMI1
Direct hardware device without any conversions
plughw:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Hardware device with all software conversions
plughw:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Hardware device with all software conversions
plughw:CARD=ALSA,DEV=2
bcm2835 ALSA, bcm2835 IEC958/HDMI1
Hardware device with all software conversions
usbstream:CARD=ALSA
bcm2835 ALSA
USB Stream Output
You can see my bluetooth speaker is present in aplay -L output - it's called marshall in my case.
alsamixer only shows one PCM gauge
@SlimShadyIAm @kikendo
try to use "default" as output in shairport.conf
and put a default-device at asound.conf
`pcm.jbl {
type plug
slave {
pcm {
type bluealsa
device "11:22:33:44:55:66"
profile "a2dp"
}
}
hint {
show on
description "JBL-GO"
}
}
pcm.!default {
type plug
slave.pcm "jbl"
}
ctl.!default {
type hw
card 0
}
`
helped at my config...
@RockSteadyBeat I tried that and it didn't work
@bedrin I don't understand how it works for you then, can you share your asound.conf and shairport-sync.conf files?
@kikendo it's all in https://github.com/mikebrady/shairport-sync/issues/200#issuecomment-520574102
Whole setup worked for me from second attempt - at first I tried to go down the pulseaudio route but it didn't work. I didn't manage to uninstall pulseaudio properly so had to start from scratch and reinstall raspbian.
On the second attempt I never touched pa - only running alsa
@bedrin [edit] I realized you referenced your own comment. Sorry!
I don't understand why some people have success and some do not. Your aplay output already is different because you have a pulseaudio device, but in your case your speaker is also a virtual device YET IT WORKS but it does NOT on our setups.
@mikebrady can you shed some light on this?
@kikendo, I have never tried to use Bluetooth with Shairport Sync. And I try not to use PulseAudio if I can avoid it, due to its apparent complexity. So I'm not much help in this one, I'm afraid.
@kikendo, I have never tried to use Bluetooth with Shairport Sync. And I try not to use PulseAudio if I can avoid it, due to its apparent complexity. So I'm not much help in this one, I'm afraid.
Yeah my question is not particularly about Bluetooth but virtual devices. You repeatedly refer to the need to use "hw.0" as device or similar, yet some people here have success referencing a virtual device (like "default" or "marshall"), some do not.
Does your software support these virtual devices, or not, and if it does, why yes in some setups, and no in others? I think this is worth looking into.
BTW we're all talking about ALSA here, not PulseAudio.
The focus in Shairport Sync is for it to work on real hardware devices – like hw:0 – first and foremost. It's great that it works on virtual devices, and one would certainly seek to avoid making it incompatible with them, but that's about it.
BTW the default ALSA device on many desktop linux systems is implemented by PulseAudio, so we very much could all be talking about PulseAudio.
Well I am not talking about Pulseaudio, I am running ALSA only.
So why would this work on virtual devices sometimes and sometimes not? this is my question. I am sorry I cannot provide more details but my own config, nobody else have posted theirs except RockSteadyBeat. and his looks just like mine and it works for him, but not for me. Very confusing.
I don't understand why some people have success and some do not. Your
aplayoutput already is different because you have a pulseaudio device, but in your case your speaker is also a virtual device YET IT WORKS but it does NOT on our setups.
I'm happy to share as much details as I can :)
I'm using shairport-sync built from 3.3.2 tag
pi@raspberrypi:~ $ shairport-sync --version
3.3.2-OpenSSL-Avahi-ALSA-soxr-sysconfdir:/etc
ALSA version 4.19.88-v7
pi@raspberrypi:~ $ cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version k4.19.88-v7+.
BlueZ version 5.50
pi@raspberrypi:~ $ bluetoothd -v
5.50
Linux Raspbian Buster
pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster
Some of mine configuration files from live system
pi@raspberrypi:~ $ cat /lib/systemd/system/bluealsa.service
[Unit]
Description=BluezALSA proxy
Requires=bluetooth.service
After=bluetooth.service
[Service]
Type=simple
User=root
ExecStart=/usr/bin/bluealsa
pi@raspberrypi:~ $ cat /lib/systemd/system/bluetooth.service
[Unit]
Description=Bluetooth service
Documentation=man:bluetoothd(8)
ConditionPathIsDirectory=/sys/class/bluetooth
[Service]
Type=dbus
BusName=org.bluez
ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=sap
NotifyAccess=main
#WatchdogSec=10
#Restart=on-failure
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
LimitNPROC=1
ProtectHome=true
ProtectSystem=full
[Install]
WantedBy=bluetooth.target
Alias=dbus-org.bluez.service
pi@raspberrypi:~ $ cat /lib/systemd/system/[email protected]
[Unit]
Description=Raspberry Pi bluetooth helper
Requires=bluetooth.service
After=bluetooth.service
[Service]
Type=simple
ExecStart=/usr/bin/bthelper %I
pi@raspberrypi:~ $ cat /etc/asound.conf
pcm.marshall {
type plug
slave {
pcm {
type bluealsa
device 04:FE:A1:CE:FC:63
profile "a2dp"
}
}
hint {
show on
description "Marshall speaker"
}
}
pi@raspberrypi:~ $ cat /etc/shairport-sync.conf
general =
{
name = "Marshall";
volume_range_db = 60 ;
};
sessioncontrol =
{
allow_session_interruption = "yes";
};
alsa =
{
output_device = "marshall";
};
diagnostics =
{
log_verbosity = 2;
};
What do you get in shairport-sync logs?
Use journalctl -n1000 to check last 1000 lines
@bedrin dude I am going to delete this whole SD card and start from scratch again because this is driving me mad. Will follow your instructions very precisely and report back. thanks!
OK i give up, I don't know wtf is going on here.
I went back and did the whole thing 1:1 like you did it in your post @bedrin and I still get no sound on the BY speaker when connecting to the airplay raspberry.
I also noticed the Airplay system on the phone shows a checkmark when connected to it, but if I connect to another "real"airplay server, it has a circle filled with a checkmark in it. Anybody knows what this means?
Versions:
shairport-sync: 3.3.5-OpenSSL-Avahi-ALSA-soxr-sysconfdir:/etc
ALSA: Advanced Linux Sound Architecture Driver Version k4.19.97+.
BlueZ: 5.50
Linux: Raspbian Buster Release 10
So both my ALSA and Shairport are newer, what has changed possibly in Shairport that causes this to not work anymore?
I also noticed the Airplay system on the phone shows a checkmark when connected to it, but if I connect to another "real"airplay server, it has a circle filled with a checkmark in it. Anybody knows what this means?
I think circle means AirPlay 2 compatible device. I have a circle for my new Samsung TV
Please note that it doesn't work if I try to stream music to both Samsung and shairport-sync simultaneously.
Sorry to hear that it still doesn't work for you :(
Any clues in shairport logs? From journalctl
@kikendo also what Raspberry are you using?
I was using this setup with bluetooth earlier and it worked. I stoped using it due to latency issues.
But problems I was dealing with resolved by thinking about these questions:
I think I have progressed a bit on this. Logs are below
So I set it up as per @bedrin 's suggestion and I have the same problem that @kikendo was facing. Audio sent to bluetooth plays perfectly. However via shairport, it doesn't work. I don't get an error, but no audio plays.
From the logs, it looks like a sync error. I tried playing around with drift_tolerance and resync_threshold but no luck.
May 14 11:08:25 Backyard-Pi shairport-sync[408]: 0.074008356 "player.c:2148" Player: packets out of sequence: expecte
May 14 11:08:26 Backyard-Pi shairport-sync[408]: 0.022991234 "player.c:2288" Large negative sync error: -7148 with sh
May 14 11:08:26 Backyard-Pi shairport-sync[408]: 0.005107476 "player.c:2300" Play a silence of 7148 frames.
May 14 11:08:26 Backyard-Pi shairport-sync[408]: 0.074860976 "player.c:2148" Player: packets out of sequence: expecte
May 14 11:08:26 Backyard-Pi shairport-sync[408]: 0.021390993 "player.c:2288" Large negative sync error: -7168 with sh
May 14 11:08:26 Backyard-Pi shairport-sync[408]: 0.004730441 "player.c:2300" Play a silence of 7168 frames.
May 14 11:08:26 Backyard-Pi shairport-sync[408]: 0.075053993 "player.c:2148" Player: packets out of sequence: expecte
May 14 11:08:26 Backyard-Pi shairport-sync[408]: 0.023072150 "player.c:2288" Large negative sync error: -7102 with sh
May 14 11:08:26 Backyard-Pi shairport-sync[408]: 0.004653434 "player.c:2300" Play a silence of 7102 frames.
May 14 11:08:26 Backyard-Pi shairport-sync[408]: 0.079116372 "player.c:2148" Player: packets out of sequence: expecte
May 14 11:08:26 Backyard-Pi shairport-sync[408]: 0.024085244 "rtsp.c:533" RTSP Message Received: "OPTIONS * RTSP/1.0"
May 14 11:08:26 Backyard-Pi shairport-sync[408]: 0.003961369 "rtsp.c:563" CSeq: 16.
May 14 11:08:26 Backyard-Pi shairport-sync[408]: 0.004182390 "rtsp.c:563" DACP-ID: C6A63F8E5BBBA83E.
May 14 11:08:26 Backyard-Pi shairport-sync[408]: 0.003025282 "rtsp.c:563" Active-Remote: 1990273104.
May 14 11:08:26 Backyard-Pi shairport-sync[408]: 0.000292027 "rtsp.c:563" User-Agent: AirPlay/420.45.
I gave up on this as it made no sense, bought an old Airport Express for $10, ended up being all round less hassle and less cost than trying to do it with a Pi Zero W plus BT Speaker. Needs a wired speaker but whatever.
Here's an update for the folks who might come to this thread.
The Wifi and BT on Pi0W use the same chip and path to process both signals. Pi0W stops processing wifi packets when there is an active bluetooth connection, so shairport keeps getting out of sync and plays silence trying to catch up.
In other words if you want to use Pi0W to run airplay and output to a bluetooth speaker, it won't work.
Hello Guys I followed below and looks like Bluealsa is not available anymore
https://github.com/mikebrady/shairport-sync/issues/200 (@bedrin commented on 12 Aug 2019 )
i am using this on a xubuntu 20.04 VM with Usb bluetooth dongle connected to it.
++
_Jul 01 17:42:16 AirplayVM shairport-sync[45337]: ALSA lib dlmisc.c:283:(snd_dlobj_cache_get0) Cannot open shared library /usr/lib/x86_64-linux-gnu/alsa-lib/libasound_m>
Jul 01 17:42:16 AirplayVM shairport-sync[45337]: 0.005965015 "audio_alsa.c:442" *warning: alsa: error -6 ("No such device or address") opening alsa device "ma>_
++
can anyone help ?
I've got this working on an RPi 4 with BlueALSA in a Docker container, which was pretty fiddly due to mounting dbus sockets etc, although it _should_ be simpler if you're doing it all natively. Rough order of execution:
bluealsa -p a2dp-source)sudo bluetoothctl to identify and connect to your loudspeakeraudio_backend_buffer_desired_length_in_seconds in the shairport-sync config to prevent buffer xruns.shairport-sync -a favourite-bt-speaker -- -d bluealsa:SRV=org.bluealsa,DEV=1A:2A:3A:4A:5A:6A,PROFILE=a2dp where the DEV value is the address of your speaker.I've tested with Sony headphones and a Bose speaker and both behaved pretty well – I ran for around an hour with only a couple of minor drops, although it wasn't happy when I started streaming the Airplay prior to turning on the BT speaker. I'm sure that all of this could be robustified with some well crafted scripts though!
BlueALSA is still being actively developed, although there isn't a version available in the Raspbian apt repo. For the Docker image I used a build available via the Alpine testing repo but for Raspbian / Raspberry Pi OS you'll want to compile.
Bluezalsa
https://github.com/Arkq/bluez-alsa
- bluealsa
ok let me tell you my setup first
i have Sony SRS XB3 speaker with Bluetooth 4.0 dongle with Diet-Pi OS installed on a VM ( bluetooth dongle is connected directly to VM)
i can discover and connected device with it gets disconnected automatically after first connection and i have tried to remove and pair but no luck.
i know this might sounds too time consuming but can you help me with step by step guide please?( i am new to all these things just a basic linux/ubuntu user here)
can switch to Ubuntu/xubuntu if needed
Most helpful comment
Here's an update for the folks who might come to this thread.
The Wifi and BT on Pi0W use the same chip and path to process both signals. Pi0W stops processing wifi packets when there is an active bluetooth connection, so shairport keeps getting out of sync and plays silence trying to catch up.
In other words if you want to use Pi0W to run airplay and output to a bluetooth speaker, it won't work.