mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
context: make a new node.max-latency property
node.latency also influences the pipeline latency in that it can push the latency above the default value. node.max-latency, instead, is only used to clamp the final latency of the pipeline.
This commit is contained in:
parent
4389e44903
commit
c8804c3d6d
7 changed files with 38 additions and 11 deletions
|
|
@ -32,6 +32,7 @@ extern "C" {
|
|||
/** node keys */
|
||||
#define SPA_KEY_NODE_NAME "node.name" /**< a node name */
|
||||
#define SPA_KEY_NODE_LATENCY "node.latency" /**< the requested node latency */
|
||||
#define SPA_KEY_NODE_MAX_LATENCY "node.max-latency" /**< maximum supported latency */
|
||||
|
||||
#define SPA_KEY_NODE_DRIVER "node.driver" /**< the node can be a driver */
|
||||
#define SPA_KEY_NODE_ALWAYS_PROCESS "node.always-process" /**< call the process function even if
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ static void emit_node_info(struct state *this, bool full)
|
|||
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);
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_MAX_LATENCY, latency);
|
||||
}
|
||||
this->info.props = &SPA_DICT_INIT(items, n_items);
|
||||
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ static void emit_node_info(struct state *this, bool full)
|
|||
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);
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_MAX_LATENCY, latency);
|
||||
}
|
||||
this->info.props = &SPA_DICT_INIT(items, n_items);
|
||||
|
||||
|
|
|
|||
|
|
@ -991,32 +991,34 @@ int pw_context_recalc_graph(struct pw_context *context, const char *reason)
|
|||
/* assign final quantum and set state for followers and drivers */
|
||||
spa_list_for_each(n, &context->driver_list, driver_link) {
|
||||
bool running = false;
|
||||
uint32_t max_quantum = 0;
|
||||
uint32_t min_quantum = 0;
|
||||
uint32_t quantum;
|
||||
uint32_t max_quantum = context->defaults.clock_max_quantum;
|
||||
uint32_t quantum = 0;
|
||||
|
||||
if (!n->driving || n->exported)
|
||||
continue;
|
||||
|
||||
/* collect quantum and count active nodes */
|
||||
spa_list_for_each(s, &n->follower_list, follower_link) {
|
||||
|
||||
if (s->quantum_size > 0) {
|
||||
if (min_quantum == 0 || s->quantum_size < min_quantum)
|
||||
min_quantum = s->quantum_size;
|
||||
if (s->quantum_size > max_quantum)
|
||||
max_quantum = s->quantum_size;
|
||||
if (quantum == 0 || s->quantum_size < quantum)
|
||||
quantum = s->quantum_size;
|
||||
}
|
||||
if (s->max_quantum_size > 0) {
|
||||
if (s->max_quantum_size < max_quantum)
|
||||
max_quantum = s->max_quantum_size;
|
||||
}
|
||||
if (s == n)
|
||||
continue;
|
||||
if (s->active)
|
||||
running = !n->passive;
|
||||
}
|
||||
quantum = min_quantum;
|
||||
if (quantum == 0)
|
||||
quantum = context->defaults.clock_quantum;
|
||||
|
||||
quantum = SPA_CLAMP(quantum,
|
||||
context->defaults.clock_min_quantum,
|
||||
context->defaults.clock_max_quantum);
|
||||
max_quantum);
|
||||
|
||||
if (n->rt.position && quantum != n->rt.position->clock.duration) {
|
||||
pw_log_info("(%s-%u) new quantum:%"PRIu64"->%u",
|
||||
|
|
|
|||
|
|
@ -865,6 +865,26 @@ static void check_properties(struct pw_impl_node *node)
|
|||
}
|
||||
}
|
||||
}
|
||||
if ((str = pw_properties_get(node->properties, PW_KEY_NODE_MAX_LATENCY))) {
|
||||
uint32_t num, denom;
|
||||
if (sscanf(str, "%u/%u", &num, &denom) == 2 && denom != 0) {
|
||||
uint32_t max_quantum_size;
|
||||
|
||||
node->max_latency = SPA_FRACTION(num, denom);
|
||||
max_quantum_size = flp2((num * context->defaults.clock_rate / denom));
|
||||
|
||||
if (max_quantum_size != node->max_quantum_size) {
|
||||
pw_log_debug(NAME" %p: max latency '%s' quantum %u/%u",
|
||||
node, str, max_quantum_size, context->defaults.clock_rate);
|
||||
pw_log_info("(%s-%u) max latency:%s ->quantum %u/%u", node->name,
|
||||
node->info.id, str, max_quantum_size,
|
||||
context->defaults.clock_rate);
|
||||
node->max_quantum_size = max_quantum_size;
|
||||
do_recalc = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pw_log_debug(NAME" %p: driver:%d recalc:%d active:%d", node, node->driver,
|
||||
do_recalc, node->active);
|
||||
|
||||
|
|
|
|||
|
|
@ -143,6 +143,8 @@ extern "C" {
|
|||
* node/session */
|
||||
#define PW_KEY_NODE_LATENCY "node.latency" /**< the requested latency of the node as
|
||||
* a fraction. Ex: 128/48000 */
|
||||
#define PW_KEY_NODE_MAX_LATENCY "node.max-latency" /**< the maximum supported latency of the
|
||||
* node as a fraction. Ex: 1024/48000 */
|
||||
#define PW_KEY_NODE_DONT_RECONNECT "node.dont-reconnect" /**< don't reconnect this node */
|
||||
#define PW_KEY_NODE_ALWAYS_PROCESS "node.always-process" /**< process even when unlinked */
|
||||
#define PW_KEY_NODE_PAUSE_ON_IDLE "node.pause-on-idle" /**< pause the node when idle */
|
||||
|
|
|
|||
|
|
@ -657,6 +657,8 @@ struct pw_impl_node {
|
|||
|
||||
struct spa_fraction latency; /**< requested latency */
|
||||
uint32_t quantum_size; /**< desired quantum */
|
||||
struct spa_fraction max_latency; /**< miximum latency */
|
||||
uint32_t max_quantum_size; /**< max supported quantum */
|
||||
struct spa_source source; /**< source to remotely trigger this node */
|
||||
struct pw_memblock *activation;
|
||||
struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue