mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pulse-server: clean up when the context is destroyed
This commit is contained in:
		
							parent
							
								
									0d9ae9d226
								
							
						
					
					
						commit
						389a0eee48
					
				
					 1 changed files with 21 additions and 0 deletions
				
			
		| 
						 | 
					@ -163,6 +163,7 @@ struct server {
 | 
				
			||||||
struct impl {
 | 
					struct impl {
 | 
				
			||||||
	struct pw_loop *loop;
 | 
						struct pw_loop *loop;
 | 
				
			||||||
	struct pw_context *context;
 | 
						struct pw_context *context;
 | 
				
			||||||
 | 
						struct spa_hook context_listener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct pw_properties *props;
 | 
						struct pw_properties *props;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2963,6 +2964,8 @@ error:
 | 
				
			||||||
static void impl_free(struct impl *impl)
 | 
					static void impl_free(struct impl *impl)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct server *s;
 | 
						struct server *s;
 | 
				
			||||||
 | 
						if (impl->context)
 | 
				
			||||||
 | 
							spa_hook_remove(&impl->context_listener);
 | 
				
			||||||
	spa_list_consume(s, &impl->servers, link)
 | 
						spa_list_consume(s, &impl->servers, link)
 | 
				
			||||||
		server_free(s);
 | 
							server_free(s);
 | 
				
			||||||
	if (impl->props)
 | 
						if (impl->props)
 | 
				
			||||||
| 
						 | 
					@ -2970,6 +2973,21 @@ static void impl_free(struct impl *impl)
 | 
				
			||||||
	free(impl);
 | 
						free(impl);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void context_destroy(void *data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct impl *impl = data;
 | 
				
			||||||
 | 
						struct server *s;
 | 
				
			||||||
 | 
						spa_list_consume(s, &impl->servers, link)
 | 
				
			||||||
 | 
							server_free(s);
 | 
				
			||||||
 | 
						spa_hook_remove(&impl->context_listener);
 | 
				
			||||||
 | 
						impl->context = NULL;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const struct pw_context_events context_events = {
 | 
				
			||||||
 | 
						PW_VERSION_CONTEXT_EVENTS,
 | 
				
			||||||
 | 
						.destroy = context_destroy,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context,
 | 
					struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context,
 | 
				
			||||||
		struct pw_properties *props, size_t user_data_size)
 | 
							struct pw_properties *props, size_t user_data_size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -2987,6 +3005,9 @@ struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context,
 | 
				
			||||||
	impl->props = props;
 | 
						impl->props = props;
 | 
				
			||||||
	spa_list_init(&impl->servers);
 | 
						spa_list_init(&impl->servers);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pw_context_add_listener(context, &impl->context_listener,
 | 
				
			||||||
 | 
								&context_events, impl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	impl->default_sink = (struct device) {
 | 
						impl->default_sink = (struct device) {
 | 
				
			||||||
		.index = 1,
 | 
							.index = 1,
 | 
				
			||||||
		.name = "input.pipewire",
 | 
							.name = "input.pipewire",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue