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

@ -115,15 +115,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->properties);
free(impl);
}
static uint32_t find_profile_id(struct device *dev, const char *name)
{
struct sm_param *p;
@ -258,6 +249,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);
}
@ -276,6 +268,15 @@ 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->properties);
free(impl);
}
static const struct sm_media_session_events session_events = {
SM_VERSION_MEDIA_SESSION_EVENTS,
.create = session_create,