mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
pulse: keep track of availability of active port
Also emit a device change event when the availability of the active port changes.
This commit is contained in:
parent
8638fd0411
commit
c8700b2e4b
2 changed files with 13 additions and 4 deletions
|
|
@ -846,30 +846,37 @@ static void device_sync_ports(struct global *g)
|
||||||
spa_list_for_each(p, &g->card_info.routes, link) {
|
spa_list_for_each(p, &g->card_info.routes, link) {
|
||||||
struct global *ng;
|
struct global *ng;
|
||||||
uint32_t index, device;
|
uint32_t index, device;
|
||||||
enum spa_direction direction;
|
enum spa_param_availability available = SPA_PARAM_AVAILABILITY_unknown;
|
||||||
struct spa_pod *props = NULL;
|
struct spa_pod *props = NULL;
|
||||||
|
const char *name;
|
||||||
|
|
||||||
if (spa_pod_parse_object(p->param,
|
if (spa_pod_parse_object(p->param,
|
||||||
SPA_TYPE_OBJECT_ParamRoute, NULL,
|
SPA_TYPE_OBJECT_ParamRoute, NULL,
|
||||||
SPA_PARAM_ROUTE_index, SPA_POD_Int(&index),
|
SPA_PARAM_ROUTE_index, SPA_POD_Int(&index),
|
||||||
SPA_PARAM_ROUTE_direction, SPA_POD_Id(&direction),
|
SPA_PARAM_ROUTE_name, SPA_POD_String(&name),
|
||||||
SPA_PARAM_ROUTE_device, SPA_POD_Int(&device),
|
SPA_PARAM_ROUTE_device, SPA_POD_Int(&device),
|
||||||
|
SPA_PARAM_ROUTE_available, SPA_POD_OPT_Id(&available),
|
||||||
SPA_PARAM_ROUTE_props, SPA_POD_OPT_Pod(&props)) < 0) {
|
SPA_PARAM_ROUTE_props, SPA_POD_OPT_Pod(&props)) < 0) {
|
||||||
pw_log_warn("device %d: can't parse route", g->id);
|
pw_log_warn("device %d: can't parse route", g->id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ng = find_node_for_route(c, g, device);
|
ng = find_node_for_route(c, g, device);
|
||||||
if (ng) {
|
if (ng) {
|
||||||
int changed = 0;
|
int changed = 0;
|
||||||
|
pw_log_debug("device: %d port:%d: name:%s available:%d", ng->id,
|
||||||
|
index, name, available);
|
||||||
if (ng->node_info.active_port != index) {
|
if (ng->node_info.active_port != index) {
|
||||||
ng->node_info.active_port = index;
|
ng->node_info.active_port = index;
|
||||||
changed++;
|
changed++;
|
||||||
}
|
}
|
||||||
|
if (ng->node_info.available_port != available) {
|
||||||
|
ng->node_info.available_port = available;
|
||||||
|
changed++;
|
||||||
|
}
|
||||||
if (props)
|
if (props)
|
||||||
changed += parse_props(ng, props, true);
|
changed += parse_props(ng, props, true);
|
||||||
if (changed)
|
if (changed)
|
||||||
emit_event(c, ng, PA_SUBSCRIPTION_EVENT_CHANGE);
|
global_sync(ng);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1258,6 +1265,7 @@ static int set_mask(pa_context *c, struct global *g)
|
||||||
g->node_info.base_volume = 1.0f;
|
g->node_info.base_volume = 1.0f;
|
||||||
g->node_info.volume_step = 1.0f / (PA_VOLUME_NORM+1);
|
g->node_info.volume_step = 1.0f / (PA_VOLUME_NORM+1);
|
||||||
g->node_info.active_port = SPA_ID_INVALID;
|
g->node_info.active_port = SPA_ID_INVALID;
|
||||||
|
g->node_info.available_port = SPA_PARAM_AVAILABILITY_unknown;
|
||||||
} else if (strcmp(g->type, PW_TYPE_INTERFACE_Port) == 0) {
|
} else if (strcmp(g->type, PW_TYPE_INTERFACE_Port) == 0) {
|
||||||
if (g->props == NULL)
|
if (g->props == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,7 @@ struct global {
|
||||||
float base_volume;
|
float base_volume;
|
||||||
float volume_step;
|
float volume_step;
|
||||||
uint32_t active_port;
|
uint32_t active_port;
|
||||||
|
enum spa_param_availability available_port;
|
||||||
uint32_t device_index;
|
uint32_t device_index;
|
||||||
} node_info;
|
} node_info;
|
||||||
struct {
|
struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue