mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-09 13:30:06 -05:00
stream: fix ticks calculation if rate is 0/0
If the rate is 0/0, converting nsec to ticks doesn't work and will
result in 0 ticks, and it is not possible to convert ticks back to a
timestamp.
This can be reproduced by connecting a GStreamer pipewiresrc to a
libcamera node. The libcamera-utils has a rate of 0/0 and the
pipewireclock won't be able to determine a correct time with that. This
error was caused by Commit 89993a3cc6 ("gst: enable the pipewire ticks
as a clock source").
Fix this by using the nsec as ticks and setting the appropriate rate.
This commit is contained in:
parent
5d35986329
commit
0468712fea
1 changed files with 11 additions and 4 deletions
|
|
@ -638,11 +638,18 @@ static inline void copy_position(struct stream *impl, int64_t queued)
|
||||||
impl->base_pos = p->clock.position - impl->time.ticks;
|
impl->base_pos = p->clock.position - impl->time.ticks;
|
||||||
impl->clock_id = p->clock.id;
|
impl->clock_id = p->clock.id;
|
||||||
}
|
}
|
||||||
if (SPA_FLAG_IS_SET(p->clock.flags, SPA_IO_CLOCK_FLAG_NO_RATE))
|
if (SPA_FLAG_IS_SET(p->clock.flags, SPA_IO_CLOCK_FLAG_NO_RATE)) {
|
||||||
impl->time.ticks = p->clock.nsec * p->clock.rate.denom /
|
if (p->clock.rate.num == 0 || p->clock.rate.denom == 0) {
|
||||||
(SPA_NSEC_PER_SEC * p->clock.rate.num);
|
impl->time.ticks = p->clock.nsec;
|
||||||
else
|
impl->time.rate.num = 1;
|
||||||
|
impl->time.rate.denom = SPA_NSEC_PER_SEC;
|
||||||
|
} else {
|
||||||
|
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.ticks = p->clock.position - impl->base_pos;
|
||||||
|
}
|
||||||
|
|
||||||
impl->time.delay = 0;
|
impl->time.delay = 0;
|
||||||
impl->time.queued = queued;
|
impl->time.queued = queued;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue