mikebrady / shairport-sync-docker

Docker setup for Shairport Sync
MIT License
49 stars 19 forks source link

Play to Bluetooth Speaker #8

Closed charlesomer closed 3 years ago

charlesomer commented 3 years ago

Hi,

Thanks for all your work on Shairport (hopefully the Airplay 2 stuff isn't going too badly!).

My basic goal is to have at least two instances of Shairport Sync on a Raspberry Pi, one outputting via the 3.5mm audio jack and one outputting via a connected Bluetooth speaker (potentially adding more bluetooth senders in the future).

However, I'm not entirely sure how to pass through the Bluetooth audio to the docker container since it's not available in ALSA. I have a feeling this will require some PulseAudio config but currently I believe the docker image doesn't contain PulseAudio?

I hoped you might have a suggestion on how to get this working? Maybe I've missed something obvious :)

Thank you Charles

mikebrady commented 3 years ago

Thanks for the post, Charles. TBH, I haven't really used Bluetooth with Shairport Sync, but if you look through the issues, both open and closed, you'll find quite a lot of discussion and tips about using Bluetooth.

[Edit] I was referring to the issues on the main Shairport Sync repository.

charlesomer commented 3 years ago

I managed to get it working in the end, completely forgot I could pipe to a file and then just play that from the Pi host using paplay, aplay or similar. Just in case someone stumbles upon this thread in the future paplay --raw shairport-sync-audio worked automatically but aplay required the following config: aplay -t raw -r 44100 -c 2 -f S16_LE shairport-sync-audio.

I also managed to get it streaming via both bluetooth and the 3.5mm headphone jack. Plus, I was able to output to them both at the same time via forked-daapd. I had to set audio_backend_latency_offset_in_seconds to -1 for the bluetooth Shairport Sync docker container.

Unfortunately, this looks like it's just going to be too unreliable (I had a feeling it might be) :( When using iTunes, the delay for the bluetooth instance has to change to -0.3 and for some reason when using forked-daapd, only static will be heard until the volume is set to anything other than 100% sometimes.

I think using Pi Zero Ws might be the way to go for now until Amazon allows multi room music on their echos properly. Ideally, something low powered, wireless and small with a 3.5mm headphone jack would be ideal but I'm not sure of anything better than a pi zero w.

Thank you for your help!

charlesomer commented 3 years ago

It turns out the delay differences between iTunes and Forked Daapd were something to do with the pipe. By pausing, waiting long enough and then restarting the stream the sync seemed to be fine initially. Unfortunately, I've also discovered that piping to a file and then to a bluetooth can end up out of sync (I'm not sure why). My next step is to try running shairport-sync directly on the pi without docker and sending the audio directly to bluetooth from shairport-sync (eliminating the pipe) or try again to access PulseAudio from docker.