pulseaudio can't play sound when jack is on with jack-pulseaudio-bridge is enabled by cadence

Official support for the KXStudio Linux distribution and applications.
More info at http://kxstudio.linuxaudio.org/

Moderators: ___, khz, MattKingUSA

jsomedon
Posts: 2
Joined: Thu Nov 15, 2018 5:32 pm

pulseaudio can't play sound when jack is on with jack-pulseaudio-bridge is enabled by cadence

Postby jsomedon » Thu Nov 15, 2018 5:46 pm

Well, tried to ask about this on github and irc but no one was answering so I ended up here..

So I set up jack-pulseaudio bridge using cadence by following the github wiki. I run arch linux.

    * When jack is up and running, supercollider(which uses jack) plays audio, so I guess that means jack works fine(?) but then I can't play youtube in firefox, the youtube player pauses and shows something like "can't play on device".
    * If I use bluetooth headphones, then run jack, then jack plays on laptop speaker and youtube plays on headphone.

I wonder:
  1. Does this happen because each device(like the speaker and the headphone) must be owned by either jack or pulseaudio but not both at the same time even with bridge? Are these expected behavior?
  2. If yes, well, I initially thought the bridge would let jack send audio(from supercollider) to pulseaudio, then pulseaudio collects audio from jack and other programs(like browsers playing youtube) and send them all to a single device, so everything from both jack and pulseaudio could play on same device. Is such setup possible?

User avatar
bluebell
Established Member
Posts: 1119
Joined: Sat Sep 15, 2012 11:44 am
Location: Saarland & Frankfurt, Germany

Re: pulseaudio can't play sound when jack is on with jack-pulseaudio-bridge is enabled by cadence

Postby bluebell » Fri Nov 16, 2018 12:36 pm

I have a static setup where I start jackd and then pulseaudio with jack-sink (all via shell script when logging in). So pulseaudio outputs via jackd and doesn't have to own the audio interface.

It looks as if pulseaudio isn't aware that it shall use jack-sink for output.
Linux – MOTU UltraLite AVB – Qtractor – https://soundcloud.com/suedwestlicht

User avatar
sysrqer
Established Member
Posts: 1811
Joined: Thu Nov 14, 2013 11:47 pm
Contact:

Re: pulseaudio can't play sound when jack is on with jack-pulseaudio-bridge is enabled by cadence

Postby sysrqer » Fri Nov 16, 2018 12:48 pm

I've had a lot of trouble with cadence and pulseaudio as well, I never found a solution and now use qjackctl instead - viewtopic.php?f=19&t=13234

User avatar
lilith
Established Member
Posts: 990
Joined: Fri May 27, 2016 11:41 pm
Location: bLACK fOREST
Contact:

Re: pulseaudio can't play sound when jack is on with jack-pulseaudio-bridge is enabled by cadence

Postby lilith » Fri Nov 16, 2018 2:17 pm

I use Cadence and the PulseAudio bridge from Cadence. In Cadence I have Jack and the PulseAudio bridge running all the time. So, sound from Firefox or Chromium gets routed from Pulse to Jack and applications like Ardour use Jack directly. I have sound from Ardour and e.g. Youtube at the same time. I don't have any ~/.pulse/default.pa file. Did you ask on IRC kxstudio? falkTX should be around there.

My asoundr file looks like:

Code: Select all

# ------------------------------------------------------
# Custom asoundrc file for use with snd-aloop and JACK
#
# use it like this:
# env JACK_SAMPLE_RATE=44100 JACK_PERIOD_SIZE=1024 alsa_in (...)
#

# ------------------------------------------------------
# playback device
pcm.aloopPlayback {
  type dmix
  ipc_key 1
  ipc_key_add_uid true
  slave {
    pcm "hw:Loopback,0,0"
    format S32_LE
    rate {
      @func igetenv
      vars [ JACK_SAMPLE_RATE ]
      default 44100
    }
    period_size {
      @func igetenv
      vars [ JACK_PERIOD_SIZE ]
      default 1024
    }
    buffer_size 4096
  }
}

# capture device
pcm.aloopCapture {
  type dsnoop
  ipc_key 2
  ipc_key_add_uid true
  slave {
    pcm "hw:Loopback,0,1"
    format S32_LE
    rate {
      @func igetenv
      vars [ JACK_SAMPLE_RATE ]
      default 44100
    }
    period_size {
      @func igetenv
      vars [ JACK_PERIOD_SIZE ]
      default 1024
    }
    buffer_size 4096
  }
}

# duplex device
pcm.aloopDuplex {
  type asym
  playback.pcm "aloopPlayback"
  capture.pcm "aloopCapture"
}

# ------------------------------------------------------
# default device
pcm.!default {
  type plug
  slave.pcm "aloopDuplex"
}

# ------------------------------------------------------
# alsa_in -j alsa_in -dcloop -q 1
pcm.cloop {
  type dsnoop
  ipc_key 3
  ipc_key_add_uid true
  slave {
    pcm "hw:Loopback,1,0"
    channels 2
    format S32_LE
    rate {
      @func igetenv
      vars [ JACK_SAMPLE_RATE ]
      default 44100
    }
    period_size {
      @func igetenv
      vars [ JACK_PERIOD_SIZE ]
      default 1024
    }
    buffer_size 32768
  }
}

# ------------------------------------------------------
# alsa_out -j alsa_out -dploop -q 1
pcm.ploop {
  type plug
  slave.pcm "hw:Loopback,1,1"
}

https://soundcloud.com/lilith_93

_____________________________
Debian 9 (XFCE) & KXStudio repos

User avatar
nikgnomicradio
Established Member
Posts: 80
Joined: Wed Feb 07, 2018 9:31 pm
Contact:

Re: pulseaudio can't play sound when jack is on with jack-pulseaudio-bridge is enabled by cadence

Postby nikgnomicradio » Sat Nov 17, 2018 11:40 am

I can't play youtube in firefox, the youtube player pauses and shows something like "can't play on device".


Likely youtube playback in Pulseaudio is trying to use hardware device now in use by JACK
youtube audio stream needs to be redirected to JACK Sink in Pulseaudio

pavucontrol has drop-down list for changing playback device to Pulseaudio Jack Sink

Making redirect change in pavucontrol once is usually enough for setting to be remembered

Pulseaudio saves changes to user configuration in folder ~/.config/pulse
folder ~/.pulse for user configuration not been used for few years now

asbak
Established Member
Posts: 647
Joined: Thu Sep 11, 2014 3:04 pm

Re: pulseaudio can't play sound when jack is on with jack-pulseaudio-bridge is enabled by cadence

Postby asbak » Sat Nov 17, 2018 8:20 pm

I wouldn't use Cadence and I'd stay far away from anything jackdbus related, it's a PITA.

The simple way to make it work (at the expense of a few CPU cycles) is to just follow this page instructions, the Redirecting PulseAudio to JACK section.

https://github.com/jackaudio/jackaudio. ... ulseOnJack

The short version:

Install pulseaudio-module-jack
Set pulseaudio to not autospawn and start it manually with a startup script.
I use qjackctl, it works reliably for my purposes with some startup & shutdown scripts for jack and pulseaudio.
I ignore most of the info on that page, the default.pa stuff should already be in the standard default.pa file.


The relevant instructions for redirecting pulse into jack is here:

If you're using qjackctl as a launcher for jackd.
in settings options add a post startup script like this:

Code: Select all

pactl load-module module-jack-sink channels=2; pactl load-module module-jack-source channels=2; pacmd set-default-sink jack_out


Note:
Be sure to first stop pulseaudio, then start jack, then start pulseaudio, then direct pulseaudio into jack.

It does chew more CPU cycles so I only use it when necessary, for example when redirecting web browser audio to jack.
When not doing music production work one may as well just run pulseaudio by itself and save some CPU.

User avatar
nikgnomicradio
Established Member
Posts: 80
Joined: Wed Feb 07, 2018 9:31 pm
Contact:

Re: pulseaudio can't play sound when jack is on with jack-pulseaudio-bridge is enabled by cadence

Postby nikgnomicradio » Tue Nov 20, 2018 12:05 am

no need to stop and start Pulseaudio to start JACK

Pulseaudio module jackdbus-detect can sometimes be awkward setting up on some distributions
but it will take care of automating JACK start and loading Pulseaudio Sink / Source

Even without jackdbus, single command in QjackCtl "execute script on startup"

Code: Select all

pacmd suspend true

is enough to allow JACK to access ALSA device to start

Leave Pulseaudio autospawn enabled and don't need to de-suspend Pulseaudio once JACK started
Pulseaudio resumes when Sinks and Sources loaded at next step

I use script at "execute script on startup" to manually load Pulseaudio Sinks?sources too
mostly because pactl commands allow options to rename Sinks/Sources
(got tired of commands/scripts for JACK connections needing edit on name to allow for spaces e.g. "Pulseaudio\ Jack\ Sink" )

pacmd set-default-sink command is important to ensure audio playback in Pulseaudio does not try to connect to ALSA device


Return to “KXStudio Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest