impl-port/audioconvert: add PORT_IGNORE_LATENCY

Add port.ignore-latency prop, which if true causes peer ports to ignore
the latency of the given port.

This is useful for ports that are not intended to affect latency
calculations of other ports, such as ports in monitor streams.
This commit is contained in:
Pauli Virtanen 2023-05-03 19:19:22 +03:00 committed by Wim Taymans
parent 85d2933268
commit 6e17962ad0
5 changed files with 22 additions and 1 deletions

View file

@ -31,6 +31,7 @@ extern "C" {
#define SPA_KEY_PORT_NAME "port.name" /**< a port name */
#define SPA_KEY_PORT_ALIAS "port.alias" /**< a port alias */
#define SPA_KEY_PORT_MONITOR "port.monitor" /**< this port is a monitor port */
#define SPA_KEY_PORT_IGNORE_LATENCY "port.ignore-latency" /**< latency ignored by peers */
/**

View file

@ -218,6 +218,7 @@ struct impl {
unsigned int ramp_volume:1;
unsigned int drained:1;
unsigned int rate_adjust:1;
unsigned int port_ignore_latency:1;
uint32_t empty_size;
float *empty;
@ -265,7 +266,7 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
if (full)
port->info.change_mask = port->info_all;
if (port->info.change_mask) {
struct spa_dict_item items[3];
struct spa_dict_item items[4];
uint32_t n_items = 0;
if (PORT_IS_DSP(this, port->direction, port->id)) {
@ -273,6 +274,8 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_AUDIO_CHANNEL, port->position);
if (port->is_monitor)
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_PORT_MONITOR, "true");
if (this->port_ignore_latency)
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_PORT_IGNORE_LATENCY, "true");
} else if (PORT_IS_CONTROL(this, port->direction, port->id)) {
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_PORT_NAME, "control");
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_FORMAT_DSP, "8 bit raw midi");
@ -3144,6 +3147,8 @@ impl_init(const struct spa_handle_factory *factory,
if (s != NULL)
this->props.n_channels = parse_position(this->props.channel_map, s, strlen(s));
}
else if (spa_streq(k, SPA_KEY_PORT_IGNORE_LATENCY))
this->port_ignore_latency = spa_atob(s);
else
audioconvert_set_param(this, k, s);
}

View file

@ -914,6 +914,7 @@ int pw_impl_port_register(struct pw_impl_port *port,
PW_KEY_PORT_CONTROL,
PW_KEY_PORT_ALIAS,
PW_KEY_PORT_EXTRA,
PW_KEY_PORT_IGNORE_LATENCY,
NULL
};
@ -992,6 +993,8 @@ int pw_impl_port_add(struct pw_impl_port *port, struct pw_impl_node *node)
is_monitor = pw_properties_get_bool(port->properties, PW_KEY_PORT_MONITOR, false);
port->ignore_latency = pw_properties_get_bool(port->properties, PW_KEY_PORT_IGNORE_LATENCY, false);
is_control = PW_IMPL_PORT_IS_CONTROL(port);
if (is_control) {
dir = port->direction == PW_DIRECTION_INPUT ? "control" : "notify";
@ -1440,6 +1443,11 @@ int pw_impl_port_recalc_latency(struct pw_impl_port *port)
if (port->direction == PW_DIRECTION_OUTPUT) {
spa_list_for_each(l, &port->links, output_link) {
other = l->input;
if (other->ignore_latency) {
pw_log_debug("port %d: peer %d: peer latency ignored",
port->info.id, other->info.id);
continue;
}
spa_latency_info_combine(&latency, &other->latency[other->direction]);
pw_log_debug("port %d: peer %d: latency %f-%f %d-%d %"PRIu64"-%"PRIu64,
port->info.id, other->info.id,
@ -1450,6 +1458,11 @@ int pw_impl_port_recalc_latency(struct pw_impl_port *port)
} else {
spa_list_for_each(l, &port->links, input_link) {
other = l->output;
if (other->ignore_latency) {
pw_log_debug("port %d: peer %d: peer latency ignored",
port->info.id, other->info.id);
continue;
}
spa_latency_info_combine(&latency, &other->latency[other->direction]);
pw_log_debug("port %d: peer %d: latency %f-%f %d-%d %"PRIu64"-%"PRIu64,
port->info.id, other->info.id,

View file

@ -197,6 +197,7 @@ extern "C" {
#define PW_KEY_PORT_EXTRA "port.extra" /**< api specific extra port info, API name
* should be prefixed. "jack:flags:56" */
#define PW_KEY_PORT_PASSIVE "port.passive" /**< the ports wants passive links, since 0.3.67 */
#define PW_KEY_PORT_IGNORE_LATENCY "port.ignore-latency" /**< latency ignored by peers, since 0.3.71 */
/** link properties */
#define PW_KEY_LINK_ID "link.id" /**< a link id */

View file

@ -893,6 +893,7 @@ struct pw_impl_port {
struct spa_latency_info latency[2]; /**< latencies */
unsigned int have_latency_param:1;
unsigned int ignore_latency:1;
void *owner_data; /**< extra owner data */
void *user_data; /**< extra user data */