mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pulse-server: recalculate tlength on quantum change
Always reevaluate the tlength or total buffered samples when the quantum changes, even for the first sample because it is possible that we completely miscalculated the length when we started, like when the quantum is force high and the requested latency is low. Also only increase the calculated tlength, for smaller sizes we don't need to do anything, we can keep the latency as is it. See #1930
This commit is contained in:
		
							parent
							
								
									512a52d9c6
								
							
						
					
					
						commit
						3c66d46007
					
				
					 2 changed files with 3 additions and 7 deletions
				
			
		| 
						 | 
					@ -1127,7 +1127,7 @@ do_process_done(struct spa_loop *loop,
 | 
				
			||||||
		stream->delay = 0;
 | 
							stream->delay = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (stream->direction == PW_DIRECTION_OUTPUT) {
 | 
						if (stream->direction == PW_DIRECTION_OUTPUT) {
 | 
				
			||||||
		if (stream->last_quantum != 0 && pd->quantum != stream->last_quantum)
 | 
							if (pd->quantum != stream->last_quantum)
 | 
				
			||||||
			stream_update_minreq(stream, pd->minreq);
 | 
								stream_update_minreq(stream, pd->minreq);
 | 
				
			||||||
		stream->last_quantum = pd->quantum;
 | 
							stream->last_quantum = pd->quantum;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -265,14 +265,10 @@ int stream_update_minreq(struct stream *stream, uint32_t minreq)
 | 
				
			||||||
	uint32_t new_tlength = minreq + 2 * stream->attr.minreq;
 | 
						uint32_t new_tlength = minreq + 2 * stream->attr.minreq;
 | 
				
			||||||
	uint64_t lat_usec;
 | 
						uint64_t lat_usec;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (new_tlength == old_tlength)
 | 
						if (new_tlength <= old_tlength)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (old_tlength > new_tlength)
 | 
					 | 
				
			||||||
		stream->missing -= old_tlength - new_tlength;
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
	stream->missing += new_tlength - old_tlength;
 | 
						stream->missing += new_tlength - old_tlength;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	stream->attr.tlength = new_tlength;
 | 
						stream->attr.tlength = new_tlength;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (client->version >= 15) {
 | 
						if (client->version >= 15) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue