mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 00:05:55 +03:00
[GH-ISSUE #812] alsa dmixer device breaks librespot #414
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#414
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 @Mitschmaster on GitHub (Jun 25, 2021).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/812
Originally assigned to: @JasonLG1979 on GitHub.
I have configured a mixer device via asound.conf to allow multiple programs to play audio simultanially through my raspberry equipped with a optical audio out hat. that used to work fine but recently i did a git pull and rebuild librespot. now i get the following error when playing something via librespot:
librespot_playback::player] Fatal error, could not start audio sink: AlsaSink Hardware Parameters Error, ALSA function 'snd_pcm_hw_params_set_periods' failed with error 'EINVAL: Invalid argument'
when i remove the dmixer plugin it works fine. i dont know what commit i was on when it worked. it was something in january or febuary i think.
thanks for help
@roderickvd commented on GitHub (Jun 25, 2021):
@JasonLG1979 could you take a look at this, it might have been introduced by #789.
@JasonLG1979 commented on GitHub (Jun 25, 2021):
@Mitschmaster What does your
asound.conflook like?That function really should not fail. We ask for a buffer with 4 periods, worse case it should set it the closest thing to 4 or in the case of
dmixwhatever you havedmixconfigured to as far as the buffer setting. I can't reproduce on real hardware or going thoughdmixeither though the default or with a customasound.confCould you also provide the output of
aplay -Dhw:x,x --dump-hw-params /usr/share/sounds/alsa/Front_Right.wavWherehw:x,xis the actual device you're trying to use. It will probability throw an error but it will give us the device's capabilities.@JasonLG1979 commented on GitHub (Jun 25, 2021):
@Mitschmaster Well I guess I can reproduce if I set the periods to under 4 in
dmix. I'm pretty sure I know how to fix it. I'll be back with a test branch and if it works for you I'll put in a PR.@JasonLG1979 commented on GitHub (Jun 25, 2021):
Still curious what your
asound.conflooks like though.@JasonLG1979 commented on GitHub (Jun 25, 2021):
@Mitschmaster try this branch I'm pretty sure it will fix the issue. If it does I will put in a PR and I'm sure @roderickvd will merge it pretty quickly.
@JasonLG1979 commented on GitHub (Jun 25, 2021):
@roderickvd I'm going to go ahead and put in a PR. I tested this by setting a ridiculously small buffer as far as period time and period count and were it crashed before, with that very small change in that branch it does not.
I think my mistake was explicitly asking for 4 periods and assuming people would not do weird things in their
asound.conf,lol!!!@Mitschmaster commented on GitHub (Jun 25, 2021):
The fix from @JasonLG1979 works for me. Thank you very much.
Besides, my asound.conf is not that weird. i just have a dmixer plugin. i dont even set buffer sizes or so. (maybe i should)
@JasonLG1979 commented on GitHub (Jun 25, 2021):
Strange that it would set the period size/count to be less than 4 by default? That seems broken to me.
If it ain't broke don't fix it.
But generally the safe norm is around 4 125ms periods for a total buffer size of around 500ms. A really small buffer will hammer your CPU and really huge buffer will lead to a noticeable delay between pausing and unpausing and manually changing tracks because the PCM has to play out what's in it's buffer before it can do what you actually want it to.
If you notice underruns, distortion or glitches I'd up the period count until it goes away. But I'd keep the buffer under 1000ms otherwise you'll notice that delay I was talking about.
@JasonLG1979 commented on GitHub (Jun 25, 2021):
There's your problem. If you don't specify any buffer setting I'm pretty sure it defaults to the device's min.
@roderickvd commented on GitHub (Jun 25, 2021):
I've done nothing with my dmix and it gives me a period size of 1024 and buffer size of 16384 regardless of your PR.
@JasonLG1979 commented on GitHub (Jun 25, 2021):
See the above comment.
@JasonLG1979 commented on GitHub (Jun 25, 2021):
So it did not change since the PR or not?
@roderickvd commented on GitHub (Jun 25, 2021):
That's right it was working before, and is working after, with no effect on the period and buffer sizes. But see my other comment over at the PR because it does do something to the sizes for
hwandplughw.@JasonLG1979 commented on GitHub (Jun 26, 2021):
@Mitschmaster I forgot to say thank you for shaking that bug out.
@Mitschmaster commented on GitHub (Jun 30, 2021):
Thanks for fixing it.