mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-09-06 08:45:44 +00:00
pulse-server: improve network and virtual node checks
Tag the sink/source as HARDWARE when it's not virtual, the presence of a DEVICE_API property is not a good check. Make a method to check if a node is a NETWORK sink/source to make it use the same logic everywhere.
This commit is contained in:
parent
ae4042e7a2
commit
39a1887a0b
|
@ -974,6 +974,16 @@ bool pw_manager_object_is_virtual(struct pw_manager_object *o)
|
|||
pw_properties_parse_bool(str);
|
||||
}
|
||||
|
||||
bool pw_manager_object_is_network(struct pw_manager_object *o)
|
||||
{
|
||||
const char *str;
|
||||
struct pw_node_info *info;
|
||||
return spa_streq(o->type, PW_TYPE_INTERFACE_Node) &&
|
||||
(info = o->info) != NULL && info->props != NULL &&
|
||||
(str = spa_dict_lookup(info->props, PW_KEY_NODE_NETWORK)) != NULL &&
|
||||
pw_properties_parse_bool(str);
|
||||
}
|
||||
|
||||
bool pw_manager_object_is_source_or_monitor(struct pw_manager_object *o)
|
||||
{
|
||||
return pw_manager_object_is_source(o) || pw_manager_object_is_monitor(o);
|
||||
|
|
|
@ -112,6 +112,7 @@ bool pw_manager_object_is_sink(struct pw_manager_object *o);
|
|||
bool pw_manager_object_is_source(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_monitor(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_virtual(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_network(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_source_or_monitor(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_sink_input(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_source_output(struct pw_manager_object *o);
|
||||
|
|
|
@ -107,7 +107,7 @@ static void manager_added(void *data, struct pw_manager_object *o)
|
|||
return;
|
||||
}
|
||||
|
||||
if (d->ignore_virtual && spa_dict_lookup(info->props, PW_KEY_DEVICE_API) == NULL) {
|
||||
if (d->ignore_virtual && pw_manager_object_is_virtual(o)) {
|
||||
pw_log_debug("not switching to virtual device");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ static void fill_service_data(struct module_zeroconf_publish_data *d, struct ser
|
|||
|
||||
collect_device_info(o, card, &dev_info, false, &impl->defs);
|
||||
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_DEVICE_API)) != NULL) {
|
||||
if (!pw_manager_object_is_virtual(o)) {
|
||||
if (is_sink)
|
||||
flags |= SINK_HARDWARE;
|
||||
else if (is_source)
|
||||
|
@ -574,7 +574,6 @@ static void manager_added(void *d, struct pw_manager_object *o)
|
|||
{
|
||||
struct service *s;
|
||||
struct pw_node_info *info;
|
||||
const char *str;
|
||||
|
||||
if (!pw_manager_object_is_sink(o) && !pw_manager_object_is_source(o))
|
||||
return;
|
||||
|
@ -583,8 +582,7 @@ static void manager_added(void *d, struct pw_manager_object *o)
|
|||
if (info == NULL || info->props == NULL)
|
||||
return;
|
||||
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_NODE_NETWORK)) != NULL &&
|
||||
spa_atob(str))
|
||||
if (pw_manager_object_is_network(o))
|
||||
return;
|
||||
|
||||
s = create_service(d, o);
|
||||
|
|
|
@ -3715,9 +3715,9 @@ static int fill_sink_info(struct client *client, struct message *m,
|
|||
}
|
||||
|
||||
flags = SINK_LATENCY | SINK_DYNAMIC_LATENCY | SINK_DECIBEL_VOLUME;
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_DEVICE_API)) != NULL)
|
||||
if (!pw_manager_object_is_virtual(o))
|
||||
flags |= SINK_HARDWARE;
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_NODE_NETWORK)) != NULL)
|
||||
if (pw_manager_object_is_network(o))
|
||||
flags |= SINK_NETWORK;
|
||||
if (SPA_FLAG_IS_SET(dev_info.volume_info.flags, VOLUME_HW_VOLUME))
|
||||
flags |= SINK_HW_VOLUME_CTRL;
|
||||
|
@ -3927,9 +3927,9 @@ static int fill_source_info(struct client *client, struct message *m,
|
|||
}
|
||||
|
||||
flags = SOURCE_LATENCY | SOURCE_DYNAMIC_LATENCY | SOURCE_DECIBEL_VOLUME;
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_DEVICE_API)) != NULL)
|
||||
if (!pw_manager_object_is_virtual(o))
|
||||
flags |= SOURCE_HARDWARE;
|
||||
if ((str = spa_dict_lookup(info->props, PW_KEY_NODE_NETWORK)) != NULL)
|
||||
if (pw_manager_object_is_network(o))
|
||||
flags |= SOURCE_NETWORK;
|
||||
if (SPA_FLAG_IS_SET(dev_info.volume_info.flags, VOLUME_HW_VOLUME))
|
||||
flags |= SOURCE_HW_VOLUME_CTRL;
|
||||
|
|
Loading…
Reference in a new issue