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

pull/127/head
f4exb 2018-01-02 01:33:09 +01:00
rodzic b731ff851a
commit 420ef78ad5
4 zmienionych plików z 42 dodań i 8 usunięć

Wyświetl plik

@ -20,7 +20,8 @@
BasebandSampleSource::BasebandSampleSource() :
m_guiMessageQueue(0),
m_sampleFifo(48000) // arbitrary, will be adjusted to match device sink FIFO size
m_sampleFifo(48000), // arbitrary, will be adjusted to match device sink FIFO size
m_deviceSampleFifo(0)
{
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
connect(&m_sampleFifo, SIGNAL(dataWrite(int)), this, SLOT(handleWriteToFifo(int)));
@ -44,16 +45,41 @@ void BasebandSampleSource::handleInputMessages()
}
void BasebandSampleSource::handleWriteToFifo(int nbSamples)
{
handleWriteToFifo(&m_sampleFifo, nbSamples);
}
void BasebandSampleSource::handleWriteToDeviceFifo(int nbSamples)
{
handleWriteToFifo(m_deviceSampleFifo, nbSamples);
}
void BasebandSampleSource::handleWriteToFifo(SampleSourceFifo *sampleFifo, int nbSamples)
{
SampleVector::iterator writeAt;
m_sampleFifo.getWriteIterator(writeAt);
sampleFifo->getWriteIterator(writeAt);
pullAudio(nbSamples); // Pre-fetch input audio samples this is mandatory to keep things running smoothly
for (int i = 0; i < nbSamples; i++)
{
pull((*writeAt));
m_sampleFifo.bumpIndex(writeAt);
sampleFifo->bumpIndex(writeAt);
}
}
void BasebandSampleSource::setDeviceSampleSourceFifo(SampleSourceFifo *deviceSampleFifo)
{
if (m_deviceSampleFifo != deviceSampleFifo)
{
if (m_deviceSampleFifo) {
disconnect(m_deviceSampleFifo, SIGNAL(dataWrite(int)), this, SLOT(handleWriteToDeviceFifo(int)));
}
if (deviceSampleFifo) {
connect(deviceSampleFifo, SIGNAL(dataWrite(int)), this, SLOT(handleWriteToDeviceFifo(int)));
}
m_deviceSampleFifo = deviceSampleFifo;
}
}

Wyświetl plik

@ -58,15 +58,20 @@ public:
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; }
void setDeviceSampleSourceFifo(SampleSourceFifo *deviceSampleFifo);
protected:
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
MessageQueue *m_guiMessageQueue; //!< Input message queue to the GUI
SampleSourceFifo m_sampleFifo; //!< Internal FIFO for multi-channel processing
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
MessageQueue *m_guiMessageQueue; //!< Input message queue to the GUI
SampleSourceFifo m_sampleFifo; //!< Internal FIFO for multi-channel processing
SampleSourceFifo *m_deviceSampleFifo; //!< Reference to the device FIFO for single channel processing
void handleWriteToFifo(SampleSourceFifo *sampleFifo, int nbSamples);
protected slots:
void handleInputMessages();
void handleWriteToFifo(int nbSamples);
void handleWriteToDeviceFifo(int nbSamples);
};
#endif /* SDRBASE_DSP_BASEBANDSAMPLESOURCE_H_ */

Wyświetl plik

@ -179,9 +179,9 @@ void DSPDeviceSinkEngine::work(int nbWriteSamples)
{
// qDebug("DSPDeviceSinkEngine::work: single channel source handling");
if (m_threadedBasebandSampleSources.size() == 1) {
m_threadedBasebandSampleSources.back()->feed(sampleFifo, nbWriteSamples);
m_threadedBasebandSampleSources.back()->setDeviceSampleSourceFifo(sampleFifo);
} else if (m_basebandSampleSources.size() == 1) {
m_basebandSampleSources.back()->feed(sampleFifo, nbWriteSamples);
m_threadedBasebandSampleSources.back()->setDeviceSampleSourceFifo(sampleFifo);
}
}
// multiple channel sources handling
@ -257,11 +257,13 @@ void DSPDeviceSinkEngine::work(int nbWriteSamples)
for (ThreadedBasebandSampleSources::iterator it = m_threadedBasebandSampleSources.begin(); it != m_threadedBasebandSampleSources.end(); ++it)
{
(*it)->setDeviceSampleSourceFifo(0);
(*it)->pullAudio(nbWriteSamples);
}
for (BasebandSampleSources::iterator it = m_basebandSampleSources.begin(); it != m_basebandSampleSources.end(); ++it)
{
(*it)->setDeviceSampleSourceFifo(0);
(*it)->pullAudio(nbWriteSamples);
}

Wyświetl plik

@ -51,6 +51,7 @@ public:
int nbSamples);
SampleSourceFifo& getSampleSourceFifo() { return m_basebandSampleSource->getSampleSourceFifo(); }
void setDeviceSampleSourceFifo(SampleSourceFifo *deviceSampleFifo) { m_basebandSampleSource->setDeviceSampleSourceFifo(deviceSampleFifo); }
QString getSampleSourceObjectName() const;