diff --git a/src/demod.hh b/src/demod.hh index 54f7c9f..2bd14b4 100644 --- a/src/demod.hh +++ b/src/demod.hh @@ -44,7 +44,7 @@ public: _buffer = Buffer(src_cfg.bufferSize()); LogMessage msg(LOG_DEBUG); - msg << "Configure AMDemod:" << std::endl + msg << "Configure AMDemod: " << this << std::endl << " input type: " << Traits< std::complex >::scalarId << std::endl << " output type: " << Traits::scalarId << std::endl << " sample rate: " << src_cfg.sampleRate() << std::endl @@ -128,7 +128,7 @@ public: _buffer = Buffer(src_cfg.bufferSize()); LogMessage msg(LOG_DEBUG); - msg << "Configure USBDemod:" << std::endl + msg << "Configure USBDemod: " << this << std::endl << " input type: " << Traits< std::complex >::scalarId << std::endl << " output type: " << Traits::scalarId << std::endl << " sample rate: " << src_cfg.sampleRate() << std::endl @@ -216,7 +216,7 @@ public: _can_overwrite = (sizeof(std::complex) >= sizeof(oScalar)); LogMessage msg(LOG_DEBUG); - msg << "Configured FMDemod node:" << std::endl + msg << "Configured FMDemod node: " << this << std::endl << " sample-rate: " << src_cfg.sampleRate() << std::endl << " in-type / out-type: " << src_cfg.type() << " / " << Config::typeId() << std::endl diff --git a/src/gui/waterfallview.cc b/src/gui/waterfallview.cc index a2e2ed2..c39ba35 100644 --- a/src/gui/waterfallview.cc +++ b/src/gui/waterfallview.cc @@ -102,6 +102,7 @@ WaterFallView::_onSpectrumUpdated() { for (size_t i=0; i<_N; i++) { int idx = (_spectrum->fftSize()/2+i) % _spectrum->fftSize(); double value = 10*log10(_spectrum->spectrum()[idx])-10*log10(_N); + if (value != value) { value = 0; } painter.setPen((*_colorMap)(value)); painter.drawPoint(i, _M-1); } diff --git a/src/node.cc b/src/node.cc index 8357e22..eb63fae 100644 --- a/src/node.cc +++ b/src/node.cc @@ -73,10 +73,11 @@ Source::send(const RawBuffer &buffer, bool allow_overwrite) { // iff, the sink is the only one receiving this buffer, the source allows it and the // connection is direct. allow_overwrite = allow_overwrite && (1 == _sinks.size()); + // Call sink directly item->first->handleBuffer(buffer, allow_overwrite); } - // otherwise, queue buffer else { + // otherwise, queue buffer allow_overwrite = allow_overwrite && (1 == _sinks.size()); Queue::get().send(buffer, item->first, allow_overwrite); } diff --git a/src/queue.cc b/src/queue.cc index 00249bd..171233c 100644 --- a/src/queue.cc +++ b/src/queue.cc @@ -68,8 +68,15 @@ Queue::stop() { void Queue::wait() { - void *p; - pthread_join(_thread, &p); + // Wait for the queue to quit + void *p; pthread_join(_thread, &p); + + // Clear queue. + std::list::iterator item = _queue.begin(); + for (; item != _queue.end(); item++) { + item->buffer().unref(); + } + _queue.clear(); } @@ -110,7 +117,11 @@ Queue::_main() } // Call all stop-signal handlers _signalStop(); - Logger::get().log(LogMessage(LOG_DEBUG, "Queue stopped.")); + { + LogMessage msg(LOG_DEBUG, "Queue stopped."); + msg << " Messages left in queue: " << _queue.size(); + Logger::get().log(msg); + } } void diff --git a/src/rtlsource.cc b/src/rtlsource.cc index 2473b20..b1bdbcb 100644 --- a/src/rtlsource.cc +++ b/src/rtlsource.cc @@ -80,8 +80,11 @@ RTLSource::setSampleRate(double sample_rate) { if (sr < 225001) { sr = 225001; } else if ((sr>300000) && (sr<900001)) { sr = 900001; } else if (sr>2400000) { sr = 2400000; } + rtlsdr_set_sample_rate(_device, sr); + rtlsdr_reset_buffer(_device); _sample_rate = rtlsdr_get_sample_rate(_device); + this->setConfig(Config(Config::Type_cu8, _sample_rate, _buffer_size, 15)); } @@ -110,7 +113,9 @@ RTLSource::stop() { void *p; // stop async reading of RTL device rtlsdr_cancel_async(_device); - // Wait for blocked thread to exit + // Wait for blocked thread to exit: + // This is important to ensure that no new messages are added to the + // queue after this function returned. pthread_join(_thread, &p); }