From 422f0dcc84345545c3a7b4da0d4def6bc11947f9 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Mon, 30 May 2022 19:55:30 +0300 Subject: [PATCH] ggwave : remove and headers --- include/ggwave/ggwave.h | 7 +++---- src/ggwave.cpp | 31 ++++++++++++++++++------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/include/ggwave/ggwave.h b/include/ggwave/ggwave.h index d828cf4..971fef0 100644 --- a/include/ggwave/ggwave.h +++ b/include/ggwave/ggwave.h @@ -303,7 +303,6 @@ extern "C" { #include #include #include -#include class GGWave { public: @@ -590,12 +589,12 @@ private: // Impl struct Rx; - std::unique_ptr m_rx; + Rx * m_rx; struct Tx; - std::unique_ptr m_tx; + Tx * m_tx; - std::unique_ptr m_resampler; + Resampler * m_resampler; }; #endif diff --git a/src/ggwave.cpp b/src/ggwave.cpp index 5fd4d83..e0c4133 100644 --- a/src/ggwave.cpp +++ b/src/ggwave.cpp @@ -3,9 +3,9 @@ #include "reed-solomon/rs.hpp" #include -#include #include #include +#include //#include #ifndef M_PI @@ -320,11 +320,6 @@ inline void addAmplitudeSmooth( } } -template -float getTime_ms(const T & tStart, const T & tEnd) { - return ((float)(std::chrono::duration_cast(tEnd - tStart).count()))/1000.0; -} - int getECCBytesForLength(int len) { return len < 4 ? 2 : std::max(4, 2*(len/5)); } @@ -493,7 +488,7 @@ GGWave::GGWave(const Parameters & parameters) : } if (m_isRxEnabled) { - m_rx = std::unique_ptr(new Rx()); + m_rx = new Rx(); m_rx->samplesNeeded = m_samplesPerFrame; @@ -541,7 +536,7 @@ GGWave::GGWave(const Parameters & parameters) : } if (m_isTxEnabled) { - m_tx = std::unique_ptr(new Tx()); + m_tx = new Tx(); const int maxDataBits = 2*16*maxBytesPerTx(); @@ -580,13 +575,27 @@ GGWave::GGWave(const Parameters & parameters) : } if (m_needResampling) { - m_resampler = std::unique_ptr(new Resampler()); + m_resampler = new Resampler(); } init("", getDefaultTxProtocol(), 0); } GGWave::~GGWave() { + if (m_rx) { + delete m_rx; + m_rx = nullptr; + } + + if (m_tx) { + delete m_tx; + m_tx = nullptr; + } + + if (m_resampler) { + delete m_resampler; + m_resampler = nullptr; + } } bool GGWave::init(const char * text, const int volume) { @@ -1438,7 +1447,6 @@ void GGWave::decode_variable() { if (m_rx->analyzingData) { ggprintf("Analyzing captured data ..\n"); - auto tStart = std::chrono::high_resolution_clock::now(); const int stepsPerFrame = 16; const int step = m_samplesPerFrame/stepsPerFrame; @@ -1585,9 +1593,6 @@ void GGWave::decode_variable() { m_rx->framesToAnalyze = 0; m_rx->framesLeftToAnalyze = 0; - - auto tEnd = std::chrono::high_resolution_clock::now(); - ggprintf("Time to analyze: %g ms\n", getTime_ms(tStart, tEnd)); } // check if receiving data