mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-10-29 05:40:27 -04:00 
			
		
		
		
	alsa-pcm: do not allow headroom plus threshold be bigger then the alsa buffer
Headroom are extra samples available in alsa buffer on top of a threshold. Its use to prefill alsa buffer with silence before the playback starts and later its use to calculate target number of a frames in the alsa buffer when get_status is called. Target is calculated as headroom plus threshold, which should be smaller then buffer size to make sense. Signed-off-by: Martin Geier <martin.geier@streamunlimited.com> Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
This commit is contained in:
		
							parent
							
								
									695f236f5f
								
							
						
					
					
						commit
						b4ed8dcf14
					
				
					 1 changed files with 4 additions and 1 deletions
				
			
		|  | @ -1939,7 +1939,10 @@ static void recalc_headroom(struct state *state) | ||||||
| 		if (state->stream == SND_PCM_STREAM_CAPTURE) | 		if (state->stream == SND_PCM_STREAM_CAPTURE) | ||||||
| 			state->headroom = SPA_MAX(state->headroom, 32u); | 			state->headroom = SPA_MAX(state->headroom, 32u); | ||||||
| 	} | 	} | ||||||
| 	state->headroom = SPA_MIN(state->headroom, state->buffer_frames); | 	if (SPA_LIKELY(state->buffer_frames >= state->threshold)) | ||||||
|  | 		state->headroom = SPA_MIN(state->headroom, state->buffer_frames - state->threshold); | ||||||
|  | 	else | ||||||
|  | 		state->headroom = 0; | ||||||
| 
 | 
 | ||||||
| 	latency = SPA_MAX(state->min_delay, SPA_MIN(state->max_delay, state->headroom)); | 	latency = SPA_MAX(state->min_delay, SPA_MIN(state->max_delay, state->headroom)); | ||||||
| 	if (rate != 0 && state->rate != 0) | 	if (rate != 0 && state->rate != 0) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Martin Geier
						Martin Geier