set_calibration


Description:

public void set_calibration (ClockTime @internal, ClockTime external, ClockTime rate_num, ClockTime rate_denom)

Adjusts the rate and time of this.

A rate of 1/1 is the normal speed of the clock. Values bigger than 1/1 make the clock go faster.

internal and external are calibration parameters that arrange that get_time should have been external at internal time internal . This internal time should not be in the future; that is, it should be less than the value of get_internal_time when this function is called.

Subsequent calls to get_time will return clock times computed as follows:

``` C time = (internal_time - internal) * rate_num / rate_denom + external ```

This formula is implemented in adjust_unlocked. Of course, it tries to do the integer arithmetic as precisely as possible.

Note that get_time always returns increasing values so when you move the clock backwards, get_time will report the previous value until the clock catches up.

Parameters:

this

a Clock to calibrate

external

a reference external time

rate_num

the numerator of the rate of the clock relative to its internal time

rate_denom

the denominator of the rate of the clock

internal

a reference internal time




2022 vala-language.org