Update XCode project.
[jack2.git] / example-clients / cpu_load.c
blob1d5787acf08b2b3ed4a106b12e0f29241b9c19ca
1 /** @file cpu_load.c
3 */
5 #include <stdio.h>
6 #include <errno.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <math.h>
10 #include <signal.h>
11 #ifndef WIN32
12 #include <unistd.h>
13 #endif
14 #include <jack/jack.h>
17 jack_client_t *client;
19 static void signal_handler ( int sig )
21 jack_client_close ( client );
22 fprintf ( stderr, "signal received, exiting ...\n" );
23 exit ( 0 );
27 /**
28 * JACK calls this shutdown_callback if the server ever shuts down or
29 * decides to disconnect the client.
31 void
32 jack_shutdown ( void *arg )
34 exit ( 1 );
37 int
38 main ( int argc, char *argv[] )
40 jack_options_t options = JackNullOption;
41 jack_status_t status;
43 /* open a client connection to the JACK server */
45 client = jack_client_open ("jack_cpu_load", options, &status);
46 if ( client == NULL )
48 fprintf ( stderr, "jack_client_open() failed, "
49 "status = 0x%2.0x\n", status );
50 if ( status & JackServerFailed )
52 fprintf ( stderr, "Unable to connect to JACK server\n" );
54 exit ( 1 );
57 jack_on_shutdown ( client, jack_shutdown, 0 );
59 /* Tell the JACK server that we are ready to roll. Our
60 * process() callback will start running now. */
62 if ( jack_activate ( client ) )
64 fprintf ( stderr, "cannot activate client" );
65 exit ( 1 );
68 /* install a signal handler to properly quits jack client */
69 #ifdef WIN32
70 signal ( SIGINT, signal_handler );
71 signal ( SIGABRT, signal_handler );
72 signal ( SIGTERM, signal_handler );
73 #else
74 signal ( SIGQUIT, signal_handler );
75 signal ( SIGTERM, signal_handler );
76 signal ( SIGHUP, signal_handler );
77 signal ( SIGINT, signal_handler );
78 #endif
80 while (1)
82 printf("jack DSP load %f\n", jack_cpu_load(client));
83 #ifdef WIN32
84 Sleep ( 1000 );
85 #else
86 sleep ( 1 );
87 #endif
90 jack_client_close ( client );
91 exit ( 0 );