stream: also return current monotonic time in _get_time()

This commit is contained in:
Wim Taymans 2017-03-30 09:07:17 +02:00
parent 9a0ada2a3f
commit 61885b00b6
2 changed files with 4 additions and 3 deletions

View file

@ -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;

View file

@ -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;