mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	bluez5: lc3: use high-reliability QoS defaults
Use the "high-reliability" values for QoS parameters instead of the low-latency ones. Under some condition BlueZ does not pass on the endpoint QoS values to us, in which case we may end up selecting bad latency.
This commit is contained in:
		
							parent
							
								
									645822b30b
								
							
						
					
					
						commit
						facef4a6c6
					
				
					 1 changed files with 30 additions and 26 deletions
				
			
		| 
						 | 
					@ -227,30 +227,31 @@ static bool select_config(bap_lc3_t *conf, const struct pac_data *pac)
 | 
				
			||||||
	if (conf->frame_duration == 0xFF || !conf->rate)
 | 
						if (conf->frame_duration == 0xFF || !conf->rate)
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* BAP v1.0.1 Table 5.2; high-reliability */
 | 
				
			||||||
	switch (conf->rate) {
 | 
						switch (conf->rate) {
 | 
				
			||||||
	case LC3_CONFIG_FREQ_48KHZ:
 | 
						case LC3_CONFIG_FREQ_48KHZ:
 | 
				
			||||||
		if (conf->frame_duration == LC3_CONFIG_DURATION_7_5)
 | 
							if (conf->frame_duration == LC3_CONFIG_DURATION_7_5)
 | 
				
			||||||
			conf->framelen = 117;
 | 
								conf->framelen = 117;	/* 48_5_2 */
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			conf->framelen = 120;
 | 
								conf->framelen = 120;	/* 48_4_2 */
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case LC3_CONFIG_FREQ_24KHZ:
 | 
						case LC3_CONFIG_FREQ_24KHZ:
 | 
				
			||||||
		if (conf->frame_duration == LC3_CONFIG_DURATION_7_5)
 | 
							if (conf->frame_duration == LC3_CONFIG_DURATION_7_5)
 | 
				
			||||||
			conf->framelen = 45;
 | 
								conf->framelen = 45;	/* 24_1_2 */
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			conf->framelen = 60;
 | 
								conf->framelen = 60;	/* 24_2_2 */
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case LC3_CONFIG_FREQ_16KHZ:
 | 
						case LC3_CONFIG_FREQ_16KHZ:
 | 
				
			||||||
		if (conf->frame_duration == LC3_CONFIG_DURATION_7_5)
 | 
							if (conf->frame_duration == LC3_CONFIG_DURATION_7_5)
 | 
				
			||||||
			conf->framelen = 30;
 | 
								conf->framelen = 30;	/* 16_1_2 */
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			conf->framelen = 40;
 | 
								conf->framelen = 40;	/* 16_2_2 */
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case LC3_CONFIG_FREQ_8KHZ:
 | 
						case LC3_CONFIG_FREQ_8KHZ:
 | 
				
			||||||
		if (conf->frame_duration == LC3_CONFIG_DURATION_7_5)
 | 
							if (conf->frame_duration == LC3_CONFIG_DURATION_7_5)
 | 
				
			||||||
			conf->framelen = 26;
 | 
								conf->framelen = 26;	/* 8_1_2 */
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			conf->framelen = 30;
 | 
								conf->framelen = 30;	/* 8_2_2 */
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
| 
						 | 
					@ -598,32 +599,35 @@ static int codec_get_qos(const struct media_codec *codec,
 | 
				
			||||||
		qos->phy = 0x1;
 | 
							qos->phy = 0x1;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		qos->phy = 0x2;
 | 
							qos->phy = 0x2;
 | 
				
			||||||
	qos->retransmission = 2; /* default */
 | 
					 | 
				
			||||||
	qos->sdu = conf.framelen * conf.n_blks * get_num_channels(conf.channels);
 | 
						qos->sdu = conf.framelen * conf.n_blks * get_num_channels(conf.channels);
 | 
				
			||||||
	qos->latency = 20; /* default */
 | 
					 | 
				
			||||||
	qos->delay = 40000U;
 | 
					 | 
				
			||||||
	qos->interval = (conf.frame_duration == LC3_CONFIG_DURATION_7_5 ? 7500 : 10000);
 | 
						qos->interval = (conf.frame_duration == LC3_CONFIG_DURATION_7_5 ? 7500 : 10000);
 | 
				
			||||||
	qos->target_latency = BT_ISO_QOS_TARGET_LATENCY_BALANCED;
 | 
						qos->target_latency = BT_ISO_QOS_TARGET_LATENCY_RELIABILITY;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Default values from BAP v1.0.1 Table 5.2; high-reliability */
 | 
				
			||||||
 | 
						qos->delay = 40000U;
 | 
				
			||||||
 | 
						qos->retransmission = 13;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (conf.rate) {
 | 
						switch (conf.rate) {
 | 
				
			||||||
	case LC3_CONFIG_FREQ_8KHZ:
 | 
						case LC3_CONFIG_FREQ_8KHZ:
 | 
				
			||||||
	case LC3_CONFIG_FREQ_16KHZ:
 | 
						case LC3_CONFIG_FREQ_16KHZ:
 | 
				
			||||||
	case LC3_CONFIG_FREQ_24KHZ:
 | 
						case LC3_CONFIG_FREQ_24KHZ:
 | 
				
			||||||
	case LC3_CONFIG_FREQ_32KHZ:
 | 
						case LC3_CONFIG_FREQ_32KHZ:
 | 
				
			||||||
			qos->retransmission = 2;
 | 
							/* F_1_2, F_2_2 */
 | 
				
			||||||
			qos->latency = (conf.frame_duration == LC3_CONFIG_DURATION_7_5 ? 8 : 10);
 | 
							qos->latency = (conf.frame_duration == LC3_CONFIG_DURATION_7_5 ? 75 : 95);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	case LC3_CONFIG_FREQ_48KHZ:
 | 
						case LC3_CONFIG_FREQ_48KHZ:
 | 
				
			||||||
			qos->retransmission = 5;
 | 
							/* 48_5_2, 48_4_2 */
 | 
				
			||||||
			qos->latency = (conf.frame_duration == LC3_CONFIG_DURATION_7_5 ? 15 : 20);
 | 
							qos->latency = (conf.frame_duration == LC3_CONFIG_DURATION_7_5 ? 75 : 100);
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
							qos->latency = 100;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Clamp to ASE values */
 | 
						/* Clamp to ASE values (if known) */
 | 
				
			||||||
	if (endpoint_qos->latency >= 0x0005 && endpoint_qos->latency <= 0x0FA0)
 | 
						if (endpoint_qos->latency >= 0x0005 && endpoint_qos->latency <= 0x0FA0)
 | 
				
			||||||
		/* Values outside the range are RFU */
 | 
							/* Values outside the range are RFU */
 | 
				
			||||||
		qos->latency = SPA_MAX(qos->latency, endpoint_qos->latency);
 | 
							qos->latency = endpoint_qos->latency;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (endpoint_qos->delay_min)
 | 
						if (endpoint_qos->delay_min)
 | 
				
			||||||
		qos->delay = SPA_MAX(qos->delay, endpoint_qos->delay_min);
 | 
							qos->delay = SPA_MAX(qos->delay, endpoint_qos->delay_min);
 | 
				
			||||||
	if (endpoint_qos->delay_max)
 | 
						if (endpoint_qos->delay_max)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue