De-template FIFO.

This commit is contained in:
Jared Boone 2016-03-27 22:39:42 -07:00
parent 59f1a32566
commit f94938db8e
3 changed files with 13 additions and 8 deletions

View File

@ -38,7 +38,7 @@ using namespace hackrf::one;
class StreamOutput { class StreamOutput {
public: public:
StreamOutput( StreamOutput(
FIFO<uint8_t, 13>* const fifo FIFO<uint8_t>* const fifo
) : fifo { fifo } ) : fifo { fifo }
{ {
} }
@ -52,7 +52,7 @@ public:
} }
private: private:
FIFO<uint8_t, 13>* const fifo; FIFO<uint8_t>* const fifo;
}; };
class AudioThread { class AudioThread {
@ -96,7 +96,7 @@ private:
while( !chThdShouldTerminate() ) { while( !chThdShouldTerminate() ) {
// SUCH A HACK!!! // SUCH A HACK!!!
auto fifo = reinterpret_cast<FIFO<uint8_t, 13>*>(shared_memory.FIFO_HACK); auto fifo = reinterpret_cast<FIFO<uint8_t>*>(shared_memory.FIFO_HACK);
if( !fifo ) { if( !fifo ) {
break; break;
} }

View File

@ -54,7 +54,7 @@ private:
IIRBiquadFilter deemph; IIRBiquadFilter deemph;
FMSquelch squelch; FMSquelch squelch;
StreamInput stream; StreamInput stream { 13 };
AudioStatsCollector audio_stats; AudioStatsCollector audio_stats;

View File

@ -32,10 +32,13 @@
class StreamInput { class StreamInput {
public: public:
StreamInput() : fifo { std::make_unique<FIFO<uint8_t, 13>>() } StreamInput(const size_t K) :
K { K },
data { std::make_unique<uint8_t[]>(1UL << K) },
fifo { data.get(), K }
{ {
// TODO: Send stream creation message. // TODO: Send stream creation message.
shared_memory.FIFO_HACK = fifo.get(); shared_memory.FIFO_HACK = &fifo;
} }
~StreamInput() { ~StreamInput() {
@ -44,11 +47,13 @@ public:
} }
size_t write(const void* const data, const size_t length) { size_t write(const void* const data, const size_t length) {
return fifo->in(reinterpret_cast<const uint8_t*>(data), length); return fifo.in(reinterpret_cast<const uint8_t*>(data), length);
} }
private: private:
std::unique_ptr<FIFO<uint8_t, 13>> fifo; const size_t K;
std::unique_ptr<uint8_t[]> data;
FIFO<uint8_t> fifo;
}; };
#endif/*__STREAM_INPUT_H__*/ #endif/*__STREAM_INPUT_H__*/