mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	resample: take rate scale property into account as well
This commit is contained in:
		
							parent
							
								
									8ec3932e97
								
							
						
					
					
						commit
						5547f9a1b9
					
				
					 1 changed files with 7 additions and 4 deletions
				
			
		| 
						 | 
					@ -391,6 +391,8 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void update_rate_match(struct impl *this, bool passthrough, uint32_t out_size, uint32_t in_queued)
 | 
					static void update_rate_match(struct impl *this, bool passthrough, uint32_t out_size, uint32_t in_queued)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						double r = this->rate_scale / this->props.rate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->io_rate_match) {
 | 
						if (this->io_rate_match) {
 | 
				
			||||||
		uint32_t delay, match_size;
 | 
							uint32_t delay, match_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -399,9 +401,9 @@ static void update_rate_match(struct impl *this, bool passthrough, uint32_t out_
 | 
				
			||||||
			match_size = out_size;
 | 
								match_size = out_size;
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			if (SPA_FLAG_IS_SET(this->io_rate_match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE))
 | 
								if (SPA_FLAG_IS_SET(this->io_rate_match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE))
 | 
				
			||||||
				resample_update_rate(&this->resample, this->rate_scale * this->io_rate_match->rate);
 | 
									resample_update_rate(&this->resample, r * this->io_rate_match->rate);
 | 
				
			||||||
			else
 | 
								else
 | 
				
			||||||
				resample_update_rate(&this->resample, this->rate_scale);
 | 
									resample_update_rate(&this->resample, r);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			delay = resample_delay(&this->resample) + in_queued;
 | 
								delay = resample_delay(&this->resample) + in_queued;
 | 
				
			||||||
			match_size = resample_in_len(&this->resample, out_size);
 | 
								match_size = resample_in_len(&this->resample, out_size);
 | 
				
			||||||
| 
						 | 
					@ -412,12 +414,13 @@ static void update_rate_match(struct impl *this, bool passthrough, uint32_t out_
 | 
				
			||||||
		spa_log_trace_fp(this->log, "%p: next match:%u queued:%u delay:%u", this, match_size,
 | 
							spa_log_trace_fp(this->log, "%p: next match:%u queued:%u delay:%u", this, match_size,
 | 
				
			||||||
				in_queued, delay);
 | 
									in_queued, delay);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		resample_update_rate(&this->resample, this->rate_scale * this->props.rate);
 | 
							resample_update_rate(&this->resample, r);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
static inline bool is_passthrough(struct impl *this)
 | 
					static inline bool is_passthrough(struct impl *this)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return this->resample.i_rate == this->resample.o_rate && this->rate_scale == 1.0 &&
 | 
						return this->resample.i_rate == this->resample.o_rate &&
 | 
				
			||||||
 | 
							this->rate_scale == 1.0 && this->props.rate == 1.0 &&
 | 
				
			||||||
		(this->io_rate_match == NULL || this->props.disabled ||
 | 
							(this->io_rate_match == NULL || this->props.disabled ||
 | 
				
			||||||
		 !SPA_FLAG_IS_SET(this->io_rate_match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE));
 | 
							 !SPA_FLAG_IS_SET(this->io_rate_match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue