aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/SDR.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2023-03-30 12:14:49 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2023-03-30 12:14:49 +0200
commit6e5fcb1054c14275ac132d9c68d5259adc3444c9 (patch)
tree1642ae9bb2af04cd906b7e8174a3f736748792db /src/output/SDR.cpp
parentfd46d43f51796a6bbdd629e08535bacbc853f283 (diff)
downloaddabmod-6e5fcb1054c14275ac132d9c68d5259adc3444c9.tar.gz
dabmod-6e5fcb1054c14275ac132d9c68d5259adc3444c9.tar.bz2
dabmod-6e5fcb1054c14275ac132d9c68d5259adc3444c9.zip
SDR: add queued_frames_ms and fix max queue calculation
Diffstat (limited to 'src/output/SDR.cpp')
-rw-r--r--src/output/SDR.cpp33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/output/SDR.cpp b/src/output/SDR.cpp
index a4f5873..99ced7d 100644
--- a/src/output/SDR.cpp
+++ b/src/output/SDR.cpp
@@ -46,8 +46,11 @@ using namespace std;
namespace Output {
-// Maximum number of frames that can wait in frames, when not using synchronised transmission
-static constexpr size_t FRAMES_MAX_SIZE = 8;
+// Maximum number of frames that can wait in frames.
+// Keep it low when not using synchronised transmission, in order to reduce delay.
+// When using synchronised transmission, use a 6s buffer to give us enough margin.
+static constexpr size_t FRAMES_MAX_SIZE_UNSYNC = 8;
+static constexpr size_t FRAMES_MAX_SIZE_SYNC = 250;
// If the timestamp is further in the future than
// 100 seconds, abort
@@ -81,6 +84,7 @@ SDR::SDR(SDRDeviceConfig& config, std::shared_ptr<SDRDevice> device) :
RC_ADD_PARAMETER(frames, "Counter of number of frames modulated");
RC_ADD_PARAMETER(gpsdo_num_sv, "Number of Satellite Vehicles tracked by GPSDO");
RC_ADD_PARAMETER(gpsdo_holdover, "1 if the GPSDO is in holdover, 0 if it is using gnss");
+ RC_ADD_PARAMETER(queued_frames_ms, "Number of frames queued, represented in milliseconds");
#ifdef HAVE_LIMESDR
if (std::dynamic_pointer_cast<Lime>(device)) {
@@ -128,10 +132,6 @@ int SDR::process(Buffer *dataIn)
meta_vec_t SDR::process_metadata(const meta_vec_t& metadataIn)
{
- double frame_duration_s =
- chrono::duration_cast<chrono::milliseconds>(
- transmission_frame_duration(m_config.dabMode)).count() / 1000.0;
-
if (m_device and m_running) {
FrameData frame;
frame.buf = std::move(m_frame);
@@ -169,10 +169,7 @@ meta_vec_t SDR::process_metadata(const meta_vec_t& metadataIn)
}
- const auto max_size = m_config.enableSync ?
- (frame.ts.timestamp_offset * 400.0) / frame_duration_s
- : FRAMES_MAX_SIZE;
-
+ const auto max_size = m_config.enableSync ? FRAMES_MAX_SIZE_SYNC : FRAMES_MAX_SIZE_UNSYNC;
auto r = m_queue.push_overflow(std::move(frame), max_size);
etiLog.log(trace, "SDR,push %d %zu", r.overflowed, r.new_size);
@@ -406,19 +403,10 @@ void SDR::set_parameter(const string& parameter, const string& value)
else if (parameter == "muting") {
ss >> m_config.muting;
}
- else if (parameter == "underruns" or
- parameter == "overruns" or
- parameter == "latepackets" or
- parameter == "frames" or
- parameter == "gpsdo_num_sv" or
- parameter == "gpsdo_holdover" or
- parameter == "fifo_fill") {
- throw ParameterError("Parameter " + parameter + " is read-only.");
- }
else {
stringstream ss_err;
ss_err << "Parameter '" << parameter
- << "' is not exported by controllable " << get_rc_name();
+ << "' is read-only or not exported by controllable " << get_rc_name();
throw ParameterError(ss_err.str());
}
}
@@ -454,6 +442,11 @@ const string SDR::get_parameter(const string& parameter) const
throw ParameterError("Temperature not available");
}
}
+ else if (parameter == "queued_frames_ms") {
+ ss << m_queue.size() *
+ chrono::duration_cast<chrono::milliseconds>(transmission_frame_duration(m_config.dabMode))
+ .count();
+ }
else {
if (m_device) {
const auto stat = m_device->get_run_statistics();