[LAU] getting gstreamer and jack to play ball
theo_linuxaudio at borm.org
Fri Jan 29 22:46:22 UTC 2016
First of all, let me introduce myself. I'm Theo, and while I'm new to
linux audio, I'm not new to linux perse (20+Y), and in general can find
my way around the system quite easily. Up until recently I've not had
much reason to delve into linux audio as It "just worked" for what I use
it for - listening to music while doing stuff behind the PC - which I
happen to do quite often as I'm working as a geneticist/bio-informatician.
And then something changed. I bought a new laptop, and found the audio
quality "lacking" to say the least. So I went to the shop and got myself
a USB external sound card with reasonable sound quality and - worth
bonus points - a 6.35mm headphone jack instead of a 3.5mm jack, a volume
control dial and an extra pair of rca outputs so I can also connect it
to my stereo. I plugged it in and found out it didn't "just work".
So I started reading up and was stupefied - it was an alien world to me,
with a new language (ok, new slang) and apparently several "competing"
ways of doing things. To make this manageable for myself I decided to
take things one step at a time. I first installed jack/qjackct, qsynth
and found a midi keyboard and got it to produce sound after some small
tweaks. Things have definitely changed a great deal since I last handled
a DX7 - and it was great fun. In the process I found out that channel 1
and 2 of my USB sound thingy went to the rca outputs and channel 3 and 4
to the headphone jack. No problem.
Then I started gstreamer - no output. So I made some more tweaks as per
google's suggestions, then gstreamer outputs appeared in qjackctl, and
after making the necessary connections from gstreamer to outputs 3 and 4
I had sound again. Great. Then the next song started playing and the
sound ceased. So I made the connections again in qjackctl and I had
sound again. This happened a few times, I got a bit annoyed and
discovered the patch bay. I tried it, and it didn't work on my usb
thingy while it worked flawlessly on my built-in sound card. Every time
a new song started, the connections in qjackctl automatically reverted
to output channels 1 and 2 (rca jacks) and disconnected channels 3 and 4
(headphone) even though there was a patch-bay active. Now, I was almost
ready to file a bug report when I noticed that the patch bay did work
after a restart of gstreamer - for one song only.
It was then that I realized that every song a new out_jackaudiosinkN_1
and out_jackaudiosinkN_2 appeared in qjackctl, with N an increasing
integer. So in the patch bay I added out_jackaudiosink2_1,
out_jackaudiosink2_2, out_jackaudiosink5_1 and out_jackaudiosink5_2, and
connected them to my headphone outputs, and sure enough, after every
restart of gstreamer I could hear the second and fifth number, while all
other songs were silent. Quite a bit of fiddling later I found out that
one can actually use regular expressions in the patch-bay. Connecting
out_jackaudiosink[0-9]+_1 and out_jackaudiosink[0-9]+_2 to channel 3 and
4 works. Wonderful. I now reliably get output through my headphones
after a new song starts. Only thing is that now I get four connections -
the (apparently) default connections to channels 1 and 2 are also
reconnected every time a new song starts.
So, to come to my questions:
- Am I the only one using 4-channel external USB sound card with
gstreamer? When I saw it's specs I was convinced that everyone would
want one as a sort of "audio docking station" - better quality audio and
no more annoying physical (un)plugging to re-route audio through an
amplifier on the wrong side of the room instead of headphones.
- What is the point of this (re-)connection behaviour of gstreamer? -
gstreamer doesn't suddenly become a "new device" when it starts playing
a new song.
- I guess gstreamer does the out_jackaudiosinkN_x numbering, correct?
VLC seems to handle this differently (and this is actually how I found
out about the regular expressions)
- How can I tell the software (gstreamer + jack) to do what I want and
not more? Simply a connection from gstreamer to my headphones (channel 3
and 4), and NOT to my RCA connectors as well unless I tell it to. This
last question may appear a bit mute as it now "just works" in my main
use case (headphones), but it bugs me that I have a device that would
perfectly allow me to keep my amplifier plugged in ready to roll at a
software flick of switch, but if I would, every new song starting would
automatically come blaring out of my speakers. I guess that others have
bumped in this as well - in particular people doing DJ-ing from from
linux (do they exist?) would get very annoyed by sound coming out the
wrong way every time a new song starts.
- I found little in terms of usable documentation for multi-output
set-ups. I'm for instance not convinced that I would be able to
configure the system to use both on-board and external usb sound-cards
simultaneously. Did I miss something here? Can anyone point me to some
relevant documentation or is there a real issue here? Also the regular
expressions bit - quite neat - but I just stumbled upon its' use in
another program, and is not something I read about.
In general I'm both impressed by and worried about the state of linux
audio - a lot is possible but to get things working is (imho) much
harder than it should be.
More information about the Linux-audio-user