Tx support: single channel: make FIFO read and writes truly independent (optimized)

pull/127/head
f4exb 2018-01-02 02:14:31 +01:00
rodzic 420ef78ad5
commit 1056a39983
4 zmienionych plików z 60 dodań i 53 usunięć

Wyświetl plik

@ -31,14 +31,14 @@ MESSAGE_CLASS_DEFINITION(DSPSetSource, Message)
MESSAGE_CLASS_DEFINITION(DSPSetSink, Message)
MESSAGE_CLASS_DEFINITION(DSPAddBasebandSampleSink, Message)
MESSAGE_CLASS_DEFINITION(DSPAddSpectrumSink, Message)
MESSAGE_CLASS_DEFINITION(DSPAddSource, Message)
MESSAGE_CLASS_DEFINITION(DSPAddBasebandSampleSource, Message)
MESSAGE_CLASS_DEFINITION(DSPRemoveBasebandSampleSink, Message)
MESSAGE_CLASS_DEFINITION(DSPRemoveSpectrumSink, Message)
MESSAGE_CLASS_DEFINITION(DSPRemoveSource, Message)
MESSAGE_CLASS_DEFINITION(DSPRemoveBasebandSampleSource, Message)
MESSAGE_CLASS_DEFINITION(DSPAddThreadedBasebandSampleSink, Message)
MESSAGE_CLASS_DEFINITION(DSPAddThreadedSampleSource, Message)
MESSAGE_CLASS_DEFINITION(DSPAddThreadedBasebandSampleSource, Message)
MESSAGE_CLASS_DEFINITION(DSPRemoveThreadedBasebandSampleSink, Message)
MESSAGE_CLASS_DEFINITION(DSPRemoveThreadedSampleSource, Message)
MESSAGE_CLASS_DEFINITION(DSPRemoveThreadedBasebandSampleSource, Message)
MESSAGE_CLASS_DEFINITION(DSPAddAudioSink, Message)
MESSAGE_CLASS_DEFINITION(DSPRemoveAudioSink, Message)
//MESSAGE_CLASS_DEFINITION(DSPConfigureSpectrumVis, Message)

Wyświetl plik

