mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-10-29 05:40:27 -04:00 
			
		
		
		
	alsa: improve xrun clock field calculation
We're missing the delay in samples plus all of the extra samples of silence we use to restart the device. This is in the samplerate of the device. Convert this to the time domain of the graph before adding it to xrun.
This commit is contained in:
		
							parent
							
								
									2c2b0f482f
								
							
						
					
					
						commit
						21392d898e
					
				
					 1 changed files with 5 additions and 6 deletions
				
			
		|  | @ -1945,16 +1945,15 @@ static int alsa_recover(struct state *state, int err) | ||||||
| 
 | 
 | ||||||
| 		delay = SPA_TIMEVAL_TO_USEC(&diff); | 		delay = SPA_TIMEVAL_TO_USEC(&diff); | ||||||
| 		missing = delay * state->rate / SPA_USEC_PER_SEC; | 		missing = delay * state->rate / SPA_USEC_PER_SEC; | ||||||
| 		if (missing == 0) | 		missing += state->start_delay + state->threshold + state->headroom; | ||||||
| 			missing = state->threshold; |  | ||||||
| 
 | 
 | ||||||
| 		spa_log_trace(state->log, "%p: xrun of %"PRIu64" usec %"PRIu64, | 		spa_log_trace(state->log, "%p: xrun of %"PRIu64" usec %"PRIu64, | ||||||
| 				state, delay, missing); | 				state, delay, missing); | ||||||
| 
 | 
 | ||||||
| 		if (state->clock) | 		if (state->clock) { | ||||||
| 			state->clock->xrun += missing; | 			state->clock->xrun += SPA_SCALE32_UP(missing, | ||||||
| 		state->sample_count += missing; | 					state->clock->rate.denom, state->rate); | ||||||
| 
 | 		} | ||||||
| 		spa_node_call_xrun(&state->callbacks, | 		spa_node_call_xrun(&state->callbacks, | ||||||
| 				SPA_TIMEVAL_TO_USEC(&trigger), delay, NULL); | 				SPA_TIMEVAL_TO_USEC(&trigger), delay, NULL); | ||||||
| 		break; | 		break; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Wim Taymans
						Wim Taymans