mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	mainloop: do better wallclock to rttime conversion
The mainloop time_new is supposed to be called with wallclock time but some apps use rttime instead. Handle the case better so that we never end up disabling the timer.
This commit is contained in:
		
							parent
							
								
									a5656777e0
								
							
						
					
					
						commit
						aba02806cf
					
				
					 1 changed files with 14 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -126,10 +126,23 @@ static void set_timer(pa_time_event *ev, const struct timeval *tv)
 | 
			
		|||
		ts.tv_nsec = 1;
 | 
			
		||||
	} else {
 | 
			
		||||
		struct timeval ttv = *tv;
 | 
			
		||||
		if ((tv->tv_usec & PA_TIMEVAL_RTCLOCK) == 0)
 | 
			
		||||
 | 
			
		||||
		if (!!(ttv.tv_usec & PA_TIMEVAL_RTCLOCK))
 | 
			
		||||
			ttv.tv_usec &= ~PA_TIMEVAL_RTCLOCK;
 | 
			
		||||
		else
 | 
			
		||||
			pa_rtclock_from_wallclock(&ttv);
 | 
			
		||||
 | 
			
		||||
		/* something strange, probably not wallclock time, try to
 | 
			
		||||
		 * use the timeval directly */
 | 
			
		||||
		if (ttv.tv_sec == 0 && ttv.tv_usec == 0)
 | 
			
		||||
			ttv = *tv;
 | 
			
		||||
 | 
			
		||||
		ts.tv_sec = ttv.tv_sec;
 | 
			
		||||
		ts.tv_nsec = ttv.tv_usec * SPA_NSEC_PER_USEC;
 | 
			
		||||
 | 
			
		||||
		/* make sure we never disable the timer */
 | 
			
		||||
		if (ts.tv_sec == 0 && ts.tv_nsec == 0)
 | 
			
		||||
			ts.tv_nsec++;
 | 
			
		||||
	}
 | 
			
		||||
	pw_log_debug("set timer %p %ld %ld", ev, ts.tv_sec, ts.tv_nsec);
 | 
			
		||||
	pw_loop_update_timer(mainloop->loop, ev->source, &ts, NULL, true);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue