Page 1 of 2

Can mplayer (JACK) connect to more than one client?

Posted: Sat Oct 28, 2023 10:06 pm
by ThatJackElliott

I'd like to be able to connect mplayer, using its -ao jack:port= syntax to connect to more than one listen-client. I've tried a few ways, such as

Code: Select all

mplayer -ao jack:port="client_1","client_2"

But it only connects its output to "client_1"

In Raysession I can wire up the two listen-clients to mplayer but I'd like to make mplayer do it when it loads. Thank you!


Re: Can mplayer (JACK) connect to more than one client?

Posted: Sun Oct 29, 2023 10:03 am
by bluebell
ThatJackElliott wrote: Sat Oct 28, 2023 10:06 pm

I'd like to be able to connect mplayer, using its -ao jack:port= syntax to connect to more than one listen-client. I've tried a few ways, such as

Code: Select all

mplayer -ao jack:port="client_1","client_2"

But it only connects its output to "client_1"

In Raysession I can wire up the two listen-clients to mplayer but I'd like to make mplayer do it when it loads. Thank you!

I solve such problems with jack-plumbing. It can handle regular expressions, too, so I can have it connect ports with changing names, e.g. with Audacity:

Code: Select all

(connect    "PortAudio:out_.*[13579]" "main:input_2")
(connect    "PortAudio:out_.*[02468]" "main:input_1")
(disconnect "PortAudio:out_.*" "system:playback_.*")

Re: Can mplayer (JACK) connect to more than one client?

Posted: Sun Oct 29, 2023 5:31 pm
by ThatJackElliott

Jack-plumbing sounds ideal. I am not finding example syntax, whether it reads in a config file or how one gets it running with all the rules loaded and enforcing them. I find only the man page, and it doesn't clearly (to me) explain how a user uses it. Thank you!


Re: Can mplayer (JACK) connect to more than one client?

Posted: Sun Oct 29, 2023 6:12 pm
by bluebell

Write your rules into ~/.jack-plumbing then start jack-plumbing e.g. in a terminal.


Re: Can mplayer (JACK) connect to more than one client?

Posted: Sun Oct 29, 2023 7:34 pm
by ThatJackElliott

@bluebell -- thank you, that's enough to get me running.


Re: Can mplayer (JACK) connect to more than one client?

Posted: Sun Oct 29, 2023 11:14 pm
by ThatJackElliott

I spoke too soon. Jack-plumbing's syntax has me baffled.

I have everything running the way I want. My source-client is mplayer and I want to use jack-plumbing it to connect to the two listen-clients. According to aj-snapshot, here is how things are:

Code: Select all

<client name="MPlayer [24001]">
    <port name="out_0">
      <connection port="ST_FM_jack:in_1" />
      <connection port="ST_Stream_jack:in_1" />
    </port>
    <port name="out_1">
      <connection port="ST_FM_jack:in_2" />
      <connection port="ST_Stream_jack:in_2" />
    </port>
  </client>

How do I write my (connect ....) statements so jack-plumbing will force these connections?

mplayer likes to connect to the System Playback client when launched so I'll need to force a disconnect.

Thank you!


Re: Can mplayer (JACK) connect to more than one client?

Posted: Mon Oct 30, 2023 8:17 am
by bluebell
ThatJackElliott wrote: Sun Oct 29, 2023 11:14 pm

I spoke too soon. Jack-plumbing's syntax has me baffled.

I have everything running the way I want. My source-client is mplayer and I want to use jack-plumbing it to connect to the two listen-clients. According to aj-snapshot, here is how things are:

Code: Select all

<client name="MPlayer [24001]">
    <port name="out_0">
      <connection port="ST_FM_jack:in_1" />
      <connection port="ST_Stream_jack:in_1" />
    </port>
    <port name="out_1">
      <connection port="ST_FM_jack:in_2" />
      <connection port="ST_Stream_jack:in_2" />
    </port>
  </client>

How do I write my (connect ....) statements so jack-plumbing will force these connections?

mplayer likes to connect to the System Playback client when launched so I'll need to force a disconnect.

Thank you!

Look with qjackctl or with jack_lsp how mplayer's ports and your destination ports are called exactly, then I can write jack-plumbing rules for you. Probably it will be like:

Code: Select all

(connect "MPlayer:out_0"  "ST_FM_jack:in_1")
(connect "MPlayer:out_1"  "ST_FM_jack:in_2")

(connect "MPlayer:out_0"  "ST_Stream_jack:in_1")
(connect "MPlayer:out_1"  "ST_Stream_jack:in_2")

Re: Can mplayer (JACK) connect to more than one client?

Posted: Mon Oct 30, 2023 5:57 pm
by ThatJackElliott

Very kind of you, @bluebell! jack_lsp reveals

Code: Select all

MPlayer [24001]:out_0
MPlayer [24001]:out_1

What has been hanging me is knowing that mplayer picks up a different PID every time and the example syntax ("PortAudio:out.[13579]") has that ".[#####]" stuff which stumped me. It looks to force a pre-existing PID so somewhere in the "_.*" part the new PID somehow gets inserted.

