mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-08 13:30:08 -05:00
node: add a clock flag to mark rate/duration inaccurate
Some clocks (v4l2) don't process exactly process buffers at the given rate/duration so mark this in the clock flags. We need to use the nsec field in the clock to derive ticks in pw-stream in that case to get a good clock.
This commit is contained in:
parent
ef8d2ab125
commit
3f0fe0032f
2 changed files with 9 additions and 1 deletions
|
|
@ -128,6 +128,9 @@ struct spa_io_clock {
|
|||
#define SPA_IO_CLOCK_FLAG_FREEWHEEL (1u<<0) /* graph is freewheeling */
|
||||
#define SPA_IO_CLOCK_FLAG_XRUN_RECOVER (1u<<1) /* recovering from xrun */
|
||||
#define SPA_IO_CLOCK_FLAG_LAZY (1u<<2) /* lazy scheduling */
|
||||
#define SPA_IO_CLOCK_FLAG_NO_RATE (1u<<3) /* the rate of the clock is only approximately.
|
||||
* it is recommended to use the nsec as a clock source.
|
||||
* The rate_diff contains the measured inaccuracy. */
|
||||
uint32_t flags; /**< Clock flags */
|
||||
uint32_t id; /**< Unique clock id, set by host application */
|
||||
char name[64]; /**< Clock name prefixed with API, set by node when it receives
|
||||
|
|
|
|||
|
|
@ -638,7 +638,12 @@ static inline void copy_position(struct stream *impl, int64_t queued)
|
|||
impl->base_pos = p->clock.position - impl->time.ticks;
|
||||
impl->clock_id = p->clock.id;
|
||||
}
|
||||
if (SPA_FLAG_IS_SET(p->clock.flags, SPA_IO_CLOCK_FLAG_NO_RATE))
|
||||
impl->time.ticks = p->clock.nsec * p->clock.rate.denom /
|
||||
(SPA_NSEC_PER_SEC * p->clock.rate.num);
|
||||
else
|
||||
impl->time.ticks = p->clock.position - impl->base_pos;
|
||||
|
||||
impl->time.delay = 0;
|
||||
impl->time.queued = queued;
|
||||
impl->quantum = p->clock.duration;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue