mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	stream: also return current monotonic time in _get_time()
This commit is contained in:
		
							parent
							
								
									9a0ada2a3f
								
							
						
					
					
						commit
						61885b00b6
					
				
					 2 changed files with 4 additions and 3 deletions
				
			
		| 
						 | 
					@ -1078,12 +1078,12 @@ pinos_stream_get_time (PinosStream *stream,
 | 
				
			||||||
                       PinosTime   *time)
 | 
					                       PinosTime   *time)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
					  PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
 | 
				
			||||||
  int64_t now, elapsed;
 | 
					  int64_t elapsed;
 | 
				
			||||||
  struct timespec ts;
 | 
					  struct timespec ts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  clock_gettime (CLOCK_MONOTONIC, &ts);
 | 
					  clock_gettime (CLOCK_MONOTONIC, &ts);
 | 
				
			||||||
  now = SPA_TIMESPEC_TO_TIME (&ts);
 | 
					  time->now = SPA_TIMESPEC_TO_TIME (&ts);
 | 
				
			||||||
  elapsed = (now - impl->last_monotonic) / 1000;
 | 
					  elapsed = (time->now - impl->last_monotonic) / 1000;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  time->ticks = impl->last_ticks + (elapsed * impl->last_rate) / SPA_USEC_PER_SEC;
 | 
					  time->ticks = impl->last_ticks + (elapsed * impl->last_rate) / SPA_USEC_PER_SEC;
 | 
				
			||||||
  time->rate = impl->last_rate;
 | 
					  time->rate = impl->last_rate;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,6 +54,7 @@ typedef enum {
 | 
				
			||||||
} PinosStreamMode;
 | 
					} PinosStreamMode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
 | 
					  int64_t now;
 | 
				
			||||||
  int64_t ticks;
 | 
					  int64_t ticks;
 | 
				
			||||||
  int32_t rate;
 | 
					  int32_t rate;
 | 
				
			||||||
} PinosTime;
 | 
					} PinosTime;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue