summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-07-24 16:30:28 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-07-24 16:30:28 +0200
commit47c0abb544590f7a3472c36dc1d405265235e3bb (patch)
tree81b57b10d8bf4ddea52093a6c37da273ab9aa09b /src
parent7dbb538a3ea139c0f8eecb06e260628572994496 (diff)
downloaddabmux-47c0abb544590f7a3472c36dc1d405265235e3bb.tar.gz
dabmux-47c0abb544590f7a3472c36dc1d405265235e3bb.tar.bz2
dabmux-47c0abb544590f7a3472c36dc1d405265235e3bb.zip
Check if a FIG has changed its rate before sorting the FIGs
Diffstat (limited to 'src')
-rw-r--r--src/fig/FIGCarousel.cpp28
-rw-r--r--src/fig/FIGCarousel.h17
2 files changed, 40 insertions, 5 deletions
diff --git a/src/fig/FIGCarousel.cpp b/src/fig/FIGCarousel.cpp
index 415f197..390dcf3 100644
--- a/src/fig/FIGCarousel.cpp
+++ b/src/fig/FIGCarousel.cpp
@@ -55,6 +55,22 @@ void FIGCarouselElement::increase_deadline()
deadline = rate_increment_ms(fig->repetition_rate());
}
+bool FIGCarouselElement::check_deadline()
+{
+ const auto new_rate = fig->repetition_rate();
+ const bool rate_changed = (m_last_rate != new_rate);
+
+ if (rate_changed) {
+ const auto new_deadline = rate_increment_ms(new_rate);
+ if (deadline > new_deadline) {
+ deadline = new_deadline;
+ }
+ m_last_rate = new_rate;
+ }
+
+ return rate_changed;
+}
+
/**************** FIGCarousel *****************/
@@ -211,6 +227,18 @@ size_t FIGCarousel::carousel(
sorted_figs.push_back(&fig);
}
+ /* Some FIGs might have changed rate since we last
+ * set the deadline */
+ for (auto& fig : sorted_figs) {
+ if (fig->check_deadline()) {
+#if CAROUSELDEBUG
+ std::cerr << " FIG" << fig->fig->figtype() << "/" <<
+ fig->fig->figextension() << " deadline changed" <<
+ std::endl;
+#endif
+ }
+ }
+
/* Sort the FIGs in the FIB according to their deadline */
std::sort(sorted_figs.begin(), sorted_figs.end(),
[]( const FIGCarouselElement* left,
diff --git a/src/fig/FIGCarousel.h b/src/fig/FIGCarousel.h
index 5e102ad..ac0574d 100644
--- a/src/fig/FIGCarousel.h
+++ b/src/fig/FIGCarousel.h
@@ -39,13 +39,20 @@
namespace FIC {
-struct FIGCarouselElement {
- IFIG* fig;
- int deadline; // unit: ms
+class FIGCarouselElement {
+ public:
+ IFIG* fig;
+ int deadline; // unit: ms
+
+ void reduce_deadline();
+ void increase_deadline();
- void reduce_deadline(void);
+ /* Returns true if the repetition rate changed and the
+ * deadline was recalculated */
+ bool check_deadline();
- void increase_deadline(void);
+ private:
+ FIG_rate m_last_rate = FIG_rate::A;
};
enum class FIBAllocation {