1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-10-02 09:46:38 -04:00

SDRdaemon plugin: change buffer allocation when sample rate changes

This commit is contained in:
f4exb 2016-02-02 08:21:16 +01:00
parent 1602525e0c
commit 9213cee156
2 changed files with 7 additions and 4 deletions

View File

@ -90,6 +90,7 @@ bool SDRdaemonBuffer::readMeta(char *array, uint32_t length)
{ {
m_sampleBytes = metaData->m_sampleBytes & 0x0F; m_sampleBytes = metaData->m_sampleBytes & 0x0F;
uint32_t frameSize = 2 * 2 * metaData->m_nbSamples * metaData->m_nbBlocks; uint32_t frameSize = 2 * 2 * metaData->m_nbSamples * metaData->m_nbBlocks;
uint32_t sampleRate = metaData->m_sampleRate;
if (metaData->m_sampleBytes & 0x10) if (metaData->m_sampleBytes & 0x10)
{ {
@ -109,9 +110,10 @@ bool SDRdaemonBuffer::readMeta(char *array, uint32_t length)
if (frameSize != m_frameSize) if (frameSize != m_frameSize)
{ {
updateBufferSize(frameSize); updateBufferSize(sampleRate, frameSize);
} }
m_sampleRate = sampleRate;
m_frameSize = frameSize; m_frameSize = frameSize;
m_sync = true; m_sync = true;
} }
@ -267,11 +269,12 @@ void SDRdaemonBuffer::updateLZ4Sizes(uint32_t frameSize)
m_lz4OutBuffer = new uint8_t[frameSize]; m_lz4OutBuffer = new uint8_t[frameSize];
} }
void SDRdaemonBuffer::updateBufferSize(uint32_t frameSize) void SDRdaemonBuffer::updateBufferSize(uint32_t sampleRate, uint32_t frameSize)
{ {
uint32_t nbFrames = ((m_sampleRate * 2 * 2) / frameSize) + 1; // store at least 1 second of samples uint32_t nbFrames = ((sampleRate * 2 * 2) / frameSize) + 1; // store at least 1 second of samples
std::cerr << "SDRdaemonBuffer::updateBufferSize:" std::cerr << "SDRdaemonBuffer::updateBufferSize:"
<< " sampleRate: " << sampleRate
<< " frameSize: " << frameSize << " frameSize: " << frameSize
<< " nbFrames: " << nbFrames << " nbFrames: " << nbFrames
<< std::endl; << std::endl;

View File

@ -76,7 +76,7 @@ private:
void writeDataUncompressed(const char *array, uint32_t length); void writeDataUncompressed(const char *array, uint32_t length);
void writeToRawBufferLZ4(const char *array, uint32_t originalLength); void writeToRawBufferLZ4(const char *array, uint32_t originalLength);
void writeToRawBufferUncompressed(const char *array, uint32_t length); void writeToRawBufferUncompressed(const char *array, uint32_t length);
void updateBufferSize(uint32_t frameSize); void updateBufferSize(uint32_t sampleRate, uint32_t frameSize);
void printMeta(MetaData *metaData); void printMeta(MetaData *metaData);
std::size_t m_blockSize; //!< UDP block (payload) size std::size_t m_blockSize; //!< UDP block (payload) size