Tx ph.1: fixed sample source FIFO

pull/27/head
f4exb 2016-10-23 23:27:19 +02:00
rodzic f87b714ac7
commit 8f70840561
3 zmienionych plików z 554 dodań i 551 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -38,7 +38,7 @@ public:
void read(SampleVector::iterator& beginRead, unsigned int nbSamples); void read(SampleVector::iterator& beginRead, unsigned int nbSamples);
void getWriteIterator(SampleVector::iterator& writeAt); //!< get iterator to current item for update - write phase 1 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 void write(const Sample& sample); //!< write directly - phase 1 + phase 2