Create an account

Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PulseJacking: How to pwn PulseAudio and stream it through JACK

pacmd suspend true #suspend PA to release the sound card
pactl load-module module-jack-sink channels=2
pactl load-module module-jack-source channels=2
pacmd set-default-sink jack_out
pacmd set-default-source jack_in
pacmd suspend false #required; allows you to play sound via PA to JACK
pacmd suspend true #suspend PA to unload modules
SINKID=$(pactl list | grep -B 1 "Name: module-jack-sink" | grep Module | sed 's/[^0-9]//g')
SOURCEID=$(pactl list | grep -B 1 "Name: module-jack-source" | grep Module | sed 's/[^0-9]//g')
pactl unload-module $SINKID
pactl unload-module $SOURCEID
sleep 5
pacmd suspend false #bring pulse back!

These go into QJackCtl's slots for before starting, after starting, before stopping and after stopping JACK. The effect: Add PA modules to JACK and JACK modules to PA. Then, you just have to connect PA Sink to system out in JACK and you're set, though sometimes some applications might need to be directed to JACK sink manually in pavucontrol.

Sounds clear enough? I'll try to elaborate later.

The Elaboration, part 1
I have been looking for this kind of setup for a long time, and I think I finally found it. True, it requires having pavucontrol constantly open, but it's worth it. Imagine the possibilities. (True, the proper fix would be to extend this and have each application go into its own PulseAudio module, but this is close.)

So what it does, is, step by step:
1. Suspend PulseAudio and make it release the sound card for JACK to grab.
2. Start JACK, then add Pulse/JACK modules - PulseAudio Sink and Source. Make those default so Pulse won't try to grab sound card again, just to fail miserably.
3. Unsuspend PulseAudio so that desktop audio can flow through it.
4. Now, the per-application volume control means you'll have to use pavucontrol to manually route every application into the JACK sink.

When you shut JACK down, it suspends Pulse, removes Pulse/JACK modules and unsuspends Pulse, so that it can get the sound card again. The applications previously routed to JACK will most likely get routed to the sound card automatically.

What it means, is that PulseAudio now acts as any other sound-producing application, although with an internal mixer (so you won't be able to record Skype only without also recording your music, if you use Totem or Banshee or whatever).

This might not be an issue if you're recording, say, a game session with sound from the game AND the conversation with your teammates on Skype. How would you do that? Well, recordMyDesktop supports JACK input, so you'll probably have to do the following:
capture_1 → PulseAudio Source (L+R is recommended if you have a mono mic)
capture_1 → JACK Mixer (L+R)
PulseAudio Sink → JACK Mixer
Select the output from JACK Mixer in gtk-recordMyDesktop as sound input.

(This is theory and it is unchecked).
(08-10-2012, 02:37 AM)Mr. Bougo Wrote: Cloud is the new Web 2.0. It makes no damn sense to me.

I changed your php forum code to code. More readable.

Possibly Related Threads...
Thread Author Replies Views Last Post
  Future Assassin - Old Skool Jungle stream end user 11 11,914 12-27-2019, 06:56 PM
Last Post: end user
  Twitch Stream Ch4mp 1 2,021 09-07-2015, 03:59 PM
Last Post: SPLAT

Forum Jump:

Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-