You are not logged in.

#1 2013-10-22 07:20:41

bhrgunatha
Member
Registered: 2009-12-16
Posts: 101

[Solved] Conflict between JACK and ALSA for soundcard

I started a course that teaches ChucK for music composition
Chuck has an IDE of sorts which uses JACK.
However I cannot get JACK and ALSA to co-operate.
They both seem to try to grab the hardware exclusively.
This is frustrating because I can't watch the videos and experiment with ChucK at the same time.

I CAN use multiple audio applications together seamlessly with ALSA - e.g. vlc, clementine and firefox can all push out sound together with no problems.

My question is:

Is it possible to configure JACK and ALSA to co-operate so that I can use ChuchK and listen to video instructions at the same time?
If so - HOW?

There is a mass of conflicting, confusing and misleading information out there - I think because of the complexity of the linux sound stack and hardware available.

Any further pointers to understand how to setup and configure sound would be much appreciated as well, but I'm mainly focussed on solving my
issue with not having simultaneous sound with ALSA and JACK.

My sound card is an on-board chip - HDA Intel (ALC1200)
I am using Phonon-vlc as the backend.
I am using KDE 4.11.2
My kernel  and architecture
3.11.5-1-ARCH #1 SMP PREEMPT x86_64 GNU/Linux

Last edited by bhrgunatha (2013-10-22 16:15:34)

Offline

#2 2013-10-22 07:44:53

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: [Solved] Conflict between JACK and ALSA for soundcard

you can do that by routing all alsa applications to use jack as output with alsa's own jack plugin.
simply make sure alsa-plugins is installed, and you can pretty much copy the asoundrc from here: http://alsa.opensrc.org/Jack_(plugin)

you can tweak alsa even further, for example to use separate volume control for alsa and jack applications with softvol plugin, route output from alsa application to jack input etc.

another option is to use pulseaudio, and its own jack plugins

EDIT: i don't know if kde has its own sound server (phonon? or pulseaudio?). i found this regarding phonon, and if you got pulseaudio there are instructions in arch wiki, although the alsa method should work in either case.

Last edited by ooo (2013-10-22 07:55:59)

Offline

#3 2013-10-22 08:54:02

bhrgunatha
Member
Registered: 2009-12-16
Posts: 101

Re: [Solved] Conflict between JACK and ALSA for soundcard

ooo wrote:

you can do that by routing all alsa applications to use jack as output with alsa's own jack plugin.
simply make sure alsa-plugins is installed, and you can pretty much copy the asoundrc from here: http://alsa.opensrc.org/Jack_(plugin)

you can tweak alsa even further, for example to use separate volume control for alsa and jack applications with softvol plugin, route output from alsa application to jack input etc.

another option is to use pulseaudio, and its own jack plugins

EDIT: i don't know if kde has its own sound server (phonon? or pulseaudio?). i found this regarding phonon, and if you got pulseaudio there are instructions in arch wiki, although the alsa method should work in either case.

I installed the jack-plugin fro alsa and set the asoundrc config file.

Now after jackd starts - I get no sound from ANY application, effectively muting my system. They all complain that the resource is busy and so it seems the plugin is not routing audio to alsa.

Offline

#4 2013-10-22 09:14:34

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: [Solved] Conflict between JACK and ALSA for soundcard

I actually noticed that my asoundrc is slightly different from the above example, which doesn't seem to work on my system either.
try this instead as .asoundrc:

pcm.!default {
    type plug
    slave { pcm "jack" }
}

pcm.jack {
     type jack
     playback_ports {
         0 system:playback_1
         1 system:playback_2
     }
     capture_ports {
         0 system:capture_1
         1 system:capture_2
     }
 }

ctl.mixer0 {
    type hw
    card 0
}

Offline

#5 2013-10-22 12:02:26

Sanne
Member
Registered: 2012-03-13
Posts: 87

Re: [Solved] Conflict between JACK and ALSA for soundcard

One very nice and easy solution to be able to watch Flash videos through JACK is libflashsupport-jack from AUR. See also no. 4 in this page for details on this lib.

Once installed, Flash sound connects through JACK. It even autostarts JACK if it's not already running, but then JACK has to run always for every Flash video. If you don't want that, you can set an environment variable for libflashsupport-jack before browser start, so Flash uses ALSA when JACK isn't running, but JACK when it is. I do it like this, using SeaMonkey as my browser:

$ export JACK_NO_START_SERVER=1
$ seamonkey

I found this solution very nice. I'm using it to play electric guitar through virtual amps and effects via my PC while watching for example Flash guitar tutorials or songs I want to play along with, all through JACK. I didn't have to set up an .asoundrc config. I'm not using pulseaudio or other sound servers, just ALSA, and JACK when making music.

Last edited by Sanne (2013-10-22 12:14:48)


If our currency were not money but appreciation and acknowledgement for what we do for others, for the community, for the benefit of all, we would have paradise on earth.

Offline

#6 2013-10-22 12:32:33

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [Solved] Conflict between JACK and ALSA for soundcard

bhrgunatha wrote:

They all complain that the resource is busy

So look:

fuser -fv /dev/snd/*

Phonon just seems to add confusion, in all the audio threads I've seen phonon mentioned.

Rewrite the GUI to use ALSA rather than Jack wink

Offline

#7 2013-10-22 16:12:34

bhrgunatha
Member
Registered: 2009-12-16
Posts: 101

Re: [Solved] Conflict between JACK and ALSA for soundcard

Thanks for these suggestions.
I've tried a few things but here's a summary of the setup I have now.

Firstly - I'm using KDE so I have no choice about phonon.
That lead me to the wiki article on KDE and phonon which says that gstreamer is the better option for a backend. So I changed the phonon backend from vlc to gstreamer.

I searched for some information on using gstreamer and jack which led me to this article

I followed those instructions and used the modified .asoundrc posted by ooo above and now I have simultaneous sound with VLC, ChucK, Flash video, clementine all routed through Jack - even skype is working.

The only slight problem I have now is no audio with HTML5 video players, but for now I think we'll call that a victory.
I can use everything I need to complete the course and I'm hoping someone figures out how to get firefox HTML5 video to work with JACK, although as afar as I can tell it should be using ALSA. Something is still not quite right.

Still thanks for the pointers and suggestions.

Offline

#8 2013-10-22 16:18:45

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [Solved] Conflict between JACK and ALSA for soundcard

Run firefox from the command-line, hopefully it shows an error message.

Offline

#9 2013-10-24 01:55:37

bhrgunatha
Member
Registered: 2009-12-16
Posts: 101

Re: [Solved] Conflict between JACK and ALSA for soundcard

So just for some update - I've discovered another problem which I can't find a solution too.

I've configured VLC's audio output to route through JACK and for most media that seems to be fine.
Unfortunately for anything that is encoded with surround sound (ac52) - sure enough JACK routes 6 channels straight to my sound card.
Unfortunately the on-board sound card is stereo and so only 2 out of the 6 channels are audible.

For some reason ALSA is able to downmix 5.1 to stereo quite well, but I can't find a way to achieve that with JACK.

For now that is a big enough problem for me to revert back to using just pure ALSA.

If anyone has any pointers to how to downmix JACK to stereo I'd love to hear about them.

Offline

#10 2013-10-24 16:31:51

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: [Solved] Conflict between JACK and ALSA for soundcard

How about if you use alsa as audio output with vlc? If you got the alsa-jack-plug working, it should handle the downmixing to stereo just fine. I've been using mplayer and its variants this way and never had problems with 5.1 audio.

the html5 video issue is strange though. especially if flash videos are working fine. I'm using chromium myself and never had any sound issues on my arch install with it. However I just tried html5 videos with firefox and they doesn't seem to work for me either (video seems to be loading fine but it just keeps buffering and doesn't start playback). I have no ideas how to solve this unfortunately unless firefox has its own internal sound settings somewhere..

Offline

#11 2013-10-27 06:55:01

bhrgunatha
Member
Registered: 2009-12-16
Posts: 101

Re: [Solved] Conflict between JACK and ALSA for soundcard

ooo wrote:

How about if you use alsa as audio output with vlc? If you got the alsa-jack-plug working, it should handle the downmixing to stereo just fine. I've been using mplayer and its variants this way and never had problems with 5.1 audio.

the html5 video issue is strange though. especially if flash videos are working fine. I'm using chromium myself and never had any sound issues on my arch install with it. However I just tried html5 videos with firefox and they doesn't seem to work for me either (video seems to be loading fine but it just keeps buffering and doesn't start playback). I have no ideas how to solve this unfortunately unless firefox has its own internal sound settings somewhere..

If I set alsa as the audio uotput in vlc and jackd is already running I get:

Audio output failed:
The audio device "sysdefault:CARD=Intel" could not be used:
Device or resource busy.

Maybe I have something misconfigured - but I have exactly what you posted in .asoundrc (there is no /etc/asound.conf on my system.) and I can;lt see what I can possibly have mis-configured.

Is it right that config you gave for .asoundrc means that I set my apps to use ALSA and ALSA takes care of routing the audio through JACK.
If that's true - why does vlc complain about not having exclusive access to the audio hardware?
I understand jackd grabs the audio exclusively but why isn't vlc sending its output to ALSA and ALSA forwading it to JACK?

I appreciate your help and suggestions, but it's so enormously frustrating. I've been struggling with this problem for so long now.

Offline

#12 2013-10-27 07:55:35

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [Solved] Conflict between JACK and ALSA for soundcard

bhrgunatha wrote:

sysdefault:CARD=Intel

I believe that will go directly to the soundcard, bypassing dmix and Jack. Which will not work if the soundcard is already open.

Configure vlc to use a different ALSA PCM, e.g. "jack".

Offline

#13 2013-10-27 08:24:52

bhrgunatha
Member
Registered: 2009-12-16
Posts: 101

Re: [Solved] Conflict between JACK and ALSA for soundcard

I don't understand why VLC is going directly to the soundcard.
ALSA dmix (or dmixer) must be working though because I can play other audio together wioth vlc media.

The VLC output module is set to ALSA

I have no option to choose JACK for the device

Offline

#14 2013-10-27 14:35:24

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: [Solved] Conflict between JACK and ALSA for soundcard

bhrgunatha wrote:

Is it right that config you gave for .asoundrc means that I set my apps to use ALSA and ALSA takes care of routing the audio through JACK.
If that's true - why does vlc complain about not having exclusive access to the audio hardware?
I understand jackd grabs the audio exclusively but why isn't vlc sending its output to ALSA and ALSA forwading it to JACK?

the config makes alsa applications use jack as default output device. In many applications it's still possible to choose to use another alsa device.
the 'Default Audio Device' that you have selected in vlc should be using the jack device. I have no idea why it wouldn't work unless it's a bug in vlc.
although you should be able to select 'jack' device from the list as well, but oddly there isn't one.

If you don't get it figured out, pulseaudio is fairly simple to set up with jack as well: https://wiki.archlinux.org/index.php/Pu … he_new_way or https://wiki.archlinux.org/index.php/Pu … he_old_way

Offline

#15 2013-10-27 16:17:54

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [Solved] Conflict between JACK and ALSA for soundcard

A tiny bit of googling shows:  In ~/.config/vlc/vlcrc

[alsa]
alsa-audio-device=default

Which should make VLC uses the ALSA PCM named "default".

I prefer mpv for playing movies wink

Last edited by brebs (2013-10-27 16:26:50)

Offline

#16 2013-10-28 04:12:03

bhrgunatha
Member
Registered: 2009-12-16
Posts: 101

Re: [Solved] Conflict between JACK and ALSA for soundcard

brebs - amazing! Thank you! That change to vlcrc is working.

To recap:

I changed KDE's phonon settings to use gstreamer as the backend.
I'm using the ~/.asoundrc posted by ooo
I set VLC to use the "default" ALSA PCM in ~/.confg/vlc/vlcrc - as shown in brebs post

gstreamer-properties Audio tab shows:
Default Output:
Plugin : ALSA
Device: Default
Pipeline: alsasink

Default Input
Plugin : ALSA
Device: Default
Pipeline: alsasrc

And finally ChucK, vlc, firefox clementine are all throwing audio out through my poor sound card together!
The only small issue is there is a problem with firefox and the HTML5 video not working - but it's a minor problem I can live with for now.
Chromium plays the exact same HTML5 video OK - and firefox plays flash video OK.

Thanks you so much for your help, suggestions and patience!

EDIT: It's a problem with firefox and the ALSA JACK plugin

Last edited by bhrgunatha (2013-10-28 05:35:52)

Offline

Board footer

Powered by FluxBB