From a1bc8727540fb039541026ddc9497a742fbed2b6 Mon Sep 17 00:00:00 2001 From: derselbst Date: Tue, 12 Jun 2018 07:39:33 +0200 Subject: [PATCH] implement new_fluid_cmd_handler() according to documentation by only registering commands requested by the user --- src/bindings/fluid_cmd.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/bindings/fluid_cmd.c b/src/bindings/fluid_cmd.c index 3eccdcc3..e032275d 100644 --- a/src/bindings/fluid_cmd.c +++ b/src/bindings/fluid_cmd.c @@ -3548,12 +3548,19 @@ fluid_cmd_handler_t* new_fluid_cmd_handler(fluid_synth_t* synth, fluid_midi_rout handler->synth = synth; handler->router = router; - if (synth != NULL) { for (i = 0; i < FLUID_N_ELEMENTS(fluid_commands); i++) { + fluid_cmd_t* cmd = &fluid_commands[i]; + int is_router_cmd = FLUID_STRCMP(cmd->topic, "router") == 0; + + if((is_router_cmd && router == NULL) || (!is_router_cmd && synth == NULL)) + { + /* omit registering router and synth commands if they were not requested */ + continue; + } + fluid_cmd_handler_register(handler, &fluid_commands[i]); } - } return handler; }