Commit 6ce2922a authored by sletz's avatar sletz
Browse files

Add test for jack_cycle_wait, jack_cycle_wait and jack_set_process_callback API.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1970 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 534475f9
......@@ -19,6 +19,10 @@ Nedko Arnaudov
Jackdmp changes log
---------------------------
2008-03-13 Stephane Letz <letz@grame.fr>
* Add test for jack_cycle_wait, jack_cycle_wait and jack_set_process_callback API.
2008-03-12 Stephane Letz <letz@grame.fr>
* Marc-Olivier Barre library related scons patch.
......
......@@ -408,6 +408,35 @@ int process2(jack_nframes_t nframes, void *arg)
return 0;
}
// Alternate thread model
static int _process (jack_nframes_t nframes)
{
jack_default_audio_sample_t *in, *out;
in = (jack_default_audio_sample_t *)jack_port_get_buffer (input_port1, nframes);
out = (jack_default_audio_sample_t *)jack_port_get_buffer (output_port1, nframes);
memcpy (out, in,
sizeof (jack_default_audio_sample_t) * nframes);
return 0;
}
static void* jack_thread(void *arg)
{
jack_client_t* client = (jack_client_t*) arg;
jack_nframes_t last_thread_time = jack_frame_time(client);
while (1) {
jack_nframes_t frames = jack_cycle_wait (client);
jack_nframes_t current_thread_time = jack_frame_time(client);
jack_nframes_t delta_time = current_thread_time - last_thread_time;
Log("jack_thread : delta_time = %ld\n", delta_time);
int status = _process(frames);
last_thread_time = current_thread_time;
jack_cycle_signal (client, status);
}
return 0;
}
// To test callback exiting
int process3(jack_nframes_t nframes, void *arg)
{
......@@ -424,10 +453,12 @@ int process3(jack_nframes_t nframes, void *arg)
int process4(jack_nframes_t nframes, void *arg)
{
static jack_nframes_t last_time = jack_frame_time((jack_client_t*)arg);
jack_client_t* client = (jack_client_t*) arg;
static jack_nframes_t last_time = jack_frame_time(client);
static jack_nframes_t tolerance = (jack_nframes_t)(cur_buffer_size * 0.1f);
jack_nframes_t cur_time = jack_frame_time((jack_client_t*)arg);
jack_nframes_t cur_time = jack_frame_time(client);
jack_nframes_t delta_time = cur_time - last_time;
Log("calling process4 callback : jack_frame_time = %ld delta_time = %ld\n", cur_time, delta_time);
......@@ -1819,11 +1850,23 @@ int main (int argc, char *argv[])
jack_activate(client1);
jack_sleep(2 * 1000);
/**
* Checking alternate thread model
*/
Log("Testing jack_frame_time...\n");
jack_deactivate(client1);
jack_set_process_callback(client1, NULL, NULL); // remove callback
jack_set_process_thread(client1, jack_thread, client1);
jack_activate(client1);
jack_sleep(2 * 1000);
/**
* Checking callback exiting : when the return code is != 0, the client is desactivated.
*/
Log("Testing callback exiting...\n");
jack_deactivate(client1);
jack_set_process_thread(client1, NULL, NULL); // remove thread callback
jack_set_process_callback(client1, process3, 0);
jack_activate(client1);
jack_sleep(3 * 1000);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment