Browse Source

Implement jack_max_cpu_load

Signed-off-by: falkTX <falktx@falktx.com>
max-dsp-load
falkTX 3 months ago
parent
commit
cb26df399a
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 28 additions and 2 deletions
  1. +15
    -0
      common/JackAPI.cpp
  2. +1
    -0
      common/JackEngineControl.cpp
  3. +4
    -2
      common/JackEngineControl.h
  4. +8
    -0
      common/jack/jack.h

+ 15
- 0
common/JackAPI.cpp View File

@@ -195,6 +195,7 @@ extern "C"
jack_time_t *next_usecs,
float *period_usecs);
LIB_EXPORT float jack_cpu_load(jack_client_t *client);
LIB_EXPORT float jack_max_cpu_load(jack_client_t *client);
LIB_EXPORT jack_native_thread_t jack_client_thread_id(jack_client_t *);
LIB_EXPORT void jack_set_error_function(print_function);
LIB_EXPORT void jack_set_info_function(print_function);
@@ -1457,6 +1458,20 @@ LIB_EXPORT float jack_cpu_load(jack_client_t* ext_client)
}
}

LIB_EXPORT float jack_max_cpu_load(jack_client_t* ext_client)
{
JackGlobals::CheckContext("jack_max_cpu_load");

JackClient* client = (JackClient*)ext_client;
if (client == NULL) {
jack_error("jack_max_cpu_load called with a NULL client");
return 0.0f;
} else {
JackEngineControl* control = GetEngineControl();
return (control ? control->fMaxCPULoad : 0.0f);
}
}

LIB_EXPORT jack_native_thread_t jack_client_thread_id(jack_client_t* ext_client)
{
JackGlobals::CheckContext("jack_client_thread_id");


+ 1
- 0
common/JackEngineControl.cpp View File

@@ -83,6 +83,7 @@ void JackEngineControl::CalcCPULoad(JackClientInterface** table,
}

fCPULoad = ((1.f - (float(fSpareUsecs) / float(fPeriodUsecs))) * 50.f + (fCPULoad * 0.5f));
fMaxCPULoad = 1.f - (float(fMaxUsecs) / float(fPeriodUsecs));
}

fRollingClientUsecsCnt++;


+ 4
- 2
common/JackEngineControl.h View File

@@ -76,9 +76,10 @@ struct SERVER_EXPORT JackEngineControl : public JackShmMem
jack_time_t fMaxUsecs;
jack_time_t fRollingClientUsecs[JACK_ENGINE_ROLLING_COUNT];
unsigned int fRollingClientUsecsCnt;
int fRollingClientUsecsIndex;
int fRollingInterval;
int fRollingClientUsecsIndex;
int fRollingInterval;
float fCPULoad;
float fMaxCPULoad;

// For OSX thread
UInt64 fPeriod;
@@ -124,6 +125,7 @@ struct SERVER_EXPORT JackEngineControl : public JackShmMem
strncpy(fServerName, server_name, sizeof(fServerName));
fServerName[sizeof(fServerName) - 1] = 0;
fCPULoad = 0.f;
fMaxCPULoad = 0.f;
fPeriod = 0;
fComputation = 0;
fConstraint = 0;


+ 8
- 0
common/jack/jack.h View File

@@ -704,6 +704,14 @@ int jack_engine_takeover_timebase (jack_client_t *) JACK_OPTIONAL_WEAK_DEPRECATE
*/
float jack_cpu_load (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;

/**
* @return the current maximum CPU load used by JACK. This is a running
* average of the time it takes to execute a full process cycle for
* all clients as a percentage of the real time available per cycle
* determined by the buffer size and sample rate.
*/
float jack_max_cpu_load (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT;

/**@}*/

/**


Loading…
Cancel
Save