pulse-server: handle metadata remove

Also handle the case where metadata is removed. Set the pointer to
the object to NULL. This can happen when the session manager restarts.
This commit is contained in:
Wim Taymans 2021-03-26 16:04:45 +01:00
parent 9690820e63
commit 98585e092c

View file

@ -885,7 +885,7 @@ static void send_default_change_subscribe_event(struct client *client, bool sink
-1); -1);
} }
static void handle_metadata_added(struct client *client, struct pw_manager_object *o, static void handle_metadata(struct client *client, struct pw_manager_object *o,
const char *name) const char *name)
{ {
if (strcmp(name, "default") == 0) { if (strcmp(name, "default") == 0) {
@ -910,7 +910,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_added(client, o, str); handle_metadata(client, 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,
@ -939,6 +939,7 @@ static void manager_removed(void *data, struct pw_manager_object *o)
{ {
struct client *client = data; struct client *client = data;
uint32_t event, id; uint32_t event, id;
const char *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,
@ -946,6 +947,12 @@ static void manager_removed(void *data, struct pw_manager_object *o)
id); id);
send_default_change_subscribe_event(client, object_is_sink(o), object_is_source_or_monitor(o)); send_default_change_subscribe_event(client, object_is_sink(o), object_is_source_or_monitor(o));
if (strcmp(o->type, PW_TYPE_INTERFACE_Metadata) == 0) {
if (o->props != NULL &&
(str = pw_properties_get(o->props, PW_KEY_METADATA_NAME)) != NULL)
handle_metadata(client, NULL, str);
}
} }
static int json_object_find(const char *obj, const char *key, char *value, size_t len) static int json_object_find(const char *obj, const char *key, char *value, size_t len)