-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pulse audio issue when running Snapclient as a service with systemd #810
Comments
The error is in the log, it's related to pulseaudio. You also said in your other issue (which you could have just reopened?) that the difference between this non-working setup and a previous working setup was the use of Pi OS full desktop, which uses pulseaudio.
Isn't this another instance of #779? |
Thanks for your reply! I have read the info in that bracnch. Before the finall step it seemed exactly my case - all the errors were reproduced step by step. But, when I made the changes marked as a solution in that case:
, everything stopped working completely. Describe it step by step:
I have tried to indicate the ip of the computer where it is all installed and PulseServer too explicitelly: 192.168.1.247 - same result When I try to tell --player pulse, I get this error:
Do you know why this might be happening? Thank you in advance for any help. UPD: I have checked if PulseAudio server starts when I indicate the default server IP and it does not. Am I missing something? |
You want
Also, when running things as a system service they often run as a different user compared to when you run them normally in a terminal. You can see the snapclient service file runs as user
And then restart the machine to ensure it takes effect. |
Thanks for the reply! I did as you suggested but with no result:
when checking the server status
This thing does not start when I make changes to client.conf I suggest... Why? Is there anything else I am missing? Thanks a alot for helping me with this! |
I wounder why if the command: pi@raspberrypi:~ $ snapclient -i 3 --player pulse runs the snapclient ok, the command: pi@raspberrypi:~ $ sudo -u pi snapclient -i 3 --player pulse leads to this: isn't that the command which is OK ran from the user 'pi'? So calling 'sudo -u pi' should do no difference, shouldn't it? |
That's a user service.... Not sure that is interesting.
When using Try running this instead to make the server IP explicit:
|
Thanks for your reply.
What do you think it might be? Thanks for your time and advise! |
UPD: it did work till first reboot only. Now, after the reboot, the pulseaudio server is inactive and give me this error on restart attempt:
|
Alsa dmix plugin allows multiple sources at the same time. It just works |
UPD 2: This one does not work either. The PulseAudio does not start now. I cannot make it running. What could happened to it? I commented back those two lines but it does not help... pi@raspberrypi:~ $ sudo -u snapclient snapclient --player pulse:server=127.0.0.1 |
It would also be better if you just post in one place. Cross posting all this different info in two places is really confusing. |
@gribouk your original issue was not at all about PulseAudio, it was about starting multiple instances of Snapclient, and you were putting your command line options to the |
P.S. I still did not manage to make pulseaudio working - I guess that none has doubts by this moment that it is a pure pulse server issue, not service file syntax... The recepee provided #779 for some reason does not work for me. But I keep digging - searching the forums, using your product with ALSA meanwhile - and it works great, you've done a exelent job! I am not expecting to have you as a tech support in no way, understanding that the product is free. As an idea, maybe it worth composing some kind of a 'Dummy Q & A" for beginners like me to search for the obvious answeers there (like pulse audio) - just an idea (thogh discussions are fine too, from the other side)... Though I understand that you cannot afford waisting your time on that, maybe someone from the community would do that for the future generations... |
As I was explained at one of the branches, dmix would not work with bluealsa, so I will not be able to stream multiple streams to BT speakers using that. But this time I would like to thank you for your valuable directions which were pretty helpfull and share the results of my investigation:
I took very strict approach to determining if it is a problem with me, or PiOS/pulseaudio config. The sequence of my actions:
I've done the procedure several times to make sure that it is not me adding something which effects the resut. I also tried skiping step 5 to se how it works without intervention into pulseaudio config - same result. So, what I did was to make it run in the system mode using this manual: And yet I do not understand how that case you directed me to initially was solved with "default-server=127.0.0.1" replacement only... I wanted to ask your oppinion if you would regard running in a system mode acceptible (this is single user machine - pi, only boot and play sond), because pulseaudio developers strongly opposed doing this... And one more thing I have forgotten to mention: --player=pulse stil not working, only player=alsa. Is it an isseu or I am missing something again? Thanks for your replies! |
If you're running an audio application as a root system service, then the pulseadio server has to run as a system service which is fine for a single-use device. If you want to run pulseaudio as a user, then you have to run the audio applications as that user as well. And that user probably has to be in the "audio" group or whatever the equivalent is for your OS. |
Pulseaudio have kindly documented what's wrong with running it in system mode: https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/ Anyway, I had a go with the latest RPi OS and found the same:
This would now work OK if you always logged onto the system before trying to actually use snapclient. But, if you've got some kind of headless setup we now run into a load of problems because Pulseaudio runs as a user service. Firstly it means that it doesn't start automatically. I think this is because it wants to use its 'autospawn' feature to start on demand by programs running as the same user. Technically I think we can force it start automatically with
And you need to do a manual
I don't know you are supposed to get around this, short of also running snapclient as a user service or running pulseaudio as root (horrible). Pulseaudio is a bit of a mess for headless audio players like snapcast and Mopidy. I'm going to stick to the lite image and hope it stays the way it is... |
@kingosticks from the page you linked (emphasis added)
Running snapclient on a raspberry pi is exactly such an embedded client; in that case it's likely best to run pulseaudio in system mode. |
Thanks! I'll keep in mind if I try to run it in a system mode again. The problem with it was that in a system mode a pulse audio sound quality collapsed (noise, cracks, frequency cuts and ect) and a BT fell off (the primary reason I was attempting to run pulse - to mix sounds before sending these to a BT speaker). So, I solved the issue from the other end without using a BT of a RPi itself, but through a line output, which is later sent to a BT speacker(s) (in some rooms I have up to 4 BT speakers synchronised), and ALSA with its stable sound quality is just enough in this case - works wonderfull... |
Yeah, pulseaudio is really designed for a single-user linux desktop running gnome + dbus + systemd where the active user is always logged in and you want to control everything with GUIs; anything else is not really very well supported. |
Raspberry Pi OS desktop image is exactly a desktop system. The lite image you can get away with pretending it's an embedded system but that's not even using pulseaudio so who cares. If you've got a reliable working recipe for the desktop image running snapclient as a system service please share. |
@gribouk I'm using RPi4 for watching movies through Kodi and also as a snapclient & server. Because of Kodi I had to use Pulseaudio to share the ALSA device. It works fine in system mode without any cracks or anything, i'm using 24bit/96khz everywhere (HiFIBerry DAC). The only problem I have is that sometimes when I start playback the sound from the local snapclient gets garbled, in this case it's enough to restart snapclient, so probably it still has some bugs... |
As mentioned in the discussion above, you're not using it in a "headless mode" (for the reason you use Kodi), whereas all the issue is addressed to the headless mode... |
@gribouk What do you mean by headless? If that's the lack of X-server then it's headless.
In the end nobody's logged in the system and it's the lite image without any desktop crap. |
Oh, now I see what you mean. Had to read this thrice... When I tried to start in a system mode, the sound quality noticeably droped. And this issue is met in the internet when I tried to google for a solution. But the biggest challenge was with a BT - it has gone, and a simple solution to get it back was not found. Actually, even if I would have turened it on again into a pulse audio scope, I would not use it anyway because of the codec - RPi does not support Aptx-LL, and not BT speaker does, I would have to use BT transmitters and recievers to buid a network of speakers as I do now anyway... |
@gribouk What's the problem with the BT? It's working for me fine, my kid is watching movies in BT headphones. Pulseaudio switches the sound from speakers to the BT automatically when the headphones connect and back when they are powered off. As for AptX and friends - I've built these modules https://github.com/EHfive/pulseaudio-modules-bt and now Pulseaudio works with LDAC/AptX/etc. Not sure about AptX LL, but anyway it's better than stupid SBC.
I haven't noticed any difference between playing from snapclient directly to ALSA or through Pulseaudio (in system mode)... |
Aha, so that's what we have the community for... The story of ̷m̷y̷ ̷l̷i̷f̷e̷ mine as it was described in the topic above:
So, quoting other participants on the branch, if you have a recipe how to make pulse audio work stable in a system mode - please share keeping as many details as possible in your manual, I would highly appreciate this, and others, I believe, as well. Resembling to the codec notice - I was kind of surprised that one can install free software to benefit from the use of a commercial codec, namely AptX, knowing that every device manufacturer is charged for using that one on device basis - 1$ per device, plus entrance fee (not willing to go deep into reasoning about legal grounds of that, maybe my info is not up to the date...). But, if you do not have AptX LL, which I did not notice in the supported codecs list, basically you do not have much difference with SBC. LL stands for Low Latency - they promise the sound would fall behind a source by no more than 40ms (less is possible), while for AptX this number is 5+ times bigger and nearly equals the one for SBC. In practice this means you will never get stable synchronized sound coming from several BT speakers without AptX LL codec, and my application is exactly that case. I like to have 2-4 speakers per room at home and introduction of arbitrary delays relative to a sound source leads to an echo effect... Even if there was an extension for PiOs to add AptX LL to a profile it would not change anything, as I mentioned earlier, since I found no BT speaker on the market supporting AptX LL - you need Apx LL receiver anyway for every speaker. So, I solved the puzzle through Transmitter --> multiple Recievers via AptX LL schema, and Aux input from my RPi as a sound source - ALSA is just fine for that. That’s in brief what was wrong with BT and system mode… |
Well, my environment is like this:
I'm using BT for two things:
So in this case I'm not much worried about BT latency as I'm not using it as an output for Snapclient. For input of audio from BT aptX works fine, there are sometimes some sound issues with BT input which i've not yet tracked, but since I don't use smartphone much as a sound source I didn't bother a lot. From my perspective using Raspberry Zero W + HiFiBerry Zero (combined cost around 30$) as a Snapclient node with SnapOS installed is much better than the complicated scheme with BT transcievers... As for system-mode Pulseaudio I'll just list the configs that I use. This way it's currently working fine. Sometimes (once in a few days) Snapclient starts to produce garbled sound - this is solved by its restart. Not sure what's the cause here, probably some interoperability with Pulseaudio, needs investigation. /etc/pulse/daemon.conf
/etc/pulse/system.pa
/etc/systemd/system/pulseaudio.service
/etc/default/snapclient
/etc/snapserver.conf
|
Since I was going through the whole discussion, thought that you might be interested in finding out out how I managed to run PulseAudio in user mode and also run an application in user mode. These are just steps for running the already developed app. Some of these steps would eventually end up the application installation script as per developers response to me. Hoping that you can pick up something to solve your problem: |
I think you should use two environment files, but I'm not an expert in systemd. But this is not a snapcast issue
Originally posted by @badaix in #809 (comment)
It feels like it is somehow related to a snapclient. After some investigation, I decided not to launch multiple instances of snapclient and test single one. It turns out, that when the device is set to default one, snapclient is unable to connect to a server, below is the log for that:
As you can see, the error originates from a snapclient. Why?
When the device is not default, the error does not appear.
The text was updated successfully, but these errors were encountered: