How to pause JACK audio client

205 views Asked by At

I'm integrating the JACK Audio Connection Kit in my app and am having a basic but annoying issue.

I basically copied and pasted the simple_client example (github code) from their own API, but the jack_shutdown() method just uses exit(1) rather than any pausing mechanism. I've tried using these two methods instead:

void jack_shutdown(void *arg){
    jack_deactivate(client);
    jack_client_close(client);
}

Although the audio stops, when running the same code as before that first starts the JACK client, from simple_client - int main (), it crashes the application. This, I'm guessing, is because of jack_client_close(client) which actually returns the following messages:

Released audio card Audio0
Released audio card Audio1
audio_reservation_finish

Can anyone tell me what "pause" function would be more appropriate? A stop function would also be useful if one were to shut down the audio system - but with the option to start it again.

2

There are 2 answers

0
Jonas Eberle On BEST ANSWER

I have not done that in my application yet, but from peeking at Ardour's code I guess that a

jack_client_close(client);

should be what JACK expects. https://github.com/Ardour/ardour/blob/365f6d633731229e7bc5d37a5fe2c9107b527e28/libs/backends/jack/jack_connection.cc#L144

I looked at Ardour because I know that it allows disconnecting and reconnecting to JACK during a session.

0
alconegro On

Well, I am not an expert, but in case that, what you actually want to do is to pause the output signal, you should use jack_port_disconnect() instead to disconnect your source_port from the destination_port, and then jack_connect() again using the source_port.