luajack icon indicating copy to clipboard operation
luajack copied to clipboard

Checking if JACK server is running

Open theGreatWhiteShark opened this issue 7 years ago • 4 comments

Is there a way of checking whether or not the JACK server is already running before opening a client (which causes an error)?

Most functions do require the JACK client as first argument. Among those which do not jack.port_name_size and jack.port_type_size still return the correct integer and jack.time results in a segmentation fault.

theGreatWhiteShark avatar May 21 '18 07:05 theGreatWhiteShark

You can do it by executing jack.client_open with pcall and checking the error message on failure, e.g.:

c, errmsg = pcall(jack.client_open, "myclientname", { no_start_server=true })
if not c and string.find(errmsg, 'server_failed') then error("server not running") end
...

The error message contains the status flags returned by jack_client_open, snake-cased and without the leading Jack, so 'server_failed' stands for JackServerFailed. (I'll add this to the documentation as soon as possible...)

stetre avatar May 21 '18 09:05 stetre

Thanks a lot!

theGreatWhiteShark avatar May 21 '18 10:05 theGreatWhiteShark

You're welcome.

Let's keep this issue open for the missing documentation and for the segmentation fault in jack.time (which is a direct binding to jack_get_time and I cannot find anywhere in the JACK documentation that it must not be called before connecting to the server).

stetre avatar May 21 '18 10:05 stetre

Alright

theGreatWhiteShark avatar May 21 '18 10:05 theGreatWhiteShark