stetre / luajack

Lua bindings for the JACK Audio Connection Kit
Other
21 stars 2 forks source link

Checking if JACK server is running #6

Open theGreatWhiteShark opened 6 years ago

theGreatWhiteShark commented 6 years ago

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.

stetre commented 6 years ago

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...)

theGreatWhiteShark commented 6 years ago

Thanks a lot!

stetre commented 6 years ago

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).

theGreatWhiteShark commented 6 years ago

Alright