mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-20 04:30:04 +01:00
stream: Fix pw_time.delay calculation for rate.num > 1
Pipewire uses a rate of 256/7680 with the integrated camera of Apple
silicon Macbooks. To calculate pw_time.delay correctly in this case it
has to be divided by time->rate.num. Without this division the delay
contribution of the `((latency->min_ns + latency->max_ns) / 2)` term
ends up as 255 which are 8.5 seconds.
pipewiresrc reports the delay as latency in the gstreamer pipeline which
results in rendering a frame every 8.5 seconds.
I suspect the non-normalized rate of 256/7680 is another bug in
pipewire. The rate for an UVC webcam is reported as 1/30. Both
Video4Linux2 devices report a discrete frame interval of 0.033s (30fps).
Fixes #4957
(cherry picked from commit f03021edd1)
This commit is contained in:
parent
43b6a83518
commit
be1677f569
1 changed files with 3 additions and 2 deletions
|
|
@ -2400,8 +2400,9 @@ int pw_stream_get_time_n(struct pw_stream *stream, struct pw_time *time, size_t
|
|||
|
||||
time->delay += (int64_t)(((impl->latency.min_quantum + impl->latency.max_quantum) / 2.0f) * quantum);
|
||||
time->delay += (impl->latency.min_rate + impl->latency.max_rate) / 2;
|
||||
time->delay += ((impl->latency.min_ns + impl->latency.max_ns) / 2) *
|
||||
(int64_t)time->rate.denom / (int64_t)SPA_NSEC_PER_SEC;
|
||||
if (time->rate.num != 0)
|
||||
time->delay += ((impl->latency.min_ns + impl->latency.max_ns) / 2) *
|
||||
(int64_t)time->rate.denom / ((int64_t)SPA_NSEC_PER_SEC * time->rate.num);
|
||||
|
||||
avail_buffers = spa_ringbuffer_get_read_index(&impl->dequeued.ring, &index);
|
||||
avail_buffers = SPA_CLAMP(avail_buffers, 0, (int32_t)impl->n_buffers);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue