mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-29 21:42:26 -04:00
Remote source first fixes
This commit is contained in:
parent
8715f4c037
commit
f7f5f4b2dd
@ -31,6 +31,7 @@ RemoteSourceSource::RemoteSourceSource() :
|
|||||||
connect(&m_dataQueue, SIGNAL(dataBlockEnqueued()), this, SLOT(handleData()), Qt::QueuedConnection);
|
connect(&m_dataQueue, SIGNAL(dataBlockEnqueued()), this, SLOT(handleData()), Qt::QueuedConnection);
|
||||||
m_cm256p = m_cm256.isInitialized() ? &m_cm256 : 0;
|
m_cm256p = m_cm256.isInitialized() ? &m_cm256 : 0;
|
||||||
m_currentMeta.init();
|
m_currentMeta.init();
|
||||||
|
m_dataReadQueue.setSize(50);
|
||||||
applyChannelSettings(m_channelSampleRate, true);
|
applyChannelSettings(m_channelSampleRate, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ void RemoteSourceSource::pull(SampleVector::iterator begin, unsigned int nbSampl
|
|||||||
|
|
||||||
void RemoteSourceSource::pullOne(Sample& sample)
|
void RemoteSourceSource::pullOne(Sample& sample)
|
||||||
{
|
{
|
||||||
m_dataReadQueue.readSample(sample, true); // true is scale for Tx
|
// m_dataReadQueue.readSample(sample, true); // true is scale for Tx
|
||||||
|
|
||||||
Complex ci;
|
Complex ci;
|
||||||
|
|
||||||
@ -130,14 +131,13 @@ void RemoteSourceSource::handleData()
|
|||||||
{
|
{
|
||||||
RemoteDataBlock* dataBlock;
|
RemoteDataBlock* dataBlock;
|
||||||
|
|
||||||
while (m_running && ((dataBlock = m_dataQueue.pop()) != 0)) {
|
while (m_running && ((dataBlock = m_dataQueue.pop()) != nullptr)) {
|
||||||
handleDataBlock(dataBlock);
|
handleDataBlock(dataBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteSourceSource::handleDataBlock(RemoteDataBlock* dataBlock)
|
void RemoteSourceSource::handleDataBlock(RemoteDataBlock* dataBlock)
|
||||||
{
|
{
|
||||||
(void) dataBlock;
|
|
||||||
if (dataBlock->m_rxControlBlock.m_blockCount < RemoteNbOrginalBlocks)
|
if (dataBlock->m_rxControlBlock.m_blockCount < RemoteNbOrginalBlocks)
|
||||||
{
|
{
|
||||||
qWarning("RemoteSourceSource::handleDataBlock: incomplete data block: not processing");
|
qWarning("RemoteSourceSource::handleDataBlock: incomplete data block: not processing");
|
||||||
@ -271,10 +271,11 @@ void RemoteSourceSource::applyChannelSettings(int channelSampleRate, bool force)
|
|||||||
|
|
||||||
if ((channelSampleRate != m_channelSampleRate) || force)
|
if ((channelSampleRate != m_channelSampleRate) || force)
|
||||||
{
|
{
|
||||||
|
uint32_t metaSampleRate = m_currentMeta.m_sampleRate == 0 ? channelSampleRate : m_currentMeta.m_sampleRate;
|
||||||
m_interpolatorDistanceRemain = 0;
|
m_interpolatorDistanceRemain = 0;
|
||||||
m_interpolatorConsumed = false;
|
m_interpolatorConsumed = false;
|
||||||
m_interpolatorDistance = (Real) m_currentMeta.m_sampleRate / (Real) channelSampleRate;
|
m_interpolatorDistance = (Real) metaSampleRate / (Real) channelSampleRate;
|
||||||
m_interpolator.create(48, m_currentMeta.m_sampleRate, m_currentMeta.m_sampleRate / 2.2, 3.0);
|
m_interpolator.create(48, metaSampleRate, metaSampleRate / 2.2, 3.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_channelSampleRate = channelSampleRate;
|
m_channelSampleRate = channelSampleRate;
|
||||||
|
@ -99,7 +99,7 @@ void RemoteSourceWorker::handleInputMessages()
|
|||||||
{
|
{
|
||||||
Message* message;
|
Message* message;
|
||||||
|
|
||||||
while ((message = m_inputMessageQueue.pop()) != 0)
|
while ((message = m_inputMessageQueue.pop()) != nullptr)
|
||||||
{
|
{
|
||||||
if (MsgDataBind::match(*message))
|
if (MsgDataBind::match(*message))
|
||||||
{
|
{
|
||||||
@ -107,6 +107,7 @@ void RemoteSourceWorker::handleInputMessages()
|
|||||||
MsgDataBind* notif = (MsgDataBind*) message;
|
MsgDataBind* notif = (MsgDataBind*) message;
|
||||||
qDebug("RemoteSourceWorker::handleInputMessages: MsgDataBind: %s:%d", qPrintable(notif->getAddress().toString()), notif->getPort());
|
qDebug("RemoteSourceWorker::handleInputMessages: MsgDataBind: %s:%d", qPrintable(notif->getAddress().toString()), notif->getPort());
|
||||||
disconnect(&m_socket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
|
disconnect(&m_socket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
|
||||||
|
m_socket.abort();
|
||||||
m_socket.bind(notif->getAddress(), notif->getPort());
|
m_socket.bind(notif->getAddress(), notif->getPort());
|
||||||
connect(&m_socket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
|
connect(&m_socket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,8 @@
|
|||||||
RemoteDataQueue::RemoteDataQueue(QObject* parent) :
|
RemoteDataQueue::RemoteDataQueue(QObject* parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_lock(QMutex::Recursive),
|
m_lock(QMutex::Recursive),
|
||||||
m_queue()
|
m_queue(),
|
||||||
|
m_count(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ RemoteDataQueue::~RemoteDataQueue()
|
|||||||
{
|
{
|
||||||
RemoteDataBlock* data;
|
RemoteDataBlock* data;
|
||||||
|
|
||||||
while ((data = pop()) != 0)
|
while ((data = pop()) != nullptr)
|
||||||
{
|
{
|
||||||
qDebug() << "RemoteDataQueue::~RemoteDataQueue: data block was still in queue";
|
qDebug() << "RemoteDataQueue::~RemoteDataQueue: data block was still in queue";
|
||||||
delete data;
|
delete data;
|
||||||
@ -50,12 +51,13 @@ void RemoteDataQueue::push(RemoteDataBlock* data, bool emitSignal)
|
|||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
m_lock.lock();
|
m_lock.lock();
|
||||||
m_queue.append(data);
|
m_queue.enqueue(data);
|
||||||
|
m_count++;
|
||||||
|
// qDebug("RemoteDataQueue::push: %d %d", m_count, m_queue.size());
|
||||||
m_lock.unlock();
|
m_lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emitSignal)
|
if (emitSignal) {
|
||||||
{
|
|
||||||
emit dataBlockEnqueued();
|
emit dataBlockEnqueued();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,13 +66,11 @@ RemoteDataBlock* RemoteDataQueue::pop()
|
|||||||
{
|
{
|
||||||
QMutexLocker locker(&m_lock);
|
QMutexLocker locker(&m_lock);
|
||||||
|
|
||||||
if (m_queue.isEmpty())
|
if (m_queue.isEmpty()) {
|
||||||
{
|
return nullptr;
|
||||||
return 0;
|
} else {
|
||||||
}
|
m_count--;
|
||||||
else
|
return m_queue.dequeue();
|
||||||
{
|
|
||||||
return m_queue.takeFirst();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ signals:
|
|||||||
private:
|
private:
|
||||||
QMutex m_lock;
|
QMutex m_lock;
|
||||||
QQueue<RemoteDataBlock*> m_queue;
|
QQueue<RemoteDataBlock*> m_queue;
|
||||||
|
int m_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CHANNEL_REMOTEDATAQUEUE_H_ */
|
#endif /* CHANNEL_REMOTEDATAQUEUE_H_ */
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
const uint32_t RemoteDataReadQueue::MinimumMaxSize = 10;
|
const uint32_t RemoteDataReadQueue::MinimumMaxSize = 10;
|
||||||
|
|
||||||
RemoteDataReadQueue::RemoteDataReadQueue() :
|
RemoteDataReadQueue::RemoteDataReadQueue() :
|
||||||
m_dataBlock(0),
|
m_dataBlock(nullptr),
|
||||||
m_maxSize(MinimumMaxSize),
|
m_maxSize(MinimumMaxSize),
|
||||||
m_blockIndex(1),
|
m_blockIndex(1),
|
||||||
m_sampleIndex(0),
|
m_sampleIndex(0),
|
||||||
@ -40,7 +40,7 @@ RemoteDataReadQueue::~RemoteDataReadQueue()
|
|||||||
{
|
{
|
||||||
RemoteDataBlock* data;
|
RemoteDataBlock* data;
|
||||||
|
|
||||||
while ((data = pop()) != 0)
|
while ((data = pop()) != nullptr)
|
||||||
{
|
{
|
||||||
qDebug("RemoteDataReadQueue::~RemoteDataReadQueue: data block was still in queue");
|
qDebug("RemoteDataReadQueue::~RemoteDataReadQueue: data block was still in queue");
|
||||||
delete data;
|
delete data;
|
||||||
@ -58,11 +58,11 @@ void RemoteDataReadQueue::push(RemoteDataBlock* dataBlock)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_full) {
|
if (m_full) {
|
||||||
m_full = (length() > m_maxSize/2); // do not fill queue again before queue is half size
|
m_full = (length() > m_maxSize/10); // do not fill queue again before queue is half size
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_full) {
|
if (!m_full) {
|
||||||
m_dataReadQueue.append(dataBlock);
|
m_dataReadQueue.enqueue(dataBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,14 +70,14 @@ RemoteDataBlock* RemoteDataReadQueue::pop()
|
|||||||
{
|
{
|
||||||
if (m_dataReadQueue.isEmpty())
|
if (m_dataReadQueue.isEmpty())
|
||||||
{
|
{
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_blockIndex = 1;
|
m_blockIndex = 1;
|
||||||
m_sampleIndex = 0;
|
m_sampleIndex = 0;
|
||||||
|
|
||||||
return m_dataReadQueue.takeFirst();
|
return m_dataReadQueue.dequeue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,13 +91,13 @@ void RemoteDataReadQueue::setSize(uint32_t size)
|
|||||||
void RemoteDataReadQueue::readSample(Sample& s, bool scaleForTx)
|
void RemoteDataReadQueue::readSample(Sample& s, bool scaleForTx)
|
||||||
{
|
{
|
||||||
// depletion/repletion state
|
// depletion/repletion state
|
||||||
if (m_dataBlock == 0)
|
if (m_dataBlock == nullptr)
|
||||||
{
|
{
|
||||||
if (length() >= m_maxSize/2)
|
if (length() >= m_maxSize/10)
|
||||||
{
|
{
|
||||||
qDebug("RemoteDataReadQueue::readSample: initial pop new block: queue size: %u", length());
|
qDebug("RemoteDataReadQueue::readSample: initial pop new block: queue size: %u", length());
|
||||||
m_blockIndex = 1;
|
m_blockIndex = 1;
|
||||||
m_dataBlock = m_dataReadQueue.takeFirst();
|
m_dataBlock = m_dataReadQueue.dequeue();
|
||||||
convertDataToSample(s, m_blockIndex, m_sampleIndex, scaleForTx);
|
convertDataToSample(s, m_blockIndex, m_sampleIndex, scaleForTx);
|
||||||
m_sampleIndex++;
|
m_sampleIndex++;
|
||||||
m_sampleCount++;
|
m_sampleCount++;
|
||||||
@ -133,7 +133,7 @@ void RemoteDataReadQueue::readSample(Sample& s, bool scaleForTx)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete m_dataBlock;
|
delete m_dataBlock;
|
||||||
m_dataBlock = 0;
|
m_dataBlock = nullptr;
|
||||||
|
|
||||||
if (length() == 0) {
|
if (length() == 0) {
|
||||||
qWarning("RemoteDataReadQueue::readSample: try to pop new block but queue is empty");
|
qWarning("RemoteDataReadQueue::readSample: try to pop new block but queue is empty");
|
||||||
@ -141,9 +141,8 @@ void RemoteDataReadQueue::readSample(Sample& s, bool scaleForTx)
|
|||||||
|
|
||||||
if (length() > 0)
|
if (length() > 0)
|
||||||
{
|
{
|
||||||
//qDebug("RemoteDataReadQueue::readSample: pop new block: queue size: %u", length());
|
|
||||||
m_blockIndex = 1;
|
m_blockIndex = 1;
|
||||||
m_dataBlock = m_dataReadQueue.takeFirst();
|
m_dataBlock = m_dataReadQueue.dequeue();
|
||||||
convertDataToSample(s, m_blockIndex, m_sampleIndex, scaleForTx);
|
convertDataToSample(s, m_blockIndex, m_sampleIndex, scaleForTx);
|
||||||
m_sampleIndex++;
|
m_sampleIndex++;
|
||||||
m_sampleCount++;
|
m_sampleCount++;
|
||||||
|
@ -39,7 +39,6 @@ public:
|
|||||||
~RemoteDataReadQueue();
|
~RemoteDataReadQueue();
|
||||||
|
|
||||||
void push(RemoteDataBlock* dataBlock); //!< push block on the queue
|
void push(RemoteDataBlock* dataBlock); //!< push block on the queue
|
||||||
RemoteDataBlock* pop(); //!< Pop block from the queue
|
|
||||||
void readSample(Sample& s, bool scaleForTx = false); //!< Read sample from queue possibly scaling to Tx size
|
void readSample(Sample& s, bool scaleForTx = false); //!< Read sample from queue possibly scaling to Tx size
|
||||||
uint32_t length() const { return m_dataReadQueue.size(); } //!< Returns queue length
|
uint32_t length() const { return m_dataReadQueue.size(); } //!< Returns queue length
|
||||||
uint32_t size() const { return m_maxSize; } //!< Returns queue size (max length)
|
uint32_t size() const { return m_maxSize; } //!< Returns queue size (max length)
|
||||||
@ -57,6 +56,8 @@ private:
|
|||||||
uint32_t m_sampleCount; //!< use a counter capped below 2^31 as it is going to be converted to an int in the web interface
|
uint32_t m_sampleCount; //!< use a counter capped below 2^31 as it is going to be converted to an int in the web interface
|
||||||
bool m_full; //!< full condition was hit
|
bool m_full; //!< full condition was hit
|
||||||
|
|
||||||
|
RemoteDataBlock* pop(); //!< Pop block from the queue
|
||||||
|
|
||||||
inline void convertDataToSample(Sample& s, uint32_t blockIndex, uint32_t sampleIndex, bool scaleForTx)
|
inline void convertDataToSample(Sample& s, uint32_t blockIndex, uint32_t sampleIndex, bool scaleForTx)
|
||||||
{
|
{
|
||||||
int sampleSize = m_dataBlock->m_superBlocks[blockIndex].m_header.m_sampleBytes * 2; // I/Q sample size in data block
|
int sampleSize = m_dataBlock->m_superBlocks[blockIndex].m_header.m_sampleBytes * 2; // I/Q sample size in data block
|
||||||
|
Loading…
x
Reference in New Issue
Block a user