mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	Add example to play sine wave
Various build fixes and cleanups Move port_add to private and make node ports based on implementation. Improve pull based scheduling on remote nodes
This commit is contained in:
		
							parent
							
								
									36ac8a6545
								
							
						
					
					
						commit
						21cd5a2918
					
				
					 26 changed files with 640 additions and 185 deletions
				
			
		| 
						 | 
				
			
			@ -783,8 +783,6 @@ static int spa_proxy_node_process_output(struct spa_node *node)
 | 
			
		|||
	this = SPA_CONTAINER_OF(node, struct proxy, node);
 | 
			
		||||
	impl = this->impl;
 | 
			
		||||
 | 
			
		||||
	pw_log_trace("process output");
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < MAX_OUTPUTS; i++) {
 | 
			
		||||
		struct spa_port_io *io = this->out_ports[i].io, tmp;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -792,11 +790,14 @@ static int spa_proxy_node_process_output(struct spa_node *node)
 | 
			
		|||
			continue;
 | 
			
		||||
 | 
			
		||||
		tmp = impl->transport->outputs[i];
 | 
			
		||||
		io->status = SPA_RESULT_NEED_BUFFER;
 | 
			
		||||
		impl->transport->outputs[i] = *io;
 | 
			
		||||
		if (tmp.status == SPA_RESULT_HAVE_BUFFER)
 | 
			
		||||
			res = SPA_RESULT_HAVE_BUFFER;
 | 
			
		||||
		*io = tmp;
 | 
			
		||||
		pw_log_trace("%d %d  %d", io->status, io->buffer_id, io->status);
 | 
			
		||||
		pw_log_trace("%d %d -> %d %d", io->status, io->buffer_id,
 | 
			
		||||
				impl->transport->outputs[i].status,
 | 
			
		||||
				impl->transport->outputs[i].buffer_id);
 | 
			
		||||
	}
 | 
			
		||||
	pw_client_node_transport_add_message(impl->transport,
 | 
			
		||||
			       &PW_CLIENT_NODE_MESSAGE_INIT(PW_CLIENT_NODE_MESSAGE_PROCESS_OUTPUT));
 | 
			
		||||
| 
						 | 
				
			
			@ -929,7 +930,7 @@ static void proxy_on_data_fd_events(struct spa_source *source)
 | 
			
		|||
		struct pw_client_node_message message;
 | 
			
		||||
		uint64_t cmd;
 | 
			
		||||
 | 
			
		||||
		if (read(this->data_source.fd, &cmd, 8) != 8)
 | 
			
		||||
		if (read(this->data_source.fd, &cmd, sizeof(uint64_t)) != sizeof(uint64_t))
 | 
			
		||||
			spa_log_warn(this->log, "proxy %p: error reading message: %s",
 | 
			
		||||
					this, strerror(errno));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -693,6 +693,8 @@ impl_add_server(struct pw_protocol *protocol,
 | 
			
		|||
	spa_list_init(&this->client_list);
 | 
			
		||||
	this->destroy = destroy_server;
 | 
			
		||||
 | 
			
		||||
	spa_list_append(&protocol->server_list, &this->link);
 | 
			
		||||
 | 
			
		||||
	name = get_name(pw_core_get_properties(core));
 | 
			
		||||
 | 
			
		||||
	if (!init_socket_name(s, name))
 | 
			
		||||
| 
						 | 
				
			
			@ -704,8 +706,6 @@ impl_add_server(struct pw_protocol *protocol,
 | 
			
		|||
	if (!add_socket(protocol, s))
 | 
			
		||||
		goto error;
 | 
			
		||||
 | 
			
		||||
	spa_list_append(&protocol->server_list, &this->link);
 | 
			
		||||
 | 
			
		||||
	pw_loop_add_hook(pw_core_get_main_loop(core), &s->hook, &impl_hooks, s);
 | 
			
		||||
 | 
			
		||||
	pw_log_info("protocol-native %p: Added server %p", protocol, this);
 | 
			
		||||
| 
						 | 
				
			
			@ -831,7 +831,8 @@ static bool module_init(struct pw_module *module, struct pw_properties *properti
 | 
			
		|||
 | 
			
		||||
	if ((val = pw_properties_get(pw_core_get_properties(core), "pipewire.daemon"))) {
 | 
			
		||||
		if (atoi(val) == 1)
 | 
			
		||||
			impl_add_server(this, core, properties);
 | 
			
		||||
			if (impl_add_server(this, core, properties) == NULL)
 | 
			
		||||
				return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	pw_module_add_listener(module, &d->module_listener, &module_events, d);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,53 +48,6 @@ struct impl {
 | 
			
		|||
	struct spa_hook node_listener;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static struct pw_port *
 | 
			
		||||
make_port(struct impl *impl, enum pw_direction direction, uint32_t port_id)
 | 
			
		||||
{
 | 
			
		||||
	struct pw_node *node = impl->this;
 | 
			
		||||
	struct pw_port *port;
 | 
			
		||||
 | 
			
		||||
	port = pw_port_new(direction, port_id, NULL, 0);
 | 
			
		||||
	if (port == NULL)
 | 
			
		||||
		return NULL;
 | 
			
		||||
 | 
			
		||||
	pw_port_add(port, node);
 | 
			
		||||
 | 
			
		||||
	return port;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void update_port_ids(struct impl *impl)
 | 
			
		||||
{
 | 
			
		||||
	struct pw_node *this = impl->this;
 | 
			
		||||
        uint32_t *input_port_ids, *output_port_ids;
 | 
			
		||||
        uint32_t n_input_ports, n_output_ports, max_input_ports, max_output_ports;
 | 
			
		||||
        uint32_t i;
 | 
			
		||||
 | 
			
		||||
        spa_node_get_n_ports(impl->node,
 | 
			
		||||
                             &n_input_ports, &max_input_ports, &n_output_ports, &max_output_ports);
 | 
			
		||||
 | 
			
		||||
	pw_node_set_max_ports(this, max_input_ports, max_output_ports);
 | 
			
		||||
 | 
			
		||||
        input_port_ids = alloca(sizeof(uint32_t) * n_input_ports);
 | 
			
		||||
        output_port_ids = alloca(sizeof(uint32_t) * n_output_ports);
 | 
			
		||||
 | 
			
		||||
        spa_node_get_port_ids(impl->node,
 | 
			
		||||
                              max_input_ports, input_port_ids, max_output_ports, output_port_ids);
 | 
			
		||||
 | 
			
		||||
        pw_log_debug("node %p: update_port ids %u/%u, %u/%u", this,
 | 
			
		||||
                     n_input_ports, max_input_ports, n_output_ports, max_output_ports);
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < n_input_ports; i++) {
 | 
			
		||||
		pw_log_debug("node %p: input port added %d", this, input_port_ids[i]);
 | 
			
		||||
		make_port(impl, PW_DIRECTION_INPUT, input_port_ids[i]);
 | 
			
		||||
	}
 | 
			
		||||
	for (i = 0; i < n_output_ports; i++) {
 | 
			
		||||
		pw_log_debug("node %p: output port added %d", this, output_port_ids[i]);
 | 
			
		||||
		make_port(impl, PW_DIRECTION_OUTPUT, output_port_ids[i]);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void pw_spa_node_destroy(void *data)
 | 
			
		||||
{
 | 
			
		||||
	struct impl *impl = data;
 | 
			
		||||
| 
						 | 
				
			
			@ -115,7 +68,6 @@ static void pw_spa_node_destroy(void *data)
 | 
			
		|||
static void complete_init(struct impl *impl)
 | 
			
		||||
{
 | 
			
		||||
        struct pw_node *this = impl->this;
 | 
			
		||||
	update_port_ids(impl);
 | 
			
		||||
	pw_node_register(this);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -177,7 +129,7 @@ pw_spa_node_new(struct pw_core *core,
 | 
			
		|||
	impl->async_init = async;
 | 
			
		||||
 | 
			
		||||
	pw_node_add_listener(this, &impl->node_listener, &node_events, impl);
 | 
			
		||||
	pw_node_set_implementation(this, node);
 | 
			
		||||
	pw_node_set_implementation(this, impl->node);
 | 
			
		||||
 | 
			
		||||
	if (!async)
 | 
			
		||||
		complete_init(impl);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue