mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	bluez5: media-sink: fix reference time vs. resampling delay
Determine correctly if we are resampling, and have the associated delay. Add off-by-one sample adjustment to the resampling delay, which seems to correctly align the resampled audio with non-resampled.
This commit is contained in:
		
							parent
							
								
									bd04af6cc9
								
							
						
					
					
						commit
						5b55118e7f
					
				
					 1 changed files with 5 additions and 1 deletions
				
			
		| 
						 | 
					@ -465,6 +465,7 @@ static uint64_t get_reference_time(struct impl *this, uint64_t *duration_ns_ret)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct port *port = &this->port;
 | 
						struct port *port = &this->port;
 | 
				
			||||||
	uint64_t t, duration_ns;
 | 
						uint64_t t, duration_ns;
 | 
				
			||||||
 | 
						bool resampling;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!this->process_rate || !this->process_duration) {
 | 
						if (!this->process_rate || !this->process_duration) {
 | 
				
			||||||
		if (this->position) {
 | 
							if (this->position) {
 | 
				
			||||||
| 
						 | 
					@ -486,9 +487,12 @@ static uint64_t get_reference_time(struct impl *this, uint64_t *duration_ns_ret)
 | 
				
			||||||
			/ port->current_format.info.raw.rate);
 | 
								/ port->current_format.info.raw.rate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Account for resampling delay */
 | 
						/* Account for resampling delay */
 | 
				
			||||||
	if (port->rate_match && this->clock && SPA_FLAG_IS_SET(port->rate_match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE))
 | 
						resampling = (port->current_format.info.raw.rate != this->process_rate) || this->following;
 | 
				
			||||||
 | 
						if (port->rate_match && this->clock && resampling) {
 | 
				
			||||||
		t -= (uint64_t)port->rate_match->delay * SPA_NSEC_PER_SEC
 | 
							t -= (uint64_t)port->rate_match->delay * SPA_NSEC_PER_SEC
 | 
				
			||||||
			/ this->clock->rate.denom;
 | 
								/ this->clock->rate.denom;
 | 
				
			||||||
 | 
							t += SPA_NSEC_PER_SEC / port->current_format.info.raw.rate;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return t;
 | 
						return t;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue