mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-08-01 13:32:33 -04:00
SDRdaemon: updated write data to raw buffer methods
This commit is contained in:
parent
2fe57dabae
commit
13d698a940
@ -117,15 +117,35 @@ void SDRdaemonBuffer::writeData(char *array, std::size_t length)
|
|||||||
}
|
}
|
||||||
else
|
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)
|
void SDRdaemonBuffer::writeDataLZ4(char *array, std::size_t length)
|
||||||
{
|
{
|
||||||
if (m_lz4InCount + length < m_lz4InSize)
|
if (m_lz4InCount + length < m_lz4InSize)
|
||||||
{
|
{
|
||||||
|
std::memcpy((void *) &m_lz4InBuffer[m_lz4InCount], (const void *) array, length);
|
||||||
m_lz4InCount += length;
|
m_lz4InCount += length;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -162,31 +182,8 @@ void SDRdaemonBuffer::writeDataLZ4(char *array, std::size_t length)
|
|||||||
|
|
||||||
if (compressedSize == m_lz4InSize)
|
if (compressedSize == m_lz4InSize)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
std::cerr << "SDRdaemonBuffer::writeAndReadLZ4: decoding OK:"
|
|
||||||
<< " read: " << compressedSize
|
|
||||||
<< " expected: " << m_lz4InSize
|
|
||||||
<< " out: " << m_lz4OutSize
|
|
||||||
<< std::endl;
|
|
||||||
*/
|
|
||||||
m_nbSuccessfulDecodes++;
|
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;
|
m_lz4InCount = 0;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void updateLZ4Sizes(uint32_t frameSize);
|
void updateLZ4Sizes(uint32_t frameSize);
|
||||||
void writeDataLZ4(char *array, std::size_t length);
|
void writeDataLZ4(char *array, std::size_t length);
|
||||||
|
void writeDataUncompressed(char *array, std::size_t length);
|
||||||
void updateBufferSize(uint32_t frameSize);
|
void updateBufferSize(uint32_t frameSize);
|
||||||
void printMeta(MetaData *metaData);
|
void printMeta(MetaData *metaData);
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ private:
|
|||||||
MetaData m_currentMeta; //!< Stored current meta data
|
MetaData m_currentMeta; //!< Stored current meta data
|
||||||
CRC64 m_crc64; //!< CRC64 calculator
|
CRC64 m_crc64; //!< CRC64 calculator
|
||||||
|
|
||||||
|
uint32_t m_inCount; //!< Current position of uncompressed input
|
||||||
uint8_t *m_lz4InBuffer; //!< Buffer for LZ4 compressed input
|
uint8_t *m_lz4InBuffer; //!< Buffer for LZ4 compressed input
|
||||||
uint32_t m_lz4InCount; //!< Current position in LZ4 input buffer
|
uint32_t m_lz4InCount; //!< Current position in LZ4 input buffer
|
||||||
uint32_t m_lz4InSize; //!< Size in bytes of the LZ4 input data
|
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_sampleBytes; //!< Current number of bytes per I or Q sample
|
||||||
uint8_t m_sampleBits; //!< Current number of effective bits per 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)
|
uint8_t *m_rawBuffer; //!< Buffer for raw samples obtained from UDP (I/Q not in a formal I/Q structure)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user