diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-10-01 12:08:55 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-10-01 12:08:55 +0200 |
commit | 5ea9d01de68fc9d0f4c6578d41b09bfe541ea20f (patch) | |
tree | e4222f33fdc777ad983f45acaefec6f426222b2f /src/input | |
parent | c5185cbf27cc01d0f097254d6a8e762a13281f52 (diff) | |
download | dabmux-5ea9d01de68fc9d0f4c6578d41b09bfe541ea20f.tar.gz dabmux-5ea9d01de68fc9d0f4c6578d41b09bfe541ea20f.tar.bz2 dabmux-5ea9d01de68fc9d0f4c6578d41b09bfe541ea20f.zip |
EDI input: fix timestamped frame read
Diffstat (limited to 'src/input')
-rw-r--r-- | src/input/Edi.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/input/Edi.cpp b/src/input/Edi.cpp index ec0f17b..4a499e1 100644 --- a/src/input/Edi.cpp +++ b/src/input/Edi.cpp @@ -257,9 +257,7 @@ size_t Edi::readFrame(uint8_t *buffer, size_t size, std::time_t seconds, int utc } } else { - EdiDecoder::sti_frame_t sti_frame; - m_frames.try_pop(sti_frame); - if (sti_frame.frame.empty()) { + if (m_pending_sti_frame.frame.empty()) { etiLog.level(warn) << "EDI input " << m_name << " empty, re-enabling pre-buffering"; memset(buffer, 0, size); @@ -267,10 +265,11 @@ size_t Edi::readFrame(uint8_t *buffer, size_t size, std::time_t seconds, int utc m_is_prebuffering = true; return 0; } - else if (not sti_frame.timestamp.valid()) { + else if (not m_pending_sti_frame.timestamp.valid()) { etiLog.level(warn) << "EDI input " << m_name << " invalid timestamp, ignoring"; memset(buffer, 0, size); + m_pending_sti_frame.frame.clear(); m_stats.notifyUnderrun(); return 0; } @@ -281,21 +280,23 @@ size_t Edi::readFrame(uint8_t *buffer, size_t size, std::time_t seconds, int utc if (offset > 24e-3) { m_stats.notifyUnderrun(); m_is_prebuffering = true; + m_pending_sti_frame.frame.clear(); etiLog.level(warn) << "EDI input " << m_name << " timestamp out of bounds, re-enabling pre-buffering"; memset(buffer, 0, size); return 0; } else { - if (not sti_frame.version_data.version.empty()) { + if (not m_pending_sti_frame.version_data.version.empty()) { m_stats.notifyVersion( - sti_frame.version_data.version, - sti_frame.version_data.uptime_s); + m_pending_sti_frame.version_data.version, + m_pending_sti_frame.version_data.uptime_s); } - m_stats.notifyPeakLevels(sti_frame.audio_levels.left, - sti_frame.audio_levels.right); - copy(sti_frame.frame.cbegin(), sti_frame.frame.cend(), buffer); + m_stats.notifyPeakLevels(m_pending_sti_frame.audio_levels.left, + m_pending_sti_frame.audio_levels.right); + copy(m_pending_sti_frame.frame.cbegin(), m_pending_sti_frame.frame.cend(), buffer); + m_pending_sti_frame.frame.clear(); return size; } } |