mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 16:08:39 -05:00
Tx ph.1: Sample source FIFO read with signal. Use a specific spectrum sink (vis) reference in Device sink engine for main spectrum rendering
This commit is contained in:
parent
7b4032ac0d
commit
289c1a203f
@ -129,7 +129,7 @@ void FileSinkThread::tick()
|
||||
|
||||
SampleVector::iterator beginRead;
|
||||
|
||||
m_sampleFifo->read(beginRead, m_samplesChunkSize);
|
||||
m_sampleFifo->readAndSignal(beginRead, m_samplesChunkSize);
|
||||
m_ofstream->write(reinterpret_cast<char*>(&(*beginRead)), m_samplesChunkSize*4);
|
||||
m_samplesCount += m_samplesChunkSize;
|
||||
}
|
||||
|
@ -42,14 +42,14 @@ DeviceSinkAPI::~DeviceSinkAPI()
|
||||
{
|
||||
}
|
||||
|
||||
void DeviceSinkAPI::addSink(BasebandSampleSink *sink)
|
||||
void DeviceSinkAPI::addSpectrumSink(BasebandSampleSink *spectrumSink)
|
||||
{
|
||||
m_deviceSinkEngine->addSink(sink);
|
||||
m_deviceSinkEngine->addSpectrumSink(spectrumSink);
|
||||
}
|
||||
|
||||
void DeviceSinkAPI::removeSink(BasebandSampleSink* sink)
|
||||
void DeviceSinkAPI::removeSpectrumSink(BasebandSampleSink* spectrumSink)
|
||||
{
|
||||
m_deviceSinkEngine->removeSink(sink);
|
||||
m_deviceSinkEngine->removeSpectrumSink(spectrumSink);
|
||||
}
|
||||
|
||||
void DeviceSinkAPI::addSource(BasebandSampleSource *source)
|
||||
|
@ -41,8 +41,8 @@ class SDRANGEL_API DeviceSinkAPI : public QObject {
|
||||
|
||||
public:
|
||||
// Device engine stuff
|
||||
void addSink(BasebandSampleSink* sink); //!< Add a sample sink to device engine (spectrum vis)
|
||||
void removeSink(BasebandSampleSink* sink); //!< Remove a sample sink from device engine (spectrum vis)
|
||||
void addSpectrumSink(BasebandSampleSink* sink); //!< Add the spectrum sample sink to device engine (spectrum vis)
|
||||
void removeSpectrumSink(BasebandSampleSink* sink); //!< Remove the spectrum sample sink from device engine (spectrum vis)
|
||||
void addSource(BasebandSampleSource* source); //!< Add a baseband sample source to device engine
|
||||
void removeSource(BasebandSampleSource* sink); //!< Remove a baseband sample source from device engine
|
||||
void addThreadedSource(ThreadedBasebandSampleSource* sink); //!< Add a baseband sample source that will run on its own thread to device engine
|
||||
|
@ -30,8 +30,10 @@ MESSAGE_CLASS_DEFINITION(DSPGetErrorMessage, Message)
|
||||
MESSAGE_CLASS_DEFINITION(DSPSetSource, Message)
|
||||
MESSAGE_CLASS_DEFINITION(DSPSetSink, Message)
|
||||
MESSAGE_CLASS_DEFINITION(DSPAddSink, Message)
|
||||
MESSAGE_CLASS_DEFINITION(DSPAddSpectrumSink, Message)
|
||||
MESSAGE_CLASS_DEFINITION(DSPAddSource, Message)
|
||||
MESSAGE_CLASS_DEFINITION(DSPRemoveSink, Message)
|
||||
MESSAGE_CLASS_DEFINITION(DSPRemoveSpectrumSink, Message)
|
||||
MESSAGE_CLASS_DEFINITION(DSPRemoveSource, Message)
|
||||
MESSAGE_CLASS_DEFINITION(DSPAddThreadedSampleSink, Message)
|
||||
MESSAGE_CLASS_DEFINITION(DSPAddThreadedSampleSource, Message)
|
||||
|
@ -128,6 +128,18 @@ private:
|
||||
BasebandSampleSink* m_sampleSink;
|
||||
};
|
||||
|
||||
class SDRANGEL_API DSPAddSpectrumSink : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
DSPAddSpectrumSink(BasebandSampleSink* sampleSink) : Message(), m_sampleSink(sampleSink) { }
|
||||
|
||||
BasebandSampleSink* getSampleSink() const { return m_sampleSink; }
|
||||
|
||||
private:
|
||||
BasebandSampleSink* m_sampleSink;
|
||||
};
|
||||
|
||||
class SDRANGEL_API DSPAddSource : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
@ -152,6 +164,18 @@ private:
|
||||
BasebandSampleSink* m_sampleSink;
|
||||
};
|
||||
|
||||
class SDRANGEL_API DSPRemoveSpectrumSink : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
DSPRemoveSpectrumSink(BasebandSampleSink* sampleSink) : Message(), m_sampleSink(sampleSink) { }
|
||||
|
||||
BasebandSampleSink* getSampleSink() const { return m_sampleSink; }
|
||||
|
||||
private:
|
||||
BasebandSampleSink* m_sampleSink;
|
||||
};
|
||||
|
||||
class SDRANGEL_API DSPRemoveSource : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
|
@ -35,6 +35,7 @@ DSPDeviceSinkEngine::DSPDeviceSinkEngine(uint uid, QObject* parent) :
|
||||
m_deviceSampleSink(0),
|
||||
m_sampleSinkSequence(0),
|
||||
m_basebandSampleSources(),
|
||||
m_spectrumSink(0),
|
||||
m_sampleRate(0),
|
||||
m_centerFrequency(0)
|
||||
{
|
||||
@ -137,17 +138,17 @@ void DSPDeviceSinkEngine::removeThreadedSource(ThreadedBasebandSampleSource* sou
|
||||
m_syncMessenger.sendWait(cmd);
|
||||
}
|
||||
|
||||
void DSPDeviceSinkEngine::addSink(BasebandSampleSink* sink)
|
||||
void DSPDeviceSinkEngine::addSpectrumSink(BasebandSampleSink* spectrumSink)
|
||||
{
|
||||
qDebug() << "DSPDeviceSinkEngine::addSink: " << sink->objectName().toStdString().c_str();
|
||||
DSPAddSink cmd(sink);
|
||||
qDebug() << "DSPDeviceSinkEngine::addSpectrumSink: " << spectrumSink->objectName().toStdString().c_str();
|
||||
DSPAddSpectrumSink cmd(spectrumSink);
|
||||
m_syncMessenger.sendWait(cmd);
|
||||
}
|
||||
|
||||
void DSPDeviceSinkEngine::removeSink(BasebandSampleSink* sink)
|
||||
void DSPDeviceSinkEngine::removeSpectrumSink(BasebandSampleSink* spectrumSink)
|
||||
{
|
||||
qDebug() << "DSPDeviceSinkEngine::removeSink: " << sink->objectName().toStdString().c_str();
|
||||
DSPRemoveSink cmd(sink);
|
||||
qDebug() << "DSPDeviceSinkEngine::removeSpectrumSink: " << spectrumSink->objectName().toStdString().c_str();
|
||||
DSPRemoveSpectrumSink cmd(spectrumSink);
|
||||
m_syncMessenger.sendWait(cmd);
|
||||
}
|
||||
|
||||
@ -216,10 +217,10 @@ void DSPDeviceSinkEngine::work()
|
||||
sourceOccurence = 0;
|
||||
}
|
||||
|
||||
// feed the mix to the sinks normally just the main spectrum vis
|
||||
for (BasebandSampleSinks::iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); ++it)
|
||||
// feed the mix to the main spectrum sink
|
||||
if (m_spectrumSink)
|
||||
{
|
||||
(*it)->feed(writeBegin, writeBegin + nbWriteSamples, false);
|
||||
m_spectrumSink->feed(writeBegin, writeBegin + nbWriteSamples, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -262,11 +263,7 @@ DSPDeviceSinkEngine::State DSPDeviceSinkEngine::gotoIdle()
|
||||
(*it)->stop();
|
||||
}
|
||||
|
||||
for(BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); it++)
|
||||
{
|
||||
(*it)->stop();
|
||||
}
|
||||
|
||||
m_spectrumSink->stop();
|
||||
m_deviceSampleSink->stop();
|
||||
m_deviceDescription.clear();
|
||||
m_sampleRate = 0;
|
||||
@ -322,11 +319,7 @@ DSPDeviceSinkEngine::State DSPDeviceSinkEngine::gotoInit()
|
||||
(*it)->handleSourceMessage(notif);
|
||||
}
|
||||
|
||||
for (BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); ++it)
|
||||
{
|
||||
qDebug() << "DSPDeviceSinkEngine::gotoInit: initializing " << (*it)->objectName().toStdString().c_str();
|
||||
(*it)->handleMessage(notif);
|
||||
}
|
||||
m_spectrumSink->handleMessage(notif);
|
||||
|
||||
// pass data to listeners
|
||||
|
||||
@ -381,11 +374,7 @@ DSPDeviceSinkEngine::State DSPDeviceSinkEngine::gotoRunning()
|
||||
(*it)->start();
|
||||
}
|
||||
|
||||
for(BasebandSampleSinks::const_iterator it = m_basebandSampleSinks.begin(); it != m_basebandSampleSinks.end(); it++)
|
||||
{
|
||||
qDebug() << "DSPDeviceSinkEngine::gotoRunning: starting " << (*it)->objectName().toStdString().c_str();
|
||||
(*it)->start();
|
||||
}
|
||||
m_spectrumSink->start();
|
||||
|
||||
qDebug() << "DSPDeviceSinkEngine::gotoRunning: input message queue pending: " << m_inputMessageQueue.size();
|
||||
|
||||
@ -472,20 +461,19 @@ void DSPDeviceSinkEngine::handleSynchronousMessages()
|
||||
else if (DSPSetSink::match(*message)) {
|
||||
handleSetSink(((DSPSetSink*) message)->getSampleSink());
|
||||
}
|
||||
else if (DSPAddSink::match(*message))
|
||||
else if (DSPAddSpectrumSink::match(*message))
|
||||
{
|
||||
BasebandSampleSink* sink = ((DSPAddSink*) message)->getSampleSink();
|
||||
m_basebandSampleSinks.push_back(sink);
|
||||
m_spectrumSink = ((DSPAddSpectrumSink*) message)->getSampleSink();
|
||||
}
|
||||
else if (DSPRemoveSink::match(*message))
|
||||
else if (DSPRemoveSpectrumSink::match(*message))
|
||||
{
|
||||
BasebandSampleSink* sink = ((DSPRemoveSink*) message)->getSampleSink();
|
||||
BasebandSampleSink* spectrumSink = ((DSPRemoveSpectrumSink*) message)->getSampleSink();
|
||||
|
||||
if(m_state == StRunning) {
|
||||
sink->stop();
|
||||
spectrumSink->stop();
|
||||
}
|
||||
|
||||
m_basebandSampleSinks.remove(sink);
|
||||
m_spectrumSink = 0;
|
||||
}
|
||||
else if (DSPAddSource::match(*message))
|
||||
{
|
||||
|
@ -70,8 +70,8 @@ public:
|
||||
void addThreadedSource(ThreadedBasebandSampleSource* source); //!< Add a baseband sample source that will run on its own thread
|
||||
void removeThreadedSource(ThreadedBasebandSampleSource* source); //!< Remove a baseband sample source that runs on its own thread
|
||||
|
||||
void addSink(BasebandSampleSink* sink); //!< Add a baseband sample sink
|
||||
void removeSink(BasebandSampleSink* sink); //!< Remove a baseband sample sink
|
||||
void addSpectrumSink(BasebandSampleSink* spectrumSink); //!< Add a spectrum vis baseband sample sink
|
||||
void removeSpectrumSink(BasebandSampleSink* spectrumSink); //!< Add a spectrum vis baseband sample sink
|
||||
|
||||
State state() const { return m_state; } //!< Return DSP engine current state
|
||||
|
||||
@ -99,8 +99,7 @@ private:
|
||||
typedef std::list<ThreadedBasebandSampleSource*> ThreadedBasebandSampleSources;
|
||||
ThreadedBasebandSampleSources m_threadedBasebandSampleSources; //!< baseband sample sources on their own threads (usually channels)
|
||||
|
||||
typedef std::list<BasebandSampleSink*> BasebandSampleSinks;
|
||||
BasebandSampleSinks m_basebandSampleSinks; //!< baseband sample sinks within main thread (this is only the spectrum vis normally)
|
||||
BasebandSampleSink *m_spectrumSink;
|
||||
|
||||
uint m_sampleRate;
|
||||
quint64 m_centerFrequency;
|
||||
|
@ -39,7 +39,7 @@ void SampleSourceFifo::init()
|
||||
m_init = true;
|
||||
}
|
||||
|
||||
void SampleSourceFifo::read(SampleVector::iterator& beginRead, unsigned int nbSamples)
|
||||
void SampleSourceFifo::readAndSignal(SampleVector::iterator& beginRead, unsigned int nbSamples)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
@ -48,6 +48,8 @@ void SampleSourceFifo::read(SampleVector::iterator& beginRead, unsigned int nbSa
|
||||
beginRead = m_data.begin() + m_size + m_ir;
|
||||
m_ir = (m_ir + nbSamples) % m_size;
|
||||
|
||||
emit dataRead(nbSamples);
|
||||
|
||||
int i_delta = m_iw - m_ir;
|
||||
|
||||
if (m_init)
|
||||
@ -82,6 +84,11 @@ void SampleSourceFifo::write(const Sample& sample)
|
||||
}
|
||||
}
|
||||
|
||||
void SampleSourceFifo::getReadIterator(SampleVector::iterator& writeUntil)
|
||||
{
|
||||
writeUntil = m_data.begin() + m_size + m_ir;
|
||||
}
|
||||
|
||||
void SampleSourceFifo::getWriteIterator(SampleVector::iterator& writeAt)
|
||||
{
|
||||
writeAt = m_data.begin() + m_iw;
|
||||
|
@ -34,9 +34,10 @@ public:
|
||||
unsigned int getChunkSize() const { return m_samplesChunkSize; }
|
||||
|
||||
void init();
|
||||
/** begin read at current read point for the given length */
|
||||
void read(SampleVector::iterator& beginRead, unsigned int nbSamples);
|
||||
/** begin read at current read point for the given length and activate R/W signals */
|
||||
void readAndSignal(SampleVector::iterator& beginRead, unsigned int nbSamples);
|
||||
|
||||
void getReadIterator(SampleVector::iterator& readUntil); //!< get iterator past the last sample that was read by a read with signal (i.e. current read iterator)
|
||||
void getWriteIterator(SampleVector::iterator& writeAt); //!< get iterator to current item for update - write phase 1
|
||||
void bumpIndex(SampleVector::iterator& writeAt); //!< copy current item to second buffer and bump write index - write phase 2
|
||||
|
||||
@ -52,7 +53,8 @@ private:
|
||||
QMutex m_mutex;
|
||||
|
||||
signals:
|
||||
void dataWrite(); // signal data is read past a read chunk of samples and write is needed
|
||||
void dataWrite(); // signal data is read past a read chunk of samples and write is needed
|
||||
void dataRead(int nbSamples); // signal a read has been done for a number of samples
|
||||
};
|
||||
|
||||
#endif /* SDRBASE_DSP_SAMPLESOURCEFIFO_H_ */
|
||||
|
@ -241,7 +241,7 @@ void MainWindow::addSinkDevice()
|
||||
|
||||
connect(m_deviceUIs.back()->m_samplingDeviceControl->getAddChannelButton(), SIGNAL(clicked(bool)), this, SLOT(on_channel_addClicked(bool)));
|
||||
|
||||
dspDeviceSinkEngine->addSink(m_deviceUIs.back()->m_spectrumVis);
|
||||
dspDeviceSinkEngine->addSpectrumSink(m_deviceUIs.back()->m_spectrumVis);
|
||||
ui->tabSpectra->addTab(m_deviceUIs.back()->m_spectrum, tabNameCStr);
|
||||
ui->tabSpectraGUI->addTab(m_deviceUIs.back()->m_spectrumGUI, tabNameCStr);
|
||||
ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, tabNameCStr);
|
||||
@ -295,7 +295,7 @@ void MainWindow::removeLastDevice()
|
||||
{
|
||||
DSPDeviceSinkEngine *lastDeviceEngine = m_deviceUIs.back()->m_deviceSinkEngine;
|
||||
lastDeviceEngine->stopGeneration();
|
||||
lastDeviceEngine->removeSink(m_deviceUIs.back()->m_spectrumVis);
|
||||
lastDeviceEngine->removeSpectrumSink(m_deviceUIs.back()->m_spectrumVis);
|
||||
|
||||
ui->tabSpectraGUI->removeTab(ui->tabSpectraGUI->count() - 1);
|
||||
ui->tabSpectra->removeTab(ui->tabSpectra->count() - 1);
|
||||
|
Loading…
Reference in New Issue
Block a user