From 13d698a9401c26192ce66178faecba90161b2077 Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 27 Jan 2016 08:40:54 +0100 Subject: [PATCH] SDRdaemon: updated write data to raw buffer methods --- .../sdrdaemon/sdrdaemonbuffer.cpp | 45 +++++++++---------- .../samplesource/sdrdaemon/sdrdaemonbuffer.h | 3 ++ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.cpp b/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.cpp index 6e4ee3e1e..7d1db9254 100644 --- a/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.cpp +++ b/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.cpp @@ -117,15 +117,35 @@ void SDRdaemonBuffer::writeData(char *array, std::size_t length) } else { - // TODO: uncompressed case + writeDataUncompressed(array, length); } } } +void SDRdaemonBuffer::writeDataUncompressed(char *array, std::size_t length) +{ + if (m_inCount + length < m_frameSize) + { + std::memcpy((void *) &m_rawBuffer[m_inCount], (const void *) array, length); + m_inCount += length; + } + else + { + std::memcpy((void *) &m_rawBuffer[m_inCount], (const void *) array, m_frameSize - m_inCount); // copy rest of data in compressed Buffer + m_inCount += length; + } + + if (m_inCount >= m_frameSize) // full block retrieved + { + // TODO: to do? + } +} + void SDRdaemonBuffer::writeDataLZ4(char *array, std::size_t length) { if (m_lz4InCount + length < m_lz4InSize) { + std::memcpy((void *) &m_lz4InBuffer[m_lz4InCount], (const void *) array, length); m_lz4InCount += length; } else @@ -162,31 +182,8 @@ void SDRdaemonBuffer::writeDataLZ4(char *array, std::size_t length) if (compressedSize == m_lz4InSize) { - /* - std::cerr << "SDRdaemonBuffer::writeAndReadLZ4: decoding OK:" - << " read: " << compressedSize - << " expected: " << m_lz4InSize - << " out: " << m_lz4OutSize - << std::endl; - */ m_nbSuccessfulDecodes++; } - else - { -// std::cerr << "SDRdaemonBuffer::writeAndReadLZ4: decoding error:" -// << " read: " << compressedSize -// << " expected: " << m_lz4InSize -// << " out: " << m_lz4OutSize -// << std::endl; - - //if (compressedSize > 0) - //{ - //} - //else - //{ - // dataLength = 0; - //} - } m_lz4InCount = 0; } diff --git a/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.h b/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.h index 5aa80202a..b88dc0ace 100644 --- a/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.h +++ b/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.h @@ -71,6 +71,7 @@ public: private: void updateLZ4Sizes(uint32_t frameSize); void writeDataLZ4(char *array, std::size_t length); + void writeDataUncompressed(char *array, std::size_t length); void updateBufferSize(uint32_t frameSize); void printMeta(MetaData *metaData); @@ -80,6 +81,7 @@ private: MetaData m_currentMeta; //!< Stored current meta data CRC64 m_crc64; //!< CRC64 calculator + uint32_t m_inCount; //!< Current position of uncompressed input 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 @@ -94,6 +96,7 @@ private: uint8_t m_sampleBytes; //!< Current number of bytes per I or Q sample uint8_t m_sampleBits; //!< Current number of effective bits per sample + uint32_t m_rawCount; //!< Current position in the raw samples buffer uint8_t *m_rawBuffer; //!< Buffer for raw samples obtained from UDP (I/Q not in a formal I/Q structure) };