[Jack-Devel] Jack_Capture not starting anymore after having Jackd running as systemd service

classic Classic list List threaded Threaded
28 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[Jack-Devel] Jack_Capture not starting anymore after having Jackd running as systemd service

jack@microfx.de
Hey!

Using the jack audio toolkit with my pisound DAC on a Raspberry Pi 3 which was a hassle - but I got it running with some hacks. 

Now for convenience I added jackd and jack_connect (to route input to output) as a service inside systemd - which works as expected. Before I could easily start jack_capture to record the input. But now it’s not starting anymore unfortunately. I get this error: 

jack_capture -c 5 -mb -tm -f flac
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
>>> jack_client_open() failed, status = 0x11

I copied jack_capture also to /usr/locale/bin 


My systemd service files:

jack-connect.service —> starts also jackd.service   
[Unit]
Description=jack-connect
Wants=jackd.service
After=jackd.service

[Service]
Type=oneshot
ExecStartPre=/bin/sleep 1s
ExecStartPre=/usr/local/bin/jack_connect system:capture_2 system:playback_2
ExecStart=/usr/local/bin/jack_connect system:capture_1 system:playback_1


jackd.service
[Unit]
Description=jackd Unit

[Service]
ExecStart=/usr/local/bin/jackd -t 2000 -P 75 -d alsa -d hw:pisound -r 48000 -p 128 -n 2 -X seq -s

ExecStop=/usr/bin/killall jackd

Can anyone help me with this?

Kind regards
Jan



_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

Kjetil Matheussen-2
I don't know if this is the problem, but it looks like it.

The problem seems to be:

"jackd" needs to run by the same user as the clients.

(At least that's how it was in the old days, but maybe something
has changed since then).

E.g. If the process owner of jackd is root, you can't run jack_capture
as a  normal user.

I'm also pretty sure you can run several jackd simultaneously
on the same machine as long as each jackd is run by a different user.



On Mon, Dec 10, 2018 at 10:53 PM [hidden email] <[hidden email]> wrote:

>
> Hey!
>
> Using the jack audio toolkit with my pisound DAC on a Raspberry Pi 3 which was a hassle - but I got it running with some hacks.
>
> Now for convenience I added jackd and jack_connect (to route input to output) as a service inside systemd - which works as expected. Before I could easily start jack_capture to record the input. But now it’s not starting anymore unfortunately. I get this error:
>
> jack_capture -c 5 -mb -tm -f flac
> Cannot connect to server socket err = No such file or directory
> Cannot connect to server request channel
> jack server is not running or cannot be started
> JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
> JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
> >>> jack_client_open() failed, status = 0x11
>
> I copied jack_capture also to /usr/locale/bin
>
>
> My systemd service files:
>
> jack-connect.service —> starts also jackd.service
> [Unit]
> Description=jack-connect
> Wants=jackd.service
> After=jackd.service
>
> [Service]
> Type=oneshot
> ExecStartPre=/bin/sleep 1s
> ExecStartPre=/usr/local/bin/jack_connect system:capture_2 system:playback_2
> ExecStart=/usr/local/bin/jack_connect system:capture_1 system:playback_1
>
>
> jackd.service
> [Unit]
> Description=jackd Unit
>
> [Service]
> ExecStart=/usr/local/bin/jackd -t 2000 -P 75 -d alsa -d hw:pisound -r 48000 -p 128 -n 2 -X seq -s
>
> ExecStop=/usr/bin/killall jackd
>
> Can anyone help me with this?
>
> Kind regards
> Jan
>
>
> _______________________________________________
> Jack-Devel mailing list
> [hidden email]
> http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

Chris Caudle
In reply to this post by jack@microfx.de
On Mon, December 10, 2018 3:53 pm, [hidden email] wrote:
> Now for convenience I added jackd and jack_connect (to route input to
> output) as a service inside systemd - which works as expected. Before I
> could easily start jack_capture to record the input. But now it’s not
> starting anymore unfortunately. I get this error:
>
> jack_capture -c 5 -mb -tm -f flac
> Cannot connect to server socket err = No such file or directory
> Cannot connect to server request channel
> jack server is not running or cannot be started

Probably as Kjetil wrote the user accounts are not the same.
In the [Service] section of the systemd file you can have User= and Group=
lines to set the user and group which the service should be run. Perhaps
if you make a user account and add that account in the systemd service
file and also log in as that user when you want to use jack_capture it
will still work as you would like.

--
Chris Caudle


_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

jack@microfx.de
Ah, that seems to be the problem! Thanks for the quick reply!

My initial idea was to add this as well as a service but jack_capture needs user input - is this possible with a service? Like an additional script that triggers the recording?


