mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	media-session: improve cleanup in some modules
This commit is contained in:
		
							parent
							
								
									451fee2208
								
							
						
					
					
						commit
						f9a5053c73
					
				
					 3 changed files with 32 additions and 30 deletions
				
			
		| 
						 | 
					@ -183,17 +183,6 @@ static const struct pw_metadata_events metadata_events = {
 | 
				
			||||||
	.property = metadata_property,
 | 
						.property = metadata_property,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void session_destroy(void *data)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct impl *impl = data;
 | 
					 | 
				
			||||||
	remove_idle_timeout(impl);
 | 
					 | 
				
			||||||
	spa_hook_remove(&impl->listener);
 | 
					 | 
				
			||||||
	if (impl->session->metadata)
 | 
					 | 
				
			||||||
		spa_hook_remove(&impl->meta_listener);
 | 
					 | 
				
			||||||
	pw_properties_free(impl->properties);
 | 
					 | 
				
			||||||
	free(impl);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void session_create(void *data, struct sm_object *object)
 | 
					static void session_create(void *data, struct sm_object *object)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct impl *impl = data;
 | 
						struct impl *impl = data;
 | 
				
			||||||
| 
						 | 
					@ -230,6 +219,17 @@ static void session_remove(void *data, struct sm_object *object)
 | 
				
			||||||
		impl->default_video_source = SPA_ID_INVALID;
 | 
							impl->default_video_source = SPA_ID_INVALID;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void session_destroy(void *data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct impl *impl = data;
 | 
				
			||||||
 | 
						remove_idle_timeout(impl);
 | 
				
			||||||
 | 
						spa_hook_remove(&impl->listener);
 | 
				
			||||||
 | 
						if (impl->session->metadata)
 | 
				
			||||||
 | 
							spa_hook_remove(&impl->meta_listener);
 | 
				
			||||||
 | 
						pw_properties_free(impl->properties);
 | 
				
			||||||
 | 
						free(impl);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const struct sm_media_session_events session_events = {
 | 
					static const struct sm_media_session_events session_events = {
 | 
				
			||||||
	SM_VERSION_MEDIA_SESSION_EVENTS,
 | 
						SM_VERSION_MEDIA_SESSION_EVENTS,
 | 
				
			||||||
	.create = session_create,
 | 
						.create = session_create,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -115,15 +115,6 @@ static void add_idle_timeout(struct impl *impl)
 | 
				
			||||||
	pw_loop_update_timer(main_loop, impl->idle_timeout, &value, NULL, false);
 | 
						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)
 | 
					static uint32_t find_profile_id(struct device *dev, const char *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct sm_param *p;
 | 
						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)
 | 
					static void destroy_device(struct impl *impl, struct device *dev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						spa_hook_remove(&dev->listener);
 | 
				
			||||||
	free(dev->name);
 | 
						free(dev->name);
 | 
				
			||||||
	sm_object_remove_data((struct sm_object*)dev->obj, SESSION_KEY);
 | 
						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);
 | 
							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 = {
 | 
					static const struct sm_media_session_events session_events = {
 | 
				
			||||||
	SM_VERSION_MEDIA_SESSION_EVENTS,
 | 
						SM_VERSION_MEDIA_SESSION_EVENTS,
 | 
				
			||||||
	.create = session_create,
 | 
						.create = session_create,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -112,16 +112,6 @@ static void add_idle_timeout(struct impl *impl)
 | 
				
			||||||
	pw_loop_update_timer(main_loop, impl->idle_timeout, &value, NULL, false);
 | 
						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)
 | 
					static char *serialize_props(struct device *dev, const struct spa_pod *param)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct spa_pod_prop *prop;
 | 
						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)
 | 
					static void destroy_device(struct impl *impl, struct device *dev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						spa_hook_remove(&dev->listener);
 | 
				
			||||||
	free(dev->name);
 | 
						free(dev->name);
 | 
				
			||||||
	sm_object_remove_data((struct sm_object*)dev->obj, SESSION_KEY);
 | 
						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);
 | 
							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 = {
 | 
					static const struct sm_media_session_events session_events = {
 | 
				
			||||||
	SM_VERSION_MEDIA_SESSION_EVENTS,
 | 
						SM_VERSION_MEDIA_SESSION_EVENTS,
 | 
				
			||||||
	.create = session_create,
 | 
						.create = session_create,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue