jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

693 lines
20KB

  1. /*
  2. NetJack Client
  3. Copyright (C) 2008 Marc-Olivier Barre <marco@marcochapeau.org>
  4. Copyright (C) 2008 Pieter Palmers <pieterpalmers@users.sourceforge.net>
  5. Copyright (C) 2006 Torben Hohn <torbenh@gmx.de>
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. 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.
  17. */
  18. /** @file netsource.c
  19. *
  20. * @brief This client connects a remote slave JACK to a local JACK server assumed to be the master
  21. */
  22. //#include "config.h"
  23. #define HAVE_CELT 1
  24. #include <stdio.h>
  25. #include <errno.h>
  26. #include <unistd.h>
  27. #include <stdlib.h>
  28. #include <string.h>
  29. #ifdef WIN32
  30. #include <winsock2.h>
  31. #include <malloc.h>
  32. #else
  33. #include <netinet/in.h>
  34. #include <netdb.h>
  35. #include <sys/socket.h>
  36. #endif
  37. /* These two required by FreeBSD. */
  38. #include <sys/types.h>
  39. #if HAVE_ALLOCA_H
  40. #include <alloca.h>
  41. #endif
  42. #include <jack/jack.h>
  43. //#include <net_driver.h>
  44. #include <netjack_packet.h>
  45. #if HAVE_SAMPLERATE
  46. #include <samplerate.h>
  47. #endif
  48. #if HAVE_CELT
  49. #include <celt/celt.h>
  50. #endif
  51. #include <math.h>
  52. JSList *capture_ports = NULL;
  53. JSList *capture_srcs = NULL;
  54. int capture_channels = 0;
  55. int capture_channels_audio = 2;
  56. int capture_channels_midi = 1;
  57. JSList *playback_ports = NULL;
  58. JSList *playback_srcs = NULL;
  59. int playback_channels = 0;
  60. int playback_channels_audio = 2;
  61. int playback_channels_midi = 1;
  62. int dont_htonl_floats = 0;
  63. int latency = 5;
  64. jack_nframes_t factor = 1;
  65. int bitdepth = 0;
  66. int mtu = 1400;
  67. int reply_port = 0;
  68. int redundancy = 1;
  69. jack_client_t *client;
  70. int state_connected = 0;
  71. int state_latency = 0;
  72. int state_netxruns = 0;
  73. int state_currentframe = 0;
  74. int state_recv_packet_queue_time = 0;
  75. int outsockfd;
  76. int insockfd;
  77. #ifdef WIN32
  78. struct sockaddr_in destaddr;
  79. struct sockaddr_in bindaddr;
  80. #else
  81. struct sockaddr destaddr;
  82. struct sockaddr bindaddr;
  83. #endif
  84. int sync_state;
  85. jack_transport_state_t last_transport_state;
  86. int framecnt = 0;
  87. int cont_miss = 0;
  88. /**
  89. * This Function allocates all the I/O Ports which are added the lists.
  90. */
  91. void
  92. alloc_ports (int n_capture_audio, int n_playback_audio, int n_capture_midi, int n_playback_midi)
  93. {
  94. int port_flags = JackPortIsOutput;
  95. int chn;
  96. jack_port_t *port;
  97. char buf[32];
  98. capture_ports = NULL;
  99. /* Allocate audio capture channels */
  100. for (chn = 0; chn < n_capture_audio; chn++)
  101. {
  102. snprintf (buf, sizeof (buf) - 1, "capture_%u", chn + 1);
  103. port = jack_port_register (client, buf, JACK_DEFAULT_AUDIO_TYPE, port_flags, 0);
  104. if (!port)
  105. {
  106. printf( "jack_netsource: cannot register %s port\n", buf);
  107. break;
  108. }
  109. if( bitdepth == 1000 ) {
  110. #if HAVE_CELT
  111. // XXX: memory leak
  112. CELTMode *celt_mode = celt_mode_create( jack_get_sample_rate( client ), 1, jack_get_buffer_size(client), NULL );
  113. capture_srcs = jack_slist_append(capture_srcs, celt_decoder_create( celt_mode ) );
  114. #endif
  115. } else {
  116. #if HAVE_SAMPLERATE
  117. capture_srcs = jack_slist_append (capture_srcs, src_new (SRC_LINEAR, 1, NULL));
  118. #endif
  119. }
  120. capture_ports = jack_slist_append (capture_ports, port);
  121. }
  122. /* Allocate midi capture channels */
  123. for (chn = n_capture_audio; chn < n_capture_midi + n_capture_audio; chn++)
  124. {
  125. snprintf (buf, sizeof (buf) - 1, "capture_%u", chn + 1);
  126. port = jack_port_register (client, buf, JACK_DEFAULT_MIDI_TYPE, port_flags, 0);
  127. if (!port)
  128. {
  129. printf ("jack_netsource: cannot register %s port\n", buf);
  130. break;
  131. }
  132. capture_ports = jack_slist_append(capture_ports, port);
  133. }
  134. /* Allocate audio playback channels */
  135. port_flags = JackPortIsInput;
  136. playback_ports = NULL;
  137. for (chn = 0; chn < n_playback_audio; chn++)
  138. {
  139. snprintf (buf, sizeof (buf) - 1, "playback_%u", chn + 1);
  140. port = jack_port_register (client, buf, JACK_DEFAULT_AUDIO_TYPE, port_flags, 0);
  141. if (!port)
  142. {
  143. printf ("jack_netsource: cannot register %s port\n", buf);
  144. break;
  145. }
  146. if( bitdepth == 1000 ) {
  147. #if HAVE_CELT
  148. // XXX: memory leak
  149. CELTMode *celt_mode = celt_mode_create( jack_get_sample_rate (client), 1, jack_get_buffer_size(client), NULL );
  150. playback_srcs = jack_slist_append(playback_srcs, celt_encoder_create( celt_mode ) );
  151. #endif
  152. } else {
  153. #if HAVE_SAMPLERATE
  154. playback_srcs = jack_slist_append (playback_srcs, src_new (SRC_LINEAR, 1, NULL));
  155. #endif
  156. }
  157. playback_ports = jack_slist_append (playback_ports, port);
  158. }
  159. /* Allocate midi playback channels */
  160. for (chn = n_playback_audio; chn < n_playback_midi + n_playback_audio; chn++)
  161. {
  162. snprintf (buf, sizeof (buf) - 1, "playback_%u", chn + 1);
  163. port = jack_port_register (client, buf, JACK_DEFAULT_MIDI_TYPE, port_flags, 0);
  164. if (!port)
  165. {
  166. printf ("jack_netsource: cannot register %s port\n", buf);
  167. break;
  168. }
  169. playback_ports = jack_slist_append (playback_ports, port);
  170. }
  171. }
  172. /**
  173. * The Sync callback... sync state is set elsewhere...
  174. * we will see if this is working correctly.
  175. * i dont really believe in it yet.
  176. */
  177. int
  178. sync_cb (jack_transport_state_t state, jack_position_t *pos, void *arg)
  179. {
  180. static int latency_count = 0;
  181. int retval = sync_state;
  182. if (latency_count) {
  183. latency_count--;
  184. retval = 0;
  185. }
  186. else if (state == JackTransportStarting && last_transport_state != JackTransportStarting)
  187. {
  188. retval = 0;
  189. latency_count = latency - 1;
  190. }
  191. last_transport_state = state;
  192. return retval;
  193. }
  194. int deadline_goodness=0;
  195. /**
  196. * The process callback for this JACK application.
  197. * It is called by JACK at the appropriate times.
  198. */
  199. int
  200. process (jack_nframes_t nframes, void *arg)
  201. {
  202. jack_nframes_t net_period;
  203. int rx_bufsize, tx_bufsize;
  204. jack_default_audio_sample_t *buf;
  205. jack_port_t *port;
  206. JSList *node;
  207. int chn;
  208. int size, i;
  209. const char *porttype;
  210. int input_fd;
  211. jack_position_t local_trans_pos;
  212. uint32_t *packet_buf, *packet_bufX;
  213. uint32_t *rx_packet_ptr;
  214. jack_time_t packet_recv_timestamp;
  215. if( bitdepth == 1000 )
  216. net_period = factor;
  217. else
  218. net_period = (float) nframes / (float) factor;
  219. rx_bufsize = get_sample_size (bitdepth) * capture_channels * net_period + sizeof (jacknet_packet_header);
  220. tx_bufsize = get_sample_size (bitdepth) * playback_channels * net_period + sizeof (jacknet_packet_header);
  221. /* Allocate a buffer where both In and Out Buffer will fit */
  222. packet_buf = alloca ((rx_bufsize > tx_bufsize) ? rx_bufsize : tx_bufsize);
  223. jacknet_packet_header *pkthdr = (jacknet_packet_header *) packet_buf;
  224. /*
  225. * ok... SEND code first.
  226. * needed some time to find out why latency=0
  227. * did not work ;S
  228. *
  229. */
  230. /* reset packet_bufX... */
  231. packet_bufX = packet_buf + sizeof (jacknet_packet_header) / sizeof (jack_default_audio_sample_t);
  232. /* ---------- Send ---------- */
  233. render_jack_ports_to_payload (bitdepth, playback_ports, playback_srcs, nframes,
  234. packet_bufX, net_period, dont_htonl_floats);
  235. /* fill in packet hdr */
  236. pkthdr->transport_state = jack_transport_query (client, &local_trans_pos);
  237. pkthdr->transport_frame = local_trans_pos.frame;
  238. pkthdr->framecnt = framecnt;
  239. pkthdr->latency = latency;
  240. pkthdr->reply_port = reply_port;
  241. pkthdr->sample_rate = jack_get_sample_rate (client);
  242. pkthdr->period_size = nframes;
  243. /* playback for us is capture on the other side */
  244. pkthdr->capture_channels_audio = playback_channels_audio;
  245. pkthdr->playback_channels_audio = capture_channels_audio;
  246. pkthdr->capture_channels_midi = playback_channels_midi;
  247. pkthdr->playback_channels_midi = capture_channels_midi;
  248. pkthdr->mtu = mtu;
  249. pkthdr->sync_state = (jack_nframes_t)deadline_goodness;
  250. //printf("goodness=%d\n", deadline_goodness );
  251. packet_header_hton (pkthdr);
  252. if (cont_miss < 3*latency+5) {
  253. int r;
  254. for( r=0; r<redundancy; r++ )
  255. netjack_sendto (outsockfd, (char *) packet_buf, tx_bufsize, 0, &destaddr, sizeof (destaddr), mtu);
  256. }
  257. else if (cont_miss > 50+5*latency)
  258. {
  259. state_connected = 0;
  260. packet_cache_reset_master_address( global_packcache );
  261. //printf ("Frame %d \tRealy too many packets missed (%d). Let's reset the counter\n", framecnt, cont_miss);
  262. cont_miss = 0;
  263. }
  264. /*
  265. * ok... now the RECEIVE code.
  266. *
  267. */
  268. /* reset packet_bufX... */
  269. packet_bufX = packet_buf + sizeof (jacknet_packet_header) / sizeof (jack_default_audio_sample_t);
  270. if( reply_port )
  271. input_fd = insockfd;
  272. else
  273. input_fd = outsockfd;
  274. // for latency == 0 we can poll.
  275. if( latency == 0 ) {
  276. jack_time_t deadline = jack_get_time() + 1000000 * jack_get_buffer_size(client)/jack_get_sample_rate(client);
  277. // Now loop until we get the right packet.
  278. while(1) {
  279. if ( ! netjack_poll_deadline( input_fd, deadline ) )
  280. break;
  281. packet_cache_drain_socket(global_packcache, input_fd);
  282. if (packet_cache_get_next_available_framecnt( global_packcache, framecnt - latency, NULL ))
  283. break;
  284. }
  285. } else {
  286. // normally:
  287. // only drain socket.
  288. packet_cache_drain_socket(global_packcache, input_fd);
  289. }
  290. size = packet_cache_retreive_packet_pointer( global_packcache, framecnt - latency, (char**)&rx_packet_ptr, rx_bufsize, &packet_recv_timestamp );
  291. /* First alternative : we received what we expected. Render the data
  292. * to the JACK ports so it can be played. */
  293. if (size == rx_bufsize)
  294. {
  295. packet_buf = rx_packet_ptr;
  296. pkthdr = (jacknet_packet_header *) packet_buf;
  297. packet_bufX = packet_buf + sizeof (jacknet_packet_header) / sizeof (jack_default_audio_sample_t);
  298. // calculate how much time there would have been, if this packet was sent at the deadline.
  299. int recv_time_offset = (int) (jack_get_time() - packet_recv_timestamp);
  300. packet_header_ntoh (pkthdr);
  301. deadline_goodness = recv_time_offset - (int)pkthdr->latency;
  302. //printf( "deadline goodness = %d ---> off: %d\n", deadline_goodness, recv_time_offset );
  303. if (cont_miss)
  304. {
  305. //printf("Frame %d \tRecovered from dropouts\n", framecnt);
  306. cont_miss = 0;
  307. }
  308. render_payload_to_jack_ports (bitdepth, packet_bufX, net_period,
  309. capture_ports, capture_srcs, nframes, dont_htonl_floats);
  310. state_currentframe = framecnt;
  311. state_recv_packet_queue_time = recv_time_offset;
  312. state_connected = 1;
  313. sync_state = pkthdr->sync_state;
  314. packet_cache_release_packet( global_packcache, framecnt - latency );
  315. }
  316. /* Second alternative : we've received something that's not
  317. * as big as expected or we missed a packet. We render silence
  318. * to the ouput ports */
  319. else
  320. {
  321. jack_nframes_t latency_estimate;
  322. if( packet_cache_find_latency( global_packcache, framecnt, &latency_estimate ) )
  323. //if( (state_latency == 0) || (latency_estimate < state_latency) )
  324. state_latency = latency_estimate;
  325. // Set the counters up.
  326. state_currentframe = framecnt;
  327. //state_latency = framecnt - pkthdr->framecnt;
  328. state_netxruns += 1;
  329. //printf ("Frame %d \tPacket missed or incomplete (expected: %d bytes, got: %d bytes)\n", framecnt, rx_bufsize, size);
  330. //printf ("Frame %d \tPacket missed or incomplete\n", framecnt);
  331. cont_miss += 1;
  332. chn = 0;
  333. node = capture_ports;
  334. while (node != NULL)
  335. {
  336. port = (jack_port_t *) node->data;
  337. buf = jack_port_get_buffer (port, nframes);
  338. porttype = jack_port_type (port);
  339. if (strncmp (porttype, JACK_DEFAULT_AUDIO_TYPE, jack_port_type_size ()) == 0)
  340. for (i = 0; i < nframes; i++)
  341. buf[i] = 0.0;
  342. else if (strncmp (porttype, JACK_DEFAULT_MIDI_TYPE, jack_port_type_size ()) == 0)
  343. jack_midi_clear_buffer (buf);
  344. node = jack_slist_next (node);
  345. chn++;
  346. }
  347. }
  348. framecnt++;
  349. return 0;
  350. }
  351. /**
  352. * This is the shutdown callback for this JACK application.
  353. * It is called by JACK if the server ever shuts down or
  354. * decides to disconnect the client.
  355. */
  356. void
  357. jack_shutdown (void *arg)
  358. {
  359. exit (1);
  360. }
  361. void
  362. init_sockaddr_in (struct sockaddr_in *name , const char *hostname , uint16_t port)
  363. {
  364. printf( "still here... \n" );
  365. fflush( stdout );
  366. name->sin_family = AF_INET ;
  367. name->sin_port = htons (port);
  368. if (hostname)
  369. {
  370. struct hostent *hostinfo = gethostbyname (hostname);
  371. if (hostinfo == NULL) {
  372. fprintf (stderr, "init_sockaddr_in: unknown host: %s.\n", hostname);
  373. fflush( stderr );
  374. }
  375. #ifdef WIN32
  376. name->sin_addr.s_addr = inet_addr( hostname );
  377. #else
  378. name->sin_addr = *(struct in_addr *) hostinfo->h_addr ;
  379. #endif
  380. }
  381. else
  382. name->sin_addr.s_addr = htonl (INADDR_ANY) ;
  383. }
  384. void
  385. printUsage ()
  386. {
  387. fprintf (stderr, "usage: jack_netsource -h <host peer> [options]\n"
  388. "\n"
  389. " -n <jack name> - Reports a different name to jack\n"
  390. " -s <server name> - The name of the local jack server\n"
  391. " -h <host_peer> - Host name of the slave JACK\n"
  392. " -p <port> - UDP port used by the slave JACK\n"
  393. " -P <num channels> - Number of audio playback channels\n"
  394. " -C <num channels> - Number of audio capture channels\n"
  395. " -o <num channels> - Number of midi playback channels\n"
  396. " -i <num channels> - Number of midi capture channels\n"
  397. " -l <latency> - Network latency in number of NetJack frames\n"
  398. " -r <reply port> - Local UDP port to use\n"
  399. " -f <downsample ratio> - Downsample data in the wire by this factor\n"
  400. " -b <bitdepth> - Set transport to use 16bit or 8bit\n"
  401. " -m <mtu> - Assume this mtu for the link\n"
  402. " -c <bytes> - Use Celt and encode <bytes> per channel and packet.\n"
  403. " -R <N> - Send out packets N times.\n"
  404. "\n");
  405. }
  406. int
  407. main (int argc, char *argv[])
  408. {
  409. /* Some startup related basics */
  410. char *client_name, *server_name = NULL, *peer_ip;
  411. int peer_port = 3000;
  412. jack_options_t options = JackNullOption;
  413. jack_status_t status;
  414. #ifdef WIN32
  415. WSADATA wsa;
  416. int rc = WSAStartup(MAKEWORD(2,0),&wsa);
  417. #endif
  418. /* Torben's famous state variables, aka "the reporting API" ! */
  419. /* heh ? these are only the copies of them ;) */
  420. int statecopy_connected, statecopy_latency, statecopy_netxruns;
  421. jack_nframes_t net_period;
  422. /* Argument parsing stuff */
  423. extern char *optarg;
  424. extern int optind, optopt;
  425. int errflg=0, c;
  426. if (argc < 3)
  427. {
  428. printUsage ();
  429. return 1;
  430. }
  431. client_name = (char *) malloc (sizeof (char) * 10);
  432. peer_ip = (char *) malloc (sizeof (char) * 10);
  433. sprintf(client_name, "netsource");
  434. sprintf(peer_ip, "localhost");
  435. while ((c = getopt (argc, argv, ":H:R:n:s:h:p:C:P:i:o:l:r:f:b:m:c:")) != -1)
  436. {
  437. switch (c)
  438. {
  439. case 'n':
  440. free(client_name);
  441. client_name = (char *) malloc (sizeof (char) * strlen (optarg)+1);
  442. strcpy (client_name, optarg);
  443. break;
  444. case 's':
  445. server_name = (char *) malloc (sizeof (char) * strlen (optarg)+1);
  446. strcpy (server_name, optarg);
  447. options |= JackServerName;
  448. break;
  449. case 'h':
  450. free(peer_ip);
  451. peer_ip = (char *) malloc (sizeof (char) * strlen (optarg)+1);
  452. strcpy (peer_ip, optarg);
  453. break;
  454. case 'p':
  455. peer_port = atoi (optarg);
  456. break;
  457. case 'P':
  458. playback_channels_audio = atoi (optarg);
  459. break;
  460. case 'C':
  461. capture_channels_audio = atoi (optarg);
  462. break;
  463. case 'o':
  464. playback_channels_midi = atoi (optarg);
  465. break;
  466. case 'i':
  467. capture_channels_midi = atoi (optarg);
  468. break;
  469. case 'l':
  470. latency = atoi (optarg);
  471. break;
  472. case 'r':
  473. reply_port = atoi (optarg);
  474. break;
  475. case 'f':
  476. factor = atoi (optarg);
  477. break;
  478. case 'b':
  479. bitdepth = atoi (optarg);
  480. break;
  481. case 'c':
  482. #if HAVE_CELT
  483. bitdepth = 1000;
  484. factor = atoi (optarg);
  485. #else
  486. printf( "not built with celt supprt\n" );
  487. exit(10);
  488. #endif
  489. break;
  490. case 'm':
  491. mtu = atoi (optarg);
  492. break;
  493. case 'R':
  494. redundancy = atoi (optarg);
  495. break;
  496. case 'H':
  497. dont_htonl_floats = atoi (optarg);
  498. break;
  499. case ':':
  500. fprintf (stderr, "Option -%c requires an operand\n", optopt);
  501. errflg++;
  502. break;
  503. case '?':
  504. fprintf (stderr, "Unrecognized option: -%c\n", optopt);
  505. errflg++;
  506. }
  507. }
  508. if (errflg)
  509. {
  510. printUsage ();
  511. exit (2);
  512. }
  513. capture_channels = capture_channels_audio + capture_channels_midi;
  514. playback_channels = playback_channels_audio + playback_channels_midi;
  515. outsockfd = socket (AF_INET, SOCK_DGRAM, 0);
  516. insockfd = socket (AF_INET, SOCK_DGRAM, 0);
  517. if( (outsockfd == -1) || (insockfd == -1) ) {
  518. fprintf (stderr, "cant open sockets\n" );
  519. return 1;
  520. }
  521. init_sockaddr_in ((struct sockaddr_in *) &destaddr, peer_ip, peer_port);
  522. if(reply_port)
  523. {
  524. init_sockaddr_in ((struct sockaddr_in *) &bindaddr, NULL, reply_port);
  525. if( bind (insockfd, &bindaddr, sizeof (bindaddr)) ) {
  526. fprintf (stderr, "bind failure\n" );
  527. }
  528. }
  529. /* try to become a client of the JACK server */
  530. client = jack_client_open (client_name, options, &status, server_name);
  531. if (client == NULL)
  532. {
  533. fprintf (stderr, "jack_client_open() failed, status = 0x%2.0x\n"
  534. "Is the JACK server running ?\n", status);
  535. return 1;
  536. }
  537. /* Set up jack callbacks */
  538. jack_set_process_callback (client, process, 0);
  539. jack_set_sync_callback (client, sync_cb, 0);
  540. jack_on_shutdown (client, jack_shutdown, 0);
  541. alloc_ports (capture_channels_audio, playback_channels_audio, capture_channels_midi, playback_channels_midi);
  542. if( bitdepth == 1000 )
  543. net_period = factor;
  544. else
  545. net_period = ceilf((float) jack_get_buffer_size (client) / (float) factor);
  546. int rx_bufsize = get_sample_size (bitdepth) * capture_channels * net_period + sizeof (jacknet_packet_header);
  547. global_packcache = packet_cache_new (latency + 50, rx_bufsize, mtu);
  548. /* tell the JACK server that we are ready to roll */
  549. if (jack_activate (client))
  550. {
  551. fprintf (stderr, "Cannot activate client");
  552. return 1;
  553. }
  554. /* Now sleep forever... and evaluate the state_ vars */
  555. statecopy_connected = 2; // make it report unconnected on start.
  556. statecopy_latency = state_latency;
  557. statecopy_netxruns = state_netxruns;
  558. while (1)
  559. {
  560. #ifdef WIN32
  561. Sleep (1000);
  562. #else
  563. sleep(1);
  564. #endif
  565. if (statecopy_connected != state_connected)
  566. {
  567. statecopy_connected = state_connected;
  568. if (statecopy_connected)
  569. {
  570. state_netxruns = 1; // We want to reset the netxrun count on each new connection
  571. printf ("Connected :-)\n");
  572. }
  573. else
  574. printf ("Not Connected\n");
  575. fflush(stdout);
  576. }
  577. if (statecopy_connected)
  578. {
  579. if (statecopy_netxruns != state_netxruns) {
  580. statecopy_netxruns = state_netxruns;
  581. printf ("at frame %06d -> total netxruns %d (%d%%) queue time= %d\n", state_currentframe,
  582. statecopy_netxruns,
  583. 100*statecopy_netxruns/state_currentframe,
  584. state_recv_packet_queue_time);
  585. fflush(stdout);
  586. }
  587. }
  588. else
  589. {
  590. if (statecopy_latency != state_latency)
  591. {
  592. statecopy_latency = state_latency;
  593. if (statecopy_latency > 1)
  594. printf ("current latency %d\n", statecopy_latency);
  595. fflush(stdout);
  596. }
  597. }
  598. }
  599. /* Never reached. Well we will be a GtkApp someday... */
  600. packet_cache_free (global_packcache);
  601. jack_client_close (client);
  602. exit (0);
  603. }