mirror of https://github.com/f4exb/sdrangel.git
Send number of samples to write in the writeData signal. Ask for half the buffer size when more than half of it is consumed
This commit is contained in:
parent
b3a470efff
commit
441c2c1817
|
@ -168,10 +168,10 @@ QString DSPDeviceSinkEngine::sinkDeviceDescription()
|
||||||
return cmd.getDeviceDescription();
|
return cmd.getDeviceDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPDeviceSinkEngine::work()
|
void DSPDeviceSinkEngine::work(int nbWriteSamples)
|
||||||
{
|
{
|
||||||
SampleSourceFifo* sampleFifo = m_deviceSampleSink->getSampleFifo();
|
SampleSourceFifo* sampleFifo = m_deviceSampleSink->getSampleFifo();
|
||||||
unsigned int nbWriteSamples = sampleFifo->getChunkSize();
|
//unsigned int nbWriteSamples = sampleFifo->getChunkSize();
|
||||||
SampleVector::iterator writeBegin;
|
SampleVector::iterator writeBegin;
|
||||||
sampleFifo->getWriteIterator(writeBegin);
|
sampleFifo->getWriteIterator(writeBegin);
|
||||||
SampleVector::iterator writeAt = writeBegin;
|
SampleVector::iterator writeAt = writeBegin;
|
||||||
|
@ -407,7 +407,7 @@ void DSPDeviceSinkEngine::handleSetSink(DeviceSampleSink* sink)
|
||||||
if(m_deviceSampleSink != 0)
|
if(m_deviceSampleSink != 0)
|
||||||
{
|
{
|
||||||
qDebug("DSPDeviceSinkEngine::handleSetSink: set %s", qPrintable(sink->getDeviceDescription()));
|
qDebug("DSPDeviceSinkEngine::handleSetSink: set %s", qPrintable(sink->getDeviceDescription()));
|
||||||
connect(m_deviceSampleSink->getSampleFifo(), SIGNAL(dataWrite()), this, SLOT(handleData()), Qt::QueuedConnection);
|
connect(m_deviceSampleSink->getSampleFifo(), SIGNAL(dataWrite(int)), this, SLOT(handleData(int)), Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -415,11 +415,11 @@ void DSPDeviceSinkEngine::handleSetSink(DeviceSampleSink* sink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSPDeviceSinkEngine::handleData()
|
void DSPDeviceSinkEngine::handleData(int nbSamples)
|
||||||
{
|
{
|
||||||
if(m_state == StRunning)
|
if(m_state == StRunning)
|
||||||
{
|
{
|
||||||
work();
|
work(nbSamples);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ private:
|
||||||
quint64 m_centerFrequency;
|
quint64 m_centerFrequency;
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
void work(); //!< transfer samples from beseband sources to sink if in running state
|
void work(int nbWriteSamples); //!< transfer samples from beseband sources to sink if in running state
|
||||||
|
|
||||||
State gotoIdle(); //!< Go to the idle state
|
State gotoIdle(); //!< Go to the idle state
|
||||||
State gotoInit(); //!< Go to the acquisition init state from idle
|
State gotoInit(); //!< Go to the acquisition init state from idle
|
||||||
|
@ -115,7 +115,7 @@ private:
|
||||||
void handleSetSink(DeviceSampleSink* sink); //!< Manage sink setting
|
void handleSetSink(DeviceSampleSink* sink); //!< Manage sink setting
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleData(); //!< Handle data when samples from source FIFO are ready to be processed
|
void handleData(int nbSamples); //!< Handle data when samples have to be written to the sample FIFO
|
||||||
void handleInputMessages(); //!< Handle input message queue
|
void handleInputMessages(); //!< Handle input message queue
|
||||||
void handleSynchronousMessages(); //!< Handle synchronous messages with the thread
|
void handleSynchronousMessages(); //!< Handle synchronous messages with the thread
|
||||||
void handleForwardToSpectrumSink(int nbSamples);
|
void handleForwardToSpectrumSink(int nbSamples);
|
||||||
|
|
|
@ -52,7 +52,7 @@ void SampleSourceFifo::init()
|
||||||
|
|
||||||
void SampleSourceFifo::readAdvance(SampleVector::iterator& readUntil, unsigned int nbSamples)
|
void SampleSourceFifo::readAdvance(SampleVector::iterator& readUntil, unsigned int nbSamples)
|
||||||
{
|
{
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
// QMutexLocker mutexLocker(&m_mutex);
|
||||||
assert(nbSamples < m_samplesChunkSize/2);
|
assert(nbSamples < m_samplesChunkSize/2);
|
||||||
|
|
||||||
m_ir = (m_ir + nbSamples) % m_size;
|
m_ir = (m_ir + nbSamples) % m_size;
|
||||||
|
@ -63,21 +63,21 @@ void SampleSourceFifo::readAdvance(SampleVector::iterator& readUntil, unsigned i
|
||||||
|
|
||||||
if (m_init)
|
if (m_init)
|
||||||
{
|
{
|
||||||
emit dataWrite();
|
emit dataWrite(m_size);
|
||||||
m_init = false;
|
m_init = false;
|
||||||
}
|
}
|
||||||
else if (i_delta > 0)
|
else if (i_delta > 0)
|
||||||
{
|
{
|
||||||
if (i_delta <= m_samplesChunkSize)
|
if (i_delta <= m_size/2) // m_samplesChunkSize)
|
||||||
{
|
{
|
||||||
emit dataWrite();
|
emit dataWrite(m_size/2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (i_delta + m_size <= m_samplesChunkSize)
|
if (i_delta + m_size <= m_size/2) //m_samplesChunkSize)
|
||||||
{
|
{
|
||||||
emit dataWrite();
|
emit dataWrite(m_size/2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ void SampleSourceFifo::write(const Sample& sample)
|
||||||
m_data[m_iw+m_size] = sample;
|
m_data[m_iw+m_size] = sample;
|
||||||
|
|
||||||
{
|
{
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
// QMutexLocker mutexLocker(&m_mutex);
|
||||||
m_iw = (m_iw+1) % m_size;
|
m_iw = (m_iw+1) % m_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ void SampleSourceFifo::bumpIndex(SampleVector::iterator& writeAt)
|
||||||
m_data[m_iw+m_size] = m_data[m_iw];
|
m_data[m_iw+m_size] = m_data[m_iw];
|
||||||
|
|
||||||
{
|
{
|
||||||
QMutexLocker mutexLocker(&m_mutex);
|
// QMutexLocker mutexLocker(&m_mutex);
|
||||||
m_iw = (m_iw+1) % m_size;
|
m_iw = (m_iw+1) % m_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ private:
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataWrite(); // signal data is read past a read chunk of samples and write is needed
|
void dataWrite(int nbSamples); // signal data is read past a threshold and writing new samples to fill in is needed
|
||||||
void dataRead(int nbSamples); // signal a read has been done for a number of samples
|
void dataRead(int nbSamples); // signal a read has been done for a number of samples
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue