mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
metadata: remove metadata when the global is removed
So that we can ensure the metadata only contains valid subject ids.
This commit is contained in:
parent
07d43a001b
commit
22bb2666c4
1 changed files with 20 additions and 1 deletions
|
|
@ -31,6 +31,8 @@
|
||||||
#define NAME "metadata"
|
#define NAME "metadata"
|
||||||
|
|
||||||
struct impl {
|
struct impl {
|
||||||
|
struct spa_hook context_listener;
|
||||||
|
|
||||||
struct pw_global *global;
|
struct pw_global *global;
|
||||||
struct spa_hook global_listener;
|
struct spa_hook global_listener;
|
||||||
|
|
||||||
|
|
@ -222,9 +224,23 @@ static const struct pw_global_events global_events = {
|
||||||
.destroy = global_destroy,
|
.destroy = global_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void context_global_removed(void *data, struct pw_global *global)
|
||||||
|
{
|
||||||
|
struct impl *impl = data;
|
||||||
|
pw_metadata_set_property(impl->metadata,
|
||||||
|
pw_global_get_id(global), NULL, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct pw_context_events context_events = {
|
||||||
|
PW_VERSION_CONTEXT_EVENTS,
|
||||||
|
.global_removed = context_global_removed,
|
||||||
|
};
|
||||||
|
|
||||||
static void global_resource_destroy(void *data)
|
static void global_resource_destroy(void *data)
|
||||||
{
|
{
|
||||||
struct impl *impl = data;
|
struct impl *impl = data;
|
||||||
|
spa_hook_remove(&impl->context_listener);
|
||||||
spa_hook_remove(&impl->resource_listener);
|
spa_hook_remove(&impl->resource_listener);
|
||||||
impl->resource = NULL;
|
impl->resource = NULL;
|
||||||
impl->metadata = NULL;
|
impl->metadata = NULL;
|
||||||
|
|
@ -272,6 +288,9 @@ pw_metadata_new(struct pw_context *context, struct pw_resource *resource,
|
||||||
impl->resource = resource;
|
impl->resource = resource;
|
||||||
impl->metadata = (struct pw_metadata*)resource;
|
impl->metadata = (struct pw_metadata*)resource;
|
||||||
|
|
||||||
|
pw_context_add_listener(context, &impl->context_listener,
|
||||||
|
&context_events, impl);
|
||||||
|
|
||||||
pw_global_add_listener(impl->global,
|
pw_global_add_listener(impl->global,
|
||||||
&impl->global_listener,
|
&impl->global_listener,
|
||||||
&global_events, impl);
|
&global_events, impl);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue