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.
39 #include "transport.h"
43 #define M_PI 3.151592653
47 #define jack_sleep(val) Sleep((val))
49 #define jack_sleep(val) usleep((val) * 1000)
54 jack_nframes_t ft
; // running counter frame time
55 jack_nframes_t fcs
; // from sycle start...
56 jack_nframes_t lft
; // last frame time...
61 FrameTimeCollector
* framecollect
;
62 FrameTimeCollector perpetualcollect
;
63 FrameTimeCollector lastperpetualcollect
;
64 int frames_collected
= 0;
67 jack_port_t
*output_port1
;
68 jack_port_t
*output_port1b
;
69 jack_port_t
*input_port2
;
70 jack_port_t
*output_port2
;
71 jack_port_t
*input_port1
;
74 jack_client_t
*client1
;
75 jack_client_t
*client2
;
76 const char *client_name1
;
77 const char *client_name2
;
79 unsigned long sr
; // sample rate
82 int time_before_exit
= 1;
83 // standard error count
85 int reorder
= 0; // graph reorder callback
86 int RT
= 0; // is real time or not...
87 int FW
= 0; // freewheel mode
88 int init_clbk
= 0; // init callback
90 int port_callback_reg
= 0;
91 jack_nframes_t cur_buffer_size
, old_buffer_size
, cur_pos
;
93 int count1
, count2
= 0; // for freewheel
95 int have_xrun
= 0; // msg to tell the process1 function to write a special thing in the frametime file.
96 int process1_activated
= -1; // to control processing...
97 int process2_activated
= -1; // to control processing...
98 unsigned long int index1
= 0;
99 unsigned long int index2
= 0;
100 jack_default_audio_sample_t
*signal1
; // signal source d'emission
101 jack_default_audio_sample_t
*signal2
; // tableau de reception
102 jack_transport_state_t ts
;
104 jack_position_t request_pos
;
105 int silent_error
= 0; // jack silent mode
106 int verbose_mode
= 0;
107 int transport_mode
= 1;
108 int 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;
121 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
122 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
124 Callbacks & basics functions
126 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
127 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
132 fprintf (stderr
, "\n\n"
133 "usage: jack_test \n"
134 " [ --time OR -t time_to_run (in seconds) ]\n"
135 " [ --quiet OR -q (quiet mode : without jack server errors) ]\n"
136 " [ --verbose OR -v (verbose mode : no details on tests done. Only main results & errors) ]\n"
137 " [ --transport OR -k (Do not test transport functions.) ]\n"
138 " --realtime OR -R (jack is in rt mode)\n\n\n"
143 void Log(char *fmt
, ...)
148 vfprintf(stderr
, fmt
, ap
);
153 void Collect(FrameTimeCollector
* TheFrame
)
155 TheFrame
->lft
= jack_last_frame_time(client1
);
156 TheFrame
->ft
= jack_frame_time(client1
);
157 TheFrame
->fcs
= jack_frames_since_cycle_start(client1
);
160 void Jack_Thread_Init_Callback(void *arg
)
162 Log("Init callback has been successfully called. (msg from callback)\n");
166 void Jack_Freewheel_Callback(int starting
, void *arg
)
168 Log("Freewhell callback has been successfully called with value %i.(msg from callback)\n", starting
);
172 int Jack_Update_Buffer_Size(jack_nframes_t nframes
, void *arg
)
174 cur_buffer_size
= jack_get_buffer_size(client1
);
175 Log("Buffer size = %d (msg from callback)\n", cur_buffer_size
);
179 int Jack_XRun_Callback(void *arg
)
183 printf("Xrun has been detected ! (msg from callback)\n");
187 int Jack_Graph_Order_Callback(void *arg
)
193 int Jack_Sample_Rate_Callback(jack_nframes_t nframes
, void *arg
)
195 Log("Sample rate : %i.\n", nframes
);
199 void Jack_Error_Callback(const char *msg
)
201 if (silent_error
== 0) {
202 fprintf(stderr
, "error : %s (msg from callback)\n", msg
);
206 void jack_shutdown (void *arg
)
208 printf("Jack_test has been kicked out by jackd !\n");
212 void Jack_Port_Register(jack_port_id_t port
, int mode
, void *arg
)
217 int Jack_Sync_Callback(jack_transport_state_t state
, jack_position_t
*pos
, void *arg
)
223 case JackTransportStarting
:
225 if (starting_state
== 0) {
226 Log("sync callback : Releasing status : now ready...\n");
229 if (sync_called
== 1) {
230 Log("sync callback : Holding status...\n");
236 case JackTransportStopped
:
237 Log("sync callback : JackTransportStopped...\n");
250 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
251 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
255 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
256 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
257 * Proccess1 is for client1
258 * 4 modes, activated with process1_activated
261 * 0 : write zeros to output 1
262 * 1 : write continuously signal1 (sinusoïdal test signal) to output1
263 * 3 : mode for summation test. While record (done by process2) is not running, write signal1 to both out1 & out1b.
264 * when record begin (index2 > 0), write signal1 in phase opposition to out1 & out2
265 * 5 : Frames Time checking mode : write the array containing the three values of frame_time, frames cycles start and
266 * last frame time during 150 cycles.
269 int process1(jack_nframes_t nframes
, void *arg
)
272 Collect(&perpetualcollect
);
274 fprintf(file
, "%i %i\n", (perpetualcollect
.ft
- lastperpetualcollect
.ft
), (2*cur_buffer_size
));
277 fprintf(file
, "%i 0\n", (perpetualcollect
.ft
- lastperpetualcollect
.ft
));
280 lastperpetualcollect
.ft
= perpetualcollect
.ft
;
283 jack_default_audio_sample_t
*out1
;
284 jack_default_audio_sample_t
*out1b
;
285 activated
++; // counter of callback activation
286 if (process1_activated
== 1) {
287 out1
= (jack_default_audio_sample_t
*) jack_port_get_buffer (output_port1
, nframes
);
288 for (int p
= 0; p
< nframes
;p
++) {
289 out1
[p
] = signal1
[index1
];
295 if (process1_activated
== 3) {
296 out1
= (jack_default_audio_sample_t
*) jack_port_get_buffer (output_port1
, nframes
);
297 out1b
= (jack_default_audio_sample_t
*) jack_port_get_buffer (output_port1b
, nframes
);
298 for (int p
= 0; p
< nframes
;p
++) {
299 out1
[p
] = signal1
[index1
];
301 out1b
[p
] = ( -1 * signal1
[index1
]);
303 out1b
[p
] = signal1
[index1
];
310 if (process1_activated
== 0) {
311 out1
= (jack_default_audio_sample_t
*) jack_port_get_buffer (output_port1
, nframes
);
312 memset (out1
, 0, sizeof (jack_default_audio_sample_t
) * nframes
); //écrit des zéros en sortie...
314 if (process1_activated
== 5) {
315 Collect(&framecollect
[frames_collected
]);
317 if (frames_collected
> 798) {
318 process1_activated
= -1;
325 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
326 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
327 * Proccess2 is for client2
328 * 3 modes, activated with process1_activated
332 * 1 : record in2 into signal2.(for first transmit test)
333 * 2 : record in2 into signal2 while send signal1 in out2. used dor Tie data test.
334 * 3 : record in2 into sigal2 for summation data test.
335 * In records modes, at the end of the record (signal2 is full), it stop the test, setting both activation states to -1.
338 int process2(jack_nframes_t nframes
, void *arg
)
340 jack_default_audio_sample_t
*out2
;
341 jack_default_audio_sample_t
*in2
;
343 if (process2_activated
== 1) { // Réception du process1 pour comparer les données
344 in2
= (jack_default_audio_sample_t
*) jack_port_get_buffer (input_port2
, nframes
);
345 for (int p
= 0; p
< nframes
;p
++) {
346 signal2
[index2
] = in2
[p
];
347 if (index2
== 95999) {
348 process2_activated
= 0;
349 process1_activated
= 0;
356 if (process2_activated
== 2) { // envoie de signal1 pour test tie mode et le récupère direct + latence de la boucle jack...
357 out2
= (jack_default_audio_sample_t
*) jack_port_get_buffer (output_port2
, nframes
);
358 in2
= (jack_default_audio_sample_t
*) jack_port_get_buffer (input_port2
, nframes
);
360 for (int p
= 0; p
< nframes
;p
++) {
361 out2
[p
] = signal1
[index1
];
365 signal2
[index2
] = in2
[p
];
366 if (index2
== 95999) {
367 process2_activated
= -1;
375 if (process2_activated
== 3) { // envoie de -signal1 pour sommation en oppo de phase par jack
376 in2
= (jack_default_audio_sample_t
*) jack_port_get_buffer (input_port2
, nframes
);
378 for (int p
= 0; p
< nframes
;p
++) {
379 signal2
[index2
] = in2
[p
];
380 if (index2
== 95999) {
381 process2_activated
= 0;
382 process1_activated
= 0;
393 static void display_transport_state()
395 jack_transport_state_t ts
;
398 ts
= jack_transport_query(client2
, &pos
);
400 case JackTransportStopped
:
401 Log("Transport is stopped...\n");
403 case JackTransportRolling
:
404 Log("Transport is rolling...\n");
406 case JackTransportLooping
:
407 Log("Transport is looping...\n");
409 case JackTransportStarting
:
410 Log("Transport is starting...\n");
416 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
417 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
418 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
419 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
421 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
422 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
423 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
424 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
426 int main (int argc
, char *argv
[])
428 const char **inports
; // array of PHY input/output
429 const char **outports
; // array of PHY input/outputs
430 const char *server_name
= NULL
;
431 const char **connexions1
;
432 const char **connexions2
;
433 jack_status_t status
;
434 char portname
[128] = "port";
435 char filename
[128] = "framefile.ext";
436 char *nullportname
= "";
439 int a
= 0; // working number for in/out port (PHY)...
440 int test_link
= 0; // for testing the "overconnect" function
441 int flag
; // flag for ports...
442 int is_mine
= 0; // to test jack_port_is_mine function...
443 int connected
= 0; // check connect functions of ports
444 const char *options
= "kRnqvt:";
445 float ratio
; // for speed calculation in freewheel mode
446 jack_options_t jack_options
= JackNullOption
;
447 struct option long_options
[] = {
448 {"realtime", 0, 0, 'R'
450 {"non-realtime", 0, 0, 'n'},
452 {"quiet", 0, 0, 'q'},
453 {"verbose", 0, 0, 'v'},
454 {"transport", 0, 0, 'k'},
458 client_name1
= "jack_test";
460 while ((opt
= getopt_long (argc
, argv
, options
, long_options
, &option_index
)) != EOF
) {
470 printf("Verbose mode is activated...\n");
473 time_to_run
= atoi(optarg
);
479 fprintf (stderr
, "unknown option %c\n", opt
);
485 printf("Jack server is said being in realtime mode...\n");
487 printf("Jack server is said being in non-realtime mode...\n");
490 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
491 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
492 init signal data for test
493 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
494 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
496 framecollect
= (FrameTimeCollector
*) malloc(800 * sizeof(FrameTimeCollector
));
498 signal1
= (jack_default_audio_sample_t
*) malloc(48000 * sizeof(jack_default_audio_sample_t
));
499 signal2
= (jack_default_audio_sample_t
*) malloc(96000 * sizeof(jack_default_audio_sample_t
));
502 for (p
= 1; p
< 48000;p
++) {
503 signal1
[p
] = (sin((p
* 2 * M_PI
* 1000 ) / 48000));
505 for (p
= 0; p
< 95999;p
++) {
511 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
512 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
514 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
515 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
517 printf("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
518 printf("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
519 printf("*-*-*-*-*-*-*-*-*-*-*-*-*-* Start jack server stress test *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
520 printf("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
521 printf("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
524 * Register a client...
527 Log("Register a client using jack_client_open()...\n");
528 client1
= jack_client_open(client_name1
, jack_options
, &status
, server_name
);
529 if (client1
== NULL
) {
530 fprintf (stderr
, "jack_client_open() failed, "
531 "status = 0x%2.0x\n", status
);
532 if (status
& JackServerFailed
) {
533 fprintf(stderr
, "Unable to connect to JACK server\n");
537 if (status
& JackServerStarted
) {
538 fprintf(stderr
, "JACK server started\n");
541 * try to register another one with the same name...
544 Log("trying to register a new jackd client with name %s using jack_client_new()...\n", client_name1
);
545 client2
= jack_client_new(client_name1
);
546 if (client2
== NULL
) {
547 Log ("valid : a second client with the same name cannot be registered\n");
549 printf("!!! ERROR !!! Jackd server has accepted multiples client with the same name !");
550 jack_client_close(client2
);
554 * testing client name...
555 * Verify that the name sended at registration and the one returned by jack server is the same...
558 Log("Testing name...");
559 client_name2
= jack_get_client_name(client1
);
560 if (strcmp(client_name1
, client_name2
) == 0)
563 printf("\n!!! ERROR !!! name returned different from the one given : %s\n", client_name2
);
567 * verify if the real time mode returned by jack match the optional argument defined when launching jack_test*/
568 if (jack_is_realtime(client1
) == RT
)
569 Log("Jackd is in realtime mode (RT = %i).\n", RT
);
571 printf("!!! ERROR !!! Jackd is in a non-expected realtime mode (RT = %i).\n", RT
);
574 * Register all callbacks...
577 if (jack_set_thread_init_callback(client1
, Jack_Thread_Init_Callback
, 0) != 0)
578 printf("!!! ERROR !!! while calling jack_set_thread_init_callback()...\n");
579 if (jack_set_freewheel_callback(client1
, Jack_Freewheel_Callback
, 0) != 0 )
580 printf("\n!!! ERROR !!! while calling jack_set_freewheel_callback()...\n");
582 if (jack_set_process_callback(client1
, process1
, 0) != 0) {
583 printf("Error when calling jack_set_process_callback() !\n");
586 jack_on_shutdown(client1
, jack_shutdown
, 0);
588 if (jack_set_buffer_size_callback(client1
, Jack_Update_Buffer_Size
, 0) != 0) {
589 printf("Error when calling buffer_size_callback !\n");
591 if (jack_set_graph_order_callback(client1
, Jack_Graph_Order_Callback
, 0) != 0) {
592 printf("Error when calling Jack_Graph_Order_Callback() !\n");
594 if (jack_set_xrun_callback(client1
, Jack_XRun_Callback
, 0 ) != 0) {
595 printf("Error when calling jack_set_xrun_callback() !\n");
597 if (jack_set_sample_rate_callback(client1
, Jack_Sample_Rate_Callback
, 0 ) != 0) {
598 printf("Error when calling Jack_Sample_Rate_Callback() !\n");
600 if (jack_set_port_registration_callback(client1
, Jack_Port_Register
, 0) != 0) {
601 printf("Error when calling jack_set_port_registration_callback() !\n");
603 jack_set_error_function (Jack_Error_Callback
);
606 * Create file for clock "frame time" analysis
609 cur_buffer_size
= jack_get_buffer_size(client1
);
610 sprintf (filename
, "framefile-%i.dat", cur_buffer_size
);
611 file
= fopen(filename
, "w");
613 fprintf(stderr
, "Erreur dans l'ouverture du fichier log framefile.dat");
618 * Try to register a client with a NULL name/zero length name...
621 output_port1
= jack_port_register(client1
, nullportname
,
622 JACK_DEFAULT_AUDIO_TYPE
,
623 JackPortIsOutput
, 0);
624 if (output_port1
== NULL
) {
625 Log("Can't register a port with a NULL portname... ok.\n");
627 printf("!!! ERROR !!! Can register a port with a NULL portname !\n");
628 jack_port_unregister(client1
, output_port1
);
632 * Register 1 port in order to stress other functions.
635 output_port1
= jack_port_register(client1
, portname
,
636 JACK_DEFAULT_AUDIO_TYPE
,
637 JackPortIsOutput
, 0);
638 if (output_port1
== NULL
) {
639 printf("!!! ERROR !!! Can't register any port for the client !\n");
644 * Try to register another port with the same name...
647 output_port2
= jack_port_register(client1
, portname
,
648 JACK_DEFAULT_AUDIO_TYPE
,
649 JackPortIsOutput
, 0);
650 if (output_port2
== NULL
) {
651 Log("Can't register two ports with the same name... ok\n");
653 if (strcmp (jack_port_name(output_port1
), jack_port_name(output_port2
)) == 0) {
654 printf("!!! ERROR !!! Can register two ports with the same name ! (%i : %s & %i : %s).\n", output_port1
, jack_port_name(output_port1
), output_port2
, jack_port_name(output_port2
));
655 jack_port_unregister(client1
, output_port2
);
657 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
));
658 jack_port_unregister(client1
, output_port2
);
663 * Verify that both port_name and port_short_name return correct results...
666 sprintf (portname
, "%s:%s", jack_get_client_name(client1
), jack_port_short_name(output_port1
));
667 if (strcmp(jack_port_name(output_port1
), portname
) != 0) {
668 printf("!!! ERROR !!! functions jack_port_name and/or jack_short_port_name seems to be invalid !\n");
669 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
));
673 * Verify the function port_set_name
676 if (jack_port_set_name (output_port1
, "renamed-port#") == 0 ) {
677 if (strcmp(jack_port_name(output_port1
), "renamed-port#") == 0) {
678 printf("!!! ERROR !!! functions jack_port_set_name seems to be invalid !\n");
679 printf("Jack_port_name return '%s' whereas 'renamed-port#' was expected...\n");
681 Log("checking jack_port_set_name... ok\n");
682 jack_port_set_name (output_port1
, "port");
685 printf("error : port_set_name function can't be tested...\n");
689 * Activate the client
692 if (jack_activate(client1
) < 0) {
693 printf ("Fatal error : cannot activate client1\n");
698 * Test if init callback initThread have been called.
702 printf("!!! ERROR !!! JackThreadInitCallback was not called !!.\n");
704 jack_sleep(10 * 1000); // test see the clock in the graph at the begining...
707 * Stress Freewheel mode...
708 * Try to enter freewheel mode. Check the realtime mode de-activation.
709 * Check that the number of call of the process callback is greater than in non-freewheel mode.
710 * Give an approximated speed ratio (number of process call) between the two modes.
711 * Then return in normal mode.
715 jack_sleep(1 * 1000);
717 Log("Testing activation freewheel mode...\n");
718 linefw
= linecount
; // count for better graph reading with gnuplot
719 jack_set_freewheel(client1
, 1);
721 jack_sleep(1 * 1000);
723 if (jack_is_realtime(client1
) == 0) {
726 printf("\n!!! ERROR !!! RT mode is always activated while freewheel mode is applied !\n");
730 printf("!!! ERROR !!! Freewheel mode doesn't activate audio callback !!\n");
732 jack_set_freewheel(client1
, 0);
733 jack_sleep(7 * 1000);
735 if (jack_is_realtime(client1
) == 1) {}
737 printf("\n!!! ERROR !!! freewheel mode fail to reactivate RT mode when exiting !\n");
741 Log("Freewheel mode appears to work well...\n");
744 Log("Audio Callback in 'standard' (non-freewheel) mode seems not to be called...\n");
745 Log("Ratio speed would be unavailable...\n");
747 ratio
= (float) ((count2
- count1
) / count1
);
748 Log("Approximative speed ratio of freewheel mode = %f : 1.00\n", ratio
);
752 * Stress buffer function...
753 * get current buffer size.
754 * Try to apply a new buffer size value ( 2 x the precedent buffer size value)
755 * Then return in previous buffer size mode.
760 old_buffer_size
= jack_get_buffer_size(client1
);
761 Log("Testing BufferSize change & Callback...\n--> Current buffer size : %i.\n", old_buffer_size
);
763 if (jack_set_buffer_size(client1
, (jack_nframes_t
)(old_buffer_size
* factor
)) < 0) {
764 printf("!!! ERROR !!! jack_set_buffer_size fails !\n");
766 jack_sleep(1 * 1000);
767 cur_buffer_size
= jack_get_buffer_size(client1
);
768 if ((old_buffer_size
* factor
) != cur_buffer_size
) {
769 printf("!!! ERROR !!! Buffer size has not been changed !\n");
770 printf("!!! Maybe jack was compiled without the '--enable-resize' flag...\n");
772 Log("jack_set_buffer_size() command successfully applied...\n");
774 jack_sleep(3 * 1000);
775 jack_set_buffer_size(client1
, old_buffer_size
);
776 cur_buffer_size
= jack_get_buffer_size(client1
);
779 * Test the last regestered port to see if port_is_mine function the right value.
780 * A second test will be performed later.
781 * The result will be printed at the end.
784 if (jack_port_is_mine(client1
, output_port1
)) {
791 * Check that the ID returned by the port_by_name is right.
792 * (it seems there is a problem here in some jack versions).
795 if (output_port1
!= jack_port_by_name(client1
, jack_port_name(output_port1
))) {
796 printf("!!! ERROR !!! function jack_port_by_name() return bad value !\n");
797 printf("!!! jack_port_by_name(jack_port_name(_ID_) ) != _ID_returned_at_port_registering ! (%i != %i)\n", jack_port_by_name(client1
, jack_port_name(output_port1
)), output_port1
);
799 Log("Checking jack_port_by_name() return value... ok\n");
801 if (NULL
!= jack_port_by_name(client1
, jack_port_short_name(output_port1
))) {
802 printf("!!! ERROR !!! function jack_port_by_name() return a value (%i) while name is incomplete !\n", jack_port_by_name(client1
, jack_port_short_name(output_port1
)));
804 Log("Checking jack_port_by_name() with bad argument... ok (returned id 0)\n");
808 * remove the output port previously created
809 * no more ports should subsist here for our client.
812 if (jack_port_unregister(client1
, output_port1
) != 0) {
813 printf("!!! ERROR !!! while unregistering port %s.\n", jack_port_name(output_port1
));
820 inports
= jack_get_ports(client1
, NULL
, NULL
, 0);
823 * Test the first PHY (physical) connection to see if it's "mine".
824 * and report the result in the test that began before.
825 * The result is printed later.
828 if (jack_port_is_mine(client1
, jack_port_by_name(client1
, inports
[0]))) {
833 * List all devices' flags and print them...
836 Log("\nTry functions jack_get_ports, jack_port_flag & jack_port_by_name to list PHY devices...\n");
837 Log("-----------------------------------------------------------\n");
838 Log("---------------------------DEVICES-------------------------\n");
839 Log("-----------------------------------------------------------\n");
841 while (inports
[a
] != NULL
) {
842 flag
= jack_port_flags(jack_port_by_name(client1
, inports
[a
]) );
843 Log(" * %s (id : %i)\n", inports
[a
], jack_port_by_name(client1
, inports
[a
]));
845 if (flag
& JackPortIsInput
)
846 Log("JackPortIsInput ");
847 if (flag
& JackPortIsOutput
)
848 Log("JackPortIsOutput ");
849 if (flag
& JackPortIsPhysical
)
850 Log("JackPortIsPhysical ");
851 if (flag
& JackPortCanMonitor
)
852 Log("JackPortCanMonitor ");
853 if (flag
& JackPortIsTerminal
)
854 Log("JackPortIsTerminal ");
858 Log("-----------------------------------------------------------\n\n");
861 * list all PHY in/out ports...
862 * This list will be used later many times.
865 outports
= jack_get_ports(client1
, NULL
, NULL
, JackPortIsPhysical
| JackPortIsOutput
);
866 inports
= jack_get_ports(client1
, NULL
, NULL
, JackPortIsPhysical
| JackPortIsInput
);
868 if (outports
== NULL
) {
869 printf("!!! WARNING !!! no physical capture ports founded !\n");
871 if (inports
== NULL
) {
872 printf("!!! WARNING !!! no physical output ports founded !\n");
876 * Brute test : try to create as many ports as possible.
877 * It stops when jack returns an error.
878 * Then try to connect each port to physical entry...
879 * Check also that graph reorder callback is called.
882 Log("Registering as many ports as possible and connect them to physical entries...\n");
883 lineports
= linecount
;
886 i
= 0; // number of couple 'input-ouput'
887 j
= 0; // number of ports created
888 port_callback_reg
= 0; // number of port registration received by the callback
889 reorder
= 0; // number of graph reorder callback activation
890 test_link
= 0 ; // Test the "overconnect" function only one time
891 while (t_error
== 0) {
892 sprintf (portname
, "input_%d", i
);
893 input_port1
= jack_port_register(client1
, portname
,
894 JACK_DEFAULT_AUDIO_TYPE
,
897 if (input_port1
== NULL
) {
901 // Connect created input to PHY output
903 while (outports
[a
] != NULL
) {
904 if (jack_connect(client1
, outports
[a
], jack_port_name(input_port1
))) {
905 printf ("error : cannot connect input PHY port to client port %s\n", jack_port_name(input_port1
));
907 // printf ("input PHY port %s connected to client port %s\n", outports[a], jack_port_name(input_port1));
911 // Try one time to "overconnect" 2 ports (the latest created)...
912 if (test_link
== 0) {
913 if (jack_connect(client1
, outports
[a
- 1], jack_port_name(input_port1
)) == EEXIST
) {
914 // cannot over-connect input PHY port to client port. ok.
920 sprintf(portname
, "output_%d", i
);
921 output_port1
= jack_port_register(client1
, portname
,
922 JACK_DEFAULT_AUDIO_TYPE
,
923 JackPortIsOutput
, 0);
925 if (output_port1
== NULL
) {
929 // Connect created input to PHY output
931 while (inports
[a
] != NULL
) {
932 if (jack_connect(client1
, jack_port_name(output_port1
), inports
[a
])) {
933 printf ("error : cannot connect input PHY port %s to client port %s\n", inports
[a
], jack_port_name(output_port1
));
935 // output PHY port %s connected to client port. ok.
939 // Try one time to "overconnect" 2 ports (the latest created)...
940 if (test_link
== 0) {
941 if (jack_connect(client1
, jack_port_name(output_port1
), inports
[a
- 1]) == EEXIST
) {
942 // cannot over-connect output PHY port to client port. ok.
950 jack_sleep(1 * 1000); // To hope all port registration and reorder callback have been received...
951 if (j
== port_callback_reg
) {
952 Log("%i ports have been successfully created, and %i callback reg ports have been received... ok\n", j
, port_callback_reg
);
954 printf("!!! ERROR !!! %i ports have been created, and %i callback reg ports have been received !\n", j
, k
);
956 if (reorder
== (2 * j
)) {
957 Log("%i graph reorder callback have been received... ok\n", reorder
);
959 printf("!!! ERROR !!! %i graph reorder callback have been received (maybe non-valid value)...\n", reorder
);
962 * print basic test connection functions result ...
963 * over-connected means here that we try to connect 2 ports that are already connected.
967 Log("Jack links can't be 'over-connected'... ok\n");
969 printf("!!! ERROR !!! Jack links can be 'over-connected'...\n");
972 * Print the result of the two jack_is_mine test.
976 Log("Checking jack_port_is_mine... ok\n");
978 printf("!!! ERROR !!! jack_port_is_mine() function seems to send non-valid datas !\n");
981 * Free the array of the physical input and ouput ports.
982 * (as mentionned in the doc of jack_get_ports)
989 * Try to "reactivate" the client whereas it's already activated...
992 if (jack_activate(client1
) < 0) {
993 printf("!!! ERROR !!! Cannot activate client1 a second time...\n");
996 Log("jackd server accept client.jack_activate() re-activation (while client was already activated).\n");
1000 * Deregister all ports previously created.
1003 Log("Deregistering all ports of the client...\n");
1004 inports
= jack_get_ports(client1
, NULL
, NULL
, 0);
1006 while (inports
[a
] != NULL
) {
1007 flag
= jack_port_flags(jack_port_by_name(client1
, inports
[a
]));
1008 input_port1
= jack_port_by_name(client1
, inports
[a
]);
1009 if (jack_port_is_mine(client1
, input_port1
)) {
1010 if (jack_port_unregister(client1
, input_port1
) != 0) {
1011 printf("!!! ERROR !!! while unregistering port %s.\n", jack_port_name(output_port1
));
1017 free(inports
); // free array of ports (as mentionned in the doc of jack_get_ports)
1020 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1021 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1022 Open a new client (second one) to test some other things...
1023 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1024 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1027 Log("\n\n----------------------------------------------------------------------\n");
1028 Log("Starting second new client 'jack_test_#2'...\n");
1029 /* open a client connection to the JACK server */
1030 client_name2
= "jack_test_#2";
1031 linecl2
= linecount
; // reminders for graph analysis
1032 client2
= jack_client_new(client_name2
);
1034 if (client2
== NULL
) {
1035 fprintf(stderr
, "jack_client_new() failed for %s.\n"
1036 "status = 0x%2.0x\n", client_name2
, status
);
1037 if (status
& JackServerFailed
) {
1038 fprintf(stderr
, "Unable to connect client2 to JACK server\n");
1044 * Register callback for this client.
1045 * Callbacks are the same as the first client for most of them, excepted for process audio callback.
1048 jack_set_port_registration_callback(client2
, Jack_Port_Register
, 0);
1050 jack_set_process_callback(client2
, process2
, 0);
1052 jack_on_shutdown(client2
, jack_shutdown
, 0);
1055 * Register one input and one output for each client.
1058 Log("registering 1 input/output ports for each client...\n");
1060 output_port1
= jack_port_register(client1
, "out1",
1061 JACK_DEFAULT_AUDIO_TYPE
,
1062 JackPortIsOutput
, 0);
1063 output_port2
= jack_port_register(client2
, "out2",
1064 JACK_DEFAULT_AUDIO_TYPE
,
1065 JackPortIsOutput
, 0);
1066 input_port1
= jack_port_register(client1
, "in1",
1067 JACK_DEFAULT_AUDIO_TYPE
,
1068 JackPortIsInput
, 0);
1069 input_port2
= jack_port_register(client2
, "in2",
1070 JACK_DEFAULT_AUDIO_TYPE
,
1071 JackPortIsInput
, 0);
1072 if ((output_port1
== NULL
) || (output_port2
== NULL
) || (input_port1
== NULL
) || (input_port2
== NULL
)) {
1073 printf("!!! ERROR !!! Unable to register ports...\n");
1077 * Set each process mode to idle and activate client2
1080 process2_activated
= -1;
1081 process1_activated
= -1;
1082 if (jack_activate(client2
) < 0) {
1083 printf ("Fatal error : cannot activate client2\n");
1088 * Connect the two clients and check that all connections are well-done.
1091 Log("Testing connections functions between clients...\n");
1092 if (jack_connect(client1
, jack_port_name(output_port1
), jack_port_name(input_port2
)) != 0) {
1093 printf("!!! ERROR !!! while client1 intenting to connect ports...\n");
1095 if (jack_connect(client2
, jack_port_name(output_port2
), jack_port_name(input_port1
)) != 0) {
1096 printf("!!! ERROR !!! while client2 intenting to connect ports...\n");
1098 if (jack_connect(client1
, jack_port_name(output_port1
), jack_port_name(input_port1
)) != 0) {
1099 printf("!!! ERROR !!! while client1 intenting to connect ports...\n");
1103 * Test the port_connected function...
1106 if ((jack_port_connected(output_port1
) == jack_port_connected(input_port1
)) &&
1107 (jack_port_connected(output_port2
) == jack_port_connected(input_port2
)) &&
1108 (jack_port_connected(output_port2
) == 1) &&
1109 (jack_port_connected(output_port1
) == 2)
1111 Log("Checking jack_port_connected()... ok.\n");
1113 printf("!!! ERROR !!! function jack_port_connected() return a bad value !\n");
1114 printf("jack_port_connected(output_port1) %ld\n", jack_port_connected(output_port1
));
1115 printf("jack_port_connected(output_port2) %ld\n", jack_port_connected(output_port2
));
1116 printf("jack_port_connected(input_port1) %ld\n", jack_port_connected(input_port1
));
1117 printf("jack_port_connected(input_port2) %ld\n", jack_port_connected(input_port2
));
1121 * Test a new time the port_by_name function...(now we are in multi-client mode)
1124 Log("Testing again jack_port_by_name...\n");
1125 if (output_port1
!= jack_port_by_name(client1
, jack_port_name(output_port1
))) {
1126 printf("!!! ERROR !!! function jack_port_by_name() return bad value in a multi-client application!\n");
1127 printf("!!! jack_port_by_name(jack_port_name(_ID_) ) != _ID_ in multiclient application.\n");
1129 Log("Checking jack_port_by_name() function with a multi-client application... ok\n");
1133 * Test the port_connected_to function...
1136 if ((jack_port_connected_to (output_port1
, jack_port_name(input_port2
))) &&
1137 (!(jack_port_connected_to (output_port2
, jack_port_name(input_port2
))))) {
1138 Log("checking jack_port_connected_to()... ok\n");
1140 printf("!!! ERROR !!! jack_port_connected_to() return bad value !\n");
1144 * Test the port_get_connections & port_get_all_connections functions...
1147 Log("Testing jack_port_get_connections and jack_port_get_all_connections...\n");
1150 connexions1
= jack_port_get_connections (output_port1
);
1151 connexions2
= jack_port_get_all_connections(client1
, output_port1
);
1152 if ((connexions1
== NULL
) || (connexions2
== NULL
)) {
1153 printf("!!! ERROR !!! port_get_connexions or port_get_all_connexions return a NULL pointer !\n");
1155 while ((connexions1
[a
] != NULL
) && (connexions2
[a
] != NULL
) && (t_error
== 0)) {
1156 t_error
= strcmp(connexions1
[a
], connexions2
[a
]);
1161 Log("Checking jack_port_get_connections Vs jack_port_get_all_connections... ok\n");
1163 printf("!!! ERROR !!! while checking jack_port_get_connections Vs jack_port_get_all_connections...\n");
1168 inports
= jack_get_ports(client1
, NULL
, NULL
, JackPortIsPhysical
| JackPortIsInput
);
1170 assert(inports
!= NULL
);
1171 if (inports
[0] != NULL
) {
1172 connexions1
= jack_port_get_connections (jack_port_by_name(client1
, inports
[0]));
1173 connexions2
= jack_port_get_all_connections(client1
, jack_port_by_name(client1
, inports
[0]));
1177 if (connexions1
== NULL
) {
1178 Log("checking jack_port_get_connections for external client... ok\n");
1180 while ((connexions1
[a
] != NULL
) && (connexions2
[a
] != NULL
) && (t_error
== 0)) {
1181 t_error
= strcmp(connexions1
[a
], connexions2
[a
]);
1186 Log("Checking jack_port_get_connections Vs jack_port_get_all_connections on PHY port... ok\n");
1188 printf("!!! ERROR !!! while checking jack_port_get_connections Vs jack_port_get_all_connections on PHY port...\n");
1192 * Test port locking function
1193 * Check the validity of the lock...
1196 Log("Testing connections locks between clients...\n");
1197 if (jack_disconnect(client1
, jack_port_name(output_port1
), jack_port_name(input_port1
)) != 0) {
1198 printf("!!! ERROR !!! while client1 intenting to disconnect ports...\n");
1201 if (jack_port_lock(client2
, output_port2
) != 0) {
1202 printf("Error while calling port_lock... jack_lock will not be checked !\n");
1204 Log("Locking port 'out2'...ok\n");
1205 if (jack_disconnect(client2
, jack_port_name(output_port2
), jack_port_name(input_port1
)) != 0) {
1206 Log("Checking lock status with disconnect... ok\n");
1208 printf("!!! ERRROR !!! Jack_lock didn't lock port_connections with disconnect!\n");
1210 if (jack_port_disconnect(client1
, output_port2
) != 0) {
1211 Log("Checking lock status with port_disconnect... ok\n");
1213 printf("!!! ERRROR !!! Jack_lock didn't lock port_connections with port_disconnect!\n");
1215 if (jack_connect(client2
, jack_port_name(output_port2
), jack_port_name(input_port2
)) != 0) {
1216 Log("Checking lock status with connect... ok\n");
1218 printf("!!! ERRROR !!! Jack_lock didn't lock port_connections with connect!\n");
1219 jack_disconnect(client2
, jack_port_name(output_port2
), jack_port_name(input_port2
));
1221 if (jack_port_unlock(client1
, output_port2
) != 0) {
1222 Log("Checking unlock by another client... ok\n");
1224 printf("!!! ERROR !!! a client can unlock a port locked previously by another client... \n");
1226 if (jack_port_unlock(client2
, output_port2
) != 0) {
1227 printf("Error while calling port_unlock... \n");
1229 if (jack_port_lock(client2
, output_port1
) != 0) {
1230 Log("Checking lock of port of an other client... ok\n");
1232 printf("!!! ERROR !!! a port can be locked by a non-owner client !\n");
1233 jack_port_unlock(client2
, output_port1
);
1237 jack_disconnect(client1
, jack_port_name(output_port2
), jack_port_name(input_port1
));
1239 // No links should subsist now...
1242 * Checking data connexion
1243 * establishing a link between client1.out1 --> client2.in2
1244 * Send the signal1 test on out1. Record the result into signal2. (see process functions).
1245 ---------------------------------------------------------------------------*/
1246 Log("Testing connections datas between clients...\n");
1247 jack_connect(client2
, jack_port_name(output_port1
), jack_port_name(input_port2
) );
1248 process2_activated
= -1;
1249 process1_activated
= -1;
1250 Log("process 2 : idle mode...\n");
1251 Log("Sending datas...");
1254 process1_activated
= 1; // We start emitting first.
1255 process2_activated
= 1; // So record begin at least when we just begin to emitt the signal, else at next call of process with
1256 // nframe = jack buffersize shifting.
1258 while (process2_activated
== 1) {
1259 jack_sleep(1 * 1000);
1263 Log("\nAnalysing datas...\n"); // search the first occurence of the first element of the reference signal in the recorded signal
1264 while (signal2
[index2
] != signal1
[1] ) {
1266 if (index2
== 95999) {
1267 printf("!!! ERROR !!! Data not found in first connexion data check!\n");
1272 Log("Data founded at offset %i.\n", index2
);
1273 // And now we founded were the recorded data are, we can see if the two signals matches...
1274 while ( (signal2
[index2
] == signal1
[index2
- index1
+ 1]) || (index2
== 95999) || ((index2
- index1
+ 1) == 47999) ) {
1277 Log("Checking difference between datas... %i have the same value...\n", index2
- index1
);
1278 if ((index2
- index1
) == 48000) {
1279 Log("Data received are valid...\n");
1281 printf("!!! ERROR !!! data transmission seems not to be valid in first connexion data check!\n");
1283 if (jack_disconnect(client1
, jack_port_name(output_port1
), jack_port_name(input_port2
) ) != 0)
1284 // no more connection between ports exist now...
1286 printf("Error while establishing new connexion (disconnect).\n");
1291 * (This mode seems to be problematic in standard jack version 0.100. It seems that nobody
1292 * is used to apply this mode because the tie mode doesn't work at all. A patch seems difficult to produce
1293 * in this version of jack. Tie mode work well in MP version.)
1294 * Test some basic thinks (tie with 2 differents client, tie non-owned ports...)
1295 * Tie client1.in1 and client1.out1 ports, and make some data test to check the validity of the tie.
1298 Log("Testing tie mode...\n");
1299 if (jack_port_tie(input_port1
, output_port2
) != 0) {
1300 Log("not possible to tie two ports from two differents clients... ok\n");
1302 printf("!!! ERROR !!! port_tie has allowed a connexion between two differents clients !\n");
1303 jack_port_untie(output_port2
);
1305 Log("Testing connections datas in tie mode...\n");
1307 for (g
= 0; g
< 96000; g
++)
1309 // Create a loop (emit test) client2.out2----client.in1--tie--client1.out1-----client2.in1 (receive test)
1310 if (jack_port_tie(input_port1
, output_port1
) != 0) {
1311 printf("Unable to tie... fatal error : data test will not be performed on tie mode !!\n");
1312 } else { // begin of tie
1313 if (jack_connect(client1
, jack_port_name(output_port1
), jack_port_name(input_port2
)) != 0) {
1314 printf("!!! ERROR !!! while client1 intenting to connect ports...\n");
1316 if (jack_connect(client1
, jack_port_name(output_port2
), jack_port_name(input_port1
)) != 0) {
1317 printf("!!! ERROR !!! while client1 intenting to connect ports...\n");
1320 process1_activated
= -1;
1321 process2_activated
= -1;
1323 // We can manualy check here that the tie is effective.
1324 // ie : playing a wav with a client, connecting ports manualy with qjackctl, and listen...
1325 // printf("manual test\n");
1327 // printf("end of manual test\n");
1331 process1_activated
= -1;
1332 process2_activated
= 2;
1334 Log("Sending datas...");
1336 while (process2_activated
== 2) {
1337 jack_sleep(1 * 1000);
1340 process1_activated
= -1;
1341 process2_activated
= -1;
1343 Log("\nAnalysing datas...\n");
1344 // We must find at least 2 identical values to ensure we are at the right place in the siusoidal array...
1345 while (!((signal2
[index2
] == signal1
[1]) && (signal2
[index2
+ 1] == signal1
[2]))) {
1347 if (index2
== 95999) {
1348 printf("!!! ERROR !!! Data not found in connexion check of tie mode!\n");
1353 Log("Tie mode : Data founded at offset %i.\n", index2
);
1354 while (signal2
[index2
] == signal1
[index2
- index1
+ 1]) {
1356 if ((index2
== 95999) || ((index2
- index1
+ 1) == 47999)) {
1360 Log("Checking difference between datas... %i have the same value...\n", index2
- index1
);
1361 if ((index2
- index1
) > 47995) {
1362 Log("Data received in tie mode are valid...\n");
1364 // in tie mode, the buffers adress should be the same for the two tied ports.
1365 printf("!!! ERROR !!! data transmission seems not to be valid !\n");
1366 printf("Links topology : (emitt) client2.out2 ----> client1.in1--(tie)--client1.out1----->client2.in2 (recive)\n");
1367 printf(" port_name : Port_adress \n");
1368 printf(" output_port1 : %x\n", jack_port_get_buffer(output_port1
, cur_buffer_size
));
1369 printf(" input_port2 : %x\n", jack_port_get_buffer(input_port2
, cur_buffer_size
));
1370 printf(" output_port2 : %x\n", jack_port_get_buffer(output_port2
, cur_buffer_size
));
1371 printf(" input_port1 : %x\n", jack_port_get_buffer(input_port1
, cur_buffer_size
));
1374 jack_port_untie(output_port1
);
1375 jack_port_disconnect(client1
, output_port2
);
1376 jack_port_disconnect(client1
, output_port1
);
1382 * Testing SUMMATION CAPABILITIES OF JACK CONNECTIONS
1384 * In a short test, we just check a simple summation in jack.
1385 * A first client(client1) send two signal in phase opposition
1386 * A second client(client2) record the summation at one of his port
1387 * So, the result must be zero...
1388 * See process1 for details about steps of this test
1391 // fprintf(file, "Sum test\n");
1392 Log("Checking summation capabilities of patching...\n");
1393 output_port1b
= jack_port_register(client1
, "out1b",
1394 JACK_DEFAULT_AUDIO_TYPE
,
1395 JackPortIsOutput
, 0);
1396 jack_connect(client2
, jack_port_name(output_port1
), jack_port_name(input_port2
));
1397 jack_connect(client2
, jack_port_name(output_port1b
), jack_port_name(input_port2
));
1399 process1_activated
= 3;
1400 process2_activated
= -1;
1401 for (g
= 0; g
< 96000; g
++)
1406 Log("Sending datas...");
1407 process2_activated
= 3;
1409 while (process2_activated
== 3) {
1410 jack_sleep(1 * 1000);
1413 process1_activated
= -1;
1414 process2_activated
= -1;
1416 Log("\nAnalysing datas...\n"); // same idea as above, with first data check...
1417 while (!((signal2
[index2
] == 0.0 ) && (signal2
[(index2
+ 1)] == 0.0 ))) {
1419 if (index2
== 95999) {
1420 printf("!!! ERROR !!! Data not found in summation check!\n");
1425 Log("Data founded at offset %i.\n", index2
);
1427 while ( signal2
[index2
] == 0.0 ) {
1429 if ((index2
> 95998) || ((index2
- index1
+ 1) > 47998)) {
1433 Log("Checking difference between datas...\n");
1434 if ((index2
- index1
) > 47996) {
1435 Log("Data mixed received are valid...\nSummation is well done.\n");
1437 printf("!!! ERROR !!! data transmission / summation seems not to be valid !\n");
1439 jack_port_disconnect(client1
, output_port1
);
1440 jack_port_disconnect(client1
, output_port1b
);
1441 jack_port_unregister(client1
, output_port1b
);
1443 if (jack_port_name(output_port1b
) != NULL
) {
1444 printf("!!! WARNING !!! port_name return something while the port have been unregistered !\n");
1445 printf("!!! Name of unregistered port : %s !\n", jack_port_name(output_port1b
));
1447 Log("checking port_name() with a non valid port... ok\n");
1450 if (jack_port_set_name(output_port1b
, "new_name") == 0 ) {
1451 printf("!!! WARNING !!! An unregistered port can be renamed successfully !\n");
1453 Log("Checking renaming of an unregistered port... ok\n");
1455 inports
= jack_get_ports(client1
, NULL
, NULL
, JackPortIsPhysical
| JackPortIsInput
);
1456 if (jack_port_set_name(jack_port_by_name(client1
, inports
[0]), "new_name") == 0 ) {
1457 printf("!!! WARNING !!! A PHYSICAL port can be renamed successfully !\n");
1459 Log("Checking renaming of an unregistered port... ok\n");
1465 * Checking latency issues
1466 * here are simple latency check
1467 * We simply check that the value returned by jack seems ok
1468 * Latency compensation is a difficult point.
1469 * Actually, jack is not able to see "thru" client to build a full latency chain.
1470 * Ardour use theses informations to do internally his compensations.
1472 * 3 test are done : one with no connections between client, one with a serial connection, and one with parallel connection
1474 Log("Checking about latency functions...\n");
1476 jack_recompute_total_latencies(client1
);
1477 if ((jack_port_get_latency (output_port1
) != 0) ||
1478 (jack_port_get_total_latency(client1
, output_port1
) != 0) ) {
1480 printf("!!! ERROR !!! default latency of a non-PHY device is not set to zero !\n");
1483 inports
= jack_get_ports(client1
, NULL
, NULL
, JackPortIsPhysical
| JackPortIsInput
);
1484 outports
= jack_get_ports(client1
, NULL
, NULL
, JackPortIsPhysical
| JackPortIsOutput
);
1485 if (inports
[0] != NULL
) {
1486 ext_latency
= jack_port_get_latency (jack_port_by_name(client1
, inports
[0]));
1487 if (ext_latency
!= jack_port_get_total_latency(client1
, jack_port_by_name(client1
, inports
[0]))) {
1489 printf("!!! ERROR !!! get_latency & get_all_latency for a PHY device (unconnected) didn't return the same value !\n");
1491 Log("Checking a serial model with 2 clients...\n");
1493 jack_connect(client1
, jack_port_name(output_port1
), jack_port_name(input_port2
));
1494 jack_connect(client1
, outports
[0], jack_port_name(input_port1
));
1495 jack_connect(client2
, jack_port_name(output_port2
), inports
[0]);
1496 jack_port_set_latency (output_port2
, 256);
1497 jack_recompute_total_latencies(client1
);
1499 if ((jack_port_get_latency (output_port1
) != 0) ||
1500 (jack_port_get_total_latency(client1
, output_port1
) != 0) ||
1501 (jack_port_get_latency (jack_port_by_name(client1
, inports
[0])) != (ext_latency
)) ||
1502 (jack_port_get_total_latency(client1
, jack_port_by_name(client1
, inports
[0])) != (ext_latency
+ 256)) ||
1503 (jack_port_get_total_latency(client1
, output_port2
) != (ext_latency
+ 256)) ||
1504 (jack_port_get_total_latency(client1
, input_port2
) != 0) ||
1505 (jack_port_get_total_latency(client1
, input_port1
) != ext_latency
) ||
1506 (jack_port_get_latency (jack_port_by_name(client1
, outports
[0])) != ext_latency
) ||
1507 (jack_port_get_total_latency(client1
, jack_port_by_name(client1
, outports
[0])) != ext_latency
)
1509 printf("!!! WARNING !!! get_latency functions may have a problem : bad value returned !\n");
1510 printf("!!! get_latency(output_port1) : %i (must be 0)\n", jack_port_get_latency (output_port1
) );
1511 printf("!!! get_total_latency(output_port1) : %i (must be 0)\n", jack_port_get_total_latency(client1
, output_port1
));
1512 printf("!!! get_latency(PHY[0]) : %i (must be external latency : %i)\n", jack_port_get_latency (jack_port_by_name(client1
, inports
[0])), ext_latency
);
1513 printf("!!! get_total_latency(PHY[0]) : %i (must be %i)\n", jack_port_get_total_latency(client1
, jack_port_by_name(client1
, inports
[0])) , (ext_latency
+ 256));
1514 printf("!!! get_total_latency(output_port2) : %i (must be %i)\n", jack_port_get_total_latency(client1
, output_port2
), (ext_latency
+ 256));
1515 printf("!!! get_total_latency(input_port2) : %i (must be 0)\n", jack_port_get_total_latency(client1
, input_port2
));
1516 printf("!!! get_total_latency(input_port1) : %i (must be %i)\n", jack_port_get_total_latency(client1
, input_port1
), ext_latency
);
1517 printf("!!! get_latency(PHY[0]) : %i (must be %i)\n", jack_port_get_latency (jack_port_by_name(client1
, outports
[0])), ext_latency
);
1518 printf("!!! get_total_latency(PHY[0]) : %i (must be %i)\n", jack_port_get_total_latency(client1
, jack_port_by_name(client1
, outports
[0])), ext_latency
);
1521 Log("get_latency & get_total_latency seems quite ok...\n");
1524 jack_port_disconnect(client1
, output_port1
);
1525 jack_port_disconnect(client1
, output_port2
);
1526 jack_port_disconnect(client1
, input_port1
);
1527 jack_port_disconnect(client1
, input_port2
);
1528 Log("Checking a parallel model with 2 clients...\n");
1529 jack_connect(client2
, outports
[0], jack_port_name(input_port1
) );
1530 jack_connect(client2
, outports
[0], jack_port_name(input_port2
) );
1531 jack_connect(client2
, jack_port_name(output_port1
), inports
[0] );
1532 jack_connect(client2
, jack_port_name(output_port2
), inports
[0] );
1533 jack_port_set_latency (output_port1
, 256);
1534 jack_port_set_latency (output_port2
, 512);
1535 jack_recompute_total_latencies(client1
);
1537 if ((jack_port_get_latency (output_port1
) != 256 ) ||
1538 (jack_port_get_total_latency(client1
, output_port1
) != (256 + ext_latency
)) ||
1539 (jack_port_get_latency (output_port2
) != 512) ||
1540 (jack_port_get_total_latency(client1
, output_port2
) != (512 + ext_latency
)) ||
1541 (jack_port_get_latency (jack_port_by_name(client1
, inports
[0])) != ext_latency
) ||
1542 (jack_port_get_total_latency(client1
, jack_port_by_name(client1
, inports
[0])) != (512 + ext_latency
))
1544 printf("!!! WARNING !!! get_latency functions may have a problem : bad value returned !\n");
1546 Log("get_latency & get_total_latency seems quite ok...\n");
1549 printf("No physical port founded : not able to test latency functions...");
1552 jack_port_disconnect(client1
, input_port1
);
1553 jack_port_disconnect(client1
, input_port2
);
1554 jack_port_disconnect(client1
, output_port1
);
1555 jack_port_disconnect(client1
, output_port2
);
1561 * Checking transport API.
1562 * Simple transport test.
1563 * Check a transport start with a "slow" client, simulating a delay around 1 sec before becoming ready.
1567 lineports
= linecount
;
1569 if (transport_mode
) {
1571 ts
= jack_transport_query(client1
, &pos
);
1572 if (ts
== JackTransportStopped
) {
1573 Log("Transport is stopped...\n");
1575 jack_transport_stop(client1
);
1576 Log("Transport state : %i\n", ts
);
1578 if (jack_set_sync_callback(client2
, Jack_Sync_Callback
, 0) != 0)
1579 printf("error while calling set_sync_callback...\n");
1581 Log("starting transport...\n");
1583 starting_state
= 1; // Simulate starting state
1584 jack_transport_start(client1
);
1586 // Wait until sync callback is called
1587 while (!(sync_called
)) {
1588 jack_sleep(1 * 1000);
1591 // Wait untill rolling : simulate sync time out
1592 Log("Simulate a slow-sync client exceeding the time-out\n");
1596 jack_sleep(100); // Wait 100 ms each cycle
1598 if (wait_count
== 100) {
1599 Log("!!! ERROR !!! max time-out exceedeed : sync time-out does not work correctly\n");
1602 ts
= jack_transport_query(client2
, &pos
);
1603 Log("Waiting....pos = %ld\n", pos
.frame
);
1604 display_transport_state();
1606 } while (ts
!= JackTransportRolling
);
1608 Log("Sync callback have been called %i times.\n", sync_called
);
1609 jack_transport_stop(client1
);
1611 // Wait until stopped
1612 ts
= jack_transport_query(client2
, &pos
);
1613 while (ts
!= JackTransportStopped
) {
1614 jack_sleep(1 * 1000);
1615 ts
= jack_transport_query(client2
, &pos
);
1618 // Simulate starting a slow-sync client that rolls after 0.5 sec
1619 Log("Simulate a slow-sync client that needs 0.5 sec to start\n");
1622 starting_state
= 1; // Simulate starting state
1624 Log("Starting transport...\n");
1625 jack_transport_start(client1
);
1626 display_transport_state();
1628 Log("Waiting 0.5 sec...\n");
1630 starting_state
= 0; // Simulate end of starting state after 0.5 sec
1632 // Wait untill rolling
1633 ts
= jack_transport_query(client2
, &pos
);
1634 while (ts
!= JackTransportRolling
) {
1635 jack_sleep(100); // Wait 100 ms each cycle
1637 if (wait_count
== 10) {
1638 Log("!!! ERROR !!! starting a slow-sync client does not work correctly\n");
1641 ts
= jack_transport_query(client2
, &pos
);
1644 if (sync_called
== 0)
1645 Log("!!! ERROR !!! starting a slow-sync client does not work correctly\n");
1647 Log("Sync callback have been called %i times.\n", sync_called
);
1648 display_transport_state();
1650 // Test jack_transport_locate while rolling
1651 Log("Test jack_transport_locate while rolling\n");
1652 ts
= jack_transport_query(client2
, &pos
);
1653 Log("Transport current frame = %ld\n", pos
.frame
);
1654 jack_nframes_t cur_frame
= pos
.frame
;
1658 display_transport_state();
1659 jack_sleep(10); // 10 ms
1660 // locate at first...
1662 if (wait_count
== 1) {
1663 Log("Do jack_transport_locate\n");
1664 jack_transport_locate(client1
, cur_frame
/ 2);
1665 } else if (wait_count
== 100) {
1668 ts
= jack_transport_query(client2
, &pos
);
1669 Log("Locating.... frame = %ld\n", pos
.frame
);
1670 } while (pos
.frame
> cur_frame
);
1672 ts
= jack_transport_query(client2
, &pos
);
1673 Log("Transport current frame = %ld\n", pos
.frame
);
1674 if (wait_count
== 100) {
1675 printf("!!! ERROR !!! jack_transport_locate does not work correctly\n");
1678 // Test jack_transport_reposition while rolling
1679 Log("Test jack_transport_reposition while rolling\n");
1680 ts
= jack_transport_query(client2
, &pos
);
1681 Log("Transport current frame = %ld\n", pos
.frame
);
1682 cur_frame
= pos
.frame
;
1686 display_transport_state();
1687 jack_sleep(10); // 10 ms
1688 // locate at first...
1690 if (wait_count
== 1) {
1691 Log("Do jack_transport_reposition\n");
1692 request_pos
.frame
= cur_frame
/ 2;
1693 jack_transport_reposition(client1
, &request_pos
);
1694 } else if (wait_count
== 100) {
1697 ts
= jack_transport_query(client2
, &pos
);
1698 Log("Locating.... frame = %ld\n", pos
.frame
);
1699 } while (pos
.frame
> cur_frame
);
1701 ts
= jack_transport_query(client2
, &pos
);
1702 Log("Transport current frame = %ld\n", pos
.frame
);
1703 if (wait_count
== 100) {
1704 printf("!!! ERROR !!! jack_transport_reposition does not work correctly\n");
1707 // Test jack_transport_reposition while stopped
1708 jack_transport_stop(client1
);
1709 ts
= jack_transport_query(client2
, &pos
);
1710 Log("Transport current frame = %ld\n", pos
.frame
);
1712 Log("Test jack_transport_reposition while stopped\n");
1714 request_pos
.frame
= 10000;
1715 jack_transport_reposition(client1
, &request_pos
);
1718 display_transport_state();
1719 jack_sleep(100); // 100 ms
1720 if (wait_count
++ == 10)
1722 ts
= jack_transport_query(client2
, &pos
);
1723 Log("Locating.... frame = %ld\n", pos
.frame
);
1724 } while (pos
.frame
!= 10000);
1726 ts
= jack_transport_query(client2
, &pos
);
1727 Log("Transport current frame = %ld\n", pos
.frame
);
1728 if (pos
.frame
!= 10000) {
1729 printf("!!! ERROR !!! jack_transport_reposition does not work correctly\n");
1732 jack_transport_stop(client1
);
1734 /* Tell the JACK server that we are ready to roll. Our
1735 * process() callback will start running now. */
1738 printf("Transport check is disabled...\n");
1741 time_before_exit
= time_to_run
;
1742 while (time_before_exit
!= 0) {
1743 jack_sleep (1 * 1000);
1748 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1749 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1750 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1752 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1753 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1754 *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1757 if (jack_deactivate(client2
) != 0) {
1758 printf("!!! ERROR !!! jack_deactivate does not return 0 for client2 !\n");
1760 if (jack_deactivate(client1
) != 0) {
1761 printf("!!! ERROR !!! jack_deactivate does not return 0 for client1 !\n");
1763 if (jack_client_close(client2
) != 0) {
1764 printf("!!! ERROR !!! jack_client_close does not return 0 for client2 !\n");
1766 if (jack_client_close(client1
) != 0) {
1767 printf("!!! ERROR !!! jack_client_close does not return 0 for client1 !\n");
1771 Log("No Xrun have been detected during this test... cool !\n");
1773 printf("%i Xrun have been detected during this session (seen callback messages to see where are the problems).\n");
1778 Log("Exiting jack_test...\n");
1780 printf("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
1781 sprintf (filename
, "framegraph-%i.gnu", cur_buffer_size
);
1782 file
= fopen(filename
, "w");
1784 fprintf(stderr
, "Erreur dans l'ouverture du fichier");
1787 fprintf(file
, "reset\n");
1788 fprintf(file
, "set terminal png transparent nocrop enhanced\n");
1789 fprintf(file
, "set output 'framegraph-%i-1.png'\n", cur_buffer_size
);
1790 fprintf(file
, "set title \"Frame time evolution during jack_test run\"\n");
1791 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));
1792 fprintf(file
, "set xrange [ 0.00000 : %i.0000 ] noreverse nowriteback\n" , linecount
- 1);
1793 fprintf(file
, "set ylabel \"Frametime evolution (d(ft)/dt)\"\n");
1794 fprintf(file
, "set xlabel \"FrameTime\"\n");
1795 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
);
1796 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
);
1798 fprintf(file
, "set output 'framegraph-%i-2.png'\n", cur_buffer_size
);
1799 fprintf(file
, "set title \"Frame time evolution during jack_test run\"\n");
1800 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)));
1801 fprintf(file
, "set xrange [ 0.00000 : %i.0000 ] noreverse nowriteback\n" , linecount
- 1);
1802 fprintf(file
, "set ylabel \"Frametime evolution (d(ft)/dt)\"\n");
1803 fprintf(file
, "set xlabel \"FrameTime\"\n");
1804 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
);
1805 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
);