sweisgerber / docker-snapcast

Snapcast Multiroom audio docker image
14 stars 7 forks source link

Shairport-sync errors when uncommented in snapcast config #3

Open cranky-coder opened 10 months ago

cranky-coder commented 10 months ago

I uncommented the shairport-sync so I could play with airplay but the following error occurs

docker-snapcast-snapcast-1 | 2024-01-08 15-17-19.892 [Info] (AirplayStream) (shairport[) Warning: the option -u is no longer needed and is deprecated. Debug and statistics output to STDERR is now the default. Use "--log-to-syslog" to revert. docker-snapcast-snapcast-1 | 2024-01-08 15-17-19.893 [Info] (AirplayStream) (shairport[) fatal error: --get-coverart: unknown option docker-snapcast-snapcast-1 | 2024-01-08 15-17-19.893 [Error] (ProcessStream) Error while reading from stderr: End of file docker-snapcast-snapcast-1 | 2024-01-08 15-17-20.015 [Error] (AirplayStream) Error opening metadata pipe, retrying in 500ms. Error: assign: Bad file descriptor [system:9 at /usr/include/boost/asio/detail/impl/reactive_descriptor_service.ipp:120 in function 'assign'] docker-snapcast-snapcast-1 | 2024-01-08 15-17-20.015 [Error] (AsioStream) Error during async wait: Operation canceled

It would seem that there is a metadata pipe issue. From what I have seen either compiling it without the metadata stuff or addressing the metadata pipe seems to be what the suggestions are.

sweisgerber commented 10 months ago

Hey, I rebuild the image, perhaps it has been fixed in upstream by now? I have zero experience with shairport and no apple environment at home, so I can't test anything. I can deploy fixes in the docker environment if you got some?

smplman commented 9 months ago

First off @sweisgerber, thank you for putting this together. I just learned about snapcast today and I was up and running in about an hour with your docker image. Thank you for your work on this!

I have the same error as described in the issue

2024-01-28 22-59-48.742 [Error] (AirplayStream) Error opening metadata pipe, retrying in 500ms. Error: assign: Bad file descriptor [system:9 at /usr/include/boost/asio/detail/impl/reactive_descriptor_service.ipp:120 in function 'assign']

After doing some googling I came across this issue https://github.com/badaix/snapcast/issues/672 and I can't find anything in there that doesn't line up with what is in the container.

Commands ran on the container

root@leonidas:/# which shairport-sync
/usr/bin/shairport-sync
root@leonidas:/# shairport-sync --version
4.3.2-OpenSSL-Avahi-ALSA-pa-pw-stdout-pipe-soxr-metadata-sysconfdir:/etc
root@leonidas:/# ps -ax | grep shairport-sync
    166 ?        Sl     0:01 /usr/bin/shairport-sync --name=Snapcast --output=stdout --use-stderr --get-coverart --metadata-pipename=/tmp/shairmeta.147.5000 --port=5000
root@leonidas:/# ls /tmp
shairmeta.147.5000

The only other thing I tried was trying to use shairport-sync from the path instead of /usr/bin/shairport-sync inside of snapserver.conf as follows

source = airplay://shairport-sync?name=shairport

I'm not sure if this a configuration issue or an issue with how shairport-sync is compiled. I will keep digging and if I find anything I will let you all know.

smplman commented 9 months ago

I may have found the issue. shairport-sync seems to require avahi along with debus support. I tried to add the APKs from what I found here https://github.com/mikebrady/shairport-sync-docker/blob/master/Dockerfile#L66 but since we are not building shairport-sync i'm not sure where the dbus config files should come from.

I also found this https://github.com/robotastic/trunk-recorder/issues/450#issuecomment-832369120 about trying to run avahi on the host and running the container in privileged mode. I was not able to get the avahi-daemon to run on my local Debian host so was not able to test it.

It does seem possible to get avahi running in this container, but I think it would be better if it were configurable so that people that don't want AirPlay don't have to install it.

I will continue to play around with building avahi into the container and if I can get it to work will PR some changes.

smplman commented 9 months ago

I have found the root of the issue, but I'm not sure the best way to fix it. Two things need to be done in the docker file, installing dbus and making a directory that it needs.

RUN apk add dbus
RUN mkdir -p /var/run/dbus

Once that is done there is currently nothing to start dbus and avahi-daemon. I found this https://github.com/mikebrady/shairport-sync/issues/320#issuecomment-222588108 which gave me a clue to what needs to happen next. If I sh into the container and run these commands shairpot-sync runs correctly with snapcast.

dbus-daemon --config-file=/usr/share/dbus-1/system.conf
avahi-daemon -D
kill {PID of s6-supervise svc-snapclient}

I would imagine that the sairport-sync apk would handle this automatically, but maybe avahi and dbus are optional for running standalone without snapcast.

I will keep messing with and see if I can find a good way to dockerize all of this.

sweisgerber commented 9 months ago

There's s6-overlay in those images (as they are based on linuxserver.io base images).

The service startup scipts are here: https://github.com/sweisgerber/docker-snapcast/tree/main/root/etc/s6-overlay/s6-rc.d There are already 2 services (snapclient & server), which you could use as an example.