Prevent overflow for huge time values (fix 99h clock limit @96kHz)
The default clock-limit is 99:59:59:00, just under 360000 seconds (see ARDOUR_UI::parameter_changed, clock-display-limit). AudioClock calculates this limit pos as `timepos_t (limit_sec * _session->sample_rate())` This caused an overflow leading to a negative value: ``` timepos_t (359999 * 96000) samples_to_superclock (359999 * 96000, 96000) int_div_round (359999 * 96000 * 282240000, 96000) ``` Ideally this will be optimized, here the sample-rate cancels out, so we could use a c'tor usin seconds. In other cases we could cache the pre-calculated sc_per_sample: `superclock_ticks_per_second() / superclock_t (sr)` which is an integer for all commonly used sample-rates.
This commit is contained in:
parent
dd680926fe
commit
8240875379
@ -47,8 +47,8 @@ static inline superclock_t superclock_ticks_per_second() { if (!scts_set) { rais
|
||||
static inline superclock_t superclock_ticks_per_second() { return _superclock_ticks_per_second; }
|
||||
#endif
|
||||
|
||||
static inline superclock_t superclock_to_samples (superclock_t s, int sr) { return int_div_round (s * sr, superclock_ticks_per_second()); }
|
||||
static inline superclock_t samples_to_superclock (int64_t samples, int sr) { return int_div_round (samples * superclock_ticks_per_second(), superclock_t (sr)); }
|
||||
static inline superclock_t superclock_to_samples (superclock_t s, int sr) { return PBD::muldiv (s, sr, superclock_ticks_per_second()); }
|
||||
static inline superclock_t samples_to_superclock (int64_t samples, int sr) { return PBD::muldiv (samples, superclock_ticks_per_second(), superclock_t (sr)); }
|
||||
|
||||
LIBTEMPORAL_API extern int most_recent_engine_sample_rate;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user