mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 00:05:55 +03:00
[GH-ISSUE #523] Playback crashes when switching users and specifying --device #336
Labels
No labels
A-Alsa
SpotifyAPI
Tokio 1.0
audio
bug
can't reproduce
compilation
dependencies
duplicate
enhancement
good first issue
help wanted
high priority
imported
imported
invalid
new api
pull-request
question
reverse engineering
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot#336
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @benblasco on GitHub (Sep 17, 2020).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/523
Description
Running librespot with the following command:
ENTRYPOINT /root/.cargo/bin/librespot --name="NUC LibreSpot Speaker" --bitrate=320 --zeroconf-port=49999 --device="hdmi:CARD=PCH,DEV=0" --initial-volume=75 -vSteps to reproduce:
No output sink matching 'hdmi:CARD=PCH,DEV=0' found.The problem does not occur if I don't specify the output device with the --device flag, and users can "hijack" each other with no problem. However not specifying --device means sound output is through the device's headphone jack, which is not what I want.
Questions that will contribute to identifying the issue:
Logs attached below:
librespot_log_working.txt
librespot_log_crashing.txt
Please let me know if there's any additional info I can provide as I do not want to waste anybody's time. I would also be more than happy to contribute to the community with documentation updates etc. so I can play my part!
@benblasco commented on GitHub (Sep 17, 2020):
For additional reference, I am running librespot in a self-built container based on a minimal Fedora 32 image, and am running it with podman rather than Docker. I am also happy to contribute a how-to on this to the community!
@JasonLG1979 commented on GitHub (Sep 17, 2020):
It will use the system's default device. Which in your case I guess is the headphone jack. If I had to guess it has to do with not properly releasing the sink. The default device works fine I'm guessing because it's routed though ALSA's software mixer, Dmix. Specifying a device directly doesn't go though any sort of mixer so basically it takes total control of the device. Nothing else can open the device. Something is going sideways when you're changing users/accounts.
You can try changing the default device by editing
/etc/asound.confand see if that helps. In your case I think your best best is to just tell Dmix to use your HDMI port as your default device and not use the raw device.Use the output of
aplay -lto find your device.Here is an example output from one of my Pi Zero's with a USB DAC connected to it.
If I want ALSA/Dmix to use the DAC as the default device I would add this to
/etc/asound.conf:Dmix also resamples everything to 48 kHz by default. If you'd like to avoid unnecessary resampling you can add is:
@JasonLG1979 commented on GitHub (Sep 17, 2020):
If you need to dig deeper to specify a device and/or subdevice
/etc/asound.confwould look something like this:That should get you 16 bit 44.1 kHz output with software mixing and software volume on whatever you configure
pcm.rawdeviceandpcm.softvol.controlto be.@JasonLG1979 commented on GitHub (Sep 17, 2020):
If you're having trouble matching
hdmi:CARD=PCH,DEV=0to:You can use the output of
cat /proc/asound/card*/pcm*/sub*/hw_paramswhile listening to some music with librespot with--device="hdmi:CARD=PCH,DEV=0"The output should be the same order asaplay -l,hdmi:CARD=PCH,DEV=0should be the device that's not closed.@benblasco commented on GitHub (Sep 18, 2020):
Hi @JasonLG1979,
Firstly, thank you for taking the time to send such a detailed reply. I really appreciate it! Let me address some of what you have said in the messages...
So I don't actually know which backend librespot uses by default. That's one thing that I need to dig into further, and perhaps update the documentation. However I think you have hit the nail on the head in saying that in specifying the device directly, I am taking direct control of the device. However I still think that librespot is doing something incorrectly in trying to access the device a second time rather than cleaning up after itself when the second user takes over the connection.
Yep, this is my next step, and I will report back on the results. The initial problem is that my asound.conf is currently empty! This could get tricky. Updates to come...
@JasonLG1979 commented on GitHub (Sep 18, 2020):
@eraser215
This says that Rodio is the default backend. For a headless Linux system I'd just use the alsa backend and talk directly to ALSA instead of though some abstraction layer. Backends are compile time options. So you may not have the alsa backend. I'm not sure with what options the binary you're using was compiled with? You can find out really quick by running librespot with
--backend alsa.That's kinda what it looks like to me to but I'm not an expert in ALSA nor Rust so I can't say for sure.
@ashthespy commented on GitHub (Sep 18, 2020):
Looking at your logs, you are on
rodioYou could also use the the
--backend ?flag to list what backends are available.@JasonLG1979 commented on GitHub (Sep 18, 2020):
That don't work for me at least with the version complied from raspotify, neither does
-h. Both just throwerror: Required option 'name' missingand gives a list of the options.@JasonLG1979 commented on GitHub (Sep 18, 2020):
My guess is the binary is complied without debugging maybe?
@JasonLG1979 commented on GitHub (Sep 18, 2020):
Nope. Apparently your command line args are messed up to get the expected result I have to do
librespot -n dummy --backend ?Then I get:
@JasonLG1979 commented on GitHub (Sep 18, 2020):
IMHO you shouldn't have to pass a name if you're using ?.
@JasonLG1979 commented on GitHub (Sep 18, 2020):
I don't know Rust but this seems to imply that name is a required argument, the only required argument in fact. It should probably be turned into a soft requirement and parsed after the args that take a ?. Meaning when you hit a ? you break and output whatever and you don't care about name but if you don't and there's no name you fail.
@roderickvd commented on GitHub (Jun 14, 2021):
Closing this after no further replies. Feel free to reopen if this still an issue with
librespotand not your configuration. Principally connecting from different users and switching between them works fine onlibrespot.