@ -140,11 +140,11 @@ private:
BasebandSampleSink* m_sampleSink;
};
class SDRANGEL_API DSPAddSource : public Message {
class SDRANGEL_API DSPAddBasebandSampleSource : public Message {
MESSAGE_CLASS_DECLARATION
public:
DSPAddSource(BasebandSampleSource* sampleSource) : Message(), m_sampleSource(sampleSource) { }
DSPAddBasebandSampleSource(BasebandSampleSource* sampleSource) : Message(), m_sampleSource(sampleSource) { }
BasebandSampleSource* getSampleSource() const { return m_sampleSource; }
@ -176,11 +176,11 @@ private:
BasebandSampleSink* m_sampleSink;
};
class SDRANGEL_API DSPRemoveSource : public Message {
class SDRANGEL_API DSPRemoveBasebandSampleSource : public Message {
MESSAGE_CLASS_DECLARATION
public:
DSPRemoveSource(BasebandSampleSource* sampleSource) : Message(), m_sampleSource(sampleSource) { }
DSPRemoveBasebandSampleSource(BasebandSampleSource* sampleSource) : Message(), m_sampleSource(sampleSource) { }
BasebandSampleSource* getSampleSource() const { return m_sampleSource; }
@ -200,11 +200,11 @@ private:
ThreadedBasebandSampleSink* m_threadedSampleSink;
};
class SDRANGEL_API DSPAddThreadedSampleSource : public Message {
class SDRANGEL_API DSPAddThreadedBasebandSampleSource : public Message {
MESSAGE_CLASS_DECLARATION
public:
DSPAddThreadedSampleSource(ThreadedBasebandSampleSource* threadedSampleSource) : Message(), m_threadedSampleSource(threadedSampleSource) { }
DSPAddThreadedBasebandSampleSource(ThreadedBasebandSampleSource* threadedSampleSource) : Message(), m_threadedSampleSource(threadedSampleSource) { }
ThreadedBasebandSampleSource* getThreadedSampleSource() const { return m_threadedSampleSource; }
@ -224,11 +224,11 @@ private:
ThreadedBasebandSampleSink* m_threadedSampleSink;
};
class SDRANGEL_API DSPRemoveThreadedSampleSource : public Message {
class SDRANGEL_API DSPRemoveThreadedBasebandSampleSource : public Message {
MESSAGE_CLASS_DECLARATION
public:
DSPRemoveThreadedSampleSource(ThreadedBasebandSampleSource* threadedSampleSource) : Message(), m_threadedSampleSource(threadedSampleSource) { }
DSPRemoveThreadedBasebandSampleSource(ThreadedBasebandSampleSource* threadedSampleSource) : Message(), m_threadedSampleSource(threadedSampleSource) { }
ThreadedBasebandSampleSource* getThreadedSampleSource() const { return m_threadedSampleSource; }

Wyświetl plik

@ -114,28 +114,28 @@ void DSPDeviceSinkEngine::setSinkSequence(int sequence)
void DSPDeviceSinkEngine::addSource(BasebandSampleSource* source)
{
qDebug() << "DSPDeviceSinkEngine::addSource: " << source->objectName().toStdString().c_str();
DSPAddSource cmd(source);
DSPAddBasebandSampleSource cmd(source);
m_syncMessenger.sendWait(cmd);
}
void DSPDeviceSinkEngine::removeSource(BasebandSampleSource* source)
{
qDebug() << "DSPDeviceSinkEngine::removeSource: " << source->objectName().toStdString().c_str();
DSPRemoveSource cmd(source);
DSPRemoveBasebandSampleSource cmd(source);
m_syncMessenger.sendWait(cmd);
}
void DSPDeviceSinkEngine::addThreadedSource(ThreadedBasebandSampleSource* source)
{
qDebug() << "DSPDeviceSinkEngine::addThreadedSource: " << source->objectName().toStdString().c_str();
DSPAddThreadedSampleSource cmd(source);
DSPAddThreadedBasebandSampleSource cmd(source);
m_syncMessenger.sendWait(cmd);
}
void DSPDeviceSinkEngine::removeThreadedSource(ThreadedBasebandSampleSource* source)
{
qDebug() << "DSPDeviceSinkEngine::removeThreadedSource: " << source->objectName().toStdString().c_str();
DSPRemoveThreadedSampleSource cmd(source);
DSPRemoveThreadedBasebandSampleSource cmd(source);
m_syncMessenger.sendWait(cmd);
}
@ -171,21 +171,8 @@ QString DSPDeviceSinkEngine::sinkDeviceDescription()
void DSPDeviceSinkEngine::work(int nbWriteSamples)
{
SampleSourceFifo* sampleFifo = m_deviceSampleSink->getSampleFifo();
//unsigned int nbWriteSamples = sampleFifo->getChunkSize();
// single channel source handling
if ((m_threadedBasebandSampleSources.size() + m_basebandSampleSources.size()) == 1)
{
// qDebug("DSPDeviceSinkEngine::work: single channel source handling");
if (m_threadedBasebandSampleSources.size() == 1) {
m_threadedBasebandSampleSources.back()->setDeviceSampleSourceFifo(sampleFifo);
} else if (m_basebandSampleSources.size() == 1) {
m_threadedBasebandSampleSources.back()->setDeviceSampleSourceFifo(sampleFifo);
}
}
// multiple channel sources handling
else if ((m_threadedBasebandSampleSources.size() + m_basebandSampleSources.size()) > 1)
if ((m_threadedBasebandSampleSources.size() + m_basebandSampleSources.size()) > 1)
{
// qDebug("DSPDeviceSinkEngine::work: multiple channel sources handling: %u", m_multipleSourcesDivisionFactor);
@ -250,6 +237,7 @@ void DSPDeviceSinkEngine::work(int nbWriteSamples)
// }
SampleVector::iterator writeBegin;
SampleSourceFifo* sampleFifo = m_deviceSampleSink->getSampleFifo();
sampleFifo->getWriteIterator(writeBegin);
SampleVector::iterator writeAt = writeBegin;
Sample s;
@ -589,48 +577,38 @@ void DSPDeviceSinkEngine::handleSynchronousMessages()
m_spectrumSink = 0;
}
else if (DSPAddSource::match(*message))
else if (DSPAddBasebandSampleSource::match(*message))
{
BasebandSampleSource* source = ((DSPAddSource*) message)->getSampleSource();
BasebandSampleSource* source = ((DSPAddBasebandSampleSource*) message)->getSampleSource();
m_basebandSampleSources.push_back(source);
// not used with sample by sample processing
// BasebandSampleSourcesIteratorMapKV kv;
// kv.first = source;
// (source->getSampleSourceFifo()).getReadIterator(kv.second);
// m_basebandSampleSourcesIteratorMap.insert(kv);
checkNumberOfBasebandSources();
}
else if (DSPRemoveSource::match(*message))
else if (DSPRemoveBasebandSampleSource::match(*message))
{
BasebandSampleSource* source = ((DSPRemoveSource*) message)->getSampleSource();
BasebandSampleSource* source = ((DSPRemoveBasebandSampleSource*) message)->getSampleSource();
if(m_state == StRunning) {
source->stop();
}
// not used with sample by sample processing
// m_basebandSampleSourcesIteratorMap.erase(source);
m_basebandSampleSources.remove(source);
checkNumberOfBasebandSources();
}
else if (DSPAddThreadedSampleSource::match(*message))
else if (DSPAddThreadedBasebandSampleSource::match(*message))
{
ThreadedBasebandSampleSource *threadedSource = ((DSPAddThreadedSampleSource*) message)->getThreadedSampleSource();
ThreadedBasebandSampleSource *threadedSource = ((DSPAddThreadedBasebandSampleSource*) message)->getThreadedSampleSource();
m_threadedBasebandSampleSources.push_back(threadedSource);
// not used with sample by sample processing
// ThreadedBasebandSampleSourcesIteratorMapKV kv;
// kv.first = threadedSource;
// (threadedSource->getSampleSourceFifo()).getReadIterator(kv.second);
// m_threadedBasebandSampleSourcesIteratorMap.insert(kv);
// threadedSource->start();
checkNumberOfBasebandSources();
}
else if (DSPRemoveThreadedSampleSource::match(*message))
else if (DSPRemoveThreadedBasebandSampleSource::match(*message))
{
ThreadedBasebandSampleSource* threadedSource = ((DSPRemoveThreadedSampleSource*) message)->getThreadedSampleSource();
ThreadedBasebandSampleSource* threadedSource = ((DSPRemoveThreadedBasebandSampleSource*) message)->getThreadedSampleSource();
if (m_state == StRunning) {
threadedSource->stop();
}
// not used with sample by sample processing
// m_threadedBasebandSampleSourcesIteratorMap.erase(threadedSource);
m_threadedBasebandSampleSources.remove(threadedSource);
checkNumberOfBasebandSources();
}
m_syncMessenger.done(m_state);
@ -693,3 +671,31 @@ void DSPDeviceSinkEngine::handleForwardToSpectrumSink(int nbSamples)
m_spectrumSink->feed(readUntil - nbSamples, readUntil, false);
}
}
void DSPDeviceSinkEngine::checkNumberOfBasebandSources()
{
SampleSourceFifo* sampleFifo = m_deviceSampleSink->getSampleFifo();
// single channel source handling
if ((m_threadedBasebandSampleSources.size() + m_basebandSampleSources.size()) == 1)
{
if (m_threadedBasebandSampleSources.size() == 1) {
m_threadedBasebandSampleSources.back()->setDeviceSampleSourceFifo(sampleFifo);
} else if (m_basebandSampleSources.size() == 1) {
m_threadedBasebandSampleSources.back()->setDeviceSampleSourceFifo(sampleFifo);
}
}
// null or multiple channel sources handling
else
{
for (ThreadedBasebandSampleSources::iterator it = m_threadedBasebandSampleSources.begin(); it != m_threadedBasebandSampleSources.end(); ++it)
{
(*it)->setDeviceSampleSourceFifo(0);
}
for (BasebandSampleSources::iterator it = m_basebandSampleSources.begin(); it != m_basebandSampleSources.end(); ++it)
{
(*it)->setDeviceSampleSourceFifo(0);
}
}
}

Wyświetl plik

@ -125,6 +125,7 @@ private:
State gotoError(const QString& errorMsg); //!< Go to an error state
void handleSetSink(DeviceSampleSink* sink); //!< Manage sink setting
void checkNumberOfBasebandSources();
private slots:
void handleData(int nbSamples); //!< Handle data when samples have to be written to the sample FIFO