librespot-org / librespot

Open Source Spotify client library
MIT License
4.7k stars 573 forks source link

I'm having troubles running Librespot to a FIFO pipe in a LXC container #1120

Closed kujac closed 1 year ago

kujac commented 1 year ago

Describe the bug Dear people,

Until now I was running LibreSpot and Scapcast (snapserver) on a raspberry 4.

Since I'm moving to proxmox (on a regular X86/AMD64 computer), I'm installing a Libresot + Snapcast dedicated Debain 11 LXC container. What I did is that I copyed all the conf and services files from the raspberry to the Debian container.

But I'm facing an issue, here is what happens when I try to play a song to LibreSpot :

Here is how librespot is executed (as root, as you can see) : root@snap:~# /usr/bin/librespot -v -H -n MultiRoom -N -b 320 --initial-volume 100 --backend pipe --device /tmp/snapfifo

And here is the / my failure :

[2023-02-12T19:32:59Z INFO  librespot] librespot 0.4.2 62f750a (Built on 2023-02-08, Build ID: g8qRyDOp, Profile: release)
[2023-02-12T19:32:59Z TRACE librespot] Command line argument(s):
[2023-02-12T19:32:59Z TRACE librespot]      v
[2023-02-12T19:32:59Z TRACE librespot]      H
[2023-02-12T19:32:59Z TRACE librespot]      n "MultiRoom"
[2023-02-12T19:32:59Z TRACE librespot]      N
[2023-02-12T19:32:59Z TRACE librespot]      b "320"
[2023-02-12T19:32:59Z TRACE librespot]      initial-volume "100"
[2023-02-12T19:32:59Z TRACE librespot]      backend "pipe"
[2023-02-12T19:32:59Z TRACE librespot]      device "/tmp/snapfifo"
[2023-02-12T19:32:59Z DEBUG librespot_discovery::server] Zeroconf server listening on 0.0.0.0:41973
[2023-02-12T19:32:59Z DEBUG librespot_discovery::server] Shutting down discovery server
[2023-02-12T19:33:04Z DEBUG librespot_discovery::server] POST "/" {}
[2023-02-12T19:33:04Z WARN  librespot_core::apresolve] Ignoring blacklisted access point ap-gew4.spotify.com:80
[2023-02-12T19:33:04Z INFO  librespot_core::session] Connecting to AP "ap-gew1.spotify.com:4070"
[2023-02-12T19:33:04Z INFO  librespot_core::session] Authenticated as "1114485622" !
[2023-02-12T19:33:04Z DEBUG librespot_core::session] new Session[0]
[2023-02-12T19:33:04Z INFO  librespot_playback::mixer::softmixer] Mixing with softvol and volume control: Log(60.0)
[2023-02-12T19:33:04Z DEBUG librespot_playback::player] Normalisation Type: Auto
[2023-02-12T19:33:04Z DEBUG librespot_playback::player] Normalisation Pregain: 0.0 dB
[2023-02-12T19:33:04Z DEBUG librespot_playback::player] Normalisation Threshold: -2.0 dBFS
[2023-02-12T19:33:04Z DEBUG librespot_playback::player] Normalisation Method: Dynamic
[2023-02-12T19:33:04Z DEBUG librespot_playback::player] Normalisation Attack: 5 ms
[2023-02-12T19:33:04Z DEBUG librespot_playback::player] Normalisation Release: 100 ms
[2023-02-12T19:33:04Z DEBUG librespot_playback::player] Normalisation Knee: 5 dB
[2023-02-12T19:33:04Z DEBUG librespot_connect::spirc] new Spirc[0]
[2023-02-12T19:33:04Z DEBUG librespot_connect::spirc] canonical_username: 1114485622
[2023-02-12T19:33:04Z DEBUG librespot::component] new MercuryManager
[2023-02-12T19:33:04Z DEBUG librespot_core::session] Session[0] strong=3 weak=2
[2023-02-12T19:33:04Z INFO  librespot_core::session] Country: "FR"
[2023-02-12T19:33:04Z DEBUG librespot_playback::player] new Player[0]
[2023-02-12T19:33:04Z INFO  librespot_playback::convert] Converting with ditherer: tpdf
[2023-02-12T19:33:04Z INFO  librespot_playback::audio_backend::pipe] Using StdoutSink (pipe) with format: S16
[2023-02-12T19:33:04Z DEBUG librespot_playback::player] command=AddEventSender
[2023-02-12T19:33:04Z DEBUG librespot_playback::player] command=VolumeSet(65535)
[2023-02-12T19:33:04Z DEBUG librespot_core::mercury] subscribed uri=hm://remote/user/1114485622/ count=0
[2023-02-12T19:33:04Z DEBUG librespot_connect::spirc] kMessageTypeNotify "CEOL" de3b1b4e234c400475d9fd3b0ebf464351e93c17 1193139741 1676230384401 kPlayStatusStop
[2023-02-12T19:33:04Z DEBUG librespot_connect::spirc] kMessageTypeNotify "iphone18 (2)" c9c85ee5df4c7ed4046fd82a71a19833b7b371d7 1193139741 1676230384401 kPlayStatusPlay
[2023-02-12T19:33:04Z DEBUG librespot_connect::spirc] kMessageTypeNotify "CEOL" de3b1b4e234c400475d9fd3b0ebf464351e93c17 1193139779 1676230384439 kPlayStatusStop
[2023-02-12T19:33:04Z DEBUG librespot_connect::spirc] kMessageTypeLoad "iphone18 (2)" c9c85ee5df4c7ed4046fd82a71a19833b7b371d7 1193139882 1676230384439 kPlayStatusPlay
[2023-02-12T19:33:04Z DEBUG librespot_connect::spirc] State: context_uri: "spotify:album:0mf2hphtGvSxnOit7Uy2aB" index: 0 position_ms: 23748 status: kPlayStatusPlay position_measured_at: 1676230384625 context_description: "" shuffle: false repeat: false playing_from_fallback: true row: 0 playing_track_index: 0 track {gid: "\222\0360\034\037qNa\201c\377\331X\373\370\356"} track {gid: "\305\223\"\300h\032DL\256\335\003\210v\374\365r"} track {gid: "\376\341@/\013+I\230\211\025\320I\034,\362_"} track {gid: "\3353\211\021\224[J\376\274u\3143H\017eq"} track {gid: "\207\334c#RjJW\257\n.\350N\307jV"} track {gid: "\230\025\243\022\222xH\t\261-\244\326\335\267j\307"}
[2023-02-12T19:33:04Z DEBUG librespot_connect::spirc] Frame has 6 tracks
[2023-02-12T19:33:04Z TRACE librespot_connect::spirc] Sending status to server: [kPlayStatusPlay]
[2023-02-12T19:33:04Z DEBUG librespot_playback::player] command=SetAutoNormaliseAsAlbum(true)
[2023-02-12T19:33:04Z DEBUG librespot_playback::player] command=Load(SpotifyId { id: 194224032074134302017715113950015387886, audio_type: Track }, true, 23748)
[2023-02-12T19:33:04Z TRACE librespot_connect::spirc] Sending status to server: [kPlayStatusPlay]
[2023-02-12T19:33:04Z INFO  librespot_playback::player] Loading <Desire> with Spotify URI <spotify:track:4rIFTfdZCRMoTFCp1P6Zoa>
[2023-02-12T19:33:04Z DEBUG librespot_audio::fetch] Downloading file 64a78986fa2a1dac4604101faf3158a769fba006
[2023-02-12T19:33:04Z DEBUG librespot::component] new ChannelManager
[2023-02-12T19:33:04Z DEBUG librespot::component] new AudioKeyManager
[2023-02-12T19:33:04Z DEBUG librespot_core::mercury] unknown subscription uri=social-connect/v2/session_update
[2023-02-12T19:33:04Z DEBUG librespot_core::mercury] unknown subscription uri=social-connect/v2/session_update
[2023-02-12T19:33:04Z INFO  librespot_playback::player] <Desire> (276909 ms) loaded
[2023-02-12T19:33:04Z DEBUG librespot_playback::player] Normalisation Data: NormalisationData { track_gain_db: -6.654156684875488, track_peak: 0.9684967994689941, album_gain_db: -8.772980690002441, album_peak: 0.9776675701141357 }
[2023-02-12T19:33:04Z DEBUG librespot_playback::player] Calculated Normalisation Factor for Album: 36.42%
[2023-02-12T19:33:04Z TRACE librespot_playback::player] == Starting sink ==
[2023-02-12T19:33:04Z ERROR librespot_playback::player] Audio Sink Error Connection Refused: <StdoutSink> File Path /tmp/snapfifo Can Not be Opened and/or Created, Permission denied (os error 13)

I'm pretty sure this looks like a container related issue, but since I'm a bit of a newbie in the proxmox AND fifo and sound on Linux in general, well I'm trying here first.

Thanks for your kind help.

conejero commented 1 year ago

Hello kujac. I run into a similiar issue. Just in case anyone ends up here looking for an answer. I solved my issue by ensuring fifo was not protected.

$> sysctl -a | grep -i protected fs.protected_fifos = 0 fs.protected_hardlinks = 1 fs.protected_regular = 2 fs.protected_symlinks = 1

In my case, I had to change it in /usr/lib/sysctl.d/protect-links.conf on a rasbian

kingosticks commented 1 year ago

Super, thanks for the update. Hopefully @kujac can confirm and close this issue. This isn't a bug in librespot, if still having problems we can create a new GitHub discussion for running on containers.