Linux - Use ALSA and Pulse side by side on Ubuntu (like in LibreELEC)?

  Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
jant90 Offline
Junior Member
Posts: 28
Joined: Apr 2011
Reputation: 1
Post: #1
I've been playing around with this for hours while reading several man pages and Wiki's but I just can't get it to work.

I'm running Ubuntu 16.04 and I would like Kodi to use my ALSA HDMI soundcard directly and do passthrough audio over it. However I would also like to run PulseAudio to support music streaming from my phone over Bluetooth. This music must be send to a different sink/ALSA card (to the analog and/or SPDIF out) so it shouldn't interfere with HDMI passthrough audio from Kodi.

So is it possible to let Kodi use my ALSA HDMI soundcard and also run PulseAudio to handle Bluetooth streaming to SPDIF and/or analog out (which are different ALSA interfaces)?

On LibreELEC this seems to be working perfectly. Kodi can passthrough audio over HDMI while watching a movie for example and I can simultaneously stream Bluetooth audio which is routed to an analog output sink.

I tried killing PulseAudio manually, then starting Kodi. Kodi can then access the HDMI ALSA sound card. However if I try to start PulseAudio again (while still running Kodi) it hangs and won't start before Kodi has been closed (thus when the ALSA card has been released by Kodi). When using pasuspender basically the same thing happens, as long as Kodi is running it's not possible to use PulseAudio.

It would be great if I could exclud the ALSA HDMI card from PulseAudio somehow so the card is not in use and can be used by Kodi exclusively, can that be done through config files for example? Or can the ALSA HDMI card be released by PulseAudio without killing the PulseAudio process altogether?

I hope anyone with more experience than me can give me some pointers or tips.

Thank you!
find quote
Derek Offline
Posting Freak
Posts: 1,710
Joined: Aug 2009
Reputation: 23
Location: Bonnie Scotland
Post: #2
You can do this but not at the same time?

When running kodi i have pulseaudio server stopped so alsa can work.

When running my WM i have pulseaudio server running.

This is very easy if you need more info if this is what you want let me know.
find quote
DaVu Offline
Team-Kodi Member
Posts: 2,721
Joined: Jan 2011
Reputation: 51
Location: Germany
Post: #3
What I do sometimes is to start Kodi via terminal like this:

Code:
AE_SINK=alsa kodi

Not the best solution, but it works Wink
find quote
wsnipex Offline
Team-Kodi
Posts: 6,419
Joined: Jun 2011
Reputation: 166
Post: #4
configure pulse to not use the SPDIF output, then start kodi as above and configure kodi to use HDMI
find quote
lrusak Offline
Team-Kodi Member
Posts: 924
Joined: Sep 2011
Reputation: 14
Location: The Great White North
Post: #5
We use a special patch to allow using alsa and pulse at the same time. https://github.com/LibreELEC/LibreELEC.t...ther.patch

"PPC is too slow, your CPU has no balls to handle HD content." ~ Davilla
"Maybe it's a toaster. Who knows, but it has nothing to do with us." ~ Ned Scott
find quote
Derek Offline
Posting Freak
Posts: 1,710
Joined: Aug 2009
Reputation: 23
Location: Bonnie Scotland
Post: #6
Ok obviously theres ways round it, i just use a couple of scripts; pulseon and pulseoff and run them as required - does the job and causes zero conflicts Smile But these boys seem to have an automated solution but im quite happy typing commands i miss it actually when i use my MAC's hehe Smile
find quote
jant90 Offline
Junior Member
Posts: 28
Joined: Apr 2011
Reputation: 1
Post: #7
Thanks guys. I was running "AE_SINK=alsa kodi" with pasuspender as per the Wiki (so: "pasuspender AE_SINK=alsa kodi"). But indeed it's also possible to run it without the pasuspender prefix and thus keep PulseAudio active. I didn't think that would work so I didn't try it before.

Anyways, Bluetooth audio continues when launching with AE_SINK=alsa and Kodi binds to the HDMI ALSA soundcard. So it looks like mission accomplished here. However, I'm not able to test HDMI sound at the moment but it looks like this should work just fine. Is it possible that the LibreELEC patch does the same thing as the AE_SINK environment variable?

Anyways, thanks for the help guys!
find quote
fritsch Offline
Team-Kodi Developer
Posts: 17,984
Joined: Aug 2011
Reputation: 559
Location: Stuttgart*
Post: #8
No it does not. LE's patch uses kodi's PA sink _AND_ kodi's ALSA sink in parallel. This works as in LE all PA devices are completely disabled besides the Bluetooth device. So there won't be any highjacking of hdmi / spdif / analog / whatever which will happen on normal distributions.

"Your most vocal users are not reflective of your userbase" J.M.
"Of course, they [XP Users and people with outdated hardware] need to tell the world about the kind of hero they are, and block innovation for everyone else because their decades old OS / hardware needs to work =p" nevcairiel (ffmpeg)
No Debug Log no issue.
find quote
jant90 Offline
Junior Member
Posts: 28
Joined: Apr 2011
Reputation: 1
Post: #9
(2017-04-22 08:53)fritsch Wrote:  No it does not. LE's patch uses kodi's PA sink _AND_ kodi's ALSA sink in parallel. This works as in LE all PA devices are completely disabled besides the Bluetooth device. So there won't be any highjacking of hdmi / spdif / analog / whatever which will happen on normal distributions.

Alright, thanks for clarifying that.

Just a question about said highjacking: when could that happen? If I configure PulseAudio to default to SPDIF or analog using pavucontrol then theoretically PulseAudio should leave the HDMI sink alone right?

I guess I will find out eventually when I start using my HTPC in my new setup but it always sucks when sound won't work or [insert any technical problem here] when you just want to watch a movie (especially when you have visitors) so I'm trying to be prepared as best as I can.
find quote
fritsch Offline
Team-Kodi Developer
Posts: 17,984
Joined: Aug 2011
Reputation: 559
Location: Stuttgart*
Post: #10
Yeah - find out.

"Your most vocal users are not reflective of your userbase" J.M.
"Of course, they [XP Users and people with outdated hardware] need to tell the world about the kind of hero they are, and block innovation for everyone else because their decades old OS / hardware needs to work =p" nevcairiel (ffmpeg)
No Debug Log no issue.
find quote