control: use quantum_limit for midi buffer size

Instead of the arbitrary default.
This commit is contained in:
Wim Taymans 2024-05-10 11:49:31 +02:00
parent 7e87bd9b34
commit 89edb9f6c5
4 changed files with 23 additions and 3 deletions

View file

@ -563,7 +563,7 @@ impl_node_port_enum_params(void *object, int seq,
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(2, 1, MAX_BUFFERS),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(
4096, 4096, INT32_MAX),
this->quantum_limit, this->quantum_limit, INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(1));
break;
@ -927,6 +927,8 @@ impl_init(const struct spa_handle_factory *factory,
this->info.n_params = N_NODE_PARAMS;
reset_props(&this->props);
this->quantum_limit = 8192;
for (i = 0; info && i < info->n_items; i++) {
const char *k = info->items[i].key;
const char *s = info->items[i].value;
@ -936,6 +938,8 @@ impl_init(const struct spa_handle_factory *factory,
} else if (spa_streq(k, "clock.name")) {
spa_scnprintf(this->props.clock_name,
sizeof(this->props.clock_name), "%s", s);
} else if (spa_streq(k, "clock.quantum-limit")) {
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);
}

View file

@ -696,7 +696,7 @@ static int process_write(struct seq_state *state)
out_rt.tv_sec = out_time / SPA_NSEC_PER_SEC;
snd_seq_ev_schedule_real(&ev, state->event.queue_id, 0, &out_rt);
spa_log_info(state->log, "event %d time:%"PRIu64" offset:%d size:%ld port:%d.%d",
spa_log_trace_fp(state->log, "event %d time:%"PRIu64" offset:%d size:%ld port:%d.%d",
ev.type, out_time, c->offset, size, port->addr.client, port->addr.port);
if ((err = snd_seq_event_output(state->event.hndl, &ev)) < 0) {

View file

@ -131,6 +131,8 @@ struct seq_state {
struct spa_io_clock *clock;
struct spa_io_position *position;
uint32_t quantum_limit;
int rate_denom;
uint32_t duration;
uint32_t threshold;

View file

@ -60,6 +60,8 @@ struct impl {
struct spa_handle handle;
struct spa_node node;
uint32_t quantum_limit;
struct spa_log *log;
struct spa_loop *data_loop;
@ -363,7 +365,8 @@ next:
SPA_TYPE_OBJECT_ParamBuffers, id,
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(1),
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(4096, 512, INT32_MAX),
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(this->quantum_limit,
this->quantum_limit, INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(1));
break;
@ -866,6 +869,7 @@ impl_init(const struct spa_handle_factory *factory,
{
struct impl *this;
struct port *port;
uint32_t i;
spa_return_val_if_fail(factory != NULL, -EINVAL);
spa_return_val_if_fail(handle != NULL, -EINVAL);
@ -883,6 +887,16 @@ impl_init(const struct spa_handle_factory *factory,
return -EINVAL;
}
this->quantum_limit = 8192;
for (i = 0; info && i < info->n_items; i++) {
const char *k = info->items[i].key;
const char *s = info->items[i].value;
if (spa_streq(k, "clock.quantum-limit")) {
spa_atou32(s, &this->quantum_limit, 0);
}
}
spa_hook_list_init(&this->hooks);
this->node.iface = SPA_INTERFACE_INIT(