mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-21 23:55:13 -05:00
Remote source: set socket receive buffer size from sample rate in meta data
This commit is contained in:
parent
bb1f833d02
commit
2515f08409
@ -31,7 +31,8 @@ RemoteSourceWorker::RemoteSourceWorker(RemoteDataQueue *dataQueue, QObject* pare
|
||||
m_running(false),
|
||||
m_dataQueue(dataQueue),
|
||||
m_address(QHostAddress::LocalHost),
|
||||
m_socket(nullptr)
|
||||
m_socket(nullptr),
|
||||
m_sampleRate(0)
|
||||
{
|
||||
std::fill(m_dataBlocks, m_dataBlocks+4, (RemoteDataBlock *) 0);
|
||||
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
||||
@ -52,6 +53,7 @@ void RemoteSourceWorker::startWork()
|
||||
{
|
||||
qDebug("RemoteSourceWorker::startWork");
|
||||
m_socket = new QUdpSocket(this);
|
||||
m_socket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, getDataSocketBufferSize(m_sampleRate));
|
||||
m_running = false;
|
||||
}
|
||||
|
||||
@ -99,6 +101,20 @@ void RemoteSourceWorker::readPendingDatagrams()
|
||||
if (size == sizeof(RemoteSuperBlock))
|
||||
{
|
||||
unsigned int dataBlockIndex = superBlock.m_header.m_frameIndex % m_nbDataBlocks;
|
||||
int blockIndex = superBlock.m_header.m_blockIndex;
|
||||
|
||||
if (blockIndex == 0) // first block with meta data
|
||||
{
|
||||
const RemoteMetaDataFEC *metaData = (const RemoteMetaDataFEC *) &superBlock.m_protectedBlock;
|
||||
uint32_t sampleRate = metaData->m_sampleRate;
|
||||
|
||||
if (m_sampleRate != sampleRate)
|
||||
{
|
||||
qDebug("RemoteSourceWorker::readPendingDatagrams: sampleRate: %u", sampleRate);
|
||||
m_socket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, getDataSocketBufferSize(sampleRate));
|
||||
m_sampleRate = sampleRate;
|
||||
}
|
||||
}
|
||||
|
||||
// create the first block for this index
|
||||
if (m_dataBlocks[dataBlockIndex] == 0) {
|
||||
@ -145,3 +161,12 @@ void RemoteSourceWorker::readPendingDatagrams()
|
||||
}
|
||||
}
|
||||
|
||||
int RemoteSourceWorker::getDataSocketBufferSize(uint32_t inSampleRate)
|
||||
{
|
||||
// set a floor value at 24 kS/s
|
||||
uint32_t samplerate = inSampleRate < 24000 ? 24000 : inSampleRate;
|
||||
// 250 ms (1/4s) at current sample rate
|
||||
int bufferSize = (samplerate * 2 * (SDR_RX_SAMP_SZ == 16 ? 2 : 4)) / 4;
|
||||
qDebug("RemoteSourceWorker::getDataSocketBufferSize: %d bytes", bufferSize);
|
||||
return bufferSize;
|
||||
}
|
||||
|
@ -70,8 +70,11 @@ private:
|
||||
QHostAddress m_address;
|
||||
QUdpSocket *m_socket;
|
||||
|
||||
static const uint32_t m_nbDataBlocks = 4; //!< number of data blocks in the ring buffer
|
||||
static const uint32_t m_nbDataBlocks = 4; //!< number of data blocks in the ring buffer
|
||||
RemoteDataBlock *m_dataBlocks[m_nbDataBlocks]; //!< ring buffer of data blocks indexed by frame affinity
|
||||
uint32_t m_sampleRate; //!< current sample rate from meta data
|
||||
|
||||
static int getDataSocketBufferSize(uint32_t inSampleRate);
|
||||
|
||||
private slots:
|
||||
void handleInputMessages();
|
||||
|
Loading…
Reference in New Issue
Block a user