From d9ef93e7e8cc94da627f39f3c443b9a845ccecf4 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 20 May 2016 15:05:02 +0200 Subject: Refactor OutputUHD, replace double buffering by queue --- src/OutputUHD.h | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'src/OutputUHD.h') diff --git a/src/OutputUHD.h b/src/OutputUHD.h index d55d38e..8cbfb3d 100644 --- a/src/OutputUHD.h +++ b/src/OutputUHD.h @@ -47,9 +47,8 @@ DESCRIPTION: #include #include #include -#include -#include -#include +#include +#include #include #include @@ -58,6 +57,7 @@ DESCRIPTION: #include "EtiReader.h" #include "TimestampDecoder.h" #include "RemoteControl.h" +#include "ThreadsafeQueue.h" #include #include @@ -73,13 +73,19 @@ DESCRIPTION: // frames are too far in the future #define TIMESTAMP_MARGIN_FUTURE 0.5 +// Maximum number of frames that can wait in uwd.frames +#define FRAMES_MAX_SIZE 2 + typedef std::complex complexf; +// Each frame contains one OFDM frame, and its +// associated timestamp struct UHDWorkerFrameData { // Buffer holding frame data - void* buf; + std::vector buf; - // Full timestamp + // A full timestamp contains a TIST according to standard + // and time information within MNSC with tx_second. struct frame_timestamp ts; }; @@ -102,20 +108,13 @@ struct UHDWorkerData { #endif unsigned sampleRate; - // Double buffering between the two threads - // Each buffer contains one OFDM frame, and it's - // associated timestamp - // A full timestamp contains a TIST according to standard - // and time information within MNSC with tx_second. bool sourceContainsTimestamp; // When working with timestamps, mute the frames that // do not have a timestamp bool muteNoTimestamps; - struct UHDWorkerFrameData frame0; - struct UHDWorkerFrameData frame1; - size_t bufsize; // in bytes + ThreadsafeQueue frames; // If we want to verify loss of refclk bool check_refclk_loss; @@ -128,9 +127,6 @@ struct UHDWorkerData { // muting set by remote control bool muting; - // A barrier to synchronise the two threads - std::shared_ptr sync_barrier; - // What to do when the reference clock PLL loses lock refclk_lock_loss_behaviour_t refclk_lock_loss_behaviour; @@ -234,9 +230,7 @@ class OutputUHD: public ModOutput, public RemoteControllable { const char* name() { return "OutputUHD"; } - void setETIReader(EtiReader *etiReader) { - myEtiReader = etiReader; - } + void setETIReader(EtiReader *etiReader); /*********** REMOTE CONTROL ***************/ /* virtual void enrol_at(BaseRemoteController& controller) @@ -264,7 +258,6 @@ class OutputUHD: public ModOutput, public RemoteControllable { bool first_run; bool gps_fix_verified; struct UHDWorkerData uwd; - int activebuffer; private: // Resize the internal delay buffer according to the dabMode and -- cgit v1.2.3