Snapcast: snapserver fifo and pulseaudio

Created on 22 Apr 2016  路  8Comments  路  Source: badaix/snapcast

I had some issues getting pulseaudio working with the snapserver. I tried following the indications from #2 and put "load-module module-pipe-sink file=/tmp/snapfifo" in by default.pa to have the sink in place automatically at ever boot, but it would fail.

The problem is that when module-pipe-sink is called, it tries to create the fifo (using mkfifo), and since it already exists because snapserver created it, it fails and doesn't load the module

As a workaround,I added some scripts to snapserver.service.

For ExecStartPost : I call a script that does "rm -f /tmp/snapfifo" and restart the pulseaudio daemon
For ExecStopPost: I call a script that does "rm -f /tmp/snapfifo"

I hope this can help someone else!

P.S. I am using pulseaudio to act as a bluetooth A2DP receiver, which now allows me to use snapcast as a whole-home bluetooth system :)

Most helpful comment

organization of streams via JSON-RPC (like adding, removing, renaming) is on the roadmap.
Maybe I will add the pipe creation mode as an optional query part to the pipe's URI.
Something like: -s pipe:///tmp/snapfifo?mode=[read|create]

All 8 comments

would it help if the Snapserver would have a "not create pipe" mode, where the server waits until someone creates the file?
=> Pulseaudio would create the pipe, but would it work after reboot? Wouldn't the pipe still be there?

Allowing a "not create pipe" mode would most likely solve my issue. It might even be useful in scenarios where we would want to change the source of snapserver to read different pipes to read different streams dynamically. Could be something nice to expose through the REST service calls.

I assume that pulseaudio would remove the pipe when it unloads the module on shutdown. If it isn't, then it's a pulseaudio bug.

organization of streams via JSON-RPC (like adding, removing, renaming) is on the roadmap.
Maybe I will add the pipe creation mode as an optional query part to the pipe's URI.
Something like: -s pipe:///tmp/snapfifo?mode=[read|create]

It's now configurable in the develop branch (86b34af0c6ac7e04cb413d0d6017f08b46578759). If you want to test it before the release (ETA during the weekend):
"read mode" (not create the fifo):

-s "pipe:///tmp/snapfifo?mode=read"

"create mode" (create the fifo if not exists):

-s "pipe:///tmp/snapfifo?mode=create"

Current default (if unconfigured) is create, i.e. behaves as before. This might change to read in future releases. The read mode already seems to work well with mpd. When I stop mpd, mpd removes the fifo and the Snapserver keeps trying to open the fifo until mpd is restarted.

It's now released in the v0.7.0. You can configure it as described in my last post.

Works great! Thanks a lot!

@pbros you mentioned that you use pulseaudio for A2DP to snapcast. Would you be so kind and tell us how to do so? Thanks in advance.

If you need I can go dig out the config, but essentially I setup my ubuntu 16.04 laptop as A2DP receiver. Then, instead of the laptop's speakers, I configured pulseaudio to output everything into a pipe, which I then configured as an input in snapserver.

Was this page helpful?
0 / 5 - 0 ratings