2 This program is free software; you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation; either version 2 of the License, or
5 (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <jack/jack.h>
25 #include <jack/transport.h>
27 jack_client_t
*client
;
32 jack_position_t current
;
33 jack_transport_state_t transport_state
;
34 jack_nframes_t frame_time
;
36 transport_state
= jack_transport_query (client
, ¤t
);
37 frame_time
= jack_frame_time (client
);
39 printf ("frame = %u frame_time = %u usecs = %" PRIu64
"\t", current
.frame
, frame_time
, current
.usecs
);
41 switch (transport_state
) {
42 case JackTransportStopped
:
43 printf ("state: Stopped");
45 case JackTransportRolling
:
46 printf ("state: Rolling");
48 case JackTransportStarting
:
49 printf ("state: Starting");
52 printf ("state: [unknown]");
55 if (current
.valid
& JackPositionBBT
)
56 printf ("\tBBT: %3" PRIi32
"|%" PRIi32
"|%04"
57 PRIi32
, current
.bar
, current
.beat
, current
.tick
);
59 if (current
.valid
& JackPositionTimecode
)
60 printf ("\tTC: (%.6f, %.6f)",
61 current
.frame_time
, current
.next_time
);
66 jack_shutdown (void *arg
)
68 fprintf(stderr
, "JACK shut down, exiting ...\n");
73 signal_handler (int sig
)
75 jack_client_close (client
);
76 fprintf (stderr
, "signal received, exiting ...\n");
81 main (int argc
, char *argv
[])
83 /* try to become a client of the JACK server */
85 if ((client
= jack_client_open ("showtime", JackNullOption
, NULL
)) == 0) {
86 fprintf (stderr
, "JACK server not running?\n");
91 signal (SIGQUIT
, signal_handler
);
92 signal (SIGHUP
, signal_handler
);
95 signal (SIGTERM
, signal_handler
);
96 signal (SIGINT
, signal_handler
);
98 /* tell the JACK server to call `jack_shutdown()' if
99 it ever shuts down, either entirely, or if it
100 just decides to stop calling us.
103 jack_on_shutdown (client
, jack_shutdown
, 0);
105 /* tell the JACK server that we are ready to roll */
107 if (jack_activate (client
)) {
108 fprintf (stderr
, "cannot activate client");
117 jack_client_close (client
);