mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-25 04:03:30 -05:00
SDRdaemon: manage data read queue full
This commit is contained in:
parent
8196a70753
commit
b07277a5e2
@ -28,7 +28,8 @@ const uint32_t SDRDaemonDataReadQueue::MaxSize = 20;
|
|||||||
SDRDaemonDataReadQueue::SDRDaemonDataReadQueue() :
|
SDRDaemonDataReadQueue::SDRDaemonDataReadQueue() :
|
||||||
m_dataBlock(0),
|
m_dataBlock(0),
|
||||||
m_blockIndex(1),
|
m_blockIndex(1),
|
||||||
m_sampleIndex(0)
|
m_sampleIndex(0),
|
||||||
|
m_full(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
SDRDaemonDataReadQueue::~SDRDaemonDataReadQueue()
|
SDRDaemonDataReadQueue::~SDRDaemonDataReadQueue()
|
||||||
@ -44,14 +45,21 @@ SDRDaemonDataReadQueue::~SDRDaemonDataReadQueue()
|
|||||||
|
|
||||||
void SDRDaemonDataReadQueue::push(SDRDaemonDataBlock* dataBlock)
|
void SDRDaemonDataReadQueue::push(SDRDaemonDataBlock* dataBlock)
|
||||||
{
|
{
|
||||||
if (size() > MaxSize)
|
if (size() >= MaxSize)
|
||||||
{
|
{
|
||||||
qWarning("SDRDaemonDataReadQueue::push: queue is full");
|
qWarning("SDRDaemonDataReadQueue::push: queue is full");
|
||||||
|
m_full = true; // stop filling the queue
|
||||||
SDRDaemonDataBlock *data = m_dataReadQueue.takeLast();
|
SDRDaemonDataBlock *data = m_dataReadQueue.takeLast();
|
||||||
delete data;
|
delete data;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dataReadQueue.append(dataBlock);
|
if (m_full) {
|
||||||
|
m_full = (size() > MaxSize/2); // do not fill queue again before queue is half size
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_full) {
|
||||||
|
m_dataReadQueue.append(dataBlock);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDRDaemonDataBlock* SDRDaemonDataReadQueue::pop()
|
SDRDaemonDataBlock* SDRDaemonDataReadQueue::pop()
|
||||||
@ -76,7 +84,7 @@ uint32_t SDRDaemonDataReadQueue::size()
|
|||||||
|
|
||||||
void SDRDaemonDataReadQueue::readSample(Sample& s)
|
void SDRDaemonDataReadQueue::readSample(Sample& s)
|
||||||
{
|
{
|
||||||
// initial state
|
// depletion/repletion state
|
||||||
if (m_dataBlock == 0)
|
if (m_dataBlock == 0)
|
||||||
{
|
{
|
||||||
if (size() >= MaxSize/2)
|
if (size() >= MaxSize/2)
|
||||||
|
@ -46,6 +46,7 @@ private:
|
|||||||
SDRDaemonDataBlock *m_dataBlock;
|
SDRDaemonDataBlock *m_dataBlock;
|
||||||
uint32_t m_blockIndex;
|
uint32_t m_blockIndex;
|
||||||
uint32_t m_sampleIndex;
|
uint32_t m_sampleIndex;
|
||||||
|
bool m_full; //!< full condition was hit
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user