From ef315f0d92ecd8ef27051fe27a7fb45cad06cdd3 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Thu, 10 Dec 2015 12:36:12 -0800 Subject: [PATCH] Const/pass-by-reference a bunch more baseband stuff. --- firmware/baseband/audio_stats_collector.hpp | 4 ++-- firmware/baseband/baseband_processor.hpp | 2 +- firmware/baseband/baseband_stats_collector.hpp | 2 +- firmware/baseband/block_decimator.hpp | 2 +- firmware/baseband/channel_decimator.cpp | 6 +++--- firmware/baseband/channel_decimator.hpp | 8 ++++---- firmware/baseband/channel_stats_collector.hpp | 2 +- firmware/baseband/proc_ais.cpp | 2 +- firmware/baseband/proc_ais.hpp | 2 +- firmware/baseband/proc_am_audio.cpp | 2 +- firmware/baseband/proc_am_audio.hpp | 2 +- firmware/baseband/proc_ert.cpp | 2 +- firmware/baseband/proc_ert.hpp | 2 +- firmware/baseband/proc_nfm_audio.cpp | 2 +- firmware/baseband/proc_nfm_audio.hpp | 2 +- firmware/baseband/proc_tpms.cpp | 2 +- firmware/baseband/proc_tpms.hpp | 2 +- firmware/baseband/proc_wfm_audio.cpp | 2 +- firmware/baseband/proc_wfm_audio.hpp | 2 +- firmware/baseband/proc_wideband_spectrum.cpp | 2 +- firmware/baseband/proc_wideband_spectrum.hpp | 2 +- firmware/baseband/rssi_stats_collector.hpp | 2 +- 22 files changed, 28 insertions(+), 28 deletions(-) diff --git a/firmware/baseband/audio_stats_collector.hpp b/firmware/baseband/audio_stats_collector.hpp index 189fff802..15405673a 100644 --- a/firmware/baseband/audio_stats_collector.hpp +++ b/firmware/baseband/audio_stats_collector.hpp @@ -32,7 +32,7 @@ class AudioStatsCollector { public: template - void feed(buffer_s16_t src, Callback callback) { + void feed(const buffer_s16_t& src, Callback callback) { consume_audio_buffer(src); if( update_stats(src.count, src.sampling_rate) ) { @@ -55,7 +55,7 @@ private: AudioStatistics statistics; - void consume_audio_buffer(buffer_s16_t src) { + void consume_audio_buffer(const buffer_s16_t& src) { auto src_p = src.p; const auto src_end = &src.p[src.count]; while(src_p < src_end) { diff --git a/firmware/baseband/baseband_processor.hpp b/firmware/baseband/baseband_processor.hpp index 26fa1dac8..127854504 100644 --- a/firmware/baseband/baseband_processor.hpp +++ b/firmware/baseband/baseband_processor.hpp @@ -37,7 +37,7 @@ class BasebandProcessor { public: virtual ~BasebandProcessor() = default; - virtual void execute(buffer_c8_t& buffer) = 0; + virtual void execute(const buffer_c8_t& buffer) = 0; void update_spectrum(); diff --git a/firmware/baseband/baseband_stats_collector.hpp b/firmware/baseband/baseband_stats_collector.hpp index a44c2936d..d214d61f7 100644 --- a/firmware/baseband/baseband_stats_collector.hpp +++ b/firmware/baseband/baseband_stats_collector.hpp @@ -46,7 +46,7 @@ public: } template - void process(buffer_c8_t buffer, Callback callback) { + void process(const buffer_c8_t& buffer, Callback callback) { samples += buffer.count; const size_t report_samples = buffer.sampling_rate * report_interval; diff --git a/firmware/baseband/block_decimator.hpp b/firmware/baseband/block_decimator.hpp index dbca0ebd9..1f7710efc 100644 --- a/firmware/baseband/block_decimator.hpp +++ b/firmware/baseband/block_decimator.hpp @@ -65,7 +65,7 @@ public: } template - void feed(const buffer_c16_t src, BlockCallback callback) { + void feed(const buffer_c16_t& src, BlockCallback callback) { /* NOTE: Input block size must be >= factor */ set_input_sampling_rate(src.sampling_rate); diff --git a/firmware/baseband/channel_decimator.cpp b/firmware/baseband/channel_decimator.cpp index 80bd136b9..59dbd7ea7 100644 --- a/firmware/baseband/channel_decimator.cpp +++ b/firmware/baseband/channel_decimator.cpp @@ -21,7 +21,7 @@ #include "channel_decimator.hpp" -buffer_c16_t ChannelDecimator::execute_decimation(buffer_c8_t buffer) { +buffer_c16_t ChannelDecimator::execute_decimation(const buffer_c8_t& buffer) { const buffer_c16_t work_baseband_buffer { work_baseband.data(), work_baseband.size() @@ -80,8 +80,8 @@ buffer_c16_t ChannelDecimator::execute_decimation(buffer_c8_t buffer) { } buffer_c16_t ChannelDecimator::execute_stage_0( - buffer_c8_t buffer, - buffer_c16_t work_baseband_buffer + const buffer_c8_t& buffer, + const buffer_c16_t& work_baseband_buffer ) { if( fs_over_4_downconvert ) { return translate.execute(buffer, work_baseband_buffer); diff --git a/firmware/baseband/channel_decimator.hpp b/firmware/baseband/channel_decimator.hpp index 10a650332..956964b07 100644 --- a/firmware/baseband/channel_decimator.hpp +++ b/firmware/baseband/channel_decimator.hpp @@ -57,7 +57,7 @@ public: decimation_factor = f; } - buffer_c16_t execute(buffer_c8_t buffer) { + buffer_c16_t execute(const buffer_c8_t& buffer) { auto decimated = execute_decimation(buffer); return decimated; @@ -76,11 +76,11 @@ private: DecimationFactor decimation_factor; const bool fs_over_4_downconvert; - buffer_c16_t execute_decimation(buffer_c8_t buffer); + buffer_c16_t execute_decimation(const buffer_c8_t& buffer); buffer_c16_t execute_stage_0( - buffer_c8_t buffer, - buffer_c16_t work_baseband_buffer + const buffer_c8_t& buffer, + const buffer_c16_t& work_baseband_buffer ); }; diff --git a/firmware/baseband/channel_stats_collector.hpp b/firmware/baseband/channel_stats_collector.hpp index 8c91ac5b4..d03f03a16 100644 --- a/firmware/baseband/channel_stats_collector.hpp +++ b/firmware/baseband/channel_stats_collector.hpp @@ -34,7 +34,7 @@ class ChannelStatsCollector { public: template - void feed(buffer_c16_t src, Callback callback) { + void feed(const buffer_c16_t& src, Callback callback) { auto src_p = src.p; while(src_p < &src.p[src.count]) { const uint32_t sample = *__SIMD32(src_p)++; diff --git a/firmware/baseband/proc_ais.cpp b/firmware/baseband/proc_ais.cpp index fa61004b1..903a7e2f8 100644 --- a/firmware/baseband/proc_ais.cpp +++ b/firmware/baseband/proc_ais.cpp @@ -26,7 +26,7 @@ #include "i2s.hpp" using namespace lpc43xx; -void AISProcessor::execute(buffer_c8_t& buffer) { +void AISProcessor::execute(const buffer_c8_t& buffer) { /* 2.4576MHz, 2048 samples */ auto decimator_out = decimator.execute(buffer); diff --git a/firmware/baseband/proc_ais.hpp b/firmware/baseband/proc_ais.hpp index 67e3c7d28..16bf42b45 100644 --- a/firmware/baseband/proc_ais.hpp +++ b/firmware/baseband/proc_ais.hpp @@ -42,7 +42,7 @@ class AISProcessor : public BasebandProcessor { public: - void execute(buffer_c8_t& buffer) override; + void execute(const buffer_c8_t& buffer) override; private: ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By32 }; diff --git a/firmware/baseband/proc_am_audio.cpp b/firmware/baseband/proc_am_audio.cpp index 4899f8021..5bb374e99 100644 --- a/firmware/baseband/proc_am_audio.cpp +++ b/firmware/baseband/proc_am_audio.cpp @@ -23,7 +23,7 @@ #include -void NarrowbandAMAudio::execute(buffer_c8_t& buffer) { +void NarrowbandAMAudio::execute(const buffer_c8_t& buffer) { auto decimator_out = decimator.execute(buffer); const buffer_c16_t work_baseband_buffer { diff --git a/firmware/baseband/proc_am_audio.hpp b/firmware/baseband/proc_am_audio.hpp index d6f6ce11f..dfa6d5ec0 100644 --- a/firmware/baseband/proc_am_audio.hpp +++ b/firmware/baseband/proc_am_audio.hpp @@ -38,7 +38,7 @@ public: channel_filter.configure(channel_filter_taps.taps, 2); } - void execute(buffer_c8_t& buffer) override; + void execute(const buffer_c8_t& buffer) override; private: ChannelDecimator decimator; diff --git a/firmware/baseband/proc_ert.cpp b/firmware/baseband/proc_ert.cpp index 34d6e0e83..5ef5d4967 100644 --- a/firmware/baseband/proc_ert.cpp +++ b/firmware/baseband/proc_ert.cpp @@ -41,7 +41,7 @@ float ERTProcessor::abs(const complex8_t& v) { return std::sqrt(r2_i2); } -void ERTProcessor::execute(buffer_c8_t& buffer) { +void ERTProcessor::execute(const buffer_c8_t& buffer) { /* 4.194304MHz, 2048 samples */ // auto decimator_out = decimator.execute(buffer); diff --git a/firmware/baseband/proc_ert.hpp b/firmware/baseband/proc_ert.hpp index 09fea85cf..439180d1c 100644 --- a/firmware/baseband/proc_ert.hpp +++ b/firmware/baseband/proc_ert.hpp @@ -50,7 +50,7 @@ constexpr size_t idm_payload_length_max { 1408 }; class ERTProcessor : public BasebandProcessor { public: - void execute(buffer_c8_t& buffer) override; + void execute(const buffer_c8_t& buffer) override; private: const uint32_t baseband_sampling_rate = 4194304; diff --git a/firmware/baseband/proc_nfm_audio.cpp b/firmware/baseband/proc_nfm_audio.cpp index c18894168..4ac7539ec 100644 --- a/firmware/baseband/proc_nfm_audio.cpp +++ b/firmware/baseband/proc_nfm_audio.cpp @@ -24,7 +24,7 @@ #include #include -void NarrowbandFMAudio::execute(buffer_c8_t& buffer) { +void NarrowbandFMAudio::execute(const buffer_c8_t& buffer) { /* Called every 2048/3072000 second -- 1500Hz. */ auto decimator_out = decimator.execute(buffer); diff --git a/firmware/baseband/proc_nfm_audio.hpp b/firmware/baseband/proc_nfm_audio.hpp index ede1c6ccd..b4112dde2 100644 --- a/firmware/baseband/proc_nfm_audio.hpp +++ b/firmware/baseband/proc_nfm_audio.hpp @@ -39,7 +39,7 @@ public: channel_filter.configure(channel_filter_taps.taps, 2); } - void execute(buffer_c8_t& buffer) override; + void execute(const buffer_c8_t& buffer) override; private: ChannelDecimator decimator; diff --git a/firmware/baseband/proc_tpms.cpp b/firmware/baseband/proc_tpms.cpp index c8431b2c8..314a05e7b 100644 --- a/firmware/baseband/proc_tpms.cpp +++ b/firmware/baseband/proc_tpms.cpp @@ -26,7 +26,7 @@ #include "i2s.hpp" using namespace lpc43xx; -void TPMSProcessor::execute(buffer_c8_t& buffer) { +void TPMSProcessor::execute(const buffer_c8_t& buffer) { /* 2.4576MHz, 2048 samples */ auto decimator_out = decimator.execute(buffer); diff --git a/firmware/baseband/proc_tpms.hpp b/firmware/baseband/proc_tpms.hpp index 79fa4ae18..541ee0e06 100644 --- a/firmware/baseband/proc_tpms.hpp +++ b/firmware/baseband/proc_tpms.hpp @@ -50,7 +50,7 @@ constexpr std::array, 8> rect_taps_153k6_1t_p { { class TPMSProcessor : public BasebandProcessor { public: - void execute(buffer_c8_t& buffer) override; + void execute(const buffer_c8_t& buffer) override; private: ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By16 }; diff --git a/firmware/baseband/proc_wfm_audio.cpp b/firmware/baseband/proc_wfm_audio.cpp index d01ab1697..a708a9ac0 100644 --- a/firmware/baseband/proc_wfm_audio.cpp +++ b/firmware/baseband/proc_wfm_audio.cpp @@ -23,7 +23,7 @@ #include -void WidebandFMAudio::execute(buffer_c8_t& buffer) { +void WidebandFMAudio::execute(const buffer_c8_t& buffer) { auto decimator_out = decimator.execute(buffer); const buffer_s16_t work_audio_buffer { diff --git a/firmware/baseband/proc_wfm_audio.hpp b/firmware/baseband/proc_wfm_audio.hpp index d638f46a8..b4aa41bd5 100644 --- a/firmware/baseband/proc_wfm_audio.hpp +++ b/firmware/baseband/proc_wfm_audio.hpp @@ -37,7 +37,7 @@ public: decimator.set_decimation_factor(ChannelDecimator::DecimationFactor::By4); } - void execute(buffer_c8_t& buffer) override; + void execute(const buffer_c8_t& buffer) override; private: ChannelDecimator decimator; diff --git a/firmware/baseband/proc_wideband_spectrum.cpp b/firmware/baseband/proc_wideband_spectrum.cpp index d6beb0516..12fe1b7d8 100644 --- a/firmware/baseband/proc_wideband_spectrum.cpp +++ b/firmware/baseband/proc_wideband_spectrum.cpp @@ -33,7 +33,7 @@ using namespace lpc43xx; #include -void WidebandSpectrum::execute(buffer_c8_t& buffer) { +void WidebandSpectrum::execute(const buffer_c8_t& buffer) { // 2048 complex8_t samples per buffer. // 102.4us per buffer. 20480 instruction cycles per buffer. diff --git a/firmware/baseband/proc_wideband_spectrum.hpp b/firmware/baseband/proc_wideband_spectrum.hpp index f142588ed..b21f6b3e2 100644 --- a/firmware/baseband/proc_wideband_spectrum.hpp +++ b/firmware/baseband/proc_wideband_spectrum.hpp @@ -30,7 +30,7 @@ class WidebandSpectrum : public BasebandProcessor { public: - void execute(buffer_c8_t& buffer) override; + void execute(const buffer_c8_t& buffer) override; private: size_t sample_count = 0; diff --git a/firmware/baseband/rssi_stats_collector.hpp b/firmware/baseband/rssi_stats_collector.hpp index 6ab945bf1..7a1cd4940 100644 --- a/firmware/baseband/rssi_stats_collector.hpp +++ b/firmware/baseband/rssi_stats_collector.hpp @@ -31,7 +31,7 @@ class RSSIStatisticsCollector { public: template - void process(rf::rssi::buffer_t buffer, Callback callback) { + void process(const rf::rssi::buffer_t& buffer, Callback callback) { auto p = buffer.p; if( p == nullptr ) { return;