** Warning: Cannot open xref database.
1 #include <stdio.h>
2 #include <errno.h>
3 #include <unistd.h>
4 #include <signal.h>
5 #include <stdlib.h>
6
7 #include <jack/jack.h>
8 #include <jack/transport.h>
9
10 jack_client_t *client;
11
12
13 void
14 showtime ()
15 {
16 jack_position_t current;
17 jack_transport_state_t transport_state;
18
19 transport_state = jack_transport_query (client, ¤t);
20
21 printf ("frame: %7" PRIu32 "\t", current.frame);
22
23 switch (transport_state) {
24 case JackTransportStopped:
25 printf ("state: Stopped");
26 break;
27 case JackTransportRolling:
28 printf ("state: Rolling");
29 break;
30 case JackTransportStarting:
31 printf ("state: Starting");
32 break;
33 default:
34 printf ("state: [unknown]");
35 }
36
37 if (current.valid & JackPositionBBT)
38 printf ("\tBBT: %3" PRIi32 "|%" PRIi32 "|%04"
39 PRIi32, current.bar, current.beat, current.tick);
40
41 if (current.valid & JackPositionTimecode)
42 printf ("\tTC: (%.6f, %.6f)",
43 current.frame_time, current.next_time);
44 printf ("\n");
45 }
46
47 void
48 jack_shutdown (void *arg)
49 {
50 exit (1);
51 }
52
53 void
54 signal_handler (int sig)
55 {
56 jack_client_close (client);
57 fprintf (stderr, "signal received, exiting ...\n");
58 exit (0);
59 }
60
61 int
62 main (int argc, char *argv[])
63
64 {
65 /* try to become a client of the JACK server */
66
67 if ((client = jack_client_new ("showtime")) == 0) {
68 fprintf (stderr, "jack server not running?\n");
69 return 1;
70 }
71
72 signal (SIGQUIT, signal_handler);
73 signal (SIGTERM, signal_handler);
74 signal (SIGHUP, signal_handler);
75 signal (SIGINT, signal_handler);
76
77 /* tell the JACK server to call `jack_shutdown()' if
78 it ever shuts down, either entirely, or if it
79 just decides to stop calling us.
80 */
81
82 jack_on_shutdown (client, jack_shutdown, 0);
83
84 /* tell the JACK server that we are ready to roll */
85
86 if (jack_activate (client)) {
87 fprintf (stderr, "cannot activate client");
88 return 1;
89 }
90
91 while (1) {
92 usleep (100000);
93 showtime ();
94 }
95
96 jack_client_close (client);
97 exit (0);
98 }
99
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.