mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
add clock
Add a gstreamer pinos clock that reports the time at the server
This commit is contained in:
parent
0b380dd43e
commit
f86b50d202
11 changed files with 259 additions and 72 deletions
|
|
@ -115,7 +115,7 @@ typedef struct {
|
|||
SpaAllocParamBuffers param_buffers;
|
||||
SpaPortStatus status;
|
||||
|
||||
int64_t last_timestamp;
|
||||
int64_t last_ticks;
|
||||
int64_t last_monotonic;
|
||||
} SpaV4l2State;
|
||||
|
||||
|
|
@ -759,7 +759,8 @@ spa_v4l2_source_clock_set_props (SpaClock *clock,
|
|||
|
||||
static SpaResult
|
||||
spa_v4l2_source_clock_get_time (SpaClock *clock,
|
||||
int64_t *clock_time,
|
||||
int32_t *rate,
|
||||
int64_t *ticks,
|
||||
int64_t *monotonic_time)
|
||||
{
|
||||
SpaV4l2Source *this;
|
||||
|
|
@ -771,8 +772,10 @@ spa_v4l2_source_clock_get_time (SpaClock *clock,
|
|||
this = (SpaV4l2Source *) clock->handle;
|
||||
state = &this->state[0];
|
||||
|
||||
if (clock_time)
|
||||
*clock_time = state->last_timestamp;
|
||||
if (rate)
|
||||
*rate = 1000000;
|
||||
if (ticks)
|
||||
*ticks = state->last_ticks;
|
||||
if (monotonic_time)
|
||||
*monotonic_time = state->last_monotonic;
|
||||
|
||||
|
|
|
|||
|
|
@ -788,7 +788,8 @@ spa_v4l2_set_format (SpaV4l2Source *this, V4l2Format *f, bool try_only)
|
|||
state->info.flags = SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS |
|
||||
SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS;
|
||||
state->info.maxbuffering = -1;
|
||||
state->info.latency = -1;
|
||||
state->info.latency = (streamparm.parm.capture.timeperframe.numerator * 1000000000LL) /
|
||||
streamparm.parm.capture.timeperframe.denominator;
|
||||
|
||||
state->info.n_params = 1;
|
||||
state->info.params = state->params;
|
||||
|
|
@ -834,12 +835,13 @@ mmap_read (SpaV4l2Source *this)
|
|||
if (buf.flags & V4L2_BUF_FLAG_ERROR)
|
||||
b->header.flags |= SPA_BUFFER_FLAG_CORRUPTED;
|
||||
|
||||
state->last_ticks = (int64_t)buf.timestamp.tv_sec * 1000000 + (uint64_t)buf.timestamp.tv_usec;
|
||||
|
||||
b->header.seq = buf.sequence;
|
||||
b->header.pts = (uint64_t)buf.timestamp.tv_sec * 1000000000lu + (uint64_t)buf.timestamp.tv_usec * 1000lu;
|
||||
state->last_timestamp = b->header.pts;
|
||||
b->header.pts = state->last_ticks * 1000;
|
||||
|
||||
if (buf.flags & V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC)
|
||||
state->last_monotonic = state->last_timestamp;
|
||||
state->last_monotonic = b->header.pts;
|
||||
else
|
||||
state->last_monotonic = SPA_TIME_INVALID;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue