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

@ -551,8 +551,8 @@ 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(this->blocks),
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(
this->props.max_latency * this->frame_size,
this->props.min_latency * this->frame_size,
this->quantum_limit * this->frame_size,
16 * this->frame_size,
INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(this->frame_size));
break;

View file

@ -500,8 +500,8 @@ 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(this->blocks),
SPA_PARAM_BUFFERS_size, SPA_POD_CHOICE_RANGE_Int(
this->props.max_latency * this->frame_size,
this->props.min_latency * this->frame_size,
this->quantum_limit * this->frame_size,
16 * this->frame_size,
INT32_MAX),
SPA_PARAM_BUFFERS_stride, SPA_POD_Int(this->frame_size));
break;

View file

@ -427,6 +427,8 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info)
state->card_index = atoi(s);
} else if (spa_streq(k, SPA_KEY_API_ALSA_OPEN_UCM)) {
state->open_ucm = spa_atob(s);
} else if (spa_streq(k, "clock.quantum-limit")) {
spa_atou32(s, &state->quantum_limit, 0);
} else if (spa_streq(k, "latency.internal.rate")) {
state->process_latency.rate = atoi(s);
} else if (spa_streq(k, "latency.internal.ns")) {
@ -2308,7 +2310,7 @@ int spa_alsa_start(struct state *state)
else {
spa_log_warn(state->log, "%s: no position set, using defaults",
state->props.device);
state->duration = state->props.min_latency;
state->duration = 1024;
state->rate_denom = state->rate;
}

View file

@ -148,6 +148,7 @@ struct state {
unsigned int disable_mmap;
unsigned int disable_batch;
char clock_name[64];
uint32_t quantum_limit;
snd_pcm_uframes_t buffer_frames;
snd_pcm_uframes_t period_frames;