airsonic-advanced / airsonic-advanced

GNU General Public License v3.0
1.24k stars 131 forks source link

Enhancement / idea : integration into mpd / snapcast multiroom protocol #645

Open johann1525 opened 2 years ago

johann1525 commented 2 years ago

Hi, i just wanted to bring in the idea of adding an option for an additional audio output method. I see the jukebox mode is a kind of good thing for solving these one device scenarios on RPIs. But there is the limitation of "one possible jukebox per instance" as far as i am aware of. (Could be wrong here). There are also other implications with the current implementation like the need for special permissions in docker environments. Plus most Servers are not located in living rooms nowadays i think. So i think this feature is currently kind of specific and not really usable by a lot of users.

To solve this I'd love to have another player type. which just streams the audio raw via tcp/udp rtp and maybe even do multicast if someone is into that. This would solve the issue of a single possible jukebox. You could create separate players for each room for example. Or just stream a couple of them directly to a Snapcast https://github.com/badaix/snapcast instance to do the Multiroom stuff in a way more cool way.

Another solution would be to let an instance of MPD do the playback of ths player type. Controlling MPD via Airsonic would be easier i think. MPD can handle playlists on its own and can be controlled via tcp so multi user awareness would not be an issue. Each user who selects this player in the web interface just would see the playlist and status of the connected MPD instance. There can be multiple MPD instances on one server and outputs can also be more flexible.

And for those using bare metal sound cards it would be possible to just put that stream into pulseaudio to get a nice local output.

I tried to get a udp stream by just adding a special transcoding line for my udp player. The Airsonic player type was left on "Web Player" mode for this (i was hoping controls would maybe work without a audio stream). Unfortunately Airsonic is not stopping old transcoding processes before creating new ones. Especially with real time decoding. So i ended up with a mess after skipping a track instead of waiting for it to play through. Another problem with this method is that it is not multi user aware. So if another user is also selecting this player he can start another stream in parallel. Player controls are of course also not working with this setup (You have to kill some processes or wait to stop it playing ^^).

beankylla commented 2 years ago

yeah would be reallly awesome :)

masterblaster79 commented 1 year ago

I am runing airsonic-advanced in an LXC container and I am using snapcast via alsa:

# cat /etc/asound.conf 
pcm.!default {
    type plug
    slave {
        pcm rate48000Hz # Direct default output to the below converter
    }
}

pcm.rate48000Hz {
     type rate
     slave {
          pcm writeFile # Direct to the plugin which will write to a file
          format S16_LE
          rate 48000
     }
}

pcm.writeFile {
    type file
    slave.pcm null
    #file "/tmp/snapfifo"
    file "/var/snapfifo/snapfifo"
    format "raw"
}