pulse-server: actually handle clearing of metadata

Make sure we also set the metadata back to NULL when the object is
removed.
This commit is contained in:
Wim Taymans 2021-03-26 16:26:29 +01:00
parent 98585e092c
commit e3323f7bca

View file

@ -885,17 +885,16 @@ static void send_default_change_subscribe_event(struct client *client, bool sink
-1); -1);
} }
static void handle_metadata(struct client *client, struct pw_manager_object *o, static void handle_metadata(struct client *client, struct pw_manager_object *old,
const char *name) struct pw_manager_object *new, const char *name)
{ {
if (strcmp(name, "default") == 0) { if (strcmp(name, "default") == 0) {
if (client->metadata_default == NULL) if (client->metadata_default == old)
client->metadata_default = o; client->metadata_default = new;
} }
else if (strcmp(name, "route-settings") == 0) { else if (strcmp(name, "route-settings") == 0) {
if (client->metadata_routes == NULL) { if (client->metadata_routes == old)
client->metadata_routes = o; client->metadata_routes = new;
}
} }
} }
@ -910,7 +909,7 @@ static void manager_added(void *data, struct pw_manager_object *o)
if (strcmp(o->type, PW_TYPE_INTERFACE_Metadata) == 0) { if (strcmp(o->type, PW_TYPE_INTERFACE_Metadata) == 0) {
if (o->props != NULL && if (o->props != NULL &&
(str = pw_properties_get(o->props, PW_KEY_METADATA_NAME)) != NULL) (str = pw_properties_get(o->props, PW_KEY_METADATA_NAME)) != NULL)
handle_metadata(client, o, str); handle_metadata(client, NULL, o, str);
} }
if ((event = get_event_and_id(client, o, &id)) != SPA_ID_INVALID) if ((event = get_event_and_id(client, o, &id)) != SPA_ID_INVALID)
send_subscribe_event(client, send_subscribe_event(client,
@ -951,7 +950,7 @@ static void manager_removed(void *data, struct pw_manager_object *o)
if (strcmp(o->type, PW_TYPE_INTERFACE_Metadata) == 0) { if (strcmp(o->type, PW_TYPE_INTERFACE_Metadata) == 0) {
if (o->props != NULL && if (o->props != NULL &&
(str = pw_properties_get(o->props, PW_KEY_METADATA_NAME)) != NULL) (str = pw_properties_get(o->props, PW_KEY_METADATA_NAME)) != NULL)
handle_metadata(client, NULL, str); handle_metadata(client, o, NULL, str);
} }
} }