1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-25 04:53:27 -04:00

All modulators: use buffer for input audio that is always in use while generation is running. This fixes lockup problem reported in issue #11

This commit is contained in:
f4exb
2016-12-26 01:39:34 +01:00
parent f5572eebc0
commit e02ac85e50
11 changed files with 131 additions and 79 deletions
+49 -42
View File
@@ -176,7 +176,9 @@ void DSPDeviceSinkEngine::work(int nbWriteSamples)
// single channel source handling
if ((m_threadedBasebandSampleSources.size() + m_basebandSampleSources.size()) == 1)
{
for (ThreadedBasebandSampleSources::iterator it = m_threadedBasebandSampleSources.begin(); it != m_threadedBasebandSampleSources.end(); ++it)
qDebug("DSPDeviceSinkEngine::work: single channel source handling");
for (ThreadedBasebandSampleSources::iterator it = m_threadedBasebandSampleSources.begin(); it != m_threadedBasebandSampleSources.end(); ++it)
{
(*it)->feed(sampleFifo, nbWriteSamples);
}
@@ -189,47 +191,52 @@ void DSPDeviceSinkEngine::work(int nbWriteSamples)
else if ((m_threadedBasebandSampleSources.size() + m_basebandSampleSources.size()) > 1)
{
qDebug("DSPDeviceSinkEngine::work: multiple channel sources handling");
SampleVector::iterator writeBegin;
sampleFifo->getWriteIterator(writeBegin);
SampleVector::iterator writeAt = writeBegin;
Sample s;
int sourceOccurence = 0;
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());
if (sourceOccurence == 0) {
(*writeAt) = s;
} else {
(*writeAt) += s;
}
sourceOccurence++;
}
// pull data from direct sources and merge them in the device sample FIFO
for (BasebandSampleSources::iterator it = m_basebandSampleSources.begin(); it != m_basebandSampleSources.end(); ++it)
{
(*it)->pull(s);
s /= (m_threadedBasebandSampleSources.size() + m_basebandSampleSources.size());
if (sourceOccurence == 0) {
(*writeAt) = s;
} else {
(*writeAt) += s;
}
sourceOccurence++;
}
sampleFifo->bumpIndex(writeAt);
sourceOccurence = 0;
}
// TODO properly
if (m_threadedBasebandSampleSources.size() > 0)
{
(*m_threadedBasebandSampleSources.begin())->feed(sampleFifo, nbWriteSamples);
}
// SampleVector::iterator writeBegin;
// sampleFifo->getWriteIterator(writeBegin);
// SampleVector::iterator writeAt = writeBegin;
// Sample s;
// int sourceOccurence = 0;
//
// 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());
//
// if (sourceOccurence == 0) {
// (*writeAt) = s;
// } else {
// (*writeAt) += s;
// }
//
// sourceOccurence++;
// }
//
// // pull data from direct sources and merge them in the device sample FIFO
// for (BasebandSampleSources::iterator it = m_basebandSampleSources.begin(); it != m_basebandSampleSources.end(); ++it)
// {
// (*it)->pull(s);
// s /= (m_threadedBasebandSampleSources.size() + m_basebandSampleSources.size());
//
// if (sourceOccurence == 0) {
// (*writeAt) = s;
// } else {
// (*writeAt) += s;
// }
//
// sourceOccurence++;
// }
//
// sampleFifo->bumpIndex(writeAt);
// sourceOccurence = 0;
// }
// feed the mix to the main spectrum sink
// if (m_spectrumSink)