X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fmixer.cpp;h=ce8a73237fd4a838ee85ca0c307663d6e3c9edda;hb=ccc8294ad233bf3b85545c15c63100d54e485e63;hp=2fdbf645e876d89cc39022a411d75f2e92016ba3;hpb=91398c6aaab0f999090821577240b94f7bcd6d9d;p=nageru diff --git a/nageru/mixer.cpp b/nageru/mixer.cpp index 2fdbf64..ce8a732 100644 --- a/nageru/mixer.cpp +++ b/nageru/mixer.cpp @@ -234,6 +234,16 @@ void JitterHistory::unregister_metrics(const vector> &label void JitterHistory::frame_arrived(steady_clock::time_point now, int64_t frame_duration, size_t dropped_frames) { + if (frame_duration != last_duration) { + // If the frame rate changed, the input clock is also going to change, + // so our historical data doesn't make much sense anymore. + // Also, format changes typically introduce blips that are not representative + // of the typical frame stream. (We make the assumption that format changes + // don't happen all the time in regular use; if they did, we should probably + // rather keep the history so that we take jitter they may introduce into account.) + clear(); + last_duration = frame_duration; + } if (expected_timestamp > steady_clock::time_point::min()) { expected_timestamp += dropped_frames * nanoseconds(frame_duration * 1000000000 / TIMEBASE); double jitter_seconds = fabs(duration(expected_timestamp - now).count());