Use configured quantum_limit instead of hardcoded value

Parse the quantum_limit parameters and use this to scale the buffers so
that they can contain the maximum allowed samples instead of the
hardcoded 8192 value.

See #1931
This commit is contained in:
Wim Taymans 2022-01-12 17:50:12 +01:00
parent 4e5ab4bcbe
commit 776b52749f
16 changed files with 124 additions and 44 deletions

View file

@ -70,7 +70,6 @@ static void reset_props(struct props *props)
#define DEFAULT_CHANNELS 2
#define DEFAULT_RATE 44100
#define MAX_SAMPLES 8192
#define MAX_BUFFERS 16
#define MAX_PORTS 1
@ -107,6 +106,8 @@ struct impl {
struct spa_loop *data_loop;
struct spa_system *data_system;
uint32_t quantum_limit;
struct props props;
uint64_t info_all;
@ -538,7 +539,7 @@ impl_node_port_enum_params(void *object, int seq,
SPA_PARAM_BUFFERS_buffers, SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS),
SPA_PARAM_BUFFERS_blocks, SPA_POD_Int(port->blocks),
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(
MAX_SAMPLES * port->bpf,
this->quantum_limit * port->bpf,
16 * port->bpf,
INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(port->bpf));
@ -856,7 +857,6 @@ impl_init(const struct spa_handle_factory *factory,
spa_log_error(this->log, "a data_system is needed");
return -EINVAL;
}
spa_hook_list_init(&this->hooks);
this->node.iface = SPA_INTERFACE_INIT(
@ -904,7 +904,9 @@ impl_init(const struct spa_handle_factory *factory,
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, SPA_KEY_AUDIO_CHANNELS)) {
if (spa_streq(k, "clock.quantum-limit")) {
spa_atou32(s, &this->quantum_limit, 0);
} else if (spa_streq(k, SPA_KEY_AUDIO_CHANNELS)) {
this->props.channels = atoi(s);
} else if (spa_streq(k, SPA_KEY_AUDIO_RATE)) {
this->props.rate = atoi(s);