mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	alsa-utils: update the threshold also for capture
This commit is contained in:
		
							parent
							
								
									0f9594e119
								
							
						
					
					
						commit
						1bbb144b59
					
				
					 1 changed files with 15 additions and 14 deletions
				
			
		| 
						 | 
					@ -885,22 +885,23 @@ int spa_alsa_read(struct state *state, snd_pcm_uframes_t silence)
 | 
				
			||||||
	snd_pcm_uframes_t read, frames, offset;
 | 
						snd_pcm_uframes_t read, frames, offset;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (state->position && !state->slaved) {
 | 
						if (state->position) {
 | 
				
			||||||
		uint64_t position, duration;
 | 
							if (state->duration != state->position->clock.duration) {
 | 
				
			||||||
 | 
								state->duration = state->position->clock.duration;
 | 
				
			||||||
 | 
								state->threshold = (state->duration * state->rate + state->rate_denom-1) / state->rate_denom;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (!state->slaved) {
 | 
				
			||||||
 | 
								uint64_t position;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		duration = state->position->clock.duration;
 | 
								position = state->position->clock.position;
 | 
				
			||||||
		if (state->duration != duration) {
 | 
								if (state->last_position && state->last_position + state->last_duration != position) {
 | 
				
			||||||
			state->duration = duration;
 | 
									state->alsa_sync = true;
 | 
				
			||||||
			state->threshold = (duration * state->rate + state->rate_denom-1) / state->rate_denom;
 | 
									spa_log_warn(state->log, "discont, resync %"PRIu64" %"PRIu64" %d",
 | 
				
			||||||
 | 
											state->last_position, position, state->last_duration);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								state->last_position = position;
 | 
				
			||||||
 | 
								state->last_duration = state->duration;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		position = state->position->clock.position;
 | 
					 | 
				
			||||||
		if (state->last_position && state->last_position + state->last_duration != position) {
 | 
					 | 
				
			||||||
			state->alsa_sync = true;
 | 
					 | 
				
			||||||
			spa_log_warn(state->log, "discont, resync %"PRIu64" %"PRIu64" %d",
 | 
					 | 
				
			||||||
					state->last_position, position, state->last_duration);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		state->last_position = position;
 | 
					 | 
				
			||||||
		state->last_duration = duration;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (state->slaved && state->alsa_started) {
 | 
						if (state->slaved && state->alsa_started) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue