summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-11-15 12:31:54 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-11-15 12:36:25 +0100
commit5b1dea7f85749d14bf85114accd01677caae7530 (patch)
tree9b5b11711cc79881876f50d5b400e49755a1cf37 /src
parenta59cb62793534117512666215549d99f9bebd98c (diff)
downloaddabmux-5b1dea7f85749d14bf85114accd01677caae7530.tar.gz
dabmux-5b1dea7f85749d14bf85114accd01677caae7530.tar.bz2
dabmux-5b1dea7f85749d14bf85114accd01677caae7530.zip
Initialise TIST with consistent system time at startup
The change introduced in fd33dd4 (v2.4.0) had the consequence of generating different timestamp offsets depending on when exactly the mux was started. The intended goal to avoid having the NULL symbol output at a fixed offset to avoid receiver synchronisation is however not so important, because most commercial receivers will cut transmission for several seconds before resuming, and the majority of the receivers will then start resynchronising. However, the different timestamp offsets upsets some modulator input modules, which so not necessarily have enough buffering capacity. This change reverts back to the previous behaviour, where the timestamp is set to current system time, rounded to 24ms.
Diffstat (limited to 'src')
-rw-r--r--src/DabMultiplexer.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp
index 9bd3c3f..2bd8d74 100644
--- a/src/DabMultiplexer.cpp
+++ b/src/DabMultiplexer.cpp
@@ -134,24 +134,23 @@ void DabMultiplexer::prepare(bool require_tai_clock)
throw MuxInitException();
}
- /* TODO:
- * In a SFN, when reconfiguring the ensemble, the multiplexer
- * has to be restarted (odr-dabmux doesn't support reconfiguration).
- * Ideally, we must be able to restart transmission s.t. the receiver
- * synchronisation is preserved.
+ /* Ensure edi_time and TIST represent current time. Keep
+ * a granularity of 24ms, which corresponds to the
+ * duration of an ETI frame, to get nicer timestamps.
*/
using Sec = chrono::seconds;
- const auto now = chrono::time_point_cast<Sec>(chrono::system_clock::now());
-
- edi_time = chrono::system_clock::to_time_t(now);
-
- // We define that when the time is multiple of six seconds, the timestamp
- // (PPS offset) is 0. This ensures consistency of TIST even across a
- // mux restart
+ const auto now = chrono::system_clock::now();
+ edi_time = chrono::system_clock::to_time_t(chrono::time_point_cast<Sec>(now));
+ auto offset = now - chrono::time_point_cast<Sec>(now);
+ if (offset >= chrono::seconds(1)) {
+ throw std::logic_error("Invalid startup offset calculation for TIST! " +
+ to_string(chrono::duration_cast<chrono::milliseconds>(offset).count()) +
+ " ms");
+ }
timestamp = 0;
- edi_time -= (edi_time % 6);
- while (edi_time < chrono::system_clock::to_time_t(now)) {
+ while (offset >= chrono::milliseconds(24)) {
increment_timestamp();
+ offset -= chrono::milliseconds(24);
}
// Try to load offset once