mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-20 06:50:03 +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
This commit is contained in:
parent
c7ebc66e64
commit
f03021edd1
1 changed files with 3 additions and 2 deletions
|
|
@ -2481,8 +2481,9 @@ int pw_stream_get_time_n(struct pw_stream *stream, struct pw_time *time, size_t
|
||||||
|
|
||||||
time->delay += (int64_t)(((latency->min_quantum + latency->max_quantum) / 2.0f) * quantum);
|
time->delay += (int64_t)(((latency->min_quantum + latency->max_quantum) / 2.0f) * quantum);
|
||||||
time->delay += (latency->min_rate + latency->max_rate) / 2;
|
time->delay += (latency->min_rate + latency->max_rate) / 2;
|
||||||
|
if (time->rate.num != 0)
|
||||||
time->delay += ((latency->min_ns + latency->max_ns) / 2) *
|
time->delay += ((latency->min_ns + latency->max_ns) / 2) *
|
||||||
(int64_t)time->rate.denom / (int64_t)SPA_NSEC_PER_SEC;
|
(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_ringbuffer_get_read_index(&impl->dequeued.ring, &index);
|
||||||
avail_buffers = SPA_CLAMP(avail_buffers, 0, (int32_t)impl->n_buffers);
|
avail_buffers = SPA_CLAMP(avail_buffers, 0, (int32_t)impl->n_buffers);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue