mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
metadata: Added context monitor for removed globals
impl-metadata would not monitor for globals being removed. This would cause stale metadata to remain in the store, causing future objects on the same ids to have invalid data.
This commit is contained in:
parent
b2c3ee5d8d
commit
72b41e5067
3 changed files with 21 additions and 1 deletions
|
|
@ -210,6 +210,8 @@ static const struct pw_global_events global_events = {
|
|||
static void context_global_removed(void *data, struct pw_global *global)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
pw_log_trace("Clearing properties for global %u in %u",
|
||||
pw_global_get_id(global), pw_global_get_id(impl->global));
|
||||
pw_metadata_set_property(impl->metadata,
|
||||
pw_global_get_id(global), NULL, NULL, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -353,6 +353,7 @@ void pw_impl_metadata_destroy(struct pw_impl_metadata *metadata)
|
|||
spa_hook_remove(&metadata->global_listener);
|
||||
pw_global_destroy(metadata->global);
|
||||
}
|
||||
spa_hook_remove(&metadata->context_listener);
|
||||
|
||||
pw_impl_metadata_emit_free(metadata);
|
||||
pw_log_debug("%p: free", metadata);
|
||||
|
|
@ -464,7 +465,7 @@ global_bind(void *object, struct pw_impl_client *client, uint32_t permissions,
|
|||
data->impl = this;
|
||||
data->resource = resource;
|
||||
|
||||
pw_log_debug("%p: bound to %d", this, resource->id);
|
||||
pw_log_debug("%p: %u bound to %d", this, id, resource->id);
|
||||
pw_global_add_resource(global, resource);
|
||||
|
||||
/* listen for when the resource goes away */
|
||||
|
|
@ -489,6 +490,20 @@ error_resource:
|
|||
return -errno;
|
||||
}
|
||||
|
||||
static void context_global_removed(void *data, struct pw_global *global)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
uint32_t id = pw_global_get_id(global);
|
||||
pw_log_trace("Clearing properties for global %u in %u",
|
||||
id, pw_global_get_id(impl->this.global));
|
||||
impl_set_property(&impl->def, id, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static const struct pw_context_events context_events = {
|
||||
PW_VERSION_CONTEXT_EVENTS,
|
||||
.global_removed = context_global_removed,
|
||||
};
|
||||
|
||||
static void global_destroy(void *data)
|
||||
{
|
||||
struct pw_impl_metadata *metadata = data;
|
||||
|
|
@ -536,6 +551,8 @@ int pw_impl_metadata_register(struct pw_impl_metadata *metadata,
|
|||
|
||||
pw_global_update_keys(metadata->global, &metadata->properties->dict, keys);
|
||||
|
||||
pw_context_add_listener(context, &metadata->context_listener, &context_events,
|
||||
SPA_CONTAINER_OF(metadata, struct impl, this));
|
||||
pw_global_add_listener(metadata->global, &metadata->global_listener, &global_events, metadata);
|
||||
pw_global_register(metadata->global);
|
||||
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ struct pw_impl_metadata {
|
|||
struct spa_list link; /**< link in context metadata_list */
|
||||
struct pw_global *global; /**< global for this metadata */
|
||||
struct spa_hook global_listener;
|
||||
struct spa_hook context_listener;
|
||||
|
||||
struct pw_properties *properties; /**< properties of the metadata */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue