pulse-server: add property to make virtual nodes

Make a property to mark virtual nodes and use it to hide the client
id from the sink-input/source-output info in pulse-server.
This commit is contained in:
Wim Taymans 2021-04-20 21:05:59 +02:00
parent 0e91233569
commit 7031471807
4 changed files with 17 additions and 2 deletions

View file

@ -856,6 +856,16 @@ bool pw_manager_object_is_monitor(struct pw_manager_object *o)
(strcmp(str, "Audio/Sink") == 0);
}
bool pw_manager_object_is_virtual(struct pw_manager_object *o)
{
const char *str;
struct pw_node_info *info;
return strcmp(o->type, PW_TYPE_INTERFACE_Node) == 0 &&
(info = o->info) != NULL && info->props != NULL &&
(str = spa_dict_lookup(info->props, PW_KEY_NODE_VIRTUAL)) != 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);

View file

@ -117,6 +117,7 @@ bool pw_manager_object_is_card(struct pw_manager_object *o);
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_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);

View file

@ -4166,7 +4166,8 @@ static int fill_sink_input_info(struct client *client, struct message *m,
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
module_id = (uint32_t)atoi(str);
if ((str = spa_dict_lookup(info->props, PW_KEY_CLIENT_ID)) != NULL)
if (!pw_manager_object_is_virtual(o) &&
(str = spa_dict_lookup(info->props, PW_KEY_CLIENT_ID)) != NULL)
client_id = (uint32_t)atoi(str);
collect_device_info(o, NULL, &dev_info);
@ -4236,7 +4237,8 @@ static int fill_source_output_info(struct client *client, struct message *m,
if ((str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID)) != NULL)
module_id = (uint32_t)atoi(str);
if ((str = spa_dict_lookup(info->props, PW_KEY_CLIENT_ID)) != NULL)
if (!pw_manager_object_is_virtual(o) &&
(str = spa_dict_lookup(info->props, PW_KEY_CLIENT_ID)) != NULL)
client_id = (uint32_t)atoi(str);
collect_device_info(o, NULL, &dev_info);

View file

@ -152,6 +152,8 @@ extern "C" {
#define PW_KEY_NODE_DRIVER "node.driver" /**< node can drive the graph */
#define PW_KEY_NODE_STREAM "node.stream" /**< node is a stream, the server side should
* add a converter */
#define PW_KEY_NODE_VIRTUAL "node.virtual" /**< the node is some sort of virtual
* object */
/** Port keys */
#define PW_KEY_PORT_ID "port.id" /**< port id */
#define PW_KEY_PORT_NAME "port.name" /**< port name */