From ff87bea0b51a26a5b3e83d770ae3fdbd262c1f78 Mon Sep 17 00:00:00 2001 From: joq Date: Mon, 18 Aug 2003 19:04:49 +0000 Subject: [PATCH] [0.78.1] some transport enhancements git-svn-id: svn+ssh://jackaudio.org/trunk/jack@457 0c269be4-1314-0410-8aa9-9f06e86f4224 --- configure.in | 3 +-- example-clients/transport.c | 2 ++ jack/transport.h | 5 ++-- jackd/transengine.c | 50 ++++++++++++++++++++----------------- libjack/transclient.c | 10 +++++--- 5 files changed, 40 insertions(+), 30 deletions(-) diff --git a/configure.in b/configure.in index 707c070..fa5a615 100644 --- a/configure.in +++ b/configure.in @@ -14,8 +14,7 @@ dnl changes are made dnl --- JACK_MAJOR_VERSION=0 JACK_MINOR_VERSION=78 -JACK_MICRO_VERSION=0 - +JACK_MICRO_VERSION=1 dnl --- dnl HOWTO: updating the jack protocal version diff --git a/example-clients/transport.c b/example-clients/transport.c index 4b7327f..134a4af 100644 --- a/example-clients/transport.c +++ b/example-clients/transport.c @@ -104,6 +104,8 @@ void timebase(jack_transport_state_t state, jack_nframes_t nframes, void jack_shutdown(void *arg) { + rl_cleanup_after_signal(); + fprintf(stderr, "JACK shut down, exiting ...\n"); exit(1); } diff --git a/jack/transport.h b/jack/transport.h index 1440b5a..8944240 100644 --- a/jack/transport.h +++ b/jack/transport.h @@ -262,8 +262,9 @@ int jack_transport_locate (jack_client_t *client, * current cycle and the state returned is valid for the entire cycle. * * @param client the JACK client structure. - * @param pos current position structure, @a pos->valid describes - * which fields contain valid data. + * @param pos NULL; or pointer to structure for returning current + * transport position, @a pos->valid will describe which fields + * contain valid data. * * @return Current transport state. */ diff --git a/jackd/transengine.c b/jackd/transengine.c index b05b9a7..83f5ac7 100644 --- a/jackd/transengine.c +++ b/jackd/transengine.c @@ -92,8 +92,9 @@ jack_sync_poll_stop (jack_engine_t *engine) //JOQ: check invariant for debugging... assert (poll_count == engine->control->sync_remain); VERBOSE (engine, - "sync poll halted with %ld clients and %llu usecs remaining\n", - engine->control->sync_remain, engine->control->sync_time_left); + "sync poll halted with %ld clients and %8.6f secs remaining\n", + engine->control->sync_remain, + (double) (engine->control->sync_time_left / 1000000.0)); engine->control->sync_remain = 0; engine->control->sync_time_left = 0; } @@ -121,8 +122,8 @@ jack_sync_poll_start (jack_engine_t *engine) engine->control->sync_remain = engine->control->sync_clients; engine->control->sync_time_left = engine->control->sync_timeout; VERBOSE (engine, "transport Starting, sync poll of %ld clients " - "for %llu usecs\n", engine->control->sync_remain, - engine->control->sync_time_left); + "for %8.6f secs\n", engine->control->sync_remain, + (double) (engine->control->sync_time_left / 1000000.0)); } /* check for sync timeout */ @@ -146,6 +147,7 @@ jack_sync_timeout (jack_engine_t *engine) return TRUE; } + /**************** subroutines used by engine.c ****************/ /* driver callback */ @@ -344,27 +346,18 @@ jack_transport_cycle_end (jack_engine_t *engine) ectl->current_time.frame + ectl->buffer_size; } - /* Handle any new transport command from the last cycle. */ - cmd = ectl->transport_cmd; - if (cmd != ectl->previous_cmd) { - ectl->previous_cmd = cmd; - VERBOSE (engine, "transport command: %s\n", - (cmd == TransportCommandStart? "START": "STOP")); - } else - cmd = TransportCommandNone; - - /* See if a position request arrived during the last cycle. - * The request_time could change during the guarded copy. If - * so, we'll handle it now, but mistake it for a new request - * in the following cycle. That may cause an extra sync poll - * cycle, but should work. */ + /* See if an asynchronous position request arrived during the + * last cycle. The request_time could change during the + * guarded copy. If so, we'll handle it now, but mistake it + * for a new request in the following cycle. That may cause + * an extra sync poll cycle, but should work. */ if (ectl->request_time.unique_1 != ectl->prev_request) { ectl->prev_request = ectl->request_time.unique_1; jack_transport_copy_position(&ectl->request_time, &ectl->pending_time); - ectl->new_pos = 1; - VERBOSE (engine, "new transport postition: %lu, id=0x%llx\n", + VERBOSE (engine, "new transport position: %lu, id=0x%llx\n", ectl->pending_time.frame, ectl->pending_time.unique_1); + ectl->new_pos = 1; } else ectl->new_pos = 0; @@ -379,11 +372,21 @@ jack_transport_cycle_end (jack_engine_t *engine) if ((ectl->sync_remain == 0) || (jack_sync_timeout(engine))) { ectl->transport_state = JackTransportRolling; - VERBOSE (engine, "transport Rolling, %lld usec" - " left for poll\n", ectl->sync_time_left); + VERBOSE (engine, "transport Rolling, %8.6f sec" + " left for poll\n", + (double) (ectl->sync_time_left / 1000000.0)); } } + /* Handle any new transport command from the last cycle. */ + cmd = ectl->transport_cmd; + if (cmd != ectl->previous_cmd) { + ectl->previous_cmd = cmd; + VERBOSE (engine, "transport command: %s\n", + (cmd == TransportCommandStart? "START": "STOP")); + } else + cmd = TransportCommandNone; + /* state transition switch */ switch (ectl->transport_state) { @@ -450,6 +453,7 @@ jack_transport_set_sync_timeout (jack_engine_t *engine, jack_time_t usecs) { engine->control->sync_timeout = usecs; - VERBOSE (engine, "new sync timeout: %llu usecs\n", usecs); + VERBOSE (engine, "new sync timeout: %8.6f secs\n", + (double) (usecs / 1000000.0)); return 0; } diff --git a/libjack/transclient.c b/libjack/transclient.c index f856f9b..19f3ef9 100644 --- a/libjack/transclient.c +++ b/libjack/transclient.c @@ -335,8 +335,11 @@ jack_transport_query (jack_client_t *client, jack_position_t *pos) { jack_control_t *ectl = client->engine; - /* the guarded copy makes this function work in any thread */ - jack_transport_copy_position (&ectl->current_time, pos); + if (pos) + /* the guarded copy makes this function work in any + * thread */ + jack_transport_copy_position (&ectl->current_time, pos); + return ectl->transport_state; } @@ -444,7 +447,8 @@ jack_set_transport_info (jack_client_t *client, (info->transport_state != ectl->transport_state)) { if (info->transport_state == JackTransportStopped) ectl->transport_cmd = TransportCommandStop; - else if (info->transport_state == JackTransportRolling) + else if ((info->transport_state == JackTransportRolling) && + (ectl->transport_state != JackTransportStarting)) ectl->transport_cmd = TransportCommandStart; /* silently ignore anything else */ }