1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

SDRdaemon: updated write data to raw buffer methods

This commit is contained in:
f4exb 2016-01-27 08:40:54 +01:00
parent 2fe57dabae
commit 13d698a940
2 changed files with 24 additions and 24 deletions

View File

@ -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;
}

View File

@ -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)
};