Browse Source

better state transition table allows clean removal of unfinished clients

git-svn-id: svn+ssh://jackaudio.org/trunk/jack@92 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.109.0
pbd 23 years ago
parent
commit
4cdb00f120
3 changed files with 17 additions and 19 deletions
  1. +3
    -3
      client.c
  2. +7
    -12
      engine.c
  3. +7
    -4
      jack/internal.h

+ 3
- 3
client.c View File

@@ -587,18 +587,18 @@ jack_client_thread (void *arg)
process().
*/

control->state = JACK_CLIENT_STATE_TRIGGERED;

if (read (client->graph_wait_fd, &c, sizeof (c)) != sizeof (c)) {
jack_error ("cannot clean up byte from inter-client pipe (%s)", strerror (errno));
err++;
break;
}

control->state = Running;

status = control->process (control->nframes, control->process_arg);
if (!status) {
control->state = JACK_CLIENT_STATE_FINISHED;
control->state = Finished;
}

/* this may fail. if it does, the engine will discover


+ 7
- 12
engine.c View File

@@ -206,7 +206,7 @@ jack_cleanup_clients (jack_engine_t *engine)
printf ("client %s state = %d\n", ctl->name, ctl->state);
if (ctl->state > JACK_CLIENT_STATE_NOT_TRIGGERED) {
if (ctl->state > NotTriggered) {
remove = g_slist_prepend (remove, node->data);
printf ("%d: removing failed client %s\n", x, ctl->name);
}
@@ -413,7 +413,7 @@ jack_process (jack_engine_t *engine, nframes_t nframes)

for (node = engine->clients; node; node = g_slist_next (node)) {
ctl = ((jack_client_internal_t *) node->data)->control;
ctl->state = JACK_CLIENT_STATE_NOT_TRIGGERED;
ctl->state = NotTriggered;
ctl->nframes = nframes;
}

@@ -436,11 +436,12 @@ jack_process (jack_engine_t *engine, nframes_t nframes)

/* in-process client ("plugin") */

ctl->state = Running;

if (ctl->process (nframes, ctl->process_arg) == 0) {
ctl->state = JACK_CLIENT_STATE_FINISHED;
ctl->state = Finished;
} else {
jack_error ("in-process client %s failed", client->control->name);
ctl->state = JACK_CLIENT_STATE_TRIGGERED;
err++;
break;
}
@@ -451,6 +452,8 @@ jack_process (jack_engine_t *engine, nframes_t nframes)

/* out of process subgraph */

ctl->state = Triggered; // a race exists if we do this after the write(2)

if (write (client->subgraph_start_fd, &c, sizeof (c)) != sizeof (c)) {
jack_error ("cannot initiate graph processing (%s)", strerror (errno));
err++;
@@ -1185,7 +1188,6 @@ jack_main_thread (void *arg)
{
jack_engine_t *engine = (jack_engine_t *) arg;
jack_driver_t *driver = engine->driver;
// unsigned long start, end;

if (engine->control->real_time) {
if (jack_become_real_time (pthread_self(), engine->rtpriority)) {
@@ -1202,12 +1204,9 @@ jack_main_thread (void *arg)
}

while (1) {
// start = end;
if (driver->wait (driver)) {
break;
}
// rdtscl (end);
// printf ("driver cycle time: %.6f usecs\n", ((float) (end - start)) / 450.00f);
}

pthread_exit (0);
@@ -1800,8 +1799,6 @@ jack_port_do_connect (jack_engine_t *engine,
jack_port_internal_t *srcport, *dstport;
jack_port_id_t src_id, dst_id;

fprintf (stderr, "trying to connect %s and %s\n", source_port, destination_port);

if ((srcport = jack_get_port_by_name (engine, source_port)) == 0) {
jack_error ("unknown source port in attempted connection [%s]", source_port);
return -1;
@@ -1881,8 +1878,6 @@ jack_port_disconnect_internal (jack_engine_t *engine,

/* call tree **** MUST HOLD **** engine->graph_lock. */
printf ("disconnecting %s and %s\n", srcport->shared->name, dstport->shared->name);
for (node = srcport->connections; node; node = g_slist_next (node)) {

connect = (jack_connection_internal_t *) node->data;


+ 7
- 4
jack/internal.h View File

@@ -110,16 +110,19 @@ typedef enum {
ClientOutOfProcess /* client is in another process */
} ClientType;

#define JACK_CLIENT_STATE_NOT_TRIGGERED 19
#define JACK_CLIENT_STATE_TRIGGERED 23
#define JACK_CLIENT_STATE_FINISHED 24
typedef enum {
NotTriggered,
Triggered,
Running,
Finished
} jack_client_state_t;

typedef volatile struct {

volatile nframes_t frame_time; /* w: client r: engine (if client is timebase) */
volatile int id; /* w: engine r: engine and client */
volatile nframes_t nframes; /* w: engine r: client */
volatile char state; /* w: engine and client r: engine JACK_CLIENT_STATE_... */
volatile jack_client_state_t state; /* w: engine and client r: engine */
volatile char name[JACK_CLIENT_NAME_SIZE+1];
volatile ClientType type; /* w: engine r: engine and client */
volatile char active : 1; /* w: engine r: engine and client */


Loading…
Cancel
Save