diff --git a/plugins/channelrx/CMakeLists.txt b/plugins/channelrx/CMakeLists.txt index 60f72906d..5c17b91e8 100644 --- a/plugins/channelrx/CMakeLists.txt +++ b/plugins/channelrx/CMakeLists.txt @@ -13,9 +13,9 @@ if(LIBDSDCC_FOUND AND LIBMBE_FOUND) add_subdirectory(demoddsd) endif(LIBDSDCC_FOUND AND LIBMBE_FOUND) -if(CM256CC_FOUND) - add_subdirectory(remotesink) -endif(CM256CC_FOUND) +# if(CM256CC_FOUND) +# add_subdirectory(remotesink) +# endif(CM256CC_FOUND) if (CODEC2_FOUND) add_subdirectory(demodfreedv) diff --git a/plugins/channelrx/remotesink/remotesink.cpp b/plugins/channelrx/remotesink/remotesink.cpp index 1357487df..5ac9e2b3f 100644 --- a/plugins/channelrx/remotesink/remotesink.cpp +++ b/plugins/channelrx/remotesink/remotesink.cpp @@ -39,7 +39,6 @@ #include "remotesinkbaseband.h" MESSAGE_CLASS_DEFINITION(RemoteSink::MsgConfigureRemoteSink, Message) -MESSAGE_CLASS_DEFINITION(RemoteSink::MsgBasebandSampleRateNotification, Message) const QString RemoteSink::m_channelIdURI = "sdrangel.channel.remotesink"; const QString RemoteSink::m_channelId = "RemoteSink"; @@ -48,7 +47,7 @@ RemoteSink::RemoteSink(DeviceAPI *deviceAPI) : ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink), m_deviceAPI(deviceAPI), m_frequencyOffset(0), - m_basebandSampleRate(48000) + m_basebandSampleRate(0) { setObjectName(m_channelId); @@ -88,8 +87,13 @@ void RemoteSink::feed(const SampleVector::const_iterator& begin, const SampleVec void RemoteSink::start() { - qDebug("RemoteSink::start"); + qDebug("RemoteSink::start: m_basebandSampleRate: %d", m_basebandSampleRate); m_basebandSink->reset(); + + if (m_basebandSampleRate != 0) { + m_basebandSink->setBasebandSampleRate(m_basebandSampleRate); + } + m_thread->start(); m_basebandSink->startSink(); } @@ -104,33 +108,7 @@ void RemoteSink::stop() bool RemoteSink::handleMessage(const Message& cmd) { - (void) cmd; - if (DSPSignalNotification::match(cmd)) - { - DSPSignalNotification& notif = (DSPSignalNotification&) cmd; - - qDebug() << "RemoteSink::handleMessage: DSPSignalNotification:" - << " inputSampleRate: " << notif.getSampleRate() - << " centerFrequency: " << notif.getCenterFrequency(); - - m_basebandSampleRate = notif.getSampleRate(); - m_centerFrequency = notif.getCenterFrequency(); - - calculateFrequencyOffset(); // This is when device sample rate changes - //propagateSampleRateAndFrequency(m_settings.m_localDeviceIndex, m_settings.m_log2Decim); - - MsgBasebandSampleRateNotification *msg = MsgBasebandSampleRateNotification::create(m_basebandSampleRate); - m_basebandSink->getInputMessageQueue()->push(msg); - - if (m_guiMessageQueue) - { - MsgBasebandSampleRateNotification *msg = MsgBasebandSampleRateNotification::create(m_basebandSampleRate); - m_guiMessageQueue->push(msg); - } - - return true; - } - else if (MsgConfigureRemoteSink::match(cmd)) + if (MsgConfigureRemoteSink::match(cmd)) { MsgConfigureRemoteSink& cfg = (MsgConfigureRemoteSink&) cmd; qDebug() << "RemoteSink::handleMessage: MsgConfigureRemoteSink"; @@ -138,6 +116,25 @@ bool RemoteSink::handleMessage(const Message& cmd) return true; } + else if (DSPSignalNotification::match(cmd)) + { + DSPSignalNotification& notif = (DSPSignalNotification&) cmd; + m_basebandSampleRate = notif.getSampleRate(); + qDebug() << "RemoteSink::handleMessage: DSPSignalNotification: m_basebandSampleRate:" << m_basebandSampleRate; + + // Forward to the sink + DSPSignalNotification* msgToBaseband = new DSPSignalNotification(notif); // make a copy + m_basebandSink->getInputMessageQueue()->push(msgToBaseband); + + // Forward to the GUI + if (getMessageQueueToGUI()) + { + DSPSignalNotification* msgToGUI = new DSPSignalNotification(notif); // make a copy + getMessageQueueToGUI()->push(msgToBaseband); + } + + return true; + } else { return false; diff --git a/plugins/channelrx/remotesink/remotesink.h b/plugins/channelrx/remotesink/remotesink.h index 3b34fa622..b2c41b758 100644 --- a/plugins/channelrx/remotesink/remotesink.h +++ b/plugins/channelrx/remotesink/remotesink.h @@ -61,26 +61,6 @@ public: { } }; - class MsgBasebandSampleRateNotification : public Message { - MESSAGE_CLASS_DECLARATION - - public: - static MsgBasebandSampleRateNotification* create(int sampleRate) { - return new MsgBasebandSampleRateNotification(sampleRate); - } - - int getBasebandSampleRate() const { return m_basebandSampleRate; } - - private: - - MsgBasebandSampleRateNotification(int sampleRate) : - Message(), - m_basebandSampleRate(sampleRate) - { } - - int m_basebandSampleRate; - }; - RemoteSink(DeviceAPI *deviceAPI); virtual ~RemoteSink(); virtual void destroy() { delete this; } diff --git a/plugins/channelrx/remotesink/remotesinkbaseband.cpp b/plugins/channelrx/remotesink/remotesinkbaseband.cpp index 121430780..2016c8ac5 100644 --- a/plugins/channelrx/remotesink/remotesinkbaseband.cpp +++ b/plugins/channelrx/remotesink/remotesinkbaseband.cpp @@ -24,10 +24,8 @@ #include "remotesinkbaseband.h" MESSAGE_CLASS_DEFINITION(RemoteSinkBaseband::MsgConfigureRemoteSinkBaseband, Message) -MESSAGE_CLASS_DEFINITION(RemoteSinkBaseband::MsgBasebandSampleRateNotification, Message) RemoteSinkBaseband::RemoteSinkBaseband() : - m_localSampleSource(nullptr), m_mutex(QMutex::Recursive) { m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(48000)); @@ -112,16 +110,15 @@ bool RemoteSinkBaseband::handleMessage(const Message& cmd) return true; } - else if (MsgBasebandSampleRateNotification::match(cmd)) + else if (DSPSignalNotification::match(cmd)) { - QMutexLocker mutexLocker(&m_mutex); - MsgBasebandSampleRateNotification& notif = (MsgBasebandSampleRateNotification&) cmd; - qDebug() << "RemoteSinkBaseband::handleMessage: MsgBasebandSampleRateNotification: basebandSampleRate: " << notif.getBasebandSampleRate(); - m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(notif.getBasebandSampleRate())); - m_channelizer->setBasebandSampleRate(notif.getBasebandSampleRate()); - m_sink.applySampleRate(m_channelizer->getChannelSampleRate()); + DSPSignalNotification& notif = (DSPSignalNotification&) cmd; + m_basebandSampleRate = notif.getSampleRate(); + qDebug() << "RemoteSinkBaseband::handleMessage: DSPSignalNotification: basebandSampleRate:" << m_basebandSampleRate; + m_channelizer->setBasebandSampleRate(m_basebandSampleRate); + m_sink.applySampleRate(m_basebandSampleRate/ (1<setDecimation(settings.m_log2Decim, settings.m_filterChainHash); - m_sink.applySampleRate(m_channelizer->getChannelSampleRate()); + m_sink.applySampleRate(m_basebandSampleRate/ (1<getChannelSampleRate(); } + +void RemoteSinkBaseband::setBasebandSampleRate(int sampleRate) +{ + m_basebandSampleRate = sampleRate; + m_channelizer->setBasebandSampleRate(m_basebandSampleRate); + m_sink.applySampleRate(m_basebandSampleRate/ (1<setupUi(this); @@ -173,7 +176,7 @@ void RemoteSinkGUI::displaySettings() m_channelMarker.blockSignals(true); m_channelMarker.setCenterFrequency(0); m_channelMarker.setTitle(m_settings.m_title); - m_channelMarker.setBandwidth(m_sampleRate); // TODO + m_channelMarker.setBandwidth(m_basebandSampleRate); // TODO m_channelMarker.setMovable(false); // do not let user move the center arbitrarily m_channelMarker.blockSignals(false); m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only @@ -207,8 +210,8 @@ void RemoteSinkGUI::displayStreamIndex() void RemoteSinkGUI::displayRateAndShift() { - int shift = m_shiftFrequencyFactor * m_sampleRate; - double channelSampleRate = ((double) m_sampleRate) / (1<offsetFrequencyText->setText(tr("%1 Hz").arg(loc.toString(shift))); ui->channelRateText->setText(tr("%1k").arg(QString::number(channelSampleRate / 1000.0, 'g', 5))); @@ -365,7 +368,7 @@ void RemoteSinkGUI::updateTxDelayTime() { double txDelayRatio = m_settings.m_txDelay / 100.0; int samplesPerBlock = RemoteNbBytesPerBlock / sizeof(Sample); - double delay = m_sampleRate == 0 ? 0.0 : (127*samplesPerBlock*txDelayRatio) / m_sampleRate; + double delay = m_basebandSampleRate == 0 ? 0.0 : (127*samplesPerBlock*txDelayRatio) / m_basebandSampleRate; delay /= 128 + m_settings.m_nbFECBlocks; ui->txDelayTime->setText(tr("%1µs").arg(QString::number(delay*1e6, 'f', 0))); } diff --git a/plugins/channelrx/remotesink/remotesinkgui.h b/plugins/channelrx/remotesink/remotesinkgui.h index d9f31fd9f..295d5471a 100644 --- a/plugins/channelrx/remotesink/remotesinkgui.h +++ b/plugins/channelrx/remotesink/remotesinkgui.h @@ -62,7 +62,7 @@ private: DeviceUISet* m_deviceUISet; ChannelMarker m_channelMarker; RemoteSinkSettings m_settings; - int m_sampleRate; + int m_basebandSampleRate; quint64 m_deviceCenterFrequency; //!< Center frequency in device double m_shiftFrequencyFactor; //!< Channel frequency shift factor bool m_doApplySettings; diff --git a/plugins/channelrx/remotesink/remotesinksink.cpp b/plugins/channelrx/remotesink/remotesinksink.cpp index 9d9435eed..94e76faeb 100644 --- a/plugins/channelrx/remotesink/remotesinksink.cpp +++ b/plugins/channelrx/remotesink/remotesinksink.cpp @@ -61,9 +61,9 @@ void RemoteSinkSink::setTxDelay(int txDelay, int nbBlocksFEC) delay /= 128 + nbBlocksFEC; m_txDelay = roundf(delay*1e6); // microseconds qDebug() << "RemoteSinkSink::setTxDelay:" - << " " << txDelay - << "% m_txDelay: " << m_txDelay << "us" - << " m_sampleRate: " << m_sampleRate << "S/s"; + << "txDelay:" << txDelay << "%" + << "m_txDelay:" << m_txDelay << "us" + << "m_sampleRate: " << m_sampleRate << "S/s"; } void RemoteSinkSink::setNbBlocksFEC(int nbBlocksFEC) @@ -210,7 +210,6 @@ void RemoteSinkSink::stop() { m_remoteSinkThread->startStop(false); m_remoteSinkThread->deleteLater(); - m_remoteSinkThread = nullptr; } m_running = false; diff --git a/plugins/channelrx/remotesink/remotesinkthread.cpp b/plugins/channelrx/remotesink/remotesinkthread.cpp index 0a4a7bfd9..28f44c662 100644 --- a/plugins/channelrx/remotesink/remotesinkthread.cpp +++ b/plugins/channelrx/remotesink/remotesinkthread.cpp @@ -114,7 +114,7 @@ void RemoteSinkThread::handleDataBlock(RemoteDataBlock& dataBlock) { // send block via UDP m_socket->writeDatagram((const char*)&txBlockx[i], (qint64 ) RemoteUdpSize, m_address, dataPort); - usleep(txDelay); + //usleep(txDelay); } } } @@ -159,7 +159,7 @@ void RemoteSinkThread::handleDataBlock(RemoteDataBlock& dataBlock) { // send block via UDP m_socket->writeDatagram((const char*)&txBlockx[i], (qint64 ) RemoteUdpSize, m_address, dataPort); - usleep(txDelay); + //usleep(txDelay); } } }