diff --git a/src/modules/module-rtp/audio.c b/src/modules/module-rtp/audio.c index 5ea16d1eb..2c56a70b9 100644 --- a/src/modules/module-rtp/audio.c +++ b/src/modules/module-rtp/audio.c @@ -521,7 +521,17 @@ static void rtp_audio_process_capture(void *data) impl->refilling = true; } } else { - if (SPA_ABS((int)expected_timestamp - (int)actual_timestamp) > (int)quantum) { + if (SPA_FLAG_IS_SET(pos->clock.flags, SPA_IO_CLOCK_FLAG_DISCONT)) { + pw_log_info("IO clock reports discontinuity; resynchronizing"); + impl->have_sync = false; + } else if (SPA_ABS((int64_t)expected_timestamp - (int64_t)actual_timestamp) > (int64_t)(pos->clock.duration)) { + /* Normally, expected and actual timestamp should be in sync, and deviate + * only minimally at most. If a major deviation occurs, then most likely + * the driver clock has experienced an unexpected jump. Note that the + * cycle duration in samples is used, and not the value of "quantum". + * That value is given in nanoseconds, not samples. Also, the timestamps + * themselves are not affected by rate_diff. See the documentation + * "Driver architecture and workflow" for an explanation why not. */ pw_log_warn("timestamp: expected %u != actual %u", expected_timestamp, actual_timestamp); impl->have_sync = false; } else if (filled + wanted > (int32_t)SPA_MIN(impl->target_buffer * 8, BUFFER_SIZE / stride)) {