A note: Before asking for help here, I did some googling and didn't find anything to help with syntax other than the man page and that's too bare-bones for my few remaining brain cells.

Thank you!


Re: Can mplayer (JACK) connect to more than one client?

Posted: Tue Oct 31, 2023 2:36 am
by tseaver

@ThatJackElliott

You should be able to rename the mplayer JACK client using jack:name=mplayer or some such.

Also, per your original post: did you try repeating the jack:port option, rather than passing multiple values to a single one?


Re: Can mplayer (JACK) connect to more than one client?

Posted: Tue Oct 31, 2023 7:47 am
by bluebell
ThatJackElliott wrote: Mon Oct 30, 2023 5:57 pm

Very kind of you, @bluebell! jack_lsp reveals

Code: Select all

MPlayer [24001]:out_0
MPlayer [24001]:out_1

What has been hanging me is knowing that mplayer picks up a different PID every time and the example syntax ("PortAudio:out.[13579]") has that ".[#####]" stuff which stumped me. It looks to force a pre-existing PID so somewhere in the "_.*" part the new PID somehow gets inserted.

A note: Before asking for help here, I did some googling and didn't find anything to help with syntax other than the man page and that's too bare-bones for my few remaining brain cells.

Thank you!

jack-plumbing can use regular expressions. That's its big advantage. Try

Code: Select all

(connect "MPlayer.*:out_0"  "ST_FM_jack:in_1")
(connect "MPlayer.*:out_1"  "ST_FM_jack:in_2")

(connect "MPlayer.*:out_0"  "ST_Stream_jack:in_1")
(connect "MPlayer.*:out_1"  "ST_Stream_jack:in_2")

The regular expression [02468] means 0 or 2 or 4 or 6 or 8.


Re: Can mplayer (JACK) connect to more than one client?

Posted: Fri Nov 03, 2023 5:23 pm
by ThatJackElliott

Thank you, @bluebell

[ EDIT: Never mind my question about /etc/jack-plumbing ]

jack-plumbing is throwing off this message:

Code: Select all

Rule file does not exist: '/etc/jack-plumbing'.

I will be using an @reboot script to start jackd and load the various clients. Where would you suggest I put in the /usr/bin/jack-plumbing command?

I need the system to hit the ground running.


Re: Can mplayer (JACK) connect to more than one client?

Posted: Fri Nov 03, 2023 5:25 pm
by ThatJackElliott

I mean, load the jack clients then run jack-plumbing, or load jack-plumbing first followed by the clients? Thank you!


Re: Can mplayer (JACK) connect to more than one client?

Posted: Sat Nov 04, 2023 6:43 am
by bluebell
ThatJackElliott wrote: Fri Nov 03, 2023 5:23 pm

Thank you, @bluebell

[ EDIT: Never mind my question about /etc/jack-plumbing ]

jack-plumbing is throwing off this message:

Code: Select all

Rule file does not exist: '/etc/jack-plumbing'.

I will be using an @reboot script to start jackd and load the various clients. Where would you suggest I put in the /usr/bin/jack-plumbing command?

I need the system to hit the ground running.

jack-plumbing checks for /etc/jack-plumbing and ~/.jack-plumbing

A missing /etc/jack-plumbing is no problem if there is a ~/.jack-plumbing. But when run system-wide you should use /etc/jack-plumbing

A @reboot script runs as root. I don't recommend that. I start my scrips when logging in.

Anyway, my script is like:

Code: Select all

/usr/bin/jackd -P${PRIO} -p512 -t2000 -dalsa \
  -r$FREQ -p$PERIODS -n$BUFFERS -dhw:$HW $JMIDI \
/tmp/jackd.log 2>&1 &
jack_wait -w

sleep 1

while true
do
  jack-plumbing -u 90000
  sleep 1
done

I've forgotten why I restart jack-plumbing when it stops. :mrgreen:

The greater sign (>) before /tmp/jackd.log 2>&1 & is not correctly displayed.


Re: Can mplayer (JACK) connect to more than one client?

Posted: Sun Nov 05, 2023 10:29 pm
by ThatJackElliott

A @reboot script runs as root. I don't recommend that. I start my scrips when logging in.

The machine is meant to hit the ground running when restarted, unattended, without anyone needing to log in. If there's another way to run the script I don't know what it is.

I've forgotten why I restart jack-plumbing when it stops.

Sometimes I forget why I went into a room. :lol:

Thank you for the help!


Re: Can mplayer (JACK) connect to more than one client?

Posted: Mon Nov 06, 2023 12:22 am
by tseaver

@ThatJackElliott

The machine is meant to hit the ground running when restarted, unattended, without anyone needing to log in. If there's another way to run the script I don't know what it is.

Hmm, I'm not sure I understand here: is your machine running "headless" (no X / Wayland session running)?

My recording machine is set to log me in without a password on boot, which means that processes launced at X / desktop manager startup are similar to @root jobs, except that they run as me, rather than as root, which I find an overall win.