]> git.sesse.net Git - nageru/commitdiff
Fix a typo/thinko in the five-frames-ahead logic.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 4 Jul 2017 20:37:36 +0000 (22:37 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 4 Jul 2017 20:37:36 +0000 (22:37 +0200)
mixer.cpp
mixer.h

index ce00bd41a3454fbfaa579349fa4f4b75c59a6beb..7bfa009ca5ee49befa636859fcbbe3237767f886 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -256,10 +256,12 @@ void QueueLengthPolicy::unregister_metrics(const vector<pair<string, string>> &l
 
 void QueueLengthPolicy::update_policy(steady_clock::time_point now,
                                       steady_clock::time_point expected_next_frame,
+                                      int64_t input_frame_duration,
                                       int64_t master_frame_duration,
                                       double max_input_card_jitter_seconds,
                                       double max_master_card_jitter_seconds)
 {
+       double input_frame_duration_seconds = input_frame_duration / double(TIMEBASE);
        double master_frame_duration_seconds = master_frame_duration / double(TIMEBASE);
 
        // Figure out when we can expect the next frame for this card, assuming
@@ -279,8 +281,8 @@ void QueueLengthPolicy::update_policy(steady_clock::time_point now,
        // We account for this by looking at the situation five frames ahead,
        // assuming everything else is the same.
        double frames_allowed;
-       if (max_master_card_jitter_seconds < max_input_card_jitter_seconds) {
-               frames_allowed = frames_needed + 5 * (max_input_card_jitter_seconds - max_master_card_jitter_seconds) / master_frame_duration_seconds;
+       if (master_frame_duration < input_frame_duration) {
+               frames_allowed = frames_needed + 5 * (input_frame_duration_seconds - master_frame_duration_seconds) / master_frame_duration_seconds;
        } else {
                frames_allowed = frames_needed;
        }
@@ -1206,6 +1208,7 @@ start:
                        card->queue_length_policy.update_policy(
                                output_frame_info.frame_timestamp,
                                card->jitter_history.get_expected_next_frame(),
+                               new_frames[master_card_index].length,
                                output_frame_info.frame_duration,
                                card->jitter_history.estimate_max_jitter(),
                                output_jitter_history.estimate_max_jitter());
diff --git a/mixer.h b/mixer.h
index ace60701f5adda9af5fa4422ce77eee2ebdebefc..572b26fcf97ef54179edddec6bcb8489ad3683bf 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -139,6 +139,7 @@ public:
        // Call after picking out a frame, so 0 means starvation.
        void update_policy(std::chrono::steady_clock::time_point now,
                           std::chrono::steady_clock::time_point expected_next_frame,
+                          int64_t input_frame_duration,
                           int64_t master_frame_duration,
                           double max_input_card_jitter_seconds,
                           double max_master_card_jitter_seconds);