> On 10. Dec 2018, at 23:11, Chris Caudle <[hidden email]> wrote:
>
> On Mon, December 10, 2018 3:53 pm, [hidden email] wrote:
>> Now for convenience I added jackd and jack_connect (to route input to
>> output) as a service inside systemd - which works as expected. Before I
>> could easily start jack_capture to record the input. But now it’s not
>> starting anymore unfortunately. I get this error:
>>
>> jack_capture -c 5 -mb -tm -f flac
>> Cannot connect to server socket err = No such file or directory
>> Cannot connect to server request channel
>> jack server is not running or cannot be started
>
> Probably as Kjetil wrote the user accounts are not the same.
> In the [Service] section of the systemd file you can have User= and Group=
> lines to set the user and group which the service should be run. Perhaps
> if you make a user account and add that account in the systemd service
> file and also log in as that user when you want to use jack_capture it
> will still work as you would like.
>
> --
> Chris Caudle
>
>
> _______________________________________________
> Jack-Devel mailing list
> [hidden email]
> http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

Chris Caudle
On Mon, December 10, 2018 4:18 pm, [hidden email] wrote:
> My initial idea was to add this as well as a service but jack_capture
> needs user input - is this possible with a service? Like an additional
> script that triggers the recording?

If you need user input, will you be using jack_capture after logging in? A
service should just be for a program which runs constantly in the
background, jack_capture seems more of an interactive program, although
you could probably run in from something like a shell script.

Have you tried the suggested solution yet, add a new account that is used
both for running jackd as a service, and as your login account when you
want to run jack_capture?

--
Chris Caudle


_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

Kjetil Matheussen-2
In reply to this post by jack@microfx.de
On Mon, Dec 10, 2018 at 11:18 PM [hidden email] <[hidden email]> wrote:
>
> Ah, that seems to be the problem! Thanks for the quick reply!
>
> My initial idea was to add this as well as a service but jack_capture needs user input - is this possible with a service? Like an additional script that triggers the recording?
>

How about letting jack_capture listen to OSC?
jack_capture --help-osc

Then you can run jack_capture as root like this:

   jack_capture --osc 7777 --filename-prefix
/recording/directory/jack_capture_recording_

And as a normal user you can run

   oscsend localhost 7777 /jack_capture/tm/start
   oscsend localhost 7777 /jack_capture/tm/stop

to start and stop recording.

Robin Gareus might help more on this, since he wrote that code.
I'm not entirely sure if this is the best way to use the OSC interface.
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

jack@microfx.de
In reply to this post by Chris Caudle
Yes! Adding User / Group to the .service fixed the problem of not starting! Thanks a lot!

My setup would best look like this:
The pisound has  a button. I have it now configured and working that when I press a button it runs a shell script which checks if my jackd service is running - if yes, stop else start (so one button solution to start / stop) - I need this because I couldn’t figure out how to use Volumio with jack2 and to switch between Spotify/Airplay with Volumio - so this is a working workaround so far.

Now I’d like to start recording when doing a double-press on the button and stop it with the same double-press (it’s a feature of the pisound).


On 10. Dec 2018, at 23:26, Chris Caudle <[hidden email]> wrote:

>
> On Mon, December 10, 2018 4:18 pm, [hidden email] wrote:
>> My initial idea was to add this as well as a service but jack_capture
>> needs user input - is this possible with a service? Like an additional
>> script that triggers the recording?
>
> If you need user input, will you be using jack_capture after logging in? A
> service should just be for a program which runs constantly in the
> background, jack_capture seems more of an interactive program, although
> you could probably run in from something like a shell script.
>
> Have you tried the suggested solution yet, add a new account that is used
> both for running jackd as a service, and as your login account when you
> want to run jack_capture?
>
> --
> Chris Caudle
>
>

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

Kjetil Matheussen-2
In reply to this post by Kjetil Matheussen-2
On Mon, Dec 10, 2018 at 11:27 PM Kjetil Matheussen
<[hidden email]> wrote:

>
> On Mon, Dec 10, 2018 at 11:18 PM [hidden email] <[hidden email]> wrote:
> >
> > Ah, that seems to be the problem! Thanks for the quick reply!
> >
> > My initial idea was to add this as well as a service but jack_capture needs user input - is this possible with a service? Like an additional script that triggers the recording?
> >
>
> How about letting jack_capture listen to OSC?
> jack_capture --help-osc
>
> Then you can run jack_capture as root like this:
>
>    jack_capture --osc 7777 --filename-prefix
> /recording/directory/jack_capture_recording_
>
> And as a normal user you can run
>
>    oscsend localhost 7777 /jack_capture/tm/start
>    oscsend localhost 7777 /jack_capture/tm/stop
>
> to start and stop recording.
>
> Robin Gareus might help more on this, since he wrote that code.
> I'm not entirely sure if this is the best way to use the OSC interface.

