diff --git a/client.c b/client.c index 6569837..6738ca1 100644 --- a/client.c +++ b/client.c @@ -1790,3 +1790,9 @@ jack_get_mhz (void) } } } + +float +jack_cpu_load (jack_client_t *client) +{ + return client->engine->cpu_load; +} diff --git a/configure.in b/configure.in index be7f20c..190fd2a 100644 --- a/configure.in +++ b/configure.in @@ -4,8 +4,8 @@ AC_INIT(client.c) AC_CONFIG_AUX_DIR(.) JACK_MAJOR_VERSION=0 -JACK_MINOR_VERSION=25 -JACK_MICRO_VERSION=1 +JACK_MINOR_VERSION=26 +JACK_MICRO_VERSION=0 BETA= diff --git a/engine.c b/engine.c index 763c90e..9f8f7ca 100644 --- a/engine.c +++ b/engine.c @@ -586,8 +586,11 @@ jack_process (jack_engine_t *engine, nframes_t nframes) engine->spare_usecs = 0; } + engine->control->cpu_load = (1.0f - (engine->spare_usecs / engine->driver->period_usecs)) * 100.0f; + if (engine->verbose) { - fprintf (stderr, "average usecs: %.3f, spare = %.3f\n", average_usecs, engine->spare_usecs); + fprintf (stderr, "load = %.4f average usecs: %.3f, spare = %.3f\n", + engine->control->cpu_load, average_usecs, engine->spare_usecs); } } } @@ -1205,7 +1208,7 @@ jack_engine_new (int realtime, int rtpriority, int verbose) engine->verbose = verbose; engine->asio_mode = FALSE; engine->cpu_mhz = jack_get_mhz(); - + jack_engine_reset_rolling_usecs (engine); pthread_mutex_init (&engine->client_lock, 0); @@ -1278,6 +1281,7 @@ jack_engine_new (int realtime, int rtpriority, int verbose) engine->control->port_max = engine->port_max; engine->control->real_time = realtime; engine->control->client_priority = engine->rtpriority - 1; + engine->control->cpu_load = 0; engine->control->buffer_size = 0; engine->control->time.frame_rate = 0; diff --git a/jack/internal.h b/jack/internal.h index 85a2c4c..933aa15 100644 --- a/jack/internal.h +++ b/jack/internal.h @@ -80,6 +80,7 @@ typedef struct { unsigned long buffer_size; char real_time; int client_priority; + float cpu_load; unsigned long port_max; jack_port_shared_t ports[0]; diff --git a/jack/jack.h b/jack/jack.h index 2c36edf..d44e228 100644 --- a/jack/jack.h +++ b/jack/jack.h @@ -517,6 +517,12 @@ void jack_update_time (jack_client_t *, nframes_t); nframes_t jack_frames_since_cycle_start (jack_client_t *); +/** + * This returns the current CPU load estimated by JACK + * as a percentage. + */ +float jack_cpu_load (jack_client_t *client); + #ifdef __cplusplus } #endif