Skip to content

Commit 8e70439

Browse files
committed
Implement "max_cpu_load" command
Signed-off-by: falkTX <[email protected]>
1 parent bcada10 commit 8e70439

File tree

6 files changed

+29
-1
lines changed

6 files changed

+29
-1
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ ifeq ($(shell pkg-config --atleast-version=1.9.0 jack && echo true), true)
8585
INCS += -DHAVE_JACK2
8686
endif
8787

88+
ifeq ($(shell pkg-config --atleast-version=1.9.23 jack && echo true), true)
89+
INCS += -DHAVE_JACK2_1_9_23
90+
endif
91+
8892
ifeq ($(HAVE_NE10),true)
8993
LIBS += -lNE10
9094
INCS += -DHAVE_NE10

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ The commands supported by mod-host are:
246246
e.g.: cv_unmap 0 "gain"
247247

248248
cpu_load
249-
* return current jack cpu load
249+
* return current average jack cpu load
250+
251+
max_cpu_load
252+
* return current maximum jack cpu load
250253

251254
load <file_name>
252255
* load a history command file

src/effects.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7952,6 +7952,15 @@ float effects_jack_cpu_load(void)
79527952
return jack_cpu_load(g_jack_global_client);
79537953
}
79547954

7955+
float effects_jack_max_cpu_load(void)
7956+
{
7957+
#ifdef HAVE_JACK2_1_9_23
7958+
return jack_max_cpu_load(g_jack_global_client);
7959+
#else
7960+
return jack_cpu_load(g_jack_global_client);
7961+
#endif
7962+
}
7963+
79557964
#define OS_SEP '/'
79567965

79577966
void effects_bundle_add(const char* bpath)

src/effects.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ int effects_hmi_map(int effect_id, const char *control_symbol, int hw_id, int pa
181181
int effects_hmi_unmap(int effect_id, const char *control_symbol);
182182

183183
float effects_jack_cpu_load(void);
184+
float effects_jack_max_cpu_load(void);
184185
void effects_bundle_add(const char *bundlepath);
185186
void effects_bundle_remove(const char *bundlepath, const char *resource);
186187
int effects_state_load(const char *dir);

src/mod-host.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,15 @@ static void cpu_load_cb(proto_t *proto)
509509
protocol_response(buffer, proto);
510510
}
511511

512+
static void max_cpu_load_cb(proto_t *proto)
513+
{
514+
float value = effects_jack_max_cpu_load();
515+
char buffer[128];
516+
sprintf(buffer, "resp 0 %.04f", value);
517+
518+
protocol_response(buffer, proto);
519+
}
520+
512521
#ifndef SKIP_READLINE
513522
static void load_cb(proto_t *proto)
514523
{
@@ -770,6 +779,7 @@ static int mod_host_init(jack_client_t* client, int socket_port, int feedback_po
770779
protocol_add_command(HMI_MAP, hmi_map_cb);
771780
protocol_add_command(HMI_UNMAP, hmi_unmap_cb);
772781
protocol_add_command(CPU_LOAD, cpu_load_cb);
782+
protocol_add_command(MAX_CPU_LOAD, max_cpu_load_cb);
773783
#ifndef SKIP_READLINE
774784
protocol_add_command(LOAD_COMMANDS, load_cb);
775785
protocol_add_command(SAVE_COMMANDS, save_cb);

src/mod-host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#define HMI_MAP "hmi_map %i %s %i %i %i %i %i %s %f %f %i"
8787
#define HMI_UNMAP "hmi_unmap %i %s"
8888
#define CPU_LOAD "cpu_load"
89+
#define MAX_CPU_LOAD "max_cpu_load"
8990
#define LOAD_COMMANDS "load %s"
9091
#define SAVE_COMMANDS "save %s"
9192
#define BUNDLE_ADD "bundle_add %s"

0 commit comments

Comments
 (0)