alsa-seq: configure pool sizes better

The default kernel pool size on the input is 200 cells. A cell is
about 28 bytes long so the maximum message that can be received in one
go is about 5600 bytes. This causes problems when using amidi to upload
larger sysex messages because they simply can't be received by the
sequencer.

It if however possible to increase this limit with the set_client_pool()
function. Increase the pool size to at least the quantum_limit * 2.
This ensures we can receive and send at least 2 quantums of raw data,
which should be a fairly long sysex message.

Make a min and max value for the pool size. There is an upper limit of
2000 in the kernel but make this configurable and clamp the final
pool size to the min/max.

Make the MAX_EVENT_SIZE 256, because this is how the sequencer seems to
splits the input data as well and it results in less wasted space in the
output buffer.

See #4005
This commit is contained in:
Wim Taymans 2024-05-13 15:18:22 +02:00
parent ea0ba1162e
commit 37224ac84c
3 changed files with 44 additions and 2 deletions

View file

@ -928,6 +928,8 @@ impl_init(const struct spa_handle_factory *factory,
reset_props(&this->props);
this->quantum_limit = 8192;
this->min_pool_size = 500;
this->max_pool_size = 2000;
for (i = 0; info && i < info->n_items; i++) {
const char *k = info->items[i].key;
@ -942,6 +944,10 @@ impl_init(const struct spa_handle_factory *factory,
spa_atou32(s, &this->quantum_limit, 0);
} else if (spa_streq(k, SPA_KEY_API_ALSA_DISABLE_LONGNAME)) {
this->props.disable_longname = spa_atob(s);
} else if (spa_streq(k, "api.alsa.seq.min-pool")) {
spa_atou32(s, &this->min_pool_size, 0);
} else if (spa_streq(k, "api.alsa.seq.max-pool")) {
spa_atou32(s, &this->max_pool_size, 0);
}
}
@ -978,7 +984,14 @@ impl_enum_interface_info(const struct spa_handle_factory *factory,
static const struct spa_dict_item info_items[] = {
{ SPA_KEY_FACTORY_AUTHOR, "Wim Taymans <wim.taymans@gmail.com>" },
{ SPA_KEY_FACTORY_DESCRIPTION, "Bridge midi ports with the alsa sequencer API" },
{ SPA_KEY_FACTORY_USAGE, "["SPA_KEY_API_ALSA_PATH"=<device>]" },
{ SPA_KEY_FACTORY_USAGE,
"["SPA_KEY_API_ALSA_PATH"=<device, default \"default\">] "
"[ clock.name=<clock name, default \"clock.system.monotonic\">] "
"[ clock.quantum-limit=<limit, default 8192>] "
"["SPA_KEY_API_ALSA_DISABLE_LONGNAME"=<bool, default false>] "
"[ api.alsa.seq.min-pool=<min-pool, default 500>] "
"[ api.alsa.seq.max-pool=<max-pool, default 2000>]"
},
};
static const struct spa_dict info = SPA_DICT_INIT_ARRAY(info_items);