mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
alsa: reconfigure max latency based on buffer size
We can't ever support a latency larger than half the buffer size. Take a fourth of the buffer size to have some extre headroom. See #724
This commit is contained in:
parent
00d8d1472d
commit
1dfa36d77b
2 changed files with 32 additions and 13 deletions
|
|
@ -271,18 +271,24 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const struct spa_dict_item node_info_items[] = {
|
||||
{ SPA_KEY_DEVICE_API, "alsa" },
|
||||
{ SPA_KEY_MEDIA_CLASS, "Audio/Source" },
|
||||
{ SPA_KEY_NODE_DRIVER, "true" },
|
||||
};
|
||||
|
||||
static void emit_node_info(struct state *this, bool full)
|
||||
{
|
||||
if (full)
|
||||
this->info.change_mask = this->info_all;
|
||||
if (this->info.change_mask) {
|
||||
this->info.props = &SPA_DICT_INIT_ARRAY(node_info_items);
|
||||
struct spa_dict_item items[4];
|
||||
uint32_t n_items = 0;
|
||||
char latency[64];
|
||||
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_DEVICE_API, "alsa");
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_MEDIA_CLASS, "Audio/Source");
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_DRIVER, "true");
|
||||
if (this->have_format) {
|
||||
snprintf(latency, sizeof(latency), "%lu/%d", this->buffer_frames / 4, this->rate);
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_LATENCY, latency);
|
||||
}
|
||||
this->info.props = &SPA_DICT_INIT(items, n_items);
|
||||
|
||||
spa_node_emit_info(&this->hooks, &this->info);
|
||||
this->info.change_mask = 0;
|
||||
}
|
||||
|
|
@ -505,6 +511,9 @@ static int port_set_format(void *object,
|
|||
this->have_format = true;
|
||||
}
|
||||
|
||||
this->info.change_mask |= SPA_NODE_CHANGE_MASK_PROPS;
|
||||
emit_node_info(this, false);
|
||||
|
||||
this->port_info.change_mask |= SPA_PORT_CHANGE_MASK_RATE;
|
||||
this->port_info.rate = SPA_FRACTION(1, this->rate);
|
||||
this->port_info.change_mask |= SPA_PORT_CHANGE_MASK_PARAMS;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue