2 Copyright (C) 2005 Samuel TRACOL for GRAME
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * @brief This client test the jack API.
37 #include <jack/jack.h>
38 #include <jack/transport.h>
41 #if defined(WIN32) && !defined(M_PI)
42 #define M_PI 3.151592653
46 #define jack_sleep(val) Sleep((val))
48 #define jack_sleep(val) usleep((val) * 1000)
53 jack_nframes_t ft
; // running counter frame time
54 jack_nframes_t fcs
; // from sycle start...
55 jack_nframes_t lft
; // last frame time...
60 FrameTimeCollector
* framecollect
;
61 FrameTimeCollector perpetualcollect
;
62 FrameTimeCollector lastperpetualcollect
;
63 int frames_collected
= 0;
66 jack_port_t
*output_port1
;
67 jack_port_t
*output_port1b
;
68 jack_port_t
*input_port2
;
69 jack_port_t
*output_port2
;
70 jack_port_t
*input_port1
;
73 jack_client_t
*client1
;
74 jack_client_t
*client2
;
75 const char *client_name1
;
76 const char *client_name2
;
78 unsigned long sr
; // sample rate
81 int time_before_exit
= 1;
82 // standard error count
84 int reorder
= 0; // graph reorder callback
85 int RT
= 0; // is real time or not...
86 int FW
= 0; // freewheel mode
87 int init_clbk
= 0; // init callback
89 int port_callback_reg
= 0;
90 jack_nframes_t cur_buffer_size
, old_buffer_size
, cur_pos
;
92 int count1
, count2
= 0; // for freewheel
94 int have_xrun
= 0; // msg to tell the process1 function to write a special thing in the frametime file.
95 int process1_activated
= -1; // to control processing...
96 int process2_activated
= -1; // to control processing...
97 unsigned long int index1
= 0;
98 unsigned long int index2
= 0;
99 jack_default_audio_sample_t
*signal1
; // signal source d'emission
100 jack_default_audio_sample_t
*signal2
; // tableau de reception
101 jack_transport_state_t ts
;
103 jack_position_t request_pos
;
104 int silent_error
= 0; // jack silent mode
105 int verbose_mode
= 0;
106 int transport_mode
= 1;
107 jack_nframes_t input_ext_latency
= 0; // test latency for PHY devices
108 jack_nframes_t output_ext_latency
= 0; // test latency for PHY devices
111 int starting_state
= 1;
113 int linecount
= 0; // line counter for log file of sampleframe counter --> for graph function.
114 int linebuf
= 0; // reminders for graph analysis
115 int linetransport
= 0;
120 int client_register
= 0;
123 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
124 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
126 Callbacks & basics functions
128 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
129 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
134 fprintf (stderr
, "\n\n"
135 "usage: jack_test \n"
136 " [ --time OR -t time_to_run (in seconds) ]\n"
137 " [ --quiet OR -q (quiet mode : without jack server errors) ]\n"
138 " [ --verbose OR -v (verbose mode : no details on tests done. Only main results & errors) ]\n"
139 " [ --transport OR -k (Do not test transport functions.) ]\n"
140 " --realtime OR -R (jack is in rt mode)\n\n\n"
145 void Log(const char *fmt
, ...)
150 vfprintf(stderr
, fmt
, ap
);
155 void Collect(FrameTimeCollector
* TheFrame
)
157 TheFrame
->lft
= jack_last_frame_time(client1
);
158 TheFrame
->ft
= jack_frame_time(client1
);
159 TheFrame
->fcs
= jack_frames_since_cycle_start(client1
);
162 void Jack_Thread_Init_Callback(void *arg
)
164 Log("Init callback has been successfully called. (msg from callback)\n");
168 void Jack_Freewheel_Callback(int starting
, void *arg
)
170 Log("Freewhell callback has been successfully called with value %i. (msg from callback)\n", starting
);
174 void Jack_Client_Registration_Callback(const char* name
, int val
, void *arg
)
176 Log("Client registration callback name = %s has been successfully called with value %i. (msg from callback)\n", name
, val
);
183 int Jack_Update_Buffer_Size(jack_nframes_t nframes
, void *arg
)
185 cur_buffer_size
= jack_get_buffer_size(client1
);
186 Log("Buffer size = %d (msg from callback)\n", cur_buffer_size
);
190 int Jack_XRun_Callback(void *arg
)
194 Log("Xrun has been detected ! (msg from callback)\n");
198 int Jack_Graph_Order_Callback(void *arg
)
204 int Jack_Sample_Rate_Callback(jack_nframes_t nframes
, void *arg
)
206 Log("Sample rate : %i.\n", nframes
);
210 void Jack_Error_Callback(const char *msg
)
212 if (silent_error
== 0) {
213 fprintf(stderr
, "error : %s (msg from callback)\n", msg
);
217 void jack_shutdown(void *arg
)
219 printf("Jack_test has been kicked out by jackd !\n");
223 void jack_info_shutdown(int code
, const char* reason
, void *arg
)
225 printf("JACK server failure : %s\n", reason
);
229 void Jack_Port_Register(jack_port_id_t port
, int mode
, void *arg
)
234 void Jack_Port_Connect(jack_port_id_t a
, jack_port_id_t b
, int connect
, void* arg
)
236 Log("PortConnect src = %ld dst = %ld onoff = %ld (msg from callback)\n", a
, b
, connect
);
239 int Jack_Sync_Callback(jack_transport_state_t state
, jack_position_t
*pos
, void *arg
)
245 case JackTransportStarting
:
247 if (starting_state
== 0) {
248 Log("sync callback : Releasing status : now ready...\n");
251 if (sync_called
== 1) {
252 Log("sync callback : Holding status...\n");
258 case JackTransportStopped
:
259 Log("sync callback : JackTransportStopped...\n");
273 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
274 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
278 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
279 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
280 * Proccess1 is for client1
281 * 4 modes, activated with process1_activated
284 * 0 : write zeros to output 1
285 * 1 : write continuously signal1 (sinusoidal test signal) to output1
286 * 3 : mode for summation test. While record (done by process2) is not running, write signal1 to both out1 & out1b.
287 * when record begin (index2 > 0), write signal1 in phase opposition to out1 & out2
288 * 5 : Frames Time checking mode : write the array containing the three values of frame_time, frames cycles start and
289 * last frame time during 150 cycles.
292 int process1(jack_nframes_t nframes
, void *arg
)
295 Collect(&perpetualcollect
);
297 fprintf(file
, "%i %i\n", (perpetualcollect
.ft
- lastperpetualcollect
.ft
), (2*cur_buffer_size
));
300 fprintf(file
, "%i 0\n", (perpetualcollect
.ft
- lastperpetualcollect
.ft
));
303 lastperpetualcollect
.ft
= perpetualcollect
.ft
;
306 jack_default_audio_sample_t
*out1
;
307 jack_default_audio_sample_t
*out1b
;
308 activated
++; // counter of callback activation
309 if (process1_activated
== 1) {
310 out1
= (jack_default_audio_sample_t
*) jack_port_get_buffer (output_port1
, nframes
);
311 for (jack_nframes_t p
= 0; p
< nframes
; p
++) {
312 out1
[p
] = signal1
[index1
];
318 if (process1_activated
== 3) {
319 out1
= (jack_default_audio_sample_t
*) jack_port_get_buffer (output_port1
, nframes
);
320 out1b
= (jack_default_audio_sample_t
*) jack_port_get_buffer (output_port1b
, nframes
);
321 for (jack_nframes_t p
= 0; p
< nframes
; p
++) {
322 out1
[p
] = signal1
[index1
];
324 out1b
[p
] = ( -1 * signal1
[index1
]);
326 out1b
[p
] = signal1
[index1
];
333 if (process1_activated
== 0) {
334 out1
= (jack_default_audio_sample_t
*) jack_port_get_buffer (output_port1
, nframes
);
335 memset (out1
, 0, sizeof (jack_default_audio_sample_t
) * nframes
); //�crit des z�ros en sortie...
337 if (process1_activated
== 5) {
338 Collect(&framecollect
[frames_collected
]);
340 if (frames_collected
> 798) {
341 process1_activated
= -1;
348 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
349 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
350 * Proccess2 is for client2
351 * 3 modes, activated with process1_activated
355 * 1 : record in2 into signal2.(for first transmit test)
356 * 2 : record in2 into signal2 while send signal1 in out2. used dor Tie data test.
357 * 3 : record in2 into sigal2 for summation data test.
358 * In records modes, at the end of the record (signal2 is full), it stop the test, setting both activation states to -1.
361 int process2(jack_nframes_t nframes
, void *arg
)
363 jack_default_audio_sample_t
*out2
;
364 jack_default_audio_sample_t
*in2
;
366 if (process2_activated
== 1) { // Reception du process1 pour comparer les donnees
367 in2
= (jack_default_audio_sample_t
*) jack_port_get_buffer (input_port2
, nframes
);
368 for (unsigned int p
= 0; p
< nframes
; p
++) {
369 signal2
[index2
] = in2
[p
];
370 if (index2
== 95999) {
371 process2_activated
= 0;
372 process1_activated
= 0;
380 if (process2_activated
== 2) { // envoie de signal1 pour test tie mode et le r�cup�re direct + latence de la boucle jack...
381 out2
= (jack_default_audio_sample_t
*) jack_port_get_buffer (output_port2
, nframes
);
382 in2
= (jack_default_audio_sample_t
*) jack_port_get_buffer (input_port2
, nframes
);
384 for (unsigned int p
= 0; p
< nframes
; p
++) {
385 out2
[p
] = signal1
[index1
];
389 signal2
[index2
] = in2
[p
];
390 if (index2
== 95999) {
391 process2_activated
= -1;
399 if (process2_activated
== 3) { // envoie de -signal1 pour sommation en oppo de phase par jack
400 in2
= (jack_default_audio_sample_t
*) jack_port_get_buffer (input_port2
, nframes
);
402 for (unsigned int p
= 0; p
< nframes
;p
++) {
403 signal2
[index2
] = in2
[p
];
404 if (index2
== 95999) {
405 process2_activated
= 0;
406 process1_activated
= 0;
417 // Alternate thread model
418 static int _process (jack_nframes_t nframes
)
420 jack_default_audio_sample_t
*in
, *out
;
421 in
= (jack_default_audio_sample_t
*)jack_port_get_buffer (input_port1
, nframes
);
422 out
= (jack_default_audio_sample_t
*)jack_port_get_buffer (output_port1
, nframes
);
424 sizeof (jack_default_audio_sample_t
) * nframes
);
428 static void* jack_thread(void *arg
)
430 jack_client_t
* client
= (jack_client_t
*) arg
;
431 jack_nframes_t last_thread_time
= jack_frame_time(client
);
434 jack_nframes_t frames
= jack_cycle_wait (client
);
435 jack_nframes_t current_thread_time
= jack_frame_time(client
);
436 jack_nframes_t delta_time
= current_thread_time
- last_thread_time
;
437 Log("jack_thread : delta_time = %ld\n", delta_time
);
438 int status
= _process(frames
);
439 last_thread_time
= current_thread_time
;
440 jack_cycle_signal (client
, status
);
446 // To test callback exiting
447 int process3(jack_nframes_t nframes
, void *arg
)
449 static int process3_call
= 0;
451 if (process3_call
++ > 10) {
452 Log("process3 callback : exiting...\n");
455 Log("calling process3 callback : process3_call = %ld\n", process3_call
);
460 int process4(jack_nframes_t nframes
, void *arg
)
462 jack_client_t
* client
= (jack_client_t
*) arg
;
464 static jack_nframes_t last_time
= jack_frame_time(client
);
465 static jack_nframes_t tolerance
= (jack_nframes_t
)(cur_buffer_size
* 0.1f
);
467 jack_nframes_t cur_time
= jack_frame_time(client
);
468 jack_nframes_t delta_time
= cur_time
- last_time
;
470 Log("calling process4 callback : jack_frame_time = %ld delta_time = %ld\n", cur_time
, delta_time
);
471 if (delta_time
> 0 && (unsigned int)abs(delta_time
- cur_buffer_size
) > tolerance
) {
472 printf("!!! ERROR !!! jack_frame_time seems to return incorrect values cur_buffer_size = %d, delta_time = %d\n", cur_buffer_size
, delta_time
);
475 last_time
= cur_time
;
479 static void display_transport_state()
481 jack_transport_state_t ts
;
484 ts
= jack_transport_query(client2
, &pos
);
486 case JackTransportStopped
:
487 Log("Transport is stopped...\n");
489 case JackTransportRolling
:
490 Log("Transport is rolling...\n");
492 case JackTransportLooping
:
493 Log("Transport is looping...\n");
495 case JackTransportStarting
:
496 Log("Transport is starting...\n");
498 case JackTransportNetStarting
:
499 Log("Transport is starting with network sync...\n");
505 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
506 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
507 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
508 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
510 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
511 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
512 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
513 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
515 int main (int argc
, char *argv
[])
517 const char **inports
; // array of PHY input/output
518 const char **outports
; // array of PHY input/outputs
519 const char *server_name
= NULL
;
520 const char **connexions1
;
521 const char **connexions2
;
522 jack_status_t status
;
523 char portname
[128] = "port";
524 char filename
[128] = "framefile.ext";
525 const char *nullportname
= "";
528 int a
= 0; // working number for in/out port (PHY)...
529 int test_link
= 0; // for testing the "overconnect" function
530 int flag
; // flag for ports...
531 int is_mine
= 0; // to test jack_port_is_mine function...
532 const char *options
= "kRnqvt:";
533 float ratio
; // for speed calculation in freewheel mode
534 jack_options_t jack_options
= JackNullOption
;
535 struct option long_options
[] = {
536 {"realtime", 0, 0, 'R'},
537 {"non-realtime", 0, 0, 'n'},
539 {"quiet", 0, 0, 'q'},
540 {"verbose", 0, 0, 'v'},
541 {"transport", 0, 0, 'k'},
545 client_name1
= "jack_test";
547 while ((opt
= getopt_long (argc
, argv
, options
, long_options
, &option_index
)) != EOF
) {
557 printf("Verbose mode is activated...\n");
560 time_to_run
= atoi(optarg
);
566 fprintf (stderr
, "unknown option %c\n", opt
);
572 printf("Jack server is said being in realtime mode...\n");
574 printf("Jack server is said being in non-realtime mode...\n");
577 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
578 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
579 init signal data for test
580 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
581 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
583 framecollect
= (FrameTimeCollector
*) malloc(800 * sizeof(FrameTimeCollector
));
585 signal1
= (jack_default_audio_sample_t
*) malloc(48000 * sizeof(jack_default_audio_sample_t
));
586 signal2
= (jack_default_audio_sample_t
*) malloc(96000 * sizeof(jack_default_audio_sample_t
));
589 for (p
= 1; p
< 48000;p
++) {
590 signal1
[p
] = (float)(sin((p
* 2 * M_PI
* 1000 ) / 48000));
592 for (p
= 0; p
< 95999;p
++) {
598 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
599 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
601 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
602 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
604 printf("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
605 printf("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
606 printf("*-*-*-*-*-*-*-*-*-*-*-*-*-* Start jack server stress test *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
607 printf("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
608 printf("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
611 * Register a client...
614 Log("Register a client using jack_client_open()...\n");
615 client1
= jack_client_open(client_name1
, jack_options
, &status
, server_name
);
616 if (client1
== NULL
) {
617 fprintf (stderr
, "jack_client_open() failed, "
618 "status = 0x%2.0x\n", status
);
619 if (status
& JackServerFailed
) {
620 fprintf(stderr
, "Unable to connect to JACK server\n");
624 if (status
& JackServerStarted
) {
625 fprintf(stderr
, "JACK server started\n");
629 * try to register another one with the same name...
632 Log("trying to register a new jackd client with name %s using jack_client_new()...\n", client_name1
);
633 client2
= jack_client_new(client_name1
);
634 if (client2
== NULL
) {
635 Log ("valid : a second client with the same name cannot be registered\n");
637 printf("!!! ERROR !!! Jackd server has accepted multiples client with the same name !\n");
638 jack_client_close(client2
);
642 * try to register another one with the same name using jack_client_open ==> since JackUseExactName is not used, an new client should be opened...
645 Log("trying to register a new jackd client with name %s using jack_client_open()...\n", client_name1
);
646 client2
= jack_client_open(client_name1
, jack_options
, &status
, server_name
);
647 if (client2
!= NULL
) {
648 Log ("valid : a second client with the same name can be registered (client automatic renaming)\n");
649 jack_client_close(client2
);
651 printf("!!! ERROR !!! Jackd server automatic renaming feature does not work!\n");
655 * testing client name...
656 * Verify that the name sended at registration and the one returned by jack server is the same...
659 Log("Testing name...");
660 client_name2
= jack_get_client_name(client1
);
661 if (strcmp(client_name1
, client_name2
) == 0)
664 printf("\n!!! ERROR !!! name returned different from the one given : %s\n", client_name2
);
668 * verify if the real time mode returned by jack match the optional argument defined when launching jack_test*/
669 if (jack_is_realtime(client1
) == RT
)
670 Log("Jackd is in realtime mode (RT = %i).\n", RT
);
672 printf("!!! ERROR !!! Jackd is in a non-expected realtime mode (RT = %i).\n", RT
);
675 * Register all callbacks...
678 if (jack_set_thread_init_callback(client1
, Jack_Thread_Init_Callback
, 0) != 0)
679 printf("!!! ERROR !!! while calling jack_set_thread_init_callback()...\n");
680 if (jack_set_freewheel_callback(client1
, Jack_Freewheel_Callback
, 0) != 0 )
681 printf("\n!!! ERROR !!! while calling jack_set_freewheel_callback()...\n");
683 if (jack_set_process_callback(client1
, process1
, 0) != 0) {
684 printf("Error when calling jack_set_process_callback() !\n");
687 jack_on_shutdown(client1
, jack_shutdown
, 0);
688 jack_on_info_shutdown(client1
, jack_info_shutdown
, 0);
690 if (jack_set_buffer_size_callback(client1
, Jack_Update_Buffer_Size
, 0) != 0) {
691 printf("Error when calling buffer_size_callback !\n");
694 if (jack_set_graph_order_callback(client1
, Jack_Graph_Order_Callback
, 0) != 0) {
695 printf("Error when calling Jack_Graph_Order_Callback() !\n");
698 if (jack_set_xrun_callback(client1
, Jack_XRun_Callback
, 0 ) != 0) {
699 printf("Error when calling jack_set_xrun_callback() !\n");
702 if (jack_set_sample_rate_callback(client1
, Jack_Sample_Rate_Callback
, 0 ) != 0) {
703 printf("Error when calling Jack_Sample_Rate_Callback() !\n");
706 if (jack_set_port_registration_callback(client1
, Jack_Port_Register
, 0) != 0) {
707 printf("Error when calling jack_set_port_registration_callback() !\n");
710 if (jack_set_port_connect_callback(client1
, Jack_Port_Connect
, 0) != 0) {
711 printf("Error when calling jack_set_port_connect_callback() !\n");
714 if (jack_set_client_registration_callback(client1
, Jack_Client_Registration_Callback
, 0) != 0) {
715 printf("Error when calling jack_set_client_registration_callback() !\n");
718 jack_set_error_function(Jack_Error_Callback
);
721 * Create file for clock "frame time" analysis
724 cur_buffer_size
= jack_get_buffer_size(client1
);
725 sprintf (filename
, "framefile-%i.dat", cur_buffer_size
);
726 file
= fopen(filename
, "w");
728 fprintf(stderr
, "Erreur dans l'ouverture du fichier log framefile.dat");
733 * Try to register a client with a NULL name/zero length name...
736 output_port1
= jack_port_register(client1
, nullportname
,
737 JACK_DEFAULT_AUDIO_TYPE
,
738 JackPortIsOutput
, 0);
739 if (output_port1
== NULL
) {
740 Log("Can't register a port with a NULL portname... ok.\n");
742 printf("!!! ERROR !!! Can register a port with a NULL portname !\n");
743 jack_port_unregister(client1
, output_port1
);
747 * Register 1 port in order to stress other functions.
750 output_port1
= jack_port_register(client1
, portname
,
751 JACK_DEFAULT_AUDIO_TYPE
,
752 JackPortIsOutput
, 0);
753 if (output_port1
== NULL
) {
754 printf("!!! ERROR !!! Can't register any port for the client !\n");
759 * Test port type of the just registered port.
762 if (strcmp(jack_port_type(output_port1
), JACK_DEFAULT_AUDIO_TYPE
) != 0) {
763 printf("!!! ERROR !!! jack_port_type returns an incorrect value!\n");
765 Log("Checking jack_port_type()... ok.\n");
769 * Try to register another port with the same name...
772 output_port2
= jack_port_register(client1
, portname
,
773 JACK_DEFAULT_AUDIO_TYPE
,
774 JackPortIsOutput
, 0);
775 if (output_port2
== NULL
) {
776 Log("Can't register two ports with the same name... ok\n");
778 if (strcmp (jack_port_name(output_port1
), jack_port_name(output_port2
)) == 0) {
779 printf("!!! ERROR !!! Can register two ports with the same name ! (%px : %s & %px : %s).\n", output_port1
, jack_port_name(output_port1
), output_port2
, jack_port_name(output_port2
));
780 jack_port_unregister(client1
, output_port2
);
782 Log("Can't register two ports with the same name... ok (auto-rename %s into %s).\n", jack_port_name(output_port1
), jack_port_name(output_port2
));
783 jack_port_unregister(client1
, output_port2
);
788 * Verify that both port_name and port_short_name return correct results...
791 sprintf (portname
, "%s:%s", jack_get_client_name(client1
), jack_port_short_name(output_port1
));
792 if (strcmp(jack_port_name(output_port1
), portname
) != 0) {
793 printf("!!! ERROR !!! functions jack_port_name and/or jack_short_port_name seems to be invalid !\n");
794 printf("client_name = %s\n short_port_name = %s\n port_name = %s\n", jack_get_client_name(client1
), jack_port_short_name(output_port1
), jack_port_name(output_port1
));
798 * Verify the function port_set_name
801 if (jack_port_set_name (output_port1
, "renamed-port#") == 0 ) {
802 if (strcmp(jack_port_name(output_port1
), "renamed-port#") == 0) {
803 printf("!!! ERROR !!! functions jack_port_set_name seems to be invalid !\n");
804 printf("jack_port_name return '%s' whereas 'renamed-port#' was expected...\n", jack_port_name(output_port1
));
806 Log("Checking jack_port_set_name()... ok\n");
807 jack_port_set_name (output_port1
, "port");
810 printf("error : port_set_name function can't be tested...\n");
814 * Activate the client
817 if (jack_activate(client1
) < 0) {
818 printf ("Fatal error : cannot activate client1\n");
823 * Test if init callback initThread have been called.
827 printf("!!! ERROR !!! JackThreadInitCallback was not called !!.\n");
829 jack_sleep(10 * 1000); // test see the clock in the graph at the begining...
832 * Stress Freewheel mode...
833 * Try to enter freewheel mode. Check the realtime mode de-activation.
834 * Check that the number of call of the process callback is greater than in non-freewheel mode.
835 * Give an approximated speed ratio (number of process call) between the two modes.
836 * Then return in normal mode.
840 jack_sleep(1 * 1000);
842 Log("Testing activation freewheel mode...\n");
843 linefw
= linecount
; // count for better graph reading with gnuplot
844 jack_set_freewheel(client1
, 1);
846 jack_sleep(1 * 1000);
848 if (jack_is_realtime(client1
) == 0) {
851 printf("\n!!! ERROR !!! RT mode is always activated while freewheel mode is applied !\n");
855 printf("!!! ERROR !!! Freewheel mode doesn't activate audio callback !!\n");
857 jack_set_freewheel(client1
, 0);
858 jack_sleep(7 * 1000);
860 if (jack_is_realtime(client1
) == 1) {}
862 printf("\n!!! ERROR !!! freewheel mode fail to reactivate RT mode when exiting !\n");
866 Log("Freewheel mode appears to work well...\n");
869 Log("Audio Callback in 'standard' (non-freewheel) mode seems not to be called...\n");
870 Log("Ratio speed would be unavailable...\n");
872 ratio
= (float) ((count2
- count1
) / count1
);
873 Log("Approximative speed ratio of freewheel mode = %f : 1.00\n", ratio
);
877 * Stress buffer function...
878 * get current buffer size.
879 * Try to apply a new buffer size value ( 2 x the precedent buffer size value)
880 * Then return in previous buffer size mode.
885 old_buffer_size
= jack_get_buffer_size(client1
);
886 Log("Testing BufferSize change & Callback...\n--> Current buffer size : %i.\n", old_buffer_size
);
888 if (jack_set_buffer_size(client1
, (jack_nframes_t
)(old_buffer_size
* factor
)) < 0) {
889 printf("!!! ERROR !!! jack_set_buffer_size fails !\n");
891 jack_sleep(1 * 1000);
892 cur_buffer_size
= jack_get_buffer_size(client1
);
893 if ((old_buffer_size
* factor
) != cur_buffer_size
) {
894 printf("!!! ERROR !!! Buffer size has not been changed !\n");
895 printf("!!! Maybe jack was compiled without the '--enable-resize' flag...\n");
897 Log("jack_set_buffer_size() command successfully applied...\n");
899 jack_sleep(3 * 1000);
900 jack_set_buffer_size(client1
, old_buffer_size
);
901 cur_buffer_size
= jack_get_buffer_size(client1
);
904 * Test the last regestered port to see if port_is_mine function the right value.
905 * A second test will be performed later.
906 * The result will be printed at the end.
909 if (jack_port_is_mine(client1
, output_port1
)) {
916 * Check that the ID returned by the port_by_name is right.
917 * (it seems there is a problem here in some jack versions).
920 if (output_port1
!= jack_port_by_name(client1
, jack_port_name(output_port1
))) {
921 printf("!!! ERROR !!! function jack_port_by_name() return bad value !\n");
922 printf("!!! jack_port_by_name(jack_port_name(_ID_) ) != _ID_returned_at_port_registering ! (%px != %px)\n", jack_port_by_name(client1
, jack_port_name(output_port1
)), output_port1
);
924 Log("Checking jack_port_by_name() return value... ok\n");
926 if (NULL
!= jack_port_by_name(client1
, jack_port_short_name(output_port1
))) {
927 printf("!!! ERROR !!! function jack_port_by_name() return a value (%px) while name is incomplete !\n", jack_port_by_name(client1
, jack_port_short_name(output_port1
)));
929 Log("Checking jack_port_by_name() with bad argument... ok (returned id 0)\n");
933 * remove the output port previously created
934 * no more ports should subsist here for our client.
937 if (jack_port_unregister(client1
, output_port1
) != 0) {
938 printf("!!! ERROR !!! while unregistering port %s.\n", jack_port_name(output_port1
));
945 inports
= jack_get_ports(client1
, NULL
, NULL
, 0);
948 * Test the first PHY (physical) connection to see if it's "mine".
949 * and report the result in the test that began before.
950 * The result is printed later.
953 if (jack_port_is_mine(client1
, jack_port_by_name(client1
, inports
[0]))) {
958 * List all devices' flags and print them...
961 Log("\nTry functions jack_get_ports, jack_port_flag & jack_port_by_name to list PHY devices...\n");
962 Log("-----------------------------------------------------------\n");
963 Log("---------------------------DEVICES-------------------------\n");
964 Log("-----------------------------------------------------------\n");
966 while (inports
[a
] != NULL
) {
967 flag
= jack_port_flags(jack_port_by_name(client1
, inports
[a
]) );
968 Log(" * %s (id : %i)\n", inports
[a
], jack_port_by_name(client1
, inports
[a
]));
970 if (flag
& JackPortIsInput
)
971 Log("JackPortIsInput ");
972 if (flag
& JackPortIsOutput
)
973 Log("JackPortIsOutput ");
974 if (flag
& JackPortIsPhysical
)
975 Log("JackPortIsPhysical ");
976 if (flag
& JackPortCanMonitor
)
977 Log("JackPortCanMonitor ");
978 if (flag
& JackPortIsTerminal
)
979 Log("JackPortIsTerminal ");
983 Log("-----------------------------------------------------------\n\n");
986 * list all PHY in/out ports...
987 * This list will be used later many times.
990 outports
= jack_get_ports(client1
, NULL
, NULL
, JackPortIsPhysical
| JackPortIsOutput
);
991 inports
= jack_get_ports(client1
, NULL
, NULL
, JackPortIsPhysical
| JackPortIsInput
);
993 if (outports
== NULL
) {
994 printf("!!! WARNING !!! no physical capture ports founded !\n");
996 if (inports
== NULL
) {
997 printf("!!! WARNING !!! no physical output ports founded !\n");
1001 * Brute test : try to create as many ports as possible.
1002 * It stops when jack returns an error.
1003 * Then try to connect each port to physical entry...
1004 * Check also that graph reorder callback is called.
1007 Log("Registering as many ports as possible and connect them to physical entries...\n");
1008 lineports
= linecount
;
1011 i
= 0; // number of couple 'input-ouput'
1012 j
= 0; // number of ports created
1013 port_callback_reg
= 0; // number of port registration received by the callback
1014 reorder
= 0; // number of graph reorder callback activation
1015 test_link
= 0 ; // Test the "overconnect" function only one time
1016 while (t_error
== 0) {
1017 sprintf (portname
, "input_%d", i
);
1018 input_port1
= jack_port_register(client1
, portname
,
1019 JACK_DEFAULT_AUDIO_TYPE
,
1020 JackPortIsInput
, 0);
1022 if (input_port1
== NULL
) {
1026 // Connect created input to PHY output
1028 while (outports
[a
] != NULL
) {
1029 if (jack_connect(client1
, outports
[a
], jack_port_name(input_port1
))) {
1030 printf ("error : cannot connect input PHY port to client port %s\n", jack_port_name(input_port1
));
1032 // printf ("input PHY port %s connected to client port %s\n", outports[a], jack_port_name(input_port1));
1036 // Try one time to "overconnect" 2 ports (the latest created)...
1037 if (test_link
== 0) {
1038 if (jack_connect(client1
, outports
[a
- 1], jack_port_name(input_port1
)) == EEXIST
) {
1039 // cannot over-connect input PHY port to client port. ok.
1045 sprintf(portname
, "output_%d", i
);
1046 output_port1
= jack_port_register(client1
, portname
,
1047 JACK_DEFAULT_AUDIO_TYPE
,
1048 JackPortIsOutput
, 0);
1050 if (output_port1
== NULL
) {
1054 // Connect created input to PHY output
1056 while (inports
[a
] != NULL
) {
1057 if (jack_connect(client1
, jack_port_name(output_port1
), inports
[a
])) {
1058 printf ("error : cannot connect input PHY port %s to client port %s\n", inports
[a
], jack_port_name(output_port1
));
1060 // output PHY port %s connected to client port. ok.
1064 // Try one time to "overconnect" 2 ports (the latest created)...
1065 if (test_link
== 0) {
1066 if (jack_connect(client1
, jack_port_name(output_port1
), inports
[a
- 1]) == EEXIST
) {
1067 // cannot over-connect output PHY port to client port. ok.
1075 jack_sleep(1 * 1000); // To hope all port registration and reorder callback have been received...
1076 if (j
== port_callback_reg
) {
1077 Log("%i ports have been successfully created, and %i callback reg ports have been received... ok\n", j
, port_callback_reg
);
1079 printf("!!! ERROR !!! %i ports have been created, and %i callback reg ports have been received !\n", j
, k
);
1081 if (reorder
== (2 * j
)) {
1082 Log("%i graph reorder callback have been received... ok\n", reorder
);
1084 printf("!!! ERROR !!! %i graph reorder callback have been received (maybe non-valid value)...\n", reorder
);
1087 * print basic test connection functions result ...
1088 * over-connected means here that we try to connect 2 ports that are already connected.
1092 Log("Jack links can't be 'over-connected'... ok\n");
1094 printf("!!! ERROR !!! Jack links can be 'over-connected'...\n");
1097 * Print the result of the two jack_is_mine test.
1101 Log("Checking jack_port_is_mine()... ok\n");
1103 printf("!!! ERROR !!! jack_port_is_mine() function seems to send non-valid datas !\n");
1106 * Free the array of the physical input and ouput ports.
1107 * (as mentionned in the doc of jack_get_ports)
1114 * Try to "reactivate" the client whereas it's already activated...
1117 if (jack_activate(client1
) < 0) {
1118 printf("!!! ERROR !!! Cannot activate client1 a second time...\n");
1121 Log("jackd server accept client.jack_activate() re-activation (while client was already activated).\n");
1125 * Deregister all ports previously created.
1128 Log("Deregistering all ports of the client...\n");
1129 inports
= jack_get_ports(client1
, NULL
, NULL
, 0);
1131 while (inports
[a
] != NULL
) {
1132 flag
= jack_port_flags(jack_port_by_name(client1
, inports
[a
]));
1133 input_port1
= jack_port_by_name(client1
, inports
[a
]);
1134 if (jack_port_is_mine(client1
, input_port1
)) {
1135 if (jack_port_unregister(client1
, input_port1
) != 0) {
1136 printf("!!! ERROR !!! while unregistering port %s.\n", jack_port_name(output_port1
));
1142 free(inports
); // free array of ports (as mentionned in the doc of jack_get_ports)
1145 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1146 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1147 Open a new client (second one) to test some other things...
1148 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1149 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1152 Log("\n\n----------------------------------------------------------------------\n");
1153 Log("Starting second new client 'jack_test_#2'...\n");
1154 /* open a client connection to the JACK server */
1155 client_name2
= "jack_test_#2";
1156 linecl2
= linecount
; // reminders for graph analysis
1157 client2
= jack_client_new(client_name2
);
1159 if (client2
== NULL
) {
1160 fprintf(stderr
, "jack_client_new() failed for %s.\n"
1161 "status = 0x%2.0x\n", client_name2
, status
);
1162 if (status
& JackServerFailed
) {
1163 fprintf(stderr
, "Unable to connect client2 to JACK server\n");
1168 // Check client registration callback
1170 if (client_register
== 0)
1171 printf("!!! ERROR !!! Client registration callback not called!\n");
1174 * Register callback for this client.
1175 * Callbacks are the same as the first client for most of them, excepted for process audio callback.
1178 jack_set_port_registration_callback(client2
, Jack_Port_Register
, 0);
1180 jack_set_process_callback(client2
, process2
, 0);
1182 jack_on_shutdown(client2
, jack_shutdown
, 0);
1185 * Register one input and one output for each client.
1188 Log("registering 1 input/output ports for each client...\n");
1190 output_port1
= jack_port_register(client1
, "out1",
1191 JACK_DEFAULT_AUDIO_TYPE
,
1192 JackPortIsOutput
, 0);
1193 output_port2
= jack_port_register(client2
, "out2",
1194 JACK_DEFAULT_AUDIO_TYPE
,
1195 JackPortIsOutput
, 0);
1196 input_port1
= jack_port_register(client1
, "in1",
1197 JACK_DEFAULT_AUDIO_TYPE
,
1198 JackPortIsInput
, 0);
1199 input_port2
= jack_port_register(client2
, "in2",
1200 JACK_DEFAULT_AUDIO_TYPE
,
1201 JackPortIsInput
, 0);
1202 if ((output_port1
== NULL
) || (output_port2
== NULL
) || (input_port1
== NULL
) || (input_port2
== NULL
)) {
1203 printf("!!! ERROR !!! Unable to register ports...\n");
1207 * Set each process mode to idle and activate client2
1210 process2_activated
= -1;
1211 process1_activated
= -1;
1212 if (jack_activate(client2
) < 0) {
1213 printf ("Fatal error : cannot activate client2\n");
1218 * Connect the two clients and check that all connections are well-done.
1221 Log("Testing connections functions between clients...\n");
1222 if (jack_connect(client1
, jack_port_name(output_port1
), jack_port_name(input_port2
)) != 0) {
1223 printf("!!! ERROR !!! while client1 intenting to connect ports...\n");
1225 if (jack_connect(client2
, jack_port_name(output_port2
), jack_port_name(input_port1
)) != 0) {
1226 printf("!!! ERROR !!! while client2 intenting to connect ports...\n");
1228 if (jack_connect(client1
, jack_port_name(output_port1
), jack_port_name(input_port1
)) != 0) {
1229 printf("!!! ERROR !!! while client1 intenting to connect ports...\n");
1233 * Test the port_connected function...
1236 if ((jack_port_connected(output_port1
) == jack_port_connected(input_port1
)) &&
1237 (jack_port_connected(output_port2
) == jack_port_connected(input_port2
)) &&
1238 (jack_port_connected(output_port2
) == 1) &&
1239 (jack_port_connected(output_port1
) == 2)
1241 Log("Checking jack_port_connected()... ok.\n");
1243 printf("!!! ERROR !!! function jack_port_connected() return a bad value !\n");
1244 printf("jack_port_connected(output_port1) %d\n", jack_port_connected(output_port1
));
1245 printf("jack_port_connected(output_port2) %d\n", jack_port_connected(output_port2
));
1246 printf("jack_port_connected(input_port1) %d\n", jack_port_connected(input_port1
));
1247 printf("jack_port_connected(input_port2) %d\n", jack_port_connected(input_port2
));
1251 * Test a new time the port_by_name function...(now we are in multi-client mode)
1254 Log("Testing again jack_port_by_name...\n");
1255 if (output_port1
!= jack_port_by_name(client1
, jack_port_name(output_port1
))) {
1256 printf("!!! ERROR !!! function jack_port_by_name() return bad value in a multi-client application!\n");
1257 printf("!!! jack_port_by_name(jack_port_name(_ID_) ) != _ID_ in multiclient application.\n");
1259 Log("Checking jack_port_by_name() function with a multi-client application... ok\n");
1263 * Test the port_connected_to function...
1266 if ((jack_port_connected_to (output_port1
, jack_port_name(input_port2
))) &&
1267 (!(jack_port_connected_to (output_port2
, jack_port_name(input_port2
))))) {
1268 Log("checking jack_port_connected_to()... ok\n");
1270 printf("!!! ERROR !!! jack_port_connected_to() return bad value !\n");
1274 * Test the port_get_connections & port_get_all_connections functions...
1277 Log("Testing jack_port_get_connections and jack_port_get_all_connections...\n");
1280 connexions1
= jack_port_get_connections (output_port1
);
1281 connexions2
= jack_port_get_all_connections(client1
, output_port1
);
1282 if ((connexions1
== NULL
) || (connexions2
== NULL
)) {
1283 printf("!!! ERROR !!! port_get_connexions or port_get_all_connexions return a NULL pointer !\n");
1285 while ((connexions1
[a
] != NULL
) && (connexions2
[a
] != NULL
) && (t_error
== 0)) {
1286 t_error
= strcmp(connexions1
[a
], connexions2
[a
]);
1291 Log("Checking jack_port_get_connections Vs jack_port_get_all_connections... ok\n");
1293 printf("!!! ERROR !!! while checking jack_port_get_connections Vs jack_port_get_all_connections...\n");
1298 inports
= jack_get_ports(client1
, NULL
, NULL
, JackPortIsPhysical
| JackPortIsInput
);
1300 assert(inports
!= NULL
);
1301 if (inports
[0] != NULL
) {
1302 connexions1
= jack_port_get_connections (jack_port_by_name(client1
, inports
[0]));
1303 connexions2
= jack_port_get_all_connections(client1
, jack_port_by_name(client1
, inports
[0]));
1307 if (connexions1
== NULL
) {
1308 Log("checking jack_port_get_connections() for external client... ok\n");
1310 while ((connexions1
[a
] != NULL
) && (connexions2
[a
] != NULL
) && (t_error
== 0)) {
1311 t_error
= strcmp(connexions1
[a
], connexions2
[a
]);
1316 Log("Checking jack_port_get_connections() Vs jack_port_get_all_connections() on PHY port... ok\n");
1318 printf("!!! ERROR !!! while checking jack_port_get_connections() Vs jack_port_get_all_connections() on PHY port...\n");
1321 if (jack_disconnect(client1
, jack_port_name(output_port1
), jack_port_name(input_port1
)) != 0) {
1322 printf("!!! ERROR !!! while client1 intenting to disconnect ports...\n");
1324 if (jack_disconnect(client1
, jack_port_name(output_port2
), jack_port_name(input_port1
)) != 0) {
1325 printf("!!! ERROR !!! while client1 intenting to disconnect ports...\n");
1327 // No links should subsist now...
1330 * Checking data connexion
1331 * establishing a link between client1.out1 --> client2.in2
1332 * Send the signal1 test on out1. Record the result into signal2. (see process functions).
1333 ---------------------------------------------------------------------------*/
1334 Log("Testing connections datas between clients...\n");
1335 jack_connect(client2
, jack_port_name(output_port1
), jack_port_name(input_port2
) );
1336 process2_activated
= -1;
1337 process1_activated
= -1;
1338 Log("process 2 : idle mode...\n");
1339 Log("Sending datas...");
1342 process1_activated
= 1; // We start emitting first.
1343 process2_activated
= 1; // So record begin at least when we just begin to emitt the signal, else at next call of process with
1344 // nframe = jack buffersize shifting.
1346 while (process2_activated
== 1) {
1347 jack_sleep(1 * 1000);
1351 Log("\nAnalysing datas...\n"); // search the first occurence of the first element of the reference signal in the recorded signal
1352 while (signal2
[index2
] != signal1
[1] ) {
1354 if (index2
== 95999) {
1355 printf("!!! ERROR !!! Data not found in first connexion data check!\n");
1360 Log("Data founded at offset %i.\n", index2
);
1361 // And now we founded were the recorded data are, we can see if the two signals matches...
1362 while ( (signal2
[index2
] == signal1
[index2
- index1
+ 1]) || (index2
== 95999) || ((index2
- index1
+ 1) == 47999) ) {
1365 Log("Checking difference between datas... %i have the same value...\n", index2
- index1
);
1366 if ((index2
- index1
) == 48000) {
1367 Log("Data received are valid...\n");
1369 printf("!!! ERROR !!! data transmission seems not to be valid in first connexion data check!\n");
1371 if (jack_disconnect(client1
, jack_port_name(output_port1
), jack_port_name(input_port2
) ) != 0)
1372 // no more connection between ports exist now...
1374 printf("Error while establishing new connexion (disconnect).\n");
1379 * (This mode seems to be problematic in standard jack version 0.100. It seems that nobody
1380 * is used to apply this mode because the tie mode doesn't work at all. A patch seems difficult to produce
1381 * in this version of jack. Tie mode work well in MP version.)
1382 * Test some basic thinks (tie with 2 differents client, tie non-owned ports...)
1383 * Tie client1.in1 and client1.out1 ports, and make some data test to check the validity of the tie.
1386 Log("Testing tie mode...\n");
1387 if (jack_port_tie(input_port1
, output_port2
) != 0) {
1388 Log("not possible to tie two ports from two differents clients... ok\n");
1390 printf("!!! ERROR !!! port_tie has allowed a connexion between two differents clients !\n");
1391 jack_port_untie(output_port2
);
1393 Log("Testing connections datas in tie mode...\n");
1395 for (g
= 0; g
< 96000; g
++)
1397 // Create a loop (emit test) client2.out2----client.in1--tie--client1.out1-----client2.in1 (receive test)
1398 if (jack_port_tie(input_port1
, output_port1
) != 0) {
1399 printf("Unable to tie... fatal error : data test will not be performed on tie mode !!\n");
1400 } else { // begin of tie
1401 if (jack_connect(client1
, jack_port_name(output_port1
), jack_port_name(input_port2
)) != 0) {
1402 printf("!!! ERROR !!! while client1 intenting to connect ports...\n");
1404 if (jack_connect(client1
, jack_port_name(output_port2
), jack_port_name(input_port1
)) != 0) {
1405 printf("!!! ERROR !!! while client1 intenting to connect ports...\n");
1408 process1_activated
= -1;
1409 process2_activated
= -1;
1411 // We can manualy check here that the tie is effective.
1412 // ie : playing a wav with a client, connecting ports manualy with qjackctl, and listen...
1413 // printf("manual test\n");
1415 // printf("end of manual test\n");
1419 process1_activated
= -1;
1420 process2_activated
= 2;
1422 Log("Sending datas...");
1424 while (process2_activated
== 2) {
1425 jack_sleep(1 * 1000);
1428 process1_activated
= -1;
1429 process2_activated
= -1;
1431 Log("\nAnalysing datas...\n");
1432 // We must find at least 2 identical values to ensure we are at the right place in the siusoidal array...
1433 while (!((signal2
[index2
] == signal1
[1]) && (signal2
[index2
+ 1] == signal1
[2]))) {
1435 if (index2
== 95999) {
1436 printf("!!! ERROR !!! Data not found in connexion check of tie mode!\n");
1441 Log("Tie mode : Data founded at offset %i.\n", index2
);
1442 while (signal2
[index2
] == signal1
[index2
- index1
+ 1]) {
1444 if ((index2
== 95999) || ((index2
- index1
+ 1) == 47999)) {
1448 Log("Checking difference between datas... %i have the same value...\n", index2
- index1
);
1449 if ((index2
- index1
) > 47995) {
1450 Log("Data received in tie mode are valid...\n");
1452 // in tie mode, the buffers adress should be the same for the two tied ports.
1453 printf("!!! ERROR !!! data transmission seems not to be valid !\n");
1454 printf("Links topology : (emitt) client2.out2 ----> client1.in1--(tie)--client1.out1----->client2.in2 (recive)\n");
1455 printf(" port_name : Port_adress \n");
1456 printf(" output_port1 : %px\n", jack_port_get_buffer(output_port1
, cur_buffer_size
));
1457 printf(" input_port2 : %px\n", jack_port_get_buffer(input_port2
, cur_buffer_size
));
1458 printf(" output_port2 : %px\n", jack_port_get_buffer(output_port2
, cur_buffer_size
));
1459 printf(" input_port1 : %px\n", jack_port_get_buffer(input_port1
, cur_buffer_size
));
1462 jack_port_untie(output_port1
);
1463 jack_port_disconnect(client1
, output_port2
);
1464 jack_port_disconnect(client1
, output_port1
);
1470 * Testing SUMMATION CAPABILITIES OF JACK CONNECTIONS
1472 * In a short test, we just check a simple summation in jack.
1473 * A first client(client1) send two signal in phase opposition
1474 * A second client(client2) record the summation at one of his port
1475 * So, the result must be zero...
1476 * See process1 for details about steps of this test
1479 // fprintf(file, "Sum test\n");
1480 Log("Checking summation capabilities of patching...\n");
1481 output_port1b
= jack_port_register(client1
, "out1b",
1482 JACK_DEFAULT_AUDIO_TYPE
,
1483 JackPortIsOutput
, 0);
1484 jack_connect(client2
, jack_port_name(output_port1
), jack_port_name(input_port2
));
1485 jack_connect(client2
, jack_port_name(output_port1b
), jack_port_name(input_port2
));
1487 process1_activated
= 3;
1488 process2_activated
= -1;
1489 for (g
= 0; g
< 96000; g
++)
1494 Log("Sending datas...");
1495 process2_activated
= 3;
1497 while (process2_activated
== 3) {
1498 jack_sleep(1 * 1000);
1501 process1_activated
= -1;
1502 process2_activated
= -1;
1504 Log("\nAnalysing datas...\n"); // same idea as above, with first data check...
1505 while (!((signal2
[index2
] == 0.0 ) && (signal2
[(index2
+ 1)] == 0.0 ))) {
1507 if (index2
== 95999) {
1508 printf("!!! ERROR !!! Data not found in summation check!\n");
1513 Log("Data founded at offset %i.\n", index2
);
1515 while ( signal2
[index2
] == 0.0 ) {
1517 if ((index2
> 95998) || ((index2
- index1
+ 1) > 47998)) {
1521 Log("Checking difference between datas...\n");
1522 if ((index2
- index1
) > 47996) {
1523 Log("Data mixed received are valid...\nSummation is well done.\n");
1525 printf("!!! ERROR !!! data transmission / summation seems not to be valid !\n");
1527 jack_port_disconnect(client1
, output_port1
);
1528 jack_port_disconnect(client1
, output_port1b
);
1529 jack_port_unregister(client1
, output_port1b
);
1531 if (jack_port_name(output_port1b
) != NULL
) {
1532 printf("!!! WARNING !!! port_name return something while the port have been unregistered !\n");
1533 printf("!!! Name of unregistered port : %s !\n", jack_port_name(output_port1b
));
1535 Log("Checking jack_port_name() with a non valid port... ok\n");
1538 if (jack_port_set_name(output_port1b
, "new_name") == 0 ) {
1539 printf("!!! WARNING !!! An unregistered port can be renamed successfully !\n");
1541 Log("Checking renaming of an unregistered port... ok\n");
1543 inports
= jack_get_ports(client1
, NULL
, NULL
, JackPortIsPhysical
| JackPortIsInput
);
1544 if (jack_port_set_name(jack_port_by_name(client1
, inports
[0]), "new_name") == 0 ) {
1545 printf("!!! WARNING !!! A PHYSICAL port can be renamed successfully !\n");
1547 Log("Checking renaming of an unregistered port... ok\n");
1553 * Checking latency issues
1554 * here are simple latency check
1555 * We simply check that the value returned by jack seems ok
1556 * Latency compensation is a difficult point.
1557 * Actually, jack is not able to see "thru" client to build a full latency chain.
1558 * Ardour use theses informations to do internally his compensations.
1560 * 3 test are done : one with no connections between client, one with a serial connection, and one with parallel connection
1562 Log("Checking about latency functions...\n");
1564 jack_recompute_total_latencies(client1
);
1565 if ((jack_port_get_latency (output_port1
) != 0) ||
1566 (jack_port_get_total_latency(client1
, output_port1
) != 0) ) {
1568 printf("!!! ERROR !!! default latency of a non-PHY device is not set to zero !\n");
1571 inports
= jack_get_ports(client1
, NULL
, NULL
, JackPortIsPhysical
| JackPortIsInput
);
1572 outports
= jack_get_ports(client1
, NULL
, NULL
, JackPortIsPhysical
| JackPortIsOutput
);
1573 if (inports
[0] != NULL
) {
1574 output_ext_latency
= jack_port_get_latency (jack_port_by_name(client1
, inports
[0])); // from client to out driver (which has "inputs" ports..)
1575 input_ext_latency
= jack_port_get_latency (jack_port_by_name(client1
, outports
[0])); // from in driver (which has "output" ports..) to client
1576 if (output_ext_latency
!= jack_port_get_total_latency(client1
, jack_port_by_name(client1
, inports
[0]))) {
1578 printf("!!! ERROR !!! get_latency & get_all_latency for a PHY device (unconnected) didn't return the same value !\n");
1580 Log("Checking a serial model with 2 clients...\n");
1582 jack_connect(client1
, jack_port_name(output_port1
), jack_port_name(input_port2
));
1583 jack_connect(client1
, outports
[0], jack_port_name(input_port1
));
1584 jack_connect(client2
, jack_port_name(output_port2
), inports
[0]);
1585 jack_port_set_latency(output_port2
, 256);
1586 jack_recompute_total_latencies(client1
);
1588 if ((jack_port_get_latency (output_port1
) != 0) ||
1589 (jack_port_get_total_latency(client1
, output_port1
) != 0) ||
1590 (jack_port_get_latency (jack_port_by_name(client1
, inports
[0])) != (output_ext_latency
)) ||
1591 (jack_port_get_total_latency(client1
, jack_port_by_name(client1
, inports
[0])) != (output_ext_latency
+ 256)) ||
1592 (jack_port_get_total_latency(client1
, output_port2
) != (output_ext_latency
+ 256)) ||
1593 (jack_port_get_total_latency(client1
, input_port2
) != 0) ||
1594 (jack_port_get_total_latency(client1
, input_port1
) != input_ext_latency
) ||
1595 (jack_port_get_latency (jack_port_by_name(client1
, outports
[0])) != input_ext_latency
) ||
1596 (jack_port_get_total_latency(client1
, jack_port_by_name(client1
, outports
[0])) != input_ext_latency
)
1598 printf("!!! WARNING !!! get_latency functions may have a problem : bad value returned !\n");
1599 printf("!!! get_latency(output_port1) : %i (must be 0)\n", jack_port_get_latency(output_port1
));
1600 printf("!!! get_total_latency(output_port1) : %i (must be 0)\n", jack_port_get_total_latency(client1
, output_port1
));
1601 printf("!!! get_latency(PHY[0]) : %i (must be external latency : %i)\n", jack_port_get_latency(jack_port_by_name(client1
, inports
[0])), output_ext_latency
);
1602 printf("!!! get_total_latency(PHY[0]) : %i (must be %i)\n", jack_port_get_total_latency(client1
, jack_port_by_name(client1
, inports
[0])) , (output_ext_latency
+ 256));
1603 printf("!!! get_total_latency(output_port2) : %i (must be %i)\n", jack_port_get_total_latency(client1
, output_port2
), (output_ext_latency
+ 256));
1604 printf("!!! get_total_latency(input_port2) : %i (must be 0)\n", jack_port_get_total_latency(client1
, input_port2
));
1605 printf("!!! get_total_latency(input_port1) : %i (must be %i)\n", jack_port_get_total_latency(client1
, input_port1
), input_ext_latency
);
1606 printf("!!! get_latency(PHY[0]) : %i (must be %i)\n", jack_port_get_latency(jack_port_by_name(client1
, outports
[0])), input_ext_latency
);
1607 printf("!!! get_total_latency(PHY[0]) : %i (must be %i)\n", jack_port_get_total_latency(client1
, jack_port_by_name(client1
, outports
[0])), input_ext_latency
);
1610 Log("get_latency & get_total_latency seems quite ok...\n");
1613 jack_port_disconnect(client1
, output_port1
);
1614 jack_port_disconnect(client1
, output_port2
);
1615 jack_port_disconnect(client1
, input_port1
);
1616 jack_port_disconnect(client1
, input_port2
);
1617 Log("Checking a parallel model with 2 clients...\n");
1618 jack_connect(client2
, outports
[0], jack_port_name(input_port1
));
1619 jack_connect(client2
, outports
[0], jack_port_name(input_port2
));
1620 jack_connect(client2
, jack_port_name(output_port1
), inports
[0]);
1621 jack_connect(client2
, jack_port_name(output_port2
), inports
[0]);
1622 jack_port_set_latency(output_port1
, 256);
1623 jack_port_set_latency(output_port2
, 512);
1624 jack_recompute_total_latencies(client1
);
1626 if ((jack_port_get_latency(output_port1
) != 256 ) ||
1627 (jack_port_get_total_latency(client1
, output_port1
) != (256 + output_ext_latency
)) ||
1628 (jack_port_get_latency(output_port2
) != 512) ||
1629 (jack_port_get_total_latency(client1
, output_port2
) != (512 + output_ext_latency
)) ||
1630 (jack_port_get_latency(jack_port_by_name(client1
, inports
[0])) != output_ext_latency
) ||
1631 (jack_port_get_total_latency(client1
, jack_port_by_name(client1
, inports
[0])) != (512 + output_ext_latency
))
1633 printf("!!! WARNING !!! get_latency functions may have a problem : bad value returned !\n");
1634 printf("!!! get_latency(output_port1) : %i (must be 256)\n", jack_port_get_latency(output_port1
));
1635 printf("!!! get_total_latency(output_port1) : %i (must be 256 + output_ext_latency)\n", jack_port_get_total_latency(client1
, output_port1
));
1636 printf("!!! get_latency(output_port2) : %i (must 512)\n", jack_port_get_latency(output_port2
));
1637 printf("!!! get_total_latency(output_port2) : %i (must 512 + output_ext_latency)\n", jack_port_get_total_latency(client1
, output_port2
));
1638 printf("!!! get_latency(inports[0])) : %i (must output_ext_latency)\n", jack_port_get_latency(jack_port_by_name(client1
, inports
[0])));
1639 printf("!!! get_total_latency(inports[0]) : %i (must 512 + output_ext_latency)\n", jack_port_get_total_latency(client1
, jack_port_by_name(client1
, inports
[0])));
1641 Log("get_latency & get_total_latency seems quite ok...\n");
1644 printf("No physical port founded : not able to test latency functions...");
1647 jack_port_disconnect(client1
, input_port1
);
1648 jack_port_disconnect(client1
, input_port2
);
1649 jack_port_disconnect(client1
, output_port1
);
1650 jack_port_disconnect(client1
, output_port2
);
1658 * Checking transport API.
1659 * Simple transport test.
1660 * Check a transport start with a "slow" client, simulating a delay around 1 sec before becoming ready.
1663 Log("-----------------------------------------------------------\n");
1664 Log("---------------------------TRANSPORT-----------------------\n");
1665 Log("-----------------------------------------------------------\n");
1667 lineports
= linecount
;
1669 if (transport_mode
) {
1671 ts
= jack_transport_query(client1
, &pos
);
1672 if (ts
== JackTransportStopped
) {
1673 Log("Transport is stopped...\n");
1675 jack_transport_stop(client1
);
1676 Log("Transport state : %i\n", ts
);
1678 if (jack_set_sync_callback(client2
, Jack_Sync_Callback
, 0) != 0)
1679 printf("error while calling set_sync_callback...\n");
1681 Log("starting transport...\n");
1683 starting_state
= 1; // Simulate starting state
1684 jack_transport_start(client1
);
1686 // Wait until sync callback is called
1687 while (!(sync_called
)) {
1688 jack_sleep(1 * 1000);
1691 // Wait untill rolling : simulate sync time out
1692 Log("Simulate a slow-sync client exceeding the time-out\n");
1696 jack_sleep(100); // Wait 100 ms each cycle
1698 if (wait_count
== 100) {
1699 Log("!!! ERROR !!! max time-out exceedeed : sync time-out does not work correctly\n");
1702 ts
= jack_transport_query(client2
, &pos
);
1703 Log("Waiting....pos = %ld\n", pos
.frame
);
1704 display_transport_state();
1706 } while (ts
!= JackTransportRolling
);
1708 Log("Sync callback have been called %i times.\n", sync_called
);
1709 jack_transport_stop(client1
);
1711 // Wait until stopped
1712 ts
= jack_transport_query(client2
, &pos
);
1713 while (ts
!= JackTransportStopped
) {
1714 jack_sleep(1 * 1000);
1715 ts
= jack_transport_query(client2
, &pos
);
1718 // Simulate starting a slow-sync client that rolls after 0.5 sec
1719 Log("Simulate a slow-sync client that needs 0.5 sec to start\n");
1722 starting_state
= 1; // Simulate starting state
1724 Log("Starting transport...\n");
1725 jack_transport_start(client1
);
1726 display_transport_state();
1728 Log("Waiting 0.5 sec...\n");
1730 starting_state
= 0; // Simulate end of starting state after 0.5 sec
1732 // Wait untill rolling
1733 ts
= jack_transport_query(client2
, &pos
);
1734 while (ts
!= JackTransportRolling
) {
1735 jack_sleep(100); // Wait 100 ms each cycle
1737 if (wait_count
== 10) {
1738 Log("!!! ERROR !!! starting a slow-sync client does not work correctly\n");
1741 ts
= jack_transport_query(client2
, &pos
);
1744 if (sync_called
== 0)
1745 Log("!!! ERROR !!! starting a slow-sync client does not work correctly\n");
1747 Log("Sync callback have been called %i times.\n", sync_called
);
1748 display_transport_state();
1750 // Test jack_transport_locate while rolling
1751 Log("Test jack_transport_locate while rolling\n");
1752 ts
= jack_transport_query(client2
, &pos
);
1753 Log("Transport current frame = %ld\n", pos
.frame
);
1754 jack_nframes_t cur_frame
= pos
.frame
;
1758 display_transport_state();
1759 jack_sleep(10); // 10 ms
1760 // locate at first...
1762 if (wait_count
== 1) {
1763 Log("Do jack_transport_locate\n");
1764 jack_transport_locate(client1
, cur_frame
/ 2);
1765 } else if (wait_count
== 100) {
1768 ts
= jack_transport_query(client2
, &pos
);
1769 Log("Locating.... frame = %ld\n", pos
.frame
);
1770 } while (pos
.frame
> cur_frame
);
1772 ts
= jack_transport_query(client2
, &pos
);
1773 Log("Transport current frame = %ld\n", pos
.frame
);
1774 if (wait_count
== 100) {
1775 printf("!!! ERROR !!! jack_transport_locate does not work correctly\n");
1778 // Test jack_transport_reposition while rolling
1779 Log("Test jack_transport_reposition while rolling\n");
1780 ts
= jack_transport_query(client2
, &pos
);
1781 Log("Transport current frame = %ld\n", pos
.frame
);
1782 cur_frame
= pos
.frame
;
1786 display_transport_state();
1787 jack_sleep(10); // 10 ms
1788 // locate at first...
1790 if (wait_count
== 1) {
1791 Log("Do jack_transport_reposition\n");
1792 request_pos
.frame
= cur_frame
/ 2;
1793 jack_transport_reposition(client1
, &request_pos
);
1794 } else if (wait_count
== 100) {
1797 ts
= jack_transport_query(client2
, &pos
);
1798 Log("Locating.... frame = %ld\n", pos
.frame
);
1799 } while (pos
.frame
> cur_frame
);
1801 ts
= jack_transport_query(client2
, &pos
);
1802 Log("Transport current frame = %ld\n", pos
.frame
);
1803 if (wait_count
== 100) {
1804 printf("!!! ERROR !!! jack_transport_reposition does not work correctly\n");
1807 // Test jack_transport_reposition while stopped
1808 jack_transport_stop(client1
);
1809 ts
= jack_transport_query(client2
, &pos
);
1810 Log("Transport current frame = %ld\n", pos
.frame
);
1812 Log("Test jack_transport_reposition while stopped\n");
1814 request_pos
.frame
= 10000;
1815 jack_transport_reposition(client1
, &request_pos
);
1818 display_transport_state();
1819 jack_sleep(100); // 100 ms
1820 if (wait_count
++ == 10)
1822 ts
= jack_transport_query(client2
, &pos
);
1823 Log("Locating.... frame = %ld\n", pos
.frame
);
1824 } while (pos
.frame
!= 10000);
1826 ts
= jack_transport_query(client2
, &pos
);
1827 Log("Transport current frame = %ld\n", pos
.frame
);
1828 if (pos
.frame
!= 10000) {
1829 printf("!!! ERROR !!! jack_transport_reposition does not work correctly\n");
1832 jack_transport_stop(client1
);
1834 /* Tell the JACK server that we are ready to roll. Our
1835 * process() callback will start running now. */
1838 printf("Transport check is disabled...\n");
1841 time_before_exit
= time_to_run
;
1842 while (time_before_exit
!= 0) {
1843 jack_sleep (1 * 1000);
1847 if (jack_deactivate(client2
) != 0) {
1848 printf("!!! ERROR !!! jack_deactivate does not return 0 for client2 !\n");
1850 if (jack_deactivate(client1
) != 0) {
1851 printf("!!! ERROR !!! jack_deactivate does not return 0 for client1 !\n");
1855 * Checking jack_frame_time.
1857 Log("Testing jack_frame_time...\n");
1858 jack_set_process_callback(client1
, process4
, client1
);
1859 jack_activate(client1
);
1860 jack_sleep(2 * 1000);
1864 * Checking alternate thread model
1866 Log("Testing alternate thread model...\n");
1867 jack_deactivate(client1
);
1868 jack_set_process_callback(client1
, NULL
, NULL
); // remove callback
1869 jack_set_process_thread(client1
, jack_thread
, client1
);
1870 jack_activate(client1
);
1871 jack_sleep(2 * 1000);
1874 * Checking callback exiting : when the return code is != 0, the client is desactivated.
1876 Log("Testing callback exiting...\n");
1877 jack_deactivate(client1
);
1878 jack_set_process_thread(client1
, NULL
, NULL
); // remove thread callback
1879 jack_set_process_callback(client1
, process3
, 0);
1880 jack_activate(client1
);
1881 jack_sleep(3 * 1000);
1884 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1885 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1886 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1888 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1889 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1890 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1893 if (jack_deactivate(client2
) != 0) {
1894 printf("!!! ERROR !!! jack_deactivate does not return 0 for client2 !\n");
1896 if (jack_deactivate(client1
) != 0) {
1897 printf("!!! ERROR !!! jack_deactivate does not return 0 for client1 !\n");
1899 if (jack_client_close(client2
) != 0) {
1900 printf("!!! ERROR !!! jack_client_close does not return 0 for client2 !\n");
1902 if (jack_client_close(client1
) != 0) {
1903 printf("!!! ERROR !!! jack_client_close does not return 0 for client1 !\n");
1907 Log("No Xrun have been detected during this test... cool !\n");
1909 printf("%i Xrun have been detected during this session (seen callback messages to see where are the problems).\n", xrun
);
1914 Log("Exiting jack_test...\n");
1916 printf("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
1917 sprintf (filename
, "framegraph-%i.gnu", cur_buffer_size
);
1918 file
= fopen(filename
, "w");
1920 fprintf(stderr
, "Erreur dans l'ouverture du fichier");
1923 fprintf(file
, "reset\n");
1924 fprintf(file
, "set terminal png transparent nocrop enhanced\n");
1925 fprintf(file
, "set output 'framegraph-%i-1.png'\n", cur_buffer_size
);
1926 fprintf(file
, "set title \"Frame time evolution during jack_test run\"\n");
1927 fprintf(file
, "set yrange [ %i.00000 : %i.0000 ] noreverse nowriteback\n", cur_buffer_size
- (cur_buffer_size
/ 8), cur_buffer_size
+ (cur_buffer_size
/ 8));
1928 fprintf(file
, "set xrange [ 0.00000 : %i.0000 ] noreverse nowriteback\n" , linecount
- 1);
1929 fprintf(file
, "set ylabel \"Frametime evolution (d(ft)/dt)\"\n");
1930 fprintf(file
, "set xlabel \"FrameTime\"\n");
1931 fprintf(file
, "set label \"| buf.siz:%i | fr.wl:%i | rg.ports:%i | 2nd.client:%i | trsprt:%i |\" at graph 0.01, 0.04\n", linebuf
, linefw
, lineports
, linecl2
, linetransport
);
1932 fprintf(file
, "plot 'framefile-%i.dat' using 2 with impulses title \"Xruns\",'framefile-%i.dat' using 1 with line title \"Sampletime variation at %i\"\n", cur_buffer_size
, cur_buffer_size
, cur_buffer_size
);
1934 fprintf(file
, "set output 'framegraph-%i-2.png'\n", cur_buffer_size
);
1935 fprintf(file
, "set title \"Frame time evolution during jack_test run\"\n");
1936 fprintf(file
, "set yrange [ %i.00000 : %i.0000 ] noreverse nowriteback\n", (int) (cur_buffer_size
/ 2), (int) (2*cur_buffer_size
+ (cur_buffer_size
/ 8)));
1937 fprintf(file
, "set xrange [ 0.00000 : %i.0000 ] noreverse nowriteback\n" , linecount
- 1);
1938 fprintf(file
, "set ylabel \"Frametime evolution (d(ft)/dt)\"\n");
1939 fprintf(file
, "set xlabel \"FrameTime\"\n");
1940 fprintf(file
, "set label \"| buf.siz:%i | fr.wl:%i | rg.ports:%i | 2nd.client:%i | trsprt:%i |\" at graph 0.01, 0.04\n", linebuf
, linefw
, lineports
, linecl2
, linetransport
);
1941 fprintf(file
, "plot 'framefile-%i.dat' using 2 with impulses title \"Xruns\",'framefile-%i.dat' using 1 with line title \"Sampletime variation at %i\"\n", cur_buffer_size
, cur_buffer_size
, cur_buffer_size
);