mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-02-26 01:40:28 -05:00
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:
parent
ea0ba1162e
commit
37224ac84c
3 changed files with 44 additions and 2 deletions
|
|
@ -250,7 +250,9 @@ int spa_alsa_seq_open(struct seq_state *state)
|
|||
snd_seq_port_subscribe_t *sub;
|
||||
snd_seq_addr_t addr;
|
||||
snd_seq_queue_timer_t *timer;
|
||||
snd_seq_client_pool_t *pool;
|
||||
struct seq_conn reserve[16];
|
||||
size_t pool_size;
|
||||
|
||||
if (state->opened)
|
||||
return 0;
|
||||
|
|
@ -319,6 +321,31 @@ int spa_alsa_seq_open(struct seq_state *state)
|
|||
spa_log_warn(state->log, "failed to set queue timer: %s", snd_strerror(res));
|
||||
}
|
||||
|
||||
/* Increase client pool sizes. This determines the max sysex message that
|
||||
* can be received. */
|
||||
snd_seq_client_pool_alloca(&pool);
|
||||
if ((res = snd_seq_get_client_pool(state->event.hndl, pool)) < 0) {
|
||||
spa_log_warn(state->log, "failed to get pool: %s", snd_strerror(res));
|
||||
} else {
|
||||
/* make sure we at least use the default size */
|
||||
pool_size = snd_seq_client_pool_get_output_pool(pool);
|
||||
pool_size = SPA_MAX(pool_size, snd_seq_client_pool_get_input_pool(pool));
|
||||
|
||||
/* The pool size is in cells, which are about 24 bytes long. Try to
|
||||
* make sure we can fit sysex of at least twice the quantum limit. */
|
||||
pool_size = SPA_MAX(pool_size, state->quantum_limit * 2 / 24);
|
||||
/* The kernel ignores values larger than 2000 (by default) so clamp
|
||||
* this here. It's configurable in case the kernel was modified. */
|
||||
pool_size = SPA_CLAMP(pool_size, state->min_pool_size, state->max_pool_size);
|
||||
|
||||
snd_seq_client_pool_set_input_pool(pool, pool_size);
|
||||
snd_seq_client_pool_set_output_pool(pool, pool_size);
|
||||
|
||||
if ((res = snd_seq_set_client_pool(state->event.hndl, pool)) < 0) {
|
||||
spa_log_warn(state->log, "failed to set pool: %s", snd_strerror(res));
|
||||
}
|
||||
}
|
||||
|
||||
init_ports(state);
|
||||
|
||||
if ((res = spa_system_timerfd_create(state->data_system,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue