Hi
How do I get snapclient to work with multiple audio devices (on the same pc) that have different capabilties?
I had an issue with snapclient that it was not able to play with the default soundcard because I am guessing it was an sampling format issue
"Exception in Controller::worker(): Can't open default:CARD=PCH PCM device: Device or resource busy"
Now I do not want to decrease the default sampling but I need to change the default format for the internal audio(that has the issue)
So how do I make snapclient to use multiple hardwares? I would like it to output multiple devices at once on the same pc.
The sound is sent from Mpd.
thanks
Hi
It would be great if I could get some feedback on it.
Basically my issue is thi. I have a usb soundcard, and I am only able to send audio to the default duplex mode. But I need to send audio to its 4.1 surround mode so that I can get sound from the additional speakers. I try looking at the alsamixer and get the devices but I cant seem to be able to achieve anyuthing with the snapclient on Debian with this issue.
"Device busy" sounds like your device is used by sth else (pulseaudio?).
You can route sound around as you wish by creating an asoundrc configuration file.
I guess it's best to search for examples on google. I remember the official alsa documentation as rather hard to understand.
@fuchsmich
I can list my devices with aplay -L etc but I do not know how to use them with -s on the client :( I can play on -s=1 and that is pretty much it.
How do I use other subdevices etc with the snap client?
My usb sound card has additional ports attached, -s=1 only plays the default outputs on it but I need the 5.1 surround output. And alsa documentation is harder to grasp :(
Here is aplay -L
What does snapclient -l show?
@fuchsmich
I am guessing you meant snapclient -l (Debian) ?
You can see now, which index corresponds to each device.
Did you try some of them?
I actually tried all of them, I can only get sound from "1" :( I am not sure that is why I am not exactly sure about formatting maybe I am not using it properly.
These hardware work fine in Pulseaudio, I can even stream simultaneously to Sb51 and Hdmi no problem.
Once again: only one client at a time can access the hardware through alsa. This seems to be pulse in your case.
One solution is to route snapclient ouput to a pulseaudio sink.
@fuchsmich
Ok that makes sense. How could I achieve routing the snapclient to pulse?
I tried setting the pulse sink, but I get module load errror. So not sure. Even if I create a sink for pulseaudio, how do I route the snapclient (which writes to the sound card) pulseaudio ?
thanks
Thanks I will try it.
Did you manage to get this running with pulseaudio? I would like to route the snapclient to pulseaudio too. Otherwise I either can listen to the music from snapclient or the local one (device busy). I have to manually change the pulseaudio configuration to switch between snapclient and local music sources when one has stopped playing and I would like to avoid that.
I looked into those ALSA examples from the Arch Wiki, but it does not change anything for me.
@hell-g
I looked into it but I did not understand how to do it. Basically I need a combo output for snap client which includes my usb sound with 5.1 (includes a subw) + Hdmi output which is how I listen my music but that is not possible with the alsa stuff.
Another issue I have wwith snap cast is that, it disables output for pulse if it is used once. I have to mess with pulseaudio outputs to regain control.
I looked around the web but combo output with alsa sounds a bit over complicated to me. Please share your solution if you find one.
thanks
@gerroon
OK, so it is not exactly the same we want to do, but I think for both of us the preferred solution would be to use pulseaudio. So maybe there we can work together.
In your earlier comment, you write that you can only get sound, if you set --soundcard 1. This is a bit surprising to me, as your snapclient -l says that 1 is your null device. When I use snapclient with the null device, I don't get any sound output and I think this is what it is supposed to do. Looking at your snapclient -l, it would make most sense to me, if you would use
0: default
Playback/recording through the PulseAudio sound server
Are you using a systemd service for snapclient, or do you do it manually in a terminal with the snapclient command?
I just noticed for myself, if I start snapclient in a terminal as my user (without --daemon), it works perfectly fine over pulseaudio, without any additional command line options. My pulseaudio volume control then lists it as ALSA plugin [snapclient].
If you manage to direct your audio output of snapclient to pulseaudio, maybe this part of the Arch wiki may help you:
https://wiki.archlinux.org/index.php/PulseAudio/Examples#Simultaneous_HDMI_and_analog_output
Well, I already can get simulataneous output with pulse, in fact that is how I use pulse. It pipes the sound to hdmi and ther usb sound.
As far as I understand it, snapclient deals with alsa directly not pulse which makes sense if you want no lag in the sound. So my issue is that I need to get alsa to treat the hdmi and the usb sound as a single output for the processes that pipes to alsa directly.
I am supposed to shape a .soundrc file such that it combines those devies as single alsa device but that is where I do not get how it is done. The language there is a bit cryptic to me :(
At the moment, I can only get sound from hdmi or usb sound only with regular speakers or the sub but not as combined output.What I want is to combine all those into a single sound output for snapcast.
As far as your issue goes, I think that snapclient originally never meant to deal with pulse rather directly work with alsa level. If you think about it makes sense because that way you guarantee certain level of latency and control otherwise you are at the mercy of pulse. At least that is how I understood the issue of snapcast and pulseaudio.
Based on my tests I can get a snapcast sink that shows as pulseaudio sink, so any app that can use pulseaudio will automatically play with snapcast, and the otherway around is not possible.
Btw I tried yor recommendation of using snapclient as my user without any options on the terminal and it works automagically. I have no idea. Thanks for the tip.
I was using the snapclient systemd
...because there is probably no pulseaudio server running for the user snapclient.
Don't mess with alsa AND pulseaudio. As you are already using pulseaudio on your computer, this will be the way to go.
Configure the primary sink properly (which is chosen by default by the alsa-plugin) and make sure pulseaudio is running for the user, which should run snapclient.
Said this, you can configure alsa-plugin paralell to pulseaudio (e.g. changing the default device to a different sink (as shown in the link i posted above)). This means your asoundrc should only contain entries of type pulse.
@gerroon
I am glad, that you configured your pulseaudio already for the simultaneous output to both devices. So now, if you manage to use pulseaudio with snapclient, it should work for you. I hope, this would be a good solution for you.
Thanks @fuchsmich for your comments.
I googled some more and played around. When I use snapclient as my user in a terminal, everything works as I want. Snapclient plays over the alsa-plugin in pulseaudio and I don't have to mess with the pulseaudio configuration and I can play other sounds at the same time.
But I have two problems to turn this into an easy long term solution.
systemctl --user ...). There systemd is aware of the user session of pulseaudio and I am optimistic, that this would work to direct the output of snapclient to pulseaudio and therefore play it the way I want. Here, I think, the issue is, that I can't set the PID file for snapclient in a systemd user service. Snapclient keeps trying to use /var/run/snapclient/pid, which I think fails because my user does not have the rights. I mentioned this in issue 106. I think, a systemd user service would be a good solution for this, but unfortunately, it does not work yet for me.
By the way, when I start snapclient in a command line and get the output over pulseaudio, it is in perfect sync with what I get from the snapcast Android app. So at least there, I don't see a lag problem when using pulseaudio on my system.
As I wrote in #106 you don't neew a PID file for systemd:
Here's a user Unit for snapclient: https://build.merproject.org/package/view_file/home:fooxl:sailfish/snapcast/snapclient-nofork-user.service?expand=1
Put it into /usr/lib/systemd/user/snapclient.service
@fuchsmich
Thanks! I just posted over at #106 that it worked with a similar user service file.
It seems, that with this, I can get the output over pulseaudio and I hope that @gerroon can solve his issue here in a similar way.
Yes, but change ExecStart to:
ExecStart=/usr/bin/snapclient $SNAPCLIENT_OPTS
$USER_OPTS are only needed, when -d is set (which we don't want).
@fuchsmich
I did change it to your linked user service file from above and it works fine. Thanks!!
Hey guys, thanks for the extensive investigation issue. I will try the new solution and get back to this bug.
thanks
Hi
I cant get this to work.
https://build.merproject.org/package/view_file/home:fooxl:sailfish/snapcast/snapclient-nofork-user.service?expand=1
I build the dev branch from today and put the systemd file that @fuchsmich recommended under /usr/lib/systemd/user/snapclient.service
Systemctl says that reload is not an option for snapclient. So not sure if I need to do something else to make sure the config is read.
It still uses the usb only alsa output.
I guess I can get this work with my user on the terminal but not as systemd file. Do I need to do some other thing to get this to work with systemd?
@gerroon I am sorry, that it does not work for you! Let me summarize what I did to make it work. Maybe this will help.
I do not use the dev branch, so I cannot comment on that. I use version 0.12.0.
I copied the snapclient.service file from @fuchsmich to /usr/lib/systemd/user/. While still debugging, maybe comment the line StandardOutput=null. Then it will be more obvious to see, that snapclient is actually getting the packages. You can check on it with systemctl --user status snapclient, or journalctl --user -xe.
I copied /etc/default/snapclient to ~/.config/snapclient.conf and in there, I deleted the USER_OPTS line and added --host mysnapcastserver to the SNAPCLIENT_OPTS line.
Then I start snapclient with my user in the terminal: systemctl --user start snapclient
This immediately worked for me. Maybe you have to still play around with the --soundcard option in the SNAPCLIENT_OPTS variable for you to get the right output. I would then suggest to use pavucontrol to see what pulseaudio is doing. For me, snapclient shows up in the playback tab as ALSA-plugin. This would confirm, that it is actually using pulseaudio.
What I have in addition, which is Arch Linux standard if I am not mistaken, is the following in /etc/asound.conf:
pcm.!default {
type pulse
fallback "sysdefault"
hint {
show on
description "Default ALSA Output (currently PulseAudio Sound Server)"
}
}ctl.!default {
type pulse
fallback "sysdefault"
}
The description given in here (Default ALSA Output (currently PulseAudio Sound Server)) also shows up for me when I do snapclient -l. So I would use that device with snapclient.
I also check from time to time, that there is an active pulseaudio session for my user: sudo ps aux | grep pulse. Sometimes, pulseaudio gets kind of stuck. I then move ~/.config/pulse to ~/.config/pulse.bak and kill pulseaudio with pulseaudio -k. Then it starts fresh and that sometimes helps.
I hope you can get it to work and let us know how it goes!
@gerroon It's very hard to understand what you are doing and what you want to achieve. What commands are you using? What is the output? What do the config files look like? What is the use case of snapclient? How and when do you want to start snapclient?
Systemctl says that reload is not an option for snapclient.
What does it mean? Is there an error message? Why don't you post it?
I guess I can get this work with my user on the terminal but not as systemd file.
- I can hardly believe this.
- So if it works as a user from terminal, why don't you use it this way?
@hell-g
Thansk for your help. That was very helpful, I say your entry should be in the wiki.
@fuchsmich
I was just trying to get snapclient service to output to both of my usb and hdmi outputs simultaneously. I am pretty newbie with systemd.
thanks
if you want to output sound to two sound devices at once, you have to load the combine-sink module in pulseaudio.
add to /etc/pulse/default.pa load-module module-combine-sink sink_name="CombinedSinkName"
Most helpful comment
@gerroon I am sorry, that it does not work for you! Let me summarize what I did to make it work. Maybe this will help.
I do not use the dev branch, so I cannot comment on that. I use version 0.12.0.
I copied the snapclient.service file from @fuchsmich to /usr/lib/systemd/user/. While still debugging, maybe comment the line
StandardOutput=null. Then it will be more obvious to see, that snapclient is actually getting the packages. You can check on it withsystemctl --user status snapclient, orjournalctl --user -xe.I copied /etc/default/snapclient to ~/.config/snapclient.conf and in there, I deleted the
USER_OPTSline and added--host mysnapcastserverto theSNAPCLIENT_OPTSline.Then I start snapclient with my user in the terminal:
systemctl --user start snapclientThis immediately worked for me. Maybe you have to still play around with the
--soundcardoption in theSNAPCLIENT_OPTSvariable for you to get the right output. I would then suggest to use pavucontrol to see what pulseaudio is doing. For me, snapclient shows up in the playback tab as ALSA-plugin. This would confirm, that it is actually using pulseaudio.What I have in addition, which is Arch Linux standard if I am not mistaken, is the following in /etc/asound.conf:
The description given in here (Default ALSA Output (currently PulseAudio Sound Server)) also shows up for me when I do
snapclient -l. So I would use that device with snapclient.I also check from time to time, that there is an active pulseaudio session for my user:
sudo ps aux | grep pulse. Sometimes, pulseaudio gets kind of stuck. I then move ~/.config/pulse to ~/.config/pulse.bak and kill pulseaudio withpulseaudio -k. Then it starts fresh and that sometimes helps.I hope you can get it to work and let us know how it goes!