mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	jack: improve properties
This commit is contained in:
		
							parent
							
								
									b284988755
								
							
						
					
					
						commit
						b3d72fb82d
					
				
					 2 changed files with 80 additions and 16 deletions
				
			
		| 
						 | 
					@ -64,7 +64,7 @@ struct port {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint64_t info_all;
 | 
						uint64_t info_all;
 | 
				
			||||||
	struct spa_port_info info;
 | 
						struct spa_port_info info;
 | 
				
			||||||
	struct spa_dict_item items[2];
 | 
						struct spa_dict_item items[4];
 | 
				
			||||||
	struct spa_dict props;
 | 
						struct spa_dict props;
 | 
				
			||||||
	struct spa_param_info params[5];
 | 
						struct spa_param_info params[5];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -257,7 +257,7 @@ static void emit_node_info(struct impl *this, bool full)
 | 
				
			||||||
		snprintf(latency, sizeof(latency), "%d/%d",
 | 
							snprintf(latency, sizeof(latency), "%d/%d",
 | 
				
			||||||
				this->client->buffer_size, this->client->frame_rate);
 | 
									this->client->buffer_size, this->client->frame_rate);
 | 
				
			||||||
		items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_MEDIA_CLASS, "Audio/Sink");
 | 
							items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_MEDIA_CLASS, "Audio/Sink");
 | 
				
			||||||
		items[1] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_NAME, "jack_system");
 | 
							items[1] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_NAME, "JACK System");
 | 
				
			||||||
		items[2] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_DRIVER, "true");
 | 
							items[2] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_DRIVER, "true");
 | 
				
			||||||
		items[3] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_PAUSE_ON_IDLE, "false");
 | 
							items[3] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_PAUSE_ON_IDLE, "false");
 | 
				
			||||||
		items[4] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_LATENCY, latency);
 | 
							items[4] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_LATENCY, latency);
 | 
				
			||||||
| 
						 | 
					@ -272,8 +272,24 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
 | 
				
			||||||
	if (full)
 | 
						if (full)
 | 
				
			||||||
		port->info.change_mask = port->info_all;
 | 
							port->info.change_mask = port->info_all;
 | 
				
			||||||
	if (port->info.change_mask) {
 | 
						if (port->info.change_mask) {
 | 
				
			||||||
 | 
							char* aliases[2];
 | 
				
			||||||
 | 
							int n_aliases, n_items;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							aliases[0] = alloca(jack_port_name_size());
 | 
				
			||||||
 | 
							aliases[1] = alloca(jack_port_name_size());
 | 
				
			||||||
 | 
							n_aliases = jack_port_get_aliases(port->jack_port, aliases);
 | 
				
			||||||
 | 
							n_items = 1;
 | 
				
			||||||
 | 
							port->items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_PORT_NAME,
 | 
				
			||||||
 | 
									jack_port_short_name(port->jack_port));
 | 
				
			||||||
 | 
							if (n_aliases > 0)
 | 
				
			||||||
 | 
								port->items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_OBJECT_PATH, aliases[0]);
 | 
				
			||||||
 | 
							if (n_aliases > 1)
 | 
				
			||||||
 | 
								port->items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_PORT_ALIAS, aliases[1]);
 | 
				
			||||||
 | 
							port->props = SPA_DICT_INIT(port->items, n_items);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		spa_node_emit_port_info(&this->hooks,
 | 
							spa_node_emit_port_info(&this->hooks,
 | 
				
			||||||
				SPA_DIRECTION_INPUT, port->id, &port->info);
 | 
									SPA_DIRECTION_INPUT, port->id, &port->info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		port->info.change_mask = 0;
 | 
							port->info.change_mask = 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -368,9 +384,11 @@ static int init_port(struct impl *this, struct port *port)
 | 
				
			||||||
			SPA_PORT_CHANGE_MASK_PARAMS;
 | 
								SPA_PORT_CHANGE_MASK_PARAMS;
 | 
				
			||||||
	port->info = SPA_PORT_INFO_INIT();
 | 
						port->info = SPA_PORT_INFO_INIT();
 | 
				
			||||||
	port->info.flags = SPA_PORT_FLAG_NO_REF;
 | 
						port->info.flags = SPA_PORT_FLAG_NO_REF;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	port->items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_FORMAT_DSP, "32 bit float mono audio");
 | 
						port->items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_FORMAT_DSP, "32 bit float mono audio");
 | 
				
			||||||
	port->props = SPA_DICT_INIT(port->items, 1);
 | 
						port->props = SPA_DICT_INIT(port->items, 1);
 | 
				
			||||||
	port->info.props = &port->props;
 | 
						port->info.props = &port->props;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);
 | 
						port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);
 | 
				
			||||||
	port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
 | 
						port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
 | 
				
			||||||
	port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);
 | 
						port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);
 | 
				
			||||||
| 
						 | 
					@ -378,6 +396,7 @@ static int init_port(struct impl *this, struct port *port)
 | 
				
			||||||
	port->params[4] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
 | 
						port->params[4] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
 | 
				
			||||||
	port->info.params = port->params;
 | 
						port->info.params = port->params;
 | 
				
			||||||
	port->info.n_params = 5;
 | 
						port->info.n_params = 5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -399,18 +418,32 @@ static int init_ports(struct impl *this)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; ports[i]; i++) {
 | 
						for (i = 0; ports[i]; i++) {
 | 
				
			||||||
		struct port *port = GET_IN_PORT(this, i);
 | 
							struct port *port = GET_IN_PORT(this, i);
 | 
				
			||||||
 | 
							jack_port_t *p = jack_port_by_name(client, ports[i]);
 | 
				
			||||||
 | 
							char *aliases[2];
 | 
				
			||||||
 | 
							int n_aliases;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		port->id = i;
 | 
							port->id = i;
 | 
				
			||||||
		init_port(this, port);
 | 
							port->jack_port = jack_port_register(client,
 | 
				
			||||||
 | 
									jack_port_short_name(p),
 | 
				
			||||||
		port->jack_port = jack_port_register(client, ports[i],
 | 
									jack_port_type(p),
 | 
				
			||||||
				JACK_DEFAULT_AUDIO_TYPE,
 | 
									JackPortIsOutput, 0);
 | 
				
			||||||
				JackPortIsOutput|JackPortIsTerminal, 0);
 | 
					 | 
				
			||||||
		if (port->jack_port == NULL) {
 | 
							if (port->jack_port == NULL) {
 | 
				
			||||||
			spa_log_error(this->log, NAME" %p: jack_port_register() failed", this);
 | 
								spa_log_error(this->log, NAME" %p: jack_port_register() %d (%s) failed",
 | 
				
			||||||
 | 
										this, i, ports[i]);
 | 
				
			||||||
			res = -EFAULT;
 | 
								res = -EFAULT;
 | 
				
			||||||
			goto exit_free;
 | 
								goto exit_free;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							aliases[0] = alloca(jack_port_name_size());
 | 
				
			||||||
 | 
							aliases[1] = alloca(jack_port_name_size());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							n_aliases = jack_port_get_aliases(p, aliases);
 | 
				
			||||||
 | 
							if (n_aliases > 0)
 | 
				
			||||||
 | 
								jack_port_set_alias(port->jack_port, aliases[0]);
 | 
				
			||||||
 | 
							if (n_aliases > 1)
 | 
				
			||||||
 | 
								jack_port_set_alias(port->jack_port, aliases[1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							init_port(this, port);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	this->n_in_ports = i;
 | 
						this->n_in_ports = i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -64,7 +64,7 @@ struct port {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint64_t info_all;
 | 
						uint64_t info_all;
 | 
				
			||||||
	struct spa_port_info info;
 | 
						struct spa_port_info info;
 | 
				
			||||||
	struct spa_dict_item items[2];
 | 
						struct spa_dict_item items[4];
 | 
				
			||||||
	struct spa_dict props;
 | 
						struct spa_dict props;
 | 
				
			||||||
	struct spa_param_info params[5];
 | 
						struct spa_param_info params[5];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -285,7 +285,7 @@ static void emit_node_info(struct impl *this, bool full)
 | 
				
			||||||
		snprintf(latency, sizeof(latency), "%d/%d",
 | 
							snprintf(latency, sizeof(latency), "%d/%d",
 | 
				
			||||||
				this->client->buffer_size, this->client->frame_rate);
 | 
									this->client->buffer_size, this->client->frame_rate);
 | 
				
			||||||
		items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_MEDIA_CLASS, "Audio/Source");
 | 
							items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_MEDIA_CLASS, "Audio/Source");
 | 
				
			||||||
		items[1] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_NAME, "jack_system");
 | 
							items[1] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_NAME, "JACK System");
 | 
				
			||||||
		items[2] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_DRIVER, "true");
 | 
							items[2] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_DRIVER, "true");
 | 
				
			||||||
		items[3] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_PAUSE_ON_IDLE, "false");
 | 
							items[3] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_PAUSE_ON_IDLE, "false");
 | 
				
			||||||
		items[4] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_LATENCY, latency);
 | 
							items[4] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_LATENCY, latency);
 | 
				
			||||||
| 
						 | 
					@ -300,6 +300,21 @@ static void emit_port_info(struct impl *this, struct port *port, bool full)
 | 
				
			||||||
	if (full)
 | 
						if (full)
 | 
				
			||||||
		port->info.change_mask = port->info_all;
 | 
							port->info.change_mask = port->info_all;
 | 
				
			||||||
	if (port->info.change_mask) {
 | 
						if (port->info.change_mask) {
 | 
				
			||||||
 | 
							char* aliases[2];
 | 
				
			||||||
 | 
							int n_aliases, n_items;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							aliases[0] = alloca(jack_port_name_size());
 | 
				
			||||||
 | 
							aliases[1] = alloca(jack_port_name_size());
 | 
				
			||||||
 | 
							n_aliases = jack_port_get_aliases(port->jack_port, aliases);
 | 
				
			||||||
 | 
							n_items = 1;
 | 
				
			||||||
 | 
							port->items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_PORT_NAME,
 | 
				
			||||||
 | 
									jack_port_short_name(port->jack_port));
 | 
				
			||||||
 | 
							if (n_aliases > 0)
 | 
				
			||||||
 | 
								port->items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_OBJECT_PATH, aliases[0]);
 | 
				
			||||||
 | 
							if (n_aliases > 1)
 | 
				
			||||||
 | 
								port->items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_PORT_ALIAS, aliases[1]);
 | 
				
			||||||
 | 
							port->props = SPA_DICT_INIT(port->items, n_items);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		spa_node_emit_port_info(&this->hooks,
 | 
							spa_node_emit_port_info(&this->hooks,
 | 
				
			||||||
				SPA_DIRECTION_OUTPUT, port->id, &port->info);
 | 
									SPA_DIRECTION_OUTPUT, port->id, &port->info);
 | 
				
			||||||
		port->info.change_mask = 0;
 | 
							port->info.change_mask = 0;
 | 
				
			||||||
| 
						 | 
					@ -366,9 +381,11 @@ static int init_port(struct impl *this, struct port *port)
 | 
				
			||||||
			SPA_PORT_CHANGE_MASK_PARAMS;
 | 
								SPA_PORT_CHANGE_MASK_PARAMS;
 | 
				
			||||||
	port->info = SPA_PORT_INFO_INIT();
 | 
						port->info = SPA_PORT_INFO_INIT();
 | 
				
			||||||
	port->info.flags = SPA_PORT_FLAG_NO_REF;
 | 
						port->info.flags = SPA_PORT_FLAG_NO_REF;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	port->items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_FORMAT_DSP, "32 bit float mono audio");
 | 
						port->items[0] = SPA_DICT_ITEM_INIT(SPA_KEY_FORMAT_DSP, "32 bit float mono audio");
 | 
				
			||||||
	port->props = SPA_DICT_INIT(port->items, 1);
 | 
						port->props = SPA_DICT_INIT(port->items, 1);
 | 
				
			||||||
	port->info.props = &port->props;
 | 
						port->info.props = &port->props;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);
 | 
						port->params[0] = SPA_PARAM_INFO(SPA_PARAM_EnumFormat, SPA_PARAM_INFO_READ);
 | 
				
			||||||
	port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
 | 
						port->params[1] = SPA_PARAM_INFO(SPA_PARAM_Meta, SPA_PARAM_INFO_READ);
 | 
				
			||||||
	port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);
 | 
						port->params[2] = SPA_PARAM_INFO(SPA_PARAM_IO, SPA_PARAM_INFO_READ);
 | 
				
			||||||
| 
						 | 
					@ -376,6 +393,7 @@ static int init_port(struct impl *this, struct port *port)
 | 
				
			||||||
	port->params[4] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
 | 
						port->params[4] = SPA_PARAM_INFO(SPA_PARAM_Buffers, 0);
 | 
				
			||||||
	port->info.params = port->params;
 | 
						port->info.params = port->params;
 | 
				
			||||||
	port->info.n_params = 5;
 | 
						port->info.n_params = 5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_list_init(&port->empty);
 | 
						spa_list_init(&port->empty);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -398,19 +416,32 @@ static int init_ports(struct impl *this)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; ports[i]; i++) {
 | 
						for (i = 0; ports[i]; i++) {
 | 
				
			||||||
		struct port *port = GET_OUT_PORT(this, i);
 | 
							struct port *port = GET_OUT_PORT(this, i);
 | 
				
			||||||
 | 
							jack_port_t *p = jack_port_by_name(client, ports[i]);
 | 
				
			||||||
 | 
							char *aliases[2];
 | 
				
			||||||
 | 
							int n_aliases;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		port->id = i;
 | 
							port->id = i;
 | 
				
			||||||
		init_port(this, port);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		port->jack_port = jack_port_register(client,
 | 
							port->jack_port = jack_port_register(client,
 | 
				
			||||||
				ports[i],
 | 
									jack_port_short_name(p),
 | 
				
			||||||
				JACK_DEFAULT_AUDIO_TYPE,
 | 
									jack_port_type(p),
 | 
				
			||||||
				JackPortIsInput|JackPortIsTerminal, 0);
 | 
									JackPortIsInput, 0);
 | 
				
			||||||
		if (port->jack_port == NULL) {
 | 
							if (port->jack_port == NULL) {
 | 
				
			||||||
			spa_log_error(this->log, NAME" %p: jack_port_register() failed", this);
 | 
								spa_log_error(this->log, NAME" %p: jack_port_register() %d (%s) failed",
 | 
				
			||||||
 | 
										this, i, ports[i]);
 | 
				
			||||||
			res = -EFAULT;
 | 
								res = -EFAULT;
 | 
				
			||||||
			goto exit_free;
 | 
								goto exit_free;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							aliases[0] = alloca(jack_port_name_size());
 | 
				
			||||||
 | 
							aliases[1] = alloca(jack_port_name_size());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							n_aliases = jack_port_get_aliases(p, aliases);
 | 
				
			||||||
 | 
							if (n_aliases > 0)
 | 
				
			||||||
 | 
								jack_port_set_alias(port->jack_port, aliases[0]);
 | 
				
			||||||
 | 
							if (n_aliases > 1)
 | 
				
			||||||
 | 
								jack_port_set_alias(port->jack_port, aliases[1]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							init_port(this, port);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	this->n_out_ports = i;
 | 
						this->n_out_ports = i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue