From 458767aa45c1783e269609dd61230a7f5262ccab Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 26 Jan 2016 08:27:45 +0100 Subject: [PATCH] SDRdaemon plugin: changed sample buffer to raw format (uint8_t) --- .../sdrdaemon/sdrdaemonbuffer.cpp | 21 +++++++++++++++---- .../samplesource/sdrdaemon/sdrdaemonbuffer.h | 17 +++++++++------ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.cpp b/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.cpp index a468eaa1f..8017e630f 100644 --- a/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.cpp +++ b/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.cpp @@ -31,7 +31,11 @@ SDRdaemonBuffer::SDRdaemonBuffer(std::size_t blockSize) : m_nbDecodes(0), m_nbSuccessfulDecodes(0), m_nbCRCOK(0), - m_dataCRC(0) + m_dataCRC(0), + m_sampleRate(1000000), + m_sampleBytes(2), + m_sampleBits(12), + m_rawBuffer(0) { m_buf = new uint8_t[blockSize]; m_currentMeta.init(); @@ -39,6 +43,10 @@ SDRdaemonBuffer::SDRdaemonBuffer(std::size_t blockSize) : SDRdaemonBuffer::~SDRdaemonBuffer() { + if (m_rawBuffer) { + delete[] m_rawBuffer; + } + delete[] m_buf; } @@ -210,6 +218,14 @@ void SDRdaemonBuffer::updateSizes(MetaData *metaData) m_lz4InCount = 0; } +void SDRdaemonBuffer::updateBufferSize() +{ + if (m_rawBuffer) { + delete[] m_rawBuffer; + } + + m_rawBuffer = new uint8_t[m_sampleRate * 2 * m_sampleBytes]; // store 1 second of samples +} void SDRdaemonBuffer::printMeta(MetaData *metaData) { @@ -227,6 +243,3 @@ void SDRdaemonBuffer::printMeta(MetaData *metaData) << std::endl; } - - - diff --git a/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.h b/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.h index 01757f8ac..7f90e2168 100644 --- a/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.h +++ b/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.h @@ -69,6 +69,7 @@ public: private: bool writeAndReadLZ4(uint8_t *array, std::size_t length, uint8_t *data, std::size_t& dataLength); void updateSizes(MetaData *metaData); + void updateBufferSize(); void printMeta(MetaData *metaData); std::size_t m_blockSize; //!< UDP block (payload) size @@ -78,17 +79,21 @@ private: CRC64 m_crc64; //!< CRC64 calculator uint8_t *m_buf; //!< UDP block buffer - uint8_t *m_lz4InBuffer; //!< Buffer for LZ4 compressed input - uint32_t m_lz4InCount; //!< Current position in LZ4 input buffer - uint32_t m_lz4InSize; //!< Size in bytes of the LZ4 input data - uint8_t *m_lz4OutBuffer; //!< Buffer for LZ4 uncompressed output - uint32_t m_lz4OutSize; //!< Size in bytes of the LZ4 output data (original uncomressed data) + uint8_t *m_lz4InBuffer; //!< Buffer for LZ4 compressed input + uint32_t m_lz4InCount; //!< Current position in LZ4 input buffer + uint32_t m_lz4InSize; //!< Size in bytes of the LZ4 input data + uint8_t *m_lz4OutBuffer; //!< Buffer for LZ4 uncompressed output + uint32_t m_lz4OutSize; //!< Size in bytes of the LZ4 output data (original uncomressed data) uint32_t m_nbDecodes; uint32_t m_nbSuccessfulDecodes; uint32_t m_nbCRCOK; uint64_t m_dataCRC; - SampleVector m_convertBuffer; + uint32_t m_sampleRate; //!< Current sample rate in Hz + uint8_t m_sampleBytes; //!< Current number of bytes per I or Q sample + uint8_t m_sampleBits; //!< Current number of effective bits per sample + + uint8_t *m_rawBuffer; //!< Buffer for raw samples obtained from UDP (I/Q not in a formal I/Q structure) };