I just tried it, and this seems to work the way you want it. But you
need to run jack_capture with the "-tm" option to start it in time
machine mode.

You might also want to use the "--daemon" option for jack_capture,
which will stop it from printing stuff to stdout.
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

jack@microfx.de
In reply to this post by Kjetil Matheussen-2
that indeed looks like a solution! But I would need to know if jack_capture is recording to stop it again because I want to use a button to trigger start/stop of the recording - and I can’t think of a solution right away. Good input for the recording directory - I was asking myself how to do that since I couldn’t find that in the help file.

> On 10. Dec 2018, at 23:27, Kjetil Matheussen <[hidden email]> wrote:
>
> On Mon, Dec 10, 2018 at 11:18 PM [hidden email] <[hidden email]> wrote:
>>
>> Ah, that seems to be the problem! Thanks for the quick reply!
>>
>> My initial idea was to add this as well as a service but jack_capture needs user input - is this possible with a service? Like an additional script that triggers the recording?
>>
>
> How about letting jack_capture listen to OSC?
> jack_capture --help-osc
>
> Then you can run jack_capture as root like this:
>
>   jack_capture --osc 7777 --filename-prefix
> /recording/directory/jack_capture_recording_
>
> And as a normal user you can run
>
>   oscsend localhost 7777 /jack_capture/tm/start
>   oscsend localhost 7777 /jack_capture/tm/stop
>
> to start and stop recording.
>
> Robin Gareus might help more on this, since he wrote that code.
> I'm not entirely sure if this is the best way to use the OSC interface.

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

Kjetil Matheussen-2
On Mon, Dec 10, 2018 at 11:37 PM [hidden email] <[hidden email]> wrote:
>
> that indeed looks like a solution! But I would need to know if jack_capture is recording to stop it again because I want to use a button to trigger start/stop of the recording - and I can’t think of a solution right away. Good input for the recording directory - I was asking myself how to do that since I couldn’t find that in the help file.
>

A little bit hacky, but you can use the --hook* functions to make
jack_capture run arbitrary commands when starting and stopping:

"
[kjetil@localhost jack_capture]$ more hookstart.sh
#!/bin/sh

touch /tmp/jack_capture_is_recording

[kjetil@localhost jack_capture]$ more hookstop.sh
#!/bin/sh

rm -f /tmp/jack_capture_is_recording
"

And if you run jack_capture with the arguments

  --hook-close ./hookstop.sh --hook-timing ./hookstart.sh

The file /tmp/jack_capture_is_recording will exist when recording.
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

Kjetil Matheussen-2
On Mon, Dec 10, 2018 at 11:56 PM Kjetil Matheussen
<[hidden email]> wrote:
>
> The file /tmp/jack_capture_is_recording will exist when recording.

By the way, with the hooks you can also (from the outside),
know the filename of the currently recording file, and also how
long time it has been recording.

(The hooks are also made by Robin Gareus, so he might have some
additional input.)
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

jack@microfx.de
Alright! I added everything… but I have some routing problems right now so I cannot install the osc package. Will try tomorrow.

I just tested the whole setup … and I get crackling when running jackd as mentioned above with systemd …does it run with another priority maybe? When using my old scripts to start jack2 everything is normal.

> On 11. Dec 2018, at 00:14, Kjetil Matheussen <[hidden email]> wrote:
>
> On Mon, Dec 10, 2018 at 11:56 PM Kjetil Matheussen
> <[hidden email]> wrote:
>>
>> The file /tmp/jack_capture_is_recording will exist when recording.
>
> By the way, with the hooks you can also (from the outside),
> know the filename of the currently recording file, and also how
> long time it has been recording.
>
> (The hooks are also made by Robin Gareus, so he might have some
> additional input.)

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

Kjetil Matheussen-2
On Tue, Dec 11, 2018 at 12:52 AM [hidden email] <[hidden email]> wrote:
>
> Alright! I added everything… but I have some routing problems right now so I cannot install the osc package. Will try tomorrow.
>
> I just tested the whole setup … and I get crackling when running jackd as mentioned above with systemd …does it run with another priority maybe? When using my old scripts to start jack2 everything is normal.

You might not have the right privilege to run jackd as a normal user
with SCHED_FIFO or SCHED_RR priority (I.e realtime priority).

Try to run jackd manually in the shell as a normal user and see if it
shows a warning message about this.

If you do get a warning, there's probably some info at jackaudio.org
on how to enable realtime privileges for normal users, or you can
google it. I don't remember exactly how right now. :-)
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

jack@microfx.de
But I was running jack before as user pi with my scripts and with systemd also as user pi … ah maybe different group? I just made the Group=pi as well… is there a special group maybe?

> On 11. Dec 2018, at 01:01, Kjetil Matheussen <[hidden email]> wrote:
>
> On Tue, Dec 11, 2018 at 12:52 AM [hidden email] <[hidden email]> wrote:
>>
>> Alright! I added everything… but I have some routing problems right now so I cannot install the osc package. Will try tomorrow.
>>
>> I just tested the whole setup … and I get crackling when running jackd as mentioned above with systemd …does it run with another priority maybe? When using my old scripts to start jack2 everything is normal.
>
> You might not have the right privilege to run jackd as a normal user
> with SCHED_FIFO or SCHED_RR priority (I.e realtime priority).
>
> Try to run jackd manually in the shell as a normal user and see if it
> shows a warning message about this.
>
> If you do get a warning, there's probably some info at jackaudio.org
> on how to enable realtime privileges for normal users, or you can
> google it. I don't remember exactly how right now. :-)

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

Kjetil Matheussen-2
On Tue, Dec 11, 2018 at 1:07 AM [hidden email] <[hidden email]> wrote:
>
> But I was running jack before as user pi with my scripts and with systemd also as user pi … ah maybe different group? I just made the Group=pi as well… is there a special group maybe?
>

Yes, maybe you need to run in the "audio" group or something like that.
Check /etc/security/limits.conf. Mine looks like this:

@realtime   -  rtprio     99
@realtime   -  memlock    unlimited

If it looks like this, you don't need to be a member of a special group.
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

jack@microfx.de
I just changed it to Group=audio …same  

@audio - rtprio 99
@audio - memlock unlimited


> On 11. Dec 2018, at 01:09, Kjetil Matheussen <[hidden email]> wrote:
>
> On Tue, Dec 11, 2018 at 1:07 AM [hidden email] <[hidden email]> wrote:
>>
>> But I was running jack before as user pi with my scripts and with systemd also as user pi … ah maybe different group? I just made the Group=pi as well… is there a special group maybe?
>>
>
> Yes, maybe you need to run in the "audio" group or something like that.
> Check /etc/security/limits.conf. Mine looks like this:
>
> @realtime   -  rtprio     99
> @realtime   -  memlock    unlimited
>
> If it looks like this, you don't need to be a member of a special group.

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

Kjetil Matheussen-2
In reply to this post by Kjetil Matheussen-2
On Tue, Dec 11, 2018 at 1:09 AM Kjetil Matheussen
<[hidden email]> wrote:
> @realtime   -  rtprio     99
> @realtime   -  memlock    unlimited
>
> If it looks like this, you don't need to be a member of a special group.

Ouch, no, you need to be a member of the realtime group.
See here: http://jackaudio.org/faq/linux_rt_config.html
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

Kjetil Matheussen-2
In reply to this post by jack@microfx.de
On Tue, Dec 11, 2018 at 1:12 AM [hidden email] <[hidden email]> wrote:
>
> I just changed it to Group=audio …same
>
>

Maybe this helps:

* - rtprio 99
* - memlock unlimited

You might also have to reboot after changing this file, don't know.
_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

jack@microfx.de
it’s already set - I pasted the output of /etc/security/limits.conf
it’s as it should be

@audio - rtprio 99
@audio - memlock unlimited

> On 11. Dec 2018, at 01:14, Kjetil Matheussen <[hidden email]> wrote:
>
> On Tue, Dec 11, 2018 at 1:12 AM [hidden email] <[hidden email]> wrote:
>>
>> I just changed it to Group=audio …same
>>
>>
>
> Maybe this helps:
>
> * - rtprio 99
> * - memlock unlimited
>
> You might also have to reboot after changing this file, don't know.

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
Reply | Threaded
Open this post in threaded view
|

Re: Jack_Capture not starting anymore after having Jackd running as systemd service

jack@microfx.de
In reply to this post by Kjetil Matheussen-2
ah.. reboot … heh … that’s it. I just rebooted - but I forgot to systemctl daemon-reload - thanks!

> On 11. Dec 2018, at 01:14, Kjetil Matheussen <[hidden email]> wrote:
>
> On Tue, Dec 11, 2018 at 1:12 AM [hidden email] <[hidden email]> wrote:
>>
>> I just changed it to Group=audio …same
>>
>>
>
> Maybe this helps:
>
> * - rtprio 99
> * - memlock unlimited
>
> You might also have to reboot after changing this file, don't know.

_______________________________________________
Jack-Devel mailing list
[hidden email]
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org
12