1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

Tx ph.1: fixed sample source FIFO

This commit is contained in:
f4exb 2016-10-23 23:27:19 +02:00
parent f87b714ac7
commit 8f70840561
3 changed files with 554 additions and 551 deletions

View File

@ -178,14 +178,14 @@ void DSPDeviceSinkEngine::work()
if ((m_threadedBasebandSampleSources.size() + m_basebandSampleSources.size()) > 0)
{
for (int is = 0; is < nbWriteSamples; is++, ++writeAt)
for (int is = 0; is < nbWriteSamples; is++)
{
// pull data from threaded sources and merge them in the device sample FIFO
for (ThreadedBasebandSampleSources::iterator it = m_threadedBasebandSampleSources.begin(); it != m_threadedBasebandSampleSources.end(); ++it)
{
(*it)->pull(s);
s /= (m_threadedBasebandSampleSources.size() + m_basebandSampleSources.size());
*writeAt += s;
(*writeAt) += s;
}
// pull data from direct sources and merge them in the device sample FIFO
@ -193,8 +193,10 @@ void DSPDeviceSinkEngine::work()
{
(*it)->pull(s);
s /= (m_threadedBasebandSampleSources.size() + m_basebandSampleSources.size());
*writeAt += s;
(*writeAt) += s;
}
sampleFifo->bumpIndex(writeAt);
}
// feed the mix to the sinks normally just the main spectrum vis

View File

@ -57,14 +57,14 @@ void SampleSourceFifo::read(SampleVector::iterator& beginRead, unsigned int nbSa
}
else if (i_delta > 0)
{
if (i_delta < m_samplesChunkSize)
if (i_delta <= m_samplesChunkSize)
{
emit dataWrite();
}
}
else
{
if (i_delta + m_size < m_samplesChunkSize)
if (i_delta + m_size <= m_samplesChunkSize)
{
emit dataWrite();
}
@ -87,13 +87,14 @@ void SampleSourceFifo::getWriteIterator(SampleVector::iterator& writeAt)
writeAt = m_data.begin() + m_iw;
}
void SampleSourceFifo::bumpIndex()
void SampleSourceFifo::bumpIndex(SampleVector::iterator& writeAt)
{
m_data[m_iw+m_size] = m_data[m_iw];
m_iw = (m_iw+1) % m_size;
{
QMutexLocker mutexLocker(&m_mutex);
m_iw = (m_iw+1) % m_size;
}
writeAt = m_data.begin() + m_iw;
}

View File

@ -38,7 +38,7 @@ public:
void read(SampleVector::iterator& beginRead, unsigned int nbSamples);
void getWriteIterator(SampleVector::iterator& writeAt); //!< get iterator to current item for update - write phase 1
void bumpIndex(); //!< copy current item to second buffer and bump write index - write phase 2
void bumpIndex(SampleVector::iterator& writeAt); //!< copy current item to second buffer and bump write index - write phase 2
void write(const Sample& sample); //!< write directly - phase 1 + phase 2