]> git.sesse.net Git - nageru/blobdiff - nageru/queue_length_policy.h
Reset jitter history when frame rate changes.
[nageru] / nageru / queue_length_policy.h
index 27259b4c54bb517c83557d277517134f3e301868..0b8a4204fbcf7893d9f323ac6808fb7d66b04824 100644 (file)
@@ -35,6 +35,7 @@ public:
        void clear() {
                history.clear();
                orders.clear();
+               expected_timestamp = std::chrono::steady_clock::time_point::min();
        }
        void frame_arrived(std::chrono::steady_clock::time_point now, int64_t frame_duration, size_t dropped_frames);
        std::chrono::steady_clock::time_point get_expected_next_frame() const { return expected_timestamp; }
@@ -53,6 +54,7 @@ private:
        std::deque<std::multiset<double>::iterator> history;
 
        std::chrono::steady_clock::time_point expected_timestamp = std::chrono::steady_clock::time_point::min();
+       int64_t last_duration = 0;
 
        // Metrics. There are no direct summaries for jitter, since we already have latency summaries.
        std::atomic<int64_t> metric_input_underestimated_jitter_frames{0};
@@ -88,7 +90,7 @@ public:
        // Call after picking out a frame, so 0 means starvation.
        // Note that the policy has no memory; everything is given in as parameters.
        void update_policy(std::chrono::steady_clock::time_point now,
-                          std::chrono::steady_clock::time_point expected_next_frame,
+                          std::chrono::steady_clock::time_point expected_next_input_frame,
                           int64_t input_frame_duration,
                           int64_t master_frame_duration,
                           double max_input_card_jitter_seconds,