mikebrady / shairport-sync

AirPlay and AirPlay 2 audio player
Other
7.29k stars 574 forks source link

Same Pulse Audio Connection refused issue Work around that works #1093

Closed daveosx closed 3 years ago

daveosx commented 4 years ago

I spent the morning trying to get Shairport to operate with the Buster release of PulseAudio. I finally tried the following and it works as a work around. First i changed the user in /etc/init.d/shairport-sync to my default desktop username Second changed the /etc/shairport-sync.conf uncommented interpolation = "basic" Changed to
interpolation = "soxr" uncommented output-backend = "alsa" changed to output-backend = "pa" uncommented application_name = "Shairport Sync"

Third created a Desktop Entry in ~/.config/autostart/Shairport.desktop [Desktop Entry] Exec=/usr/bin/shairport-sync Name=Shairport-Sync type=Application

Looks like the issue is in the way pulseaudio is trying to secure by going to a user mode rather than daemon. In my searching I saw many other apps that no longer connect to the post jessie versions of pulseaudio not sure of all the changes didn't really care. If Shairplay is launched after user logs in with that user it will work great. When launched as a daemon chuid does not seem to be allowing authentication to pulseaudio. Not a critique but many distros seem to be going the way of perl with only one distro actually intact. Much of the mess seems to be caused by differing opinions on security methodologies. It would be great if someone could just create a standard and everyone follow it. As I have time I have been working on my own distro to abandon all of the others. As many of my portable devices are Apple brand interoperability is desired. Also legacy files of mine date back to the early 1980s In my current desktop I have older versions of Apple software emulated in a few different VM instances and old dos apps running in Dosbox. I integrate robotic systems and automotive controllers by vocation so all of my old crap is necessary. It is very great of you to provide the Shairplay-Sync so that I can hear the audio ques. Shairplay-sync allows me to connect from a virtual instance of Macosx to the linux Host better than the emulated audio of Vbox.

imabuddha commented 3 years ago

FYI:

The latest raspberry pi OS update this week switches to pulseaudio. 🙁 I followed your instructions for the pi in the INSTALL.md (using alsa, default config) and it did work. However the airplay sound wasn't affected by the gui's pa volume control. (the airplay volume did work) I rebuilt, this time including the pa & alac libs and it does work, although as you mention it can't be run as a service, and the airplay volume & play/pause responds slower than via alsa.

BTW, I just wanted to thank you for the work you do with this project! 🙇

EDIT: I ended up going back to using it as an alsa service because I want to use D-Bus for play controls. 😜

EDIT 2: Ugh, although D-Bus control is nice I ran into trouble with audio in other apps when using alsa via service, so back to pa… 🤷🏻‍♂

imabuddha commented 3 years ago

Further raspi specific suggestion:

Since the OS now uses pulseaudio shairport-sync often doesn't work after logout/login. To remedy this I created this simple script that will automatically kill it on logout if added to the lightdm.conf file:

https://gist.github.com/imabuddha/85d90acd71c155f08949764cd2cbef68

#!/bin/bash
# This script is for Raspberry pi os (current as of 7 Dec 2020)
# Make sure shairport-sync is terminated on logout
# (with pulseaudio backend can't run shairport-sync as service)
#
# Suggested location for this script: /usr/local/bin/kill-shairport-sync
#
# Place the following line in /etc/lightdm/lightdm.conf [Seat:*] section:
# session-cleanup-script={LOCATION_OF_THIS_SCRIPT_FILE}

pgrep -x shairport-sync | xargs -t kill -1

I'm not good bash or linux hacker, so please let me know if this is flawed in some way or if you have suggestions to improve it. 🙇

github-actions[bot] commented 3 years ago

This issue has been inactive for 60 days so will be closed 7 days from now. To prevent this, please remove the "stale" label or post a comment.