mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	stream: add pw_stream_get_nsec() to get current time
Make a method to get the current time to compare agains the pw_time-now field. This is currently CLOCK_MONOTONIC but make this into a method so that we can more easily change it later.
This commit is contained in:
		
							parent
							
								
									b3c7dda96a
								
							
						
					
					
						commit
						4c75d4f660
					
				
					 15 changed files with 52 additions and 55 deletions
				
			
		| 
						 | 
				
			
			@ -200,7 +200,6 @@ static int snd_pcm_pipewire_delay(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delay
 | 
			
		|||
	snd_pcm_pipewire_t *pw = io->private_data;
 | 
			
		||||
	uintptr_t seq1, seq2;
 | 
			
		||||
	int64_t elapsed = 0, delay, now, avail;
 | 
			
		||||
	struct timespec ts;
 | 
			
		||||
	int64_t diff;
 | 
			
		||||
 | 
			
		||||
	do {
 | 
			
		||||
| 
						 | 
				
			
			@ -218,8 +217,7 @@ static int snd_pcm_pipewire_delay(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delay
 | 
			
		|||
 | 
			
		||||
	if (now != 0 && (io->state == SND_PCM_STATE_RUNNING ||
 | 
			
		||||
	    io->state == SND_PCM_STATE_DRAINING)) {
 | 
			
		||||
		clock_gettime(CLOCK_MONOTONIC, &ts);
 | 
			
		||||
		diff = SPA_TIMESPEC_TO_NSEC(&ts) - now;
 | 
			
		||||
		diff = pw_stream_get_nsec(pw->stream) - now;
 | 
			
		||||
		elapsed = (io->rate * diff) / SPA_NSEC_PER_SEC;
 | 
			
		||||
 | 
			
		||||
		if (io->stream == SND_PCM_STREAM_PLAYBACK)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue