mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	impl-port: make the rt.mix_list private
The rt.mix_lst is really something internal to the tee and fallback mixer in the ports so make it private. Use the port_set_io call to add the Buffer io area to the mix_list tee and fallback mixer on the port, like we do for remote-node. We can then remove the custom code to do this in remote-node and impl-link. Remove an unused field (clock) in the port struct. Remove the unused io_set field in impl-link, it is always in sync with the activated field.
This commit is contained in:
		
							parent
							
								
									9ba3792038
								
							
						
					
					
						commit
						b080b31848
					
				
					 4 changed files with 77 additions and 90 deletions
				
			
		| 
						 | 
				
			
			@ -42,7 +42,6 @@ struct mix {
 | 
			
		|||
	uint32_t mix_id;
 | 
			
		||||
	struct pw_impl_port_mix mix;
 | 
			
		||||
	struct pw_array buffers;
 | 
			
		||||
	bool active;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct node_data {
 | 
			
		||||
| 
						 | 
				
			
			@ -152,54 +151,10 @@ static void mix_init(struct mix *mix, struct pw_impl_port *port, uint32_t mix_id
 | 
			
		|||
	mix->port = port;
 | 
			
		||||
	mix->mix_id = mix_id;
 | 
			
		||||
	pw_impl_port_init_mix(port, &mix->mix);
 | 
			
		||||
	mix->active = false;
 | 
			
		||||
	pw_array_init(&mix->buffers, 32);
 | 
			
		||||
	pw_array_ensure_size(&mix->buffers, sizeof(struct buffer) * 64);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
do_deactivate_mix(struct spa_loop *loop,
 | 
			
		||||
                bool async, uint32_t seq, const void *data, size_t size, void *user_data)
 | 
			
		||||
{
 | 
			
		||||
	struct mix *mix = user_data;
 | 
			
		||||
	spa_list_remove(&mix->mix.rt_link);
 | 
			
		||||
        return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
deactivate_mix(struct node_data *data, struct mix *mix)
 | 
			
		||||
{
 | 
			
		||||
	if (mix->active) {
 | 
			
		||||
		pw_log_debug("node %p: mix %p deactivate", data, mix);
 | 
			
		||||
		pw_loop_invoke(data->data_loop,
 | 
			
		||||
                       do_deactivate_mix, SPA_ID_INVALID, NULL, 0, true, mix);
 | 
			
		||||
		mix->active = false;
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
do_activate_mix(struct spa_loop *loop,
 | 
			
		||||
                bool async, uint32_t seq, const void *data, size_t size, void *user_data)
 | 
			
		||||
{
 | 
			
		||||
	struct mix *mix = user_data;
 | 
			
		||||
 | 
			
		||||
	spa_list_append(&mix->port->rt.mix_list, &mix->mix.rt_link);
 | 
			
		||||
        return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
activate_mix(struct node_data *data, struct mix *mix)
 | 
			
		||||
{
 | 
			
		||||
	if (!mix->active) {
 | 
			
		||||
		pw_log_debug("node %p: mix %p activate", data, mix);
 | 
			
		||||
		pw_loop_invoke(data->data_loop,
 | 
			
		||||
                       do_activate_mix, SPA_ID_INVALID, NULL, 0, false, mix);
 | 
			
		||||
		mix->active = true;
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct mix *find_mix(struct node_data *data,
 | 
			
		||||
		enum spa_direction direction, uint32_t port_id, uint32_t mix_id)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -829,11 +784,6 @@ client_node_port_set_io(void *_data,
 | 
			
		|||
	pw_log_debug("port %p: set io:%s new:%p old:%p", mix->port,
 | 
			
		||||
			spa_debug_type_find_name(spa_type_io, id), ptr, mix->mix.io);
 | 
			
		||||
 | 
			
		||||
	if (id == SPA_IO_Buffers) {
 | 
			
		||||
		if (ptr == NULL && mix->mix.io)
 | 
			
		||||
			deactivate_mix(data, mix);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ((res = spa_node_port_set_io(mix->port->mix,
 | 
			
		||||
			     direction, mix->mix.port.port_id, id, ptr, size)) < 0) {
 | 
			
		||||
		if (res == -ENOTSUP)
 | 
			
		||||
| 
						 | 
				
			
			@ -841,11 +791,6 @@ client_node_port_set_io(void *_data,
 | 
			
		|||
		else
 | 
			
		||||
			goto exit_free;
 | 
			
		||||
	}
 | 
			
		||||
	if (id == SPA_IO_Buffers) {
 | 
			
		||||
		mix->mix.io = ptr;
 | 
			
		||||
		if (ptr)
 | 
			
		||||
			activate_mix(data, mix);
 | 
			
		||||
	}
 | 
			
		||||
exit_free:
 | 
			
		||||
	pw_memmap_free(old);
 | 
			
		||||
exit:
 | 
			
		||||
| 
						 | 
				
			
			@ -984,8 +929,6 @@ static void clear_mix(struct node_data *data, struct mix *mix)
 | 
			
		|||
{
 | 
			
		||||
	pw_log_debug("port %p: mix clear %d.%d", mix->port, mix->port->port_id, mix->mix_id);
 | 
			
		||||
 | 
			
		||||
	deactivate_mix(data, mix);
 | 
			
		||||
 | 
			
		||||
	spa_list_remove(&mix->link);
 | 
			
		||||
 | 
			
		||||
	clear_buffers(data, mix);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue