]> git.sesse.net Git - nageru/commitdiff
QueueLengthPolicy::reset() does nothing anymore, so just remove it.
authorSteinar H. Gunderson <steinar+nageru@gunderson.no>
Sun, 23 Aug 2020 19:18:19 +0000 (21:18 +0200)
committerSteinar H. Gunderson <steinar+nageru@gunderson.no>
Sun, 23 Aug 2020 19:18:19 +0000 (21:18 +0200)
In its place, what we often want is to clear the associated jitter history,
so do that instead.

nageru/mixer.cpp
nageru/mixer.h

index 80fcb64a054bf3c2c3c8047dfb28de321e4e3604..191ddb7a50c64d5fd621d986dd452fbc2b0d9aec 100644 (file)
@@ -499,10 +499,6 @@ Mixer::Mixer(const QSurfaceFormat &format)
        }
 #endif
 
-       for (unsigned card_index = 0; card_index < MAX_VIDEO_CARDS; ++card_index) {
-               cards[card_index].queue_length_policy.reset(card_index);
-       }
-
        chroma_subsampler.reset(new ChromaSubsampler(resource_pool.get()));
 
        if (global_flags.ten_bit_input) {
@@ -890,7 +886,7 @@ void Mixer::set_output_card_internal(int card_index)
                card->parked_capture = move(card->capture);
                CaptureInterface *fake_capture = new FakeCapture(global_flags.width, global_flags.height, FAKE_FPS, OUTPUT_FREQUENCY, card_index, global_flags.fake_cards_audio);
                configure_card(card_index, fake_capture, CardType::FAKE_CAPTURE, card->output.release(), /*is_srt_card=*/false);
-               card->queue_length_policy.reset(card_index);
+               card->jitter_history.clear();
                card->capture->start_bm_capture();
                desired_output_video_mode = output_video_mode = card->output->pick_video_mode(desired_output_video_mode);
                card->output->start_output(desired_output_video_mode, pts_int);
@@ -1608,7 +1604,7 @@ void Mixer::handle_hotplugged_cards()
                                fprintf(stderr, "Card %u went away, replacing with a fake card.\n", card_index);
                                FakeCapture *capture = new FakeCapture(global_flags.width, global_flags.height, FAKE_FPS, OUTPUT_FREQUENCY, card_index, global_flags.fake_cards_audio);
                                configure_card(card_index, capture, CardType::FAKE_CAPTURE, /*output=*/nullptr, /*is_srt_card=*/false);
-                               card->queue_length_policy.reset(card_index);
+                               card->jitter_history.clear();
                                card->capture->start_bm_capture();
                        } else {
                                // NOTE: The theme might end up forcing the card back at some later point
@@ -1618,7 +1614,7 @@ void Mixer::handle_hotplugged_cards()
                                fprintf(stderr, "Card %u went away, removing. (To keep a fake card, increase --num-cards.)\n", card_index);
                                theme->remove_card(card_index);
                                configure_card(card_index, /*capture=*/nullptr, CardType::FAKE_CAPTURE, /*output=*/nullptr, /*is_srt_card=*/false);
-                               card->queue_length_policy.reset(card_index);
+                               card->jitter_history.clear();
                        }
                }
        }
@@ -1665,7 +1661,7 @@ void Mixer::handle_hotplugged_cards()
                        CaptureCard *card = &cards[free_card_index];
                        BMUSBCapture *capture = new BMUSBCapture(free_card_index, new_dev);
                        configure_card(free_card_index, capture, CardType::LIVE_CARD, /*output=*/nullptr, /*is_srt_card=*/false);
-                       card->queue_length_policy.reset(free_card_index);
+                       card->jitter_history.clear();
                        capture->set_card_disconnected_callback(bind(&Mixer::bm_hotplug_remove, this, free_card_index));
                        capture->start_bm_capture();
                }
@@ -1721,7 +1717,7 @@ void Mixer::handle_hotplugged_cards()
                        configure_card(free_card_index, capture, CardType::FFMPEG_INPUT, /*output=*/nullptr, /*is_srt_card=*/true);
                        update_srt_stats(sock, card);  // Initial zero stats.
                        card->last_srt_stream_id = stream_id;
-                       card->queue_length_policy.reset(free_card_index);
+                       card->jitter_history.clear();
                        capture->set_card_disconnected_callback(bind(&Mixer::bm_hotplug_remove, this, free_card_index));
                        capture->start_bm_capture();
                }
@@ -1734,7 +1730,7 @@ void Mixer::handle_hotplugged_cards()
                if (card->capture == nullptr && card->force_active) {
                        FakeCapture *capture = new FakeCapture(global_flags.width, global_flags.height, FAKE_FPS, OUTPUT_FREQUENCY, card_index, global_flags.fake_cards_audio);
                        configure_card(card_index, capture, CardType::FAKE_CAPTURE, /*output=*/nullptr, /*is_srt_card=*/false);
-                       card->queue_length_policy.reset(card_index);
+                       card->jitter_history.clear();
                        card->capture->start_bm_capture();
                }
        }
index e382f7755ed31f642513118c8a2b41dbf6c6756e..3ad74f8dd7a878b2f18c9f490104ff96830ca80c 100644 (file)
@@ -132,14 +132,12 @@ private:
 class QueueLengthPolicy {
 public:
        QueueLengthPolicy() {}
-       void reset(unsigned card_index) {
-               this->card_index = card_index;
-       }
 
        void register_metrics(const std::vector<std::pair<std::string, std::string>> &labels);
        void unregister_metrics(const std::vector<std::pair<std::string, std::string>> &labels);
 
        // 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,
                           int64_t input_frame_duration,
@@ -149,7 +147,6 @@ public:
        unsigned get_safe_queue_length() const { return safe_queue_length; }
 
 private:
-       unsigned card_index;  // For debugging and metrics only.
        unsigned safe_queue_length = 0;  // Can never go below zero.
 
        // Metrics.