mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-19 08:57:14 -05:00
media-session: round buffer-size down to power of 2
use rate of the session to calculate the buffer size and round down to power of 2
This commit is contained in:
parent
73602ad98a
commit
1eae3f1a2c
1 changed files with 18 additions and 4 deletions
|
|
@ -435,6 +435,16 @@ static int find_session(void *data, struct session *sess)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t flp2(uint32_t x)
|
||||||
|
{
|
||||||
|
x = x | (x >> 1);
|
||||||
|
x = x | (x >> 2);
|
||||||
|
x = x | (x >> 4);
|
||||||
|
x = x | (x >> 8);
|
||||||
|
x = x | (x >> 16);
|
||||||
|
return x - (x >> 1);
|
||||||
|
}
|
||||||
|
|
||||||
static int handle_autoconnect(struct impl *impl, struct pw_node *node,
|
static int handle_autoconnect(struct impl *impl, struct pw_node *node,
|
||||||
const struct pw_properties *props)
|
const struct pw_properties *props)
|
||||||
{
|
{
|
||||||
|
|
@ -474,10 +484,14 @@ static int handle_autoconnect(struct impl *impl, struct pw_node *node,
|
||||||
else
|
else
|
||||||
exclusive = false;
|
exclusive = false;
|
||||||
|
|
||||||
if ((str = pw_properties_get(props, "node.latency")) != NULL)
|
buffer_size = MAX_BUFFER_SIZE;
|
||||||
buffer_size = atoi(str) * sizeof(float);
|
if ((str = pw_properties_get(props, "node.latency")) != NULL) {
|
||||||
else
|
uint32_t num, denom;
|
||||||
buffer_size = MAX_BUFFER_SIZE;
|
pw_log_info("module %p: '%s'", impl, str);
|
||||||
|
if (sscanf(str, "%u/%u", &num, &denom) == 2 && denom != 0) {
|
||||||
|
buffer_size = flp2((num * denom / sample_rate) * sizeof(float));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pw_log_info("module %p: '%s' '%s' '%s' exclusive:%d quantum:%d/%d", impl,
|
pw_log_info("module %p: '%s' '%s' '%s' exclusive:%d quantum:%d/%d", impl,
|
||||||
media, category, role, exclusive,
|
media, category, role, exclusive,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue