fix(vrtsim): handle CLOCK_REALTIME jump after PTP sync

Signed-off-by: Bartosz Podrygajlo <bartosz.podrygajlo@openairinterface.org>
This commit is contained in:
Bartosz Podrygajlo
2026-05-25 15:58:04 +02:00
parent 0a097fcedd
commit b82dd47d03

View File

@@ -271,12 +271,14 @@ static void *vrtsim_timing_job(void *arg)
LOG_E(UTIL, "clock_gettime failed\n");
exit(1);
}
uint64_t diff = (current_time.tv_sec - vrtsim_state->start_ts.tv_sec) * 1000000000
int64_t diff = (current_time.tv_sec - vrtsim_state->start_ts.tv_sec) * 1000000000
+ (current_time.tv_nsec - vrtsim_state->start_ts.tv_nsec);
double sample_index = vrtsim_state->sample_rate * vrtsim_state->timescale * diff / 1e9;
int64_t samples_to_produce = sample_index - last_sample_index;
shm_td_iq_channel_produce_samples(vrtsim_state->channel, samples_to_produce);
last_sample_index = sample_index;
if (samples_to_produce > 0) {
shm_td_iq_channel_produce_samples(vrtsim_state->channel, samples_to_produce);
last_sample_index = sample_index;
}
usleep(1);
}
return 0;