diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-09-05 17:09:44 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-09-05 17:10:48 +0200 |
commit | 716b3d84adaaa36c9dd8652ec43fc88e760da611 (patch) | |
tree | 0543ad7760e3b76e44ff623eaf07872ecdb9013c /src/input/Edi.cpp | |
parent | 1ed62f38f32b219f1eb7e9e06024f9fa86eb58bc (diff) | |
download | dabmux-716b3d84adaaa36c9dd8652ec43fc88e760da611.tar.gz dabmux-716b3d84adaaa36c9dd8652ec43fc88e760da611.tar.bz2 dabmux-716b3d84adaaa36c9dd8652ec43fc88e760da611.zip |
Fix EDI with timestamping input
Diffstat (limited to 'src/input/Edi.cpp')
-rw-r--r-- | src/input/Edi.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/input/Edi.cpp b/src/input/Edi.cpp index 6e0e683..247c16f 100644 --- a/src/input/Edi.cpp +++ b/src/input/Edi.cpp @@ -155,7 +155,7 @@ size_t Edi::readFrame(uint8_t *buffer, size_t size) } } -size_t Edi::readFrame(uint8_t *buffer, size_t size, uint32_t seconds, uint32_t tsta) +size_t Edi::readFrame(uint8_t *buffer, size_t size, std::time_t seconds, int utco, uint32_t tsta) { if (m_pending_sti_frame.frame.empty()) { m_frames.try_pop(m_pending_sti_frame); @@ -171,12 +171,10 @@ size_t Edi::readFrame(uint8_t *buffer, size_t size, uint32_t seconds, uint32_t t // difference between the input frame timestamp and the requested // timestamp. if (m_pending_sti_frame.timestamp.valid()) { - double ts_frame = (double)m_pending_sti_frame.timestamp.seconds + - (m_pending_sti_frame.timestamp.tsta / 16384000.0); + const auto ts_req = EdiDecoder::frame_timestamp_t::from_unix_epoch(seconds, utco, tsta); + const double offset = m_pending_sti_frame.timestamp.diff_ms(ts_req); - double ts_req = (double)seconds + (tsta / 16384000.0); - - if (std::abs(ts_frame - ts_req) < 24e-3) { + if (offset < 24e-3) { m_is_prebuffering = false; etiLog.level(warn) << "EDI input " << m_name << " valid timestamp, pre-buffering complete"; @@ -226,12 +224,10 @@ size_t Edi::readFrame(uint8_t *buffer, size_t size, uint32_t seconds, uint32_t t return 0; } else { - double ts_frame = (double)sti_frame.timestamp.seconds + - (sti_frame.timestamp.tsta / 16384000.0); - - double ts_req = (double)seconds + (tsta / 16384000.0); + const auto ts_req = EdiDecoder::frame_timestamp_t::from_unix_epoch(seconds, utco, tsta); + const double offset = m_pending_sti_frame.timestamp.diff_ms(ts_req); - if (std::abs(ts_frame - ts_req) > 24e-3) { + if (offset > 24e-3) { m_is_prebuffering = true; etiLog.level(warn) << "EDI input " << m_name << " timestamp out of bounds, re-enabling pre-buffering"; |