diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-01-14 08:46:37 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-01-14 08:46:37 +0100 |
commit | bcf39bd3ff478deae0dcc51f1021ceb8700c22cc (patch) | |
tree | be97bd84040ec6549d1cb278ed6a1d0826f17eaf /src | |
parent | b3d71cdcdad02fb17f7d6e484a3e043def426782 (diff) | |
download | dabmod-bcf39bd3ff478deae0dcc51f1021ceb8700c22cc.tar.gz dabmod-bcf39bd3ff478deae0dcc51f1021ceb8700c22cc.tar.bz2 dabmod-bcf39bd3ff478deae0dcc51f1021ceb8700c22cc.zip |
Fix timestamp handling
Diffstat (limited to 'src')
-rw-r--r-- | src/output/SDR.cpp | 38 | ||||
-rw-r--r-- | src/output/SDR.h | 1 | ||||
-rw-r--r-- | src/output/UHD.cpp | 25 |
3 files changed, 23 insertions, 41 deletions
diff --git a/src/output/SDR.cpp b/src/output/SDR.cpp index ed5da13..a2fb42a 100644 --- a/src/output/SDR.cpp +++ b/src/output/SDR.cpp @@ -260,10 +260,18 @@ void SDR::handle_frame(struct FrameData& frame) } double device_time = m_device->get_real_secs(); - bool timestamp_discontinuity = false; const auto& time_spec = frame.ts; - if (sourceContainsTimestamp) { + if (m_config.enableSync and m_config.muteNoTimestamps and + not time_spec.timestamp_valid) { + sleep_through_frame(); + etiLog.log(info, + "OutputSDR: Muting sample %d : no timestamp\n", + frame.ts.fct); + return; + } + + if (m_config.enableSync and time_spec.timestamp_valid) { // Tx time from MNSC and TIST const uint32_t tx_second = frame.ts.timestamp_sec; const uint32_t tx_pps = frame.ts.timestamp_pps; @@ -305,7 +313,7 @@ void SDR::handle_frame(struct FrameData& frame) tx_second << "+" << (double)tx_pps/16384000.0 << "(" << tx_pps << ")"; - timestamp_discontinuity = true; + frame.ts.timestamp_refresh = true; } } @@ -337,26 +345,14 @@ void SDR::handle_frame(struct FrameData& frame) throw std::runtime_error("Timestamp error. Aborted."); } } - else { // !sourceContainsTimestamp - if (m_config.muting or m_config.muteNoTimestamps) { - /* There was some error decoding the timestamp */ - if (m_config.muting) { - etiLog.log(info, - "OutputSDR: Muting sample %d requested\n", - frame.ts.fct); - } - else { - etiLog.log(info, - "OutputSDR: Muting sample %d : no timestamp\n", - frame.ts.fct); - } - return; - } - } - if (timestamp_discontinuity) { - frame.ts.timestamp_refresh = true; + if (m_config.muting) { + etiLog.log(info, + "OutputSDR: Muting sample %d requested\n", + frame.ts.fct); + return; } + m_device->transmit_frame(frame); } diff --git a/src/output/SDR.h b/src/output/SDR.h index 8affaf9..4c7de5a 100644 --- a/src/output/SDR.h +++ b/src/output/SDR.h @@ -83,7 +83,6 @@ class SDR : public ModOutput, public ModMetadata, public RemoteControllable { std::shared_ptr<DPDFeedbackServer> m_dpd_feedback_server; - bool sourceContainsTimestamp = false; bool last_tx_time_initialised = false; uint32_t last_tx_second = 0; uint32_t last_tx_pps = 0; diff --git a/src/output/UHD.cpp b/src/output/UHD.cpp index 0d46360..97cf5bb 100644 --- a/src/output/UHD.cpp +++ b/src/output/UHD.cpp @@ -256,25 +256,12 @@ void UHD::transmit_frame(const struct FrameData& frame) bool tx_allowed = true; - if (m_conf.enableSync) { - if (frame.ts.timestamp_valid) { - uhd::time_spec_t timespec( - frame.ts.timestamp_sec, frame.ts.pps_offset()); - md_tx.time_spec = timespec; - md_tx.has_time_spec = true; - } - else { - if (m_conf.muteNoTimestamps) { - std::this_thread::sleep_for(std::chrono::seconds( - std::lround( - ((double)sizeIn) / - ((double)m_conf.sampleRate)))); - tx_allowed = false; - } - else { - md_tx.has_time_spec = false; - } - } + // muting and mutenotimestamp is handled by SDR + if (m_conf.enableSync and frame.ts.timestamp_valid) { + uhd::time_spec_t timespec( + frame.ts.timestamp_sec, frame.ts.pps_offset()); + md_tx.time_spec = timespec; + md_tx.has_time_spec = true; } else { md_tx.has_time_spec = false; |