mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	Improve channel positions
Sort the channel positions as the suggested format Use the session node channel positions as the target profile
This commit is contained in:
		
							parent
							
								
									1edf2dd210
								
							
						
					
					
						commit
						805240258b
					
				
					 2 changed files with 14 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -305,6 +305,11 @@ impl_node_port_get_info(struct spa_node *node,
 | 
			
		|||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int int32_cmp(const void *v1, const void *v2)
 | 
			
		||||
{
 | 
			
		||||
	return *(int32_t*)v1 - *(int32_t*)v2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int port_enum_formats(struct spa_node *node,
 | 
			
		||||
			     enum spa_direction direction, uint32_t port_id,
 | 
			
		||||
			     uint32_t *index,
 | 
			
		||||
| 
						 | 
				
			
			@ -320,6 +325,12 @@ static int port_enum_formats(struct spa_node *node,
 | 
			
		|||
	switch (*index) {
 | 
			
		||||
	case 0:
 | 
			
		||||
		if (other->info.raw.channels > 0) {
 | 
			
		||||
			struct spa_audio_info info;
 | 
			
		||||
 | 
			
		||||
			info = *other;
 | 
			
		||||
 | 
			
		||||
			qsort(info.info.raw.position, info.info.raw.channels, sizeof(uint32_t), int32_cmp);
 | 
			
		||||
 | 
			
		||||
			spa_pod_builder_push_object(builder,
 | 
			
		||||
				SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
 | 
			
		||||
			spa_pod_builder_props(builder,
 | 
			
		||||
| 
						 | 
				
			
			@ -335,7 +346,7 @@ static int port_enum_formats(struct spa_node *node,
 | 
			
		|||
				0);
 | 
			
		||||
			spa_pod_builder_prop(builder, SPA_FORMAT_AUDIO_position, 0);
 | 
			
		||||
	                spa_pod_builder_array(builder, sizeof(uint32_t), SPA_TYPE_Id,
 | 
			
		||||
					other->info.raw.channels, other->info.raw.position);
 | 
			
		||||
					info.info.raw.channels, info.info.raw.position);
 | 
			
		||||
			*param = spa_pod_builder_pop(builder);
 | 
			
		||||
		} else {
 | 
			
		||||
			*param = spa_pod_builder_object(builder,
 | 
			
		||||
| 
						 | 
				
			
			@ -536,11 +547,6 @@ static int clear_buffers(struct impl *this, struct port *port)
 | 
			
		|||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
static int int32_cmp(const void *v1, const void *v2)
 | 
			
		||||
{
 | 
			
		||||
	return *(int32_t*)v1 - *(int32_t*)v2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int port_set_format(struct spa_node *node,
 | 
			
		||||
			   enum spa_direction direction,
 | 
			
		||||
			   uint32_t port_id,
 | 
			
		||||
| 
						 | 
				
			
			@ -581,8 +587,6 @@ static int port_set_format(struct spa_node *node,
 | 
			
		|||
				return -ENOTSUP;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		qsort(info.info.raw.position, info.info.raw.channels, sizeof(uint32_t), int32_cmp);
 | 
			
		||||
 | 
			
		||||
		port->stride = calc_width(&info);
 | 
			
		||||
 | 
			
		||||
		if (SPA_AUDIO_FORMAT_IS_PLANAR(info.info.raw.format)) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -913,10 +913,10 @@ static int rescan_node(struct impl *impl, struct node *node)
 | 
			
		|||
	spa_list_append(&session->node_list, &node->session_link);
 | 
			
		||||
 | 
			
		||||
	if (!exclusive) {
 | 
			
		||||
		audio_info = node->format;
 | 
			
		||||
		audio_info = session->node->format;
 | 
			
		||||
		audio_info.format = SPA_AUDIO_FORMAT_F32P;
 | 
			
		||||
		audio_info.rate = session->node->format.rate;
 | 
			
		||||
		audio_info.channels = SPA_MIN(session->node->format.channels, audio_info.channels);
 | 
			
		||||
		audio_info.channels = SPA_MIN(session->node->format.channels, node->format.channels);
 | 
			
		||||
 | 
			
		||||
		spa_pod_builder_init(&b, buf, sizeof(buf));
 | 
			
		||||
		param = spa_pod_builder_object(&b,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue