From f94938db8ef0629058b995b24f117fd187df8f07 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sun, 27 Mar 2016 22:39:42 -0700 Subject: [PATCH] De-template FIFO. --- firmware/application/audio_thread.hpp | 6 +++--- firmware/baseband/audio_output.hpp | 2 +- firmware/baseband/stream_input.hpp | 13 +++++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/firmware/application/audio_thread.hpp b/firmware/application/audio_thread.hpp index 1d7374d1..2893ca8e 100644 --- a/firmware/application/audio_thread.hpp +++ b/firmware/application/audio_thread.hpp @@ -38,7 +38,7 @@ using namespace hackrf::one; class StreamOutput { public: StreamOutput( - FIFO* const fifo + FIFO* const fifo ) : fifo { fifo } { } @@ -52,7 +52,7 @@ public: } private: - FIFO* const fifo; + FIFO* const fifo; }; class AudioThread { @@ -96,7 +96,7 @@ private: while( !chThdShouldTerminate() ) { // SUCH A HACK!!! - auto fifo = reinterpret_cast*>(shared_memory.FIFO_HACK); + auto fifo = reinterpret_cast*>(shared_memory.FIFO_HACK); if( !fifo ) { break; } diff --git a/firmware/baseband/audio_output.hpp b/firmware/baseband/audio_output.hpp index 47f01a92..c935ed86 100644 --- a/firmware/baseband/audio_output.hpp +++ b/firmware/baseband/audio_output.hpp @@ -54,7 +54,7 @@ private: IIRBiquadFilter deemph; FMSquelch squelch; - StreamInput stream; + StreamInput stream { 13 }; AudioStatsCollector audio_stats; diff --git a/firmware/baseband/stream_input.hpp b/firmware/baseband/stream_input.hpp index 76f94252..ed508aaa 100644 --- a/firmware/baseband/stream_input.hpp +++ b/firmware/baseband/stream_input.hpp @@ -32,10 +32,13 @@ class StreamInput { public: - StreamInput() : fifo { std::make_unique>() } + StreamInput(const size_t K) : + K { K }, + data { std::make_unique(1UL << K) }, + fifo { data.get(), K } { // TODO: Send stream creation message. - shared_memory.FIFO_HACK = fifo.get(); + shared_memory.FIFO_HACK = &fifo; } ~StreamInput() { @@ -44,11 +47,13 @@ public: } size_t write(const void* const data, const size_t length) { - return fifo->in(reinterpret_cast(data), length); + return fifo.in(reinterpret_cast(data), length); } private: - std::unique_ptr> fifo; + const size_t K; + std::unique_ptr data; + FIFO fifo; }; #endif/*__STREAM_INPUT_H__*/