mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	add new API pa_rtclock_from_wallclock()
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2234 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									e1c1a782b6
								
							
						
					
					
						commit
						6cddf6135c
					
				
					 2 changed files with 23 additions and 0 deletions
				
			
		| 
						 | 
					@ -96,3 +96,24 @@ pa_usec_t pa_rtclock_usec(void) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return pa_timeval_load(pa_rtclock_get(&tv));
 | 
					    return pa_timeval_load(pa_rtclock_get(&tv));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct timeval* pa_rtclock_from_wallclock(struct timeval *tv) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef HAVE_CLOCK_GETTIME
 | 
				
			||||||
 | 
					    struct timeval wc_now, rt_now;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_gettimeofday(&wc_now);
 | 
				
			||||||
 | 
					    pa_rtclock_get(&rt_now);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(tv);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (pa_timeval_cmp(&wc_now, tv) < 0)
 | 
				
			||||||
 | 
					        pa_timeval_add(&rt_now, pa_timeval_diff(tv, &wc_now));
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        pa_timeval_sub(&rt_now, pa_timeval_diff(&wc_now, tv));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    *tv = rt_now;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return tv;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,4 +40,6 @@ pa_bool_t pa_rtclock_hrtimer(void);
 | 
				
			||||||
/* timer with a resolution better than this are considered high-resolution */
 | 
					/* timer with a resolution better than this are considered high-resolution */
 | 
				
			||||||
#define PA_HRTIMER_THRESHOLD_USEC 10
 | 
					#define PA_HRTIMER_THRESHOLD_USEC 10
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct timeval* pa_rtclock_from_wallclock(struct timeval *tv);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue