Browse Source

jack_showtime fixes; transport doc clarifications

git-svn-id: svn+ssh://jackaudio.org/trunk/jack@407 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.109.0
joq 23 years ago
parent
commit
6e253b59bd
3 changed files with 59 additions and 14 deletions
  1. +1
    -1
      configure.in
  2. +55
    -11
      example-clients/showtime.c
  3. +3
    -2
      jack/transport.h

+ 1
- 1
configure.in View File

@@ -14,7 +14,7 @@ dnl changes are made
dnl ---
JACK_MAJOR_VERSION=0
JACK_MINOR_VERSION=71
JACK_MICRO_VERSION=5
JACK_MICRO_VERSION=6

dnl ---
dnl HOWTO: updating the jack protocal version


+ 55
- 11
example-clients/showtime.c View File

@@ -7,26 +7,70 @@
#include <jack/jack.h>
#include <jack/transport.h>

typedef struct {
volatile jack_nframes_t guard1;
volatile jack_transport_info_t info;
volatile jack_nframes_t guard2;
} guarded_transport_info_t;

guarded_transport_info_t now;
jack_client_t *client;
jack_transport_info_t now;

void
showtime ()
{
jack_transport_info_t current = now;
printf ("frame: %lu state: %d loop: %lu-%lu "
"BBT: %d|%d|%d\n",
current.frame, current.transport_state, current.loop_start, current.loop_end,
current.bar,
current.beat,
current.tick);
guarded_transport_info_t current;
int tries = 0;

/* Since "now" is updated from the process() thread every
* buffer period, we must copy it carefully to avoid getting
* an incoherent hash of multiple versions. */
do {
/* Throttle the busy wait if we don't get the a clean
* copy very quickly. */
if (tries > 10) {
usleep (20);
tries = 0;
}
current = now;
tries++;

} while (current.guard1 != current.guard2);

if (current.info.valid & JackTransportPosition)
printf ("frame: %lu ", current.info.frame);
else
printf ("frame: [-] ");

if (current.info.valid & JackTransportState)
printf ("state: %d ", current.info.transport_state);
else
printf ("state: [-] ");

if (current.info.valid & JackTransportLoop)
printf ("loop: %lu-%lu ", current.info.loop_start,
current.info.loop_end);
else
printf ("loop: [-] ");

if (current.info.valid & JackTransportBBT)
printf ("BBT: %d|%d|%d\n", current.info.bar,
current.info.beat, current.info.tick);
else
printf ("BBT: [-]\n");
}

int
process (jack_nframes_t nframes, void *arg)
{
now.valid = JackTransportState|JackTransportPosition|JackTransportLoop;
jack_get_transport_info (client, &now);
/* The guard flags contain a running counter of sufficiently
* high resolution, that showtime() can detect whether the
* last update is complete. */
now.guard1 = jack_frame_time(client);
jack_get_transport_info (client, &now.info);
now.guard2 = now.guard1;

return 0;
}

@@ -39,8 +83,8 @@ jack_shutdown (void *arg)
void
signal_handler (int sig)
{
fprintf (stderr, "signal received, exiting ...\n");
jack_client_close (client);
fprintf (stderr, "signal received, exiting ...\n");
exit (0);
}



+ 3
- 2
jack/transport.h View File

@@ -95,8 +95,8 @@ typedef struct {
* a bitmask of all transport info fields that are set
* in tinfo.
*
* @pre Caller must be the current timebase master.
*
* @pre Caller must be the current timebase master. Must be called
* from the process() thread.
*/
void jack_set_transport_info (jack_client_t *client,
jack_transport_info_t *tinfo);
@@ -108,6 +108,7 @@ void jack_set_transport_info (jack_client_t *client,
* a bitmask of all transport info fields that are legal to
* use.
*
* @pre Must be called from the process() thread.
*/
void jack_get_transport_info (jack_client_t *client,
jack_transport_info_t *tinfo);


Loading…
Cancel
Save