media-session: improve cleanup in some modules

This commit is contained in:
Wim Taymans 2020-08-17 17:50:15 +02:00
parent 451fee2208
commit f9a5053c73
3 changed files with 32 additions and 30 deletions

View file

@ -112,16 +112,6 @@ static void add_idle_timeout(struct impl *impl)
pw_loop_update_timer(main_loop, impl->idle_timeout, &value, NULL, false);
}
static void session_destroy(void *data)
{
struct impl *impl = data;
remove_idle_timeout(impl);
spa_hook_remove(&impl->listener);
pw_properties_free(impl->to_restore);
pw_properties_free(impl->to_save);
free(impl);
}
static char *serialize_props(struct device *dev, const struct spa_pod *param)
{
struct spa_pod_prop *prop;
@ -319,6 +309,7 @@ static void session_create(void *data, struct sm_object *object)
static void destroy_device(struct impl *impl, struct device *dev)
{
spa_hook_remove(&dev->listener);
free(dev->name);
sm_object_remove_data((struct sm_object*)dev->obj, SESSION_KEY);
}
@ -337,6 +328,16 @@ static void session_remove(void *data, struct sm_object *object)
destroy_device(impl, dev);
}
static void session_destroy(void *data)
{
struct impl *impl = data;
remove_idle_timeout(impl);
spa_hook_remove(&impl->listener);
pw_properties_free(impl->to_restore);
pw_properties_free(impl->to_save);
free(impl);
}
static const struct sm_media_session_events session_events = {
SM_VERSION_MEDIA_SESSION_EVENTS,
.create = session_create,