mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-30 21:37:53 -04:00
spa: plugins: libcamera: Drop rate dependent calculations
The clock has SPA_IO_CLOCK_FLAG_NO_RATE set unconditionally and the rate is usally 0/0. So all the rate calculations produce NaN and are not necessary. Drop them. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
This commit is contained in:
parent
e2f2b9a273
commit
c8f81fcdbb
1 changed files with 8 additions and 16 deletions
|
|
@ -1060,20 +1060,12 @@ void handle_completed_request(struct impl *impl, libcamera::Request *request)
|
|||
const FrameMetadata &fmd = buffer->metadata();
|
||||
|
||||
if (impl->clock) {
|
||||
double target = (double)port->info.rate.num / port->info.rate.denom;
|
||||
double corr;
|
||||
|
||||
if (impl->dll.bw == 0.0) {
|
||||
spa_dll_set_bw(&impl->dll, SPA_DLL_BW_MAX, port->info.rate.denom, port->info.rate.denom);
|
||||
impl->clock->next_nsec = fmd.timestamp;
|
||||
corr = 1.0;
|
||||
} else {
|
||||
double diff = ((double)impl->clock->next_nsec - (double)fmd.timestamp) / SPA_NSEC_PER_SEC;
|
||||
double error = port->info.rate.denom * (diff - target);
|
||||
corr = spa_dll_update(&impl->dll, SPA_CLAMPD(error, -128., 128.));
|
||||
}
|
||||
/* FIXME, we should follow the driver clock and target_ values.
|
||||
* for now we ignore and use our own. */
|
||||
/*
|
||||
* The clock has SPA_IO_CLOCK_FLAG_NO_RATE set, so there is no
|
||||
* need to update any rate specific fields.
|
||||
* As libcamera uses CLOCK_MONOTONIC internally, there is no
|
||||
* need to adjust the timestamps.
|
||||
*/
|
||||
impl->clock->target_rate = port->rate;
|
||||
impl->clock->target_duration = 1;
|
||||
|
||||
|
|
@ -1082,8 +1074,8 @@ void handle_completed_request(struct impl *impl, libcamera::Request *request)
|
|||
impl->clock->position = fmd.sequence;
|
||||
impl->clock->duration = 1;
|
||||
impl->clock->delay = 0;
|
||||
impl->clock->rate_diff = corr;
|
||||
impl->clock->next_nsec += (uint64_t) (target * SPA_NSEC_PER_SEC * corr);
|
||||
impl->clock->rate_diff = 1.0;
|
||||
impl->clock->next_nsec = fmd.timestamp+1;
|
||||
}
|
||||
|
||||
if (b->h) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue