From c42b72196eeb1f24f428b40e53dd3fd88ce0188c Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Wed, 12 Oct 2011 18:28:15 -0400
Subject: [PATCH] * #7131: cleanup in audiolayer

---
 daemon/src/audio/alsa/alsalayer.cpp  | 30 +++++++++++++--------------
 daemon/src/audio/audiolayer.cpp      |  4 ++--
 daemon/src/audio/audiorecorder.cpp   | 31 +++++++++-------------------
 daemon/src/audio/audiorecorder.h     | 14 ++++++-------
 daemon/src/audio/codecs/g722.cpp     |  4 ++--
 daemon/src/audio/codecs/gsmcodec.cpp |  2 +-
 daemon/src/audio/noisesuppress.cpp   | 28 ++++++++++++-------------
 daemon/src/audio/noisesuppress.h     | 10 +++------
 8 files changed, 54 insertions(+), 69 deletions(-)

diff --git a/daemon/src/audio/alsa/alsalayer.cpp b/daemon/src/audio/alsa/alsalayer.cpp
index e9020ea5eb..6acb6f8ed8 100644
--- a/daemon/src/audio/alsa/alsalayer.cpp
+++ b/daemon/src/audio/alsa/alsalayer.cpp
@@ -44,7 +44,7 @@ class AlsaThread : public ost::Thread {
             terminate();
         }
 
-        virtual void run(void);
+        virtual void run();
 
     private:
         AlsaThread(const AlsaThread& at);
@@ -62,7 +62,7 @@ AlsaThread::AlsaThread(AlsaLayer *alsa)
 /**
  * Reimplementation of run()
  */
-void AlsaThread::run(void)
+void AlsaThread::run()
 {
     while (!testCancel()) {
         alsa_->audioCallback();
@@ -91,7 +91,7 @@ AlsaLayer::AlsaLayer()
 }
 
 // Destructor
-AlsaLayer::~AlsaLayer(void)
+AlsaLayer::~AlsaLayer()
 {
     delete audioThread_;
 
@@ -127,7 +127,7 @@ bool AlsaLayer::openDevice(snd_pcm_t **pcm, const std::string &dev, snd_pcm_stre
 }
 
 void
-AlsaLayer::startStream(void)
+AlsaLayer::startStream()
 {
     dcblocker_.reset();
 
@@ -184,7 +184,7 @@ AlsaLayer::startStream(void)
 }
 
 void
-AlsaLayer::stopStream(void)
+AlsaLayer::stopStream()
 {
     isStarted_ = false;
 
@@ -222,7 +222,7 @@ AlsaLayer::stopStream(void)
 			err_code; \
 		})
 
-void AlsaLayer::stopCaptureStream(void)
+void AlsaLayer::stopCaptureStream()
 {
     if (captureHandle_ && ALSA_CALL(snd_pcm_drop(captureHandle_), "couldn't stop capture") >= 0) {
         is_capture_running_ = false;
@@ -230,7 +230,7 @@ void AlsaLayer::stopCaptureStream(void)
     }
 }
 
-void AlsaLayer::closeCaptureStream(void)
+void AlsaLayer::closeCaptureStream()
 {
     if (is_capture_prepared_ and is_capture_running_)
         stopCaptureStream();
@@ -239,14 +239,14 @@ void AlsaLayer::closeCaptureStream(void)
         is_capture_open_ = false;
 }
 
-void AlsaLayer::startCaptureStream(void)
+void AlsaLayer::startCaptureStream()
 {
     if (captureHandle_ and not is_capture_running_)
         if (ALSA_CALL(snd_pcm_start(captureHandle_), "Couldn't start capture") >= 0)
             is_capture_running_ = true;
 }
 
-void AlsaLayer::stopPlaybackStream(void)
+void AlsaLayer::stopPlaybackStream()
 {
     if (ringtoneHandle_ and is_playback_running_)
         ALSA_CALL(snd_pcm_drop(ringtoneHandle_), "Couldn't stop ringtone");
@@ -260,7 +260,7 @@ void AlsaLayer::stopPlaybackStream(void)
 }
 
 
-void AlsaLayer::closePlaybackStream(void)
+void AlsaLayer::closePlaybackStream()
 {
     if (is_playback_prepared_ and is_playback_running_)
         stopPlaybackStream();
@@ -275,21 +275,21 @@ void AlsaLayer::closePlaybackStream(void)
 
 }
 
-void AlsaLayer::startPlaybackStream(void)
+void AlsaLayer::startPlaybackStream()
 {
     if (playbackHandle_ and not is_playback_running_)
         if (ALSA_CALL(snd_pcm_start(playbackHandle_), "Couldn't start playback") >= 0)
             is_playback_running_ = true;
 }
 
-void AlsaLayer::prepareCaptureStream(void)
+void AlsaLayer::prepareCaptureStream()
 {
     if (is_capture_open_ and not is_capture_prepared_)
         if (ALSA_CALL(snd_pcm_prepare(captureHandle_), "Couldn't prepare capture") >= 0)
             is_capture_prepared_ = true;
 }
 
-void AlsaLayer::preparePlaybackStream(void)
+void AlsaLayer::preparePlaybackStream()
 {
     if (is_playback_open_ and not is_playback_prepared_)
         if (ALSA_CALL(snd_pcm_prepare(playbackHandle_), "Couldn't prepare playback") >= 0)
@@ -523,7 +523,7 @@ void adjustVolume(SFLDataFormat *src , int samples, int volumePercentage)
 }
 }
 
-void AlsaLayer::capture(void)
+void AlsaLayer::capture()
 {
     unsigned int mainBufferSampleRate = Manager::instance().getMainBuffer()->getInternalSamplingRate();
     bool resample = audioSampleRate_ != mainBufferSampleRate;
@@ -628,7 +628,7 @@ void AlsaLayer::playback(int maxSamples)
     free(out);
 }
 
-void AlsaLayer::audioCallback(void)
+void AlsaLayer::audioCallback()
 {
     if (!playbackHandle_ or !captureHandle_)
         return;
diff --git a/daemon/src/audio/audiolayer.cpp b/daemon/src/audio/audiolayer.cpp
index 4da5fdcee8..a094b006a3 100644
--- a/daemon/src/audio/audiolayer.cpp
+++ b/daemon/src/audio/audiolayer.cpp
@@ -52,14 +52,14 @@ AudioLayer::~AudioLayer()
     delete converter_;
 }
 
-void AudioLayer::flushMain(void)
+void AudioLayer::flushMain()
 {
     ost::MutexLock guard(mutex_);
     // should pass call id
     Manager::instance().getMainBuffer()->flushAllBuffers();
 }
 
-void AudioLayer::flushUrgent(void)
+void AudioLayer::flushUrgent()
 {
     ost::MutexLock guard(mutex_);
     urgentRingBuffer_.flushAll();
diff --git a/daemon/src/audio/audiorecorder.cpp b/daemon/src/audio/audiorecorder.cpp
index 5d18859930..8c7a6acd2f 100644
--- a/daemon/src/audio/audiorecorder.cpp
+++ b/daemon/src/audio/audiorecorder.cpp
@@ -30,56 +30,45 @@
 
 #include "audiorecorder.h"
 #include "mainbuffer.h"
-#include <assert.h>
+#include <cassert>
 
-int AudioRecorder::count = 0;
+int AudioRecorder::count_ = 0;
 
-AudioRecorder::AudioRecorder(AudioRecord  *arec, MainBuffer *mb) : Thread()
+AudioRecorder::AudioRecorder(AudioRecord  *arec, MainBuffer *mb) : Thread(), mbuffer_(mb), arecord_(arec)
 {
     assert(mb);
     setCancel(cancelDeferred);
 
-    ++count;
+    ++count_;
 
     std::string id("processid_");
 
     // convert count into string
     std::string s;
     std::stringstream out;
-    out << count;
+    out << count_;
     s = out.str();
 
-    recorderId = id.append(s);
-
-    arecord = arec;
-    mbuffer = mb;
+    recorderId_ = id.append(s);
 }
 
-
 /**
  * Reimplementation of run()
  */
 void AudioRecorder::run()
 {
-
     int bufferLength = 10000;
     SFLDataFormat buffer[bufferLength];
 
     while (true) {
-
-        int availBytes = mbuffer->availForGet(recorderId);
-
+        int availBytes = mbuffer_->availForGet(recorderId_);
         int toGet = (availBytes < bufferLength) ? availBytes : bufferLength;
 
-        mbuffer->getData(buffer, toGet, recorderId);
-
-        if (availBytes > 0) {
+        mbuffer_->getData(buffer, toGet, recorderId_);
 
-            arecord->recData(buffer, availBytes/sizeof(SFLDataFormat));
-        }
+        if (availBytes > 0)
+            arecord_->recData(buffer, availBytes / sizeof(SFLDataFormat));
 
         sleep(20);
-
     }
-
 }
diff --git a/daemon/src/audio/audiorecorder.h b/daemon/src/audio/audiorecorder.h
index 8947b7667d..cc51162c36 100644
--- a/daemon/src/audio/audiorecorder.h
+++ b/daemon/src/audio/audiorecorder.h
@@ -42,14 +42,14 @@ class AudioRecorder : public ost::Thread {
     public:
         AudioRecorder(AudioRecord  *arec, MainBuffer *mb);
 
-        ~AudioRecorder(void) {
+        ~AudioRecorder() {
             terminate();
         }
 
-        static int count;
+        static int count_;
 
-        std::string getRecorderID() {
-            return recorderId;
+        std::string getRecorderID() const {
+            return recorderId_;
         }
 
         virtual void run();
@@ -58,11 +58,11 @@ class AudioRecorder : public ost::Thread {
         AudioRecorder(const AudioRecorder& ar);
         AudioRecorder& operator= (const AudioRecorder& ar);
 
-        std::string recorderId;
+        std::string recorderId_;
 
-        MainBuffer *mbuffer;
+        MainBuffer *mbuffer_;
 
-        AudioRecord *arecord;
+        AudioRecord *arecord_;
 };
 
 #endif
diff --git a/daemon/src/audio/codecs/g722.cpp b/daemon/src/audio/codecs/g722.cpp
index 9f8cc4b099..1df5b0f86b 100644
--- a/daemon/src/audio/codecs/g722.cpp
+++ b/daemon/src/audio/codecs/g722.cpp
@@ -83,7 +83,7 @@ class G722 : public sfl::AudioCodec {
         }
 
 
-        void g722_encode_init(void) {
+        void g722_encode_init() {
             encode_s->itu_test_mode = FALSE;
 
             // 8 => 64 kbps;  7 => 56 kbps;  6 => 48 kbps
@@ -108,7 +108,7 @@ class G722 : public sfl::AudioCodec {
             decode_s->out_bits = 0;
         }
 
-        void g722_decode_init(void) {
+        void g722_decode_init() {
 
             decode_s->itu_test_mode = FALSE;
 
diff --git a/daemon/src/audio/codecs/gsmcodec.cpp b/daemon/src/audio/codecs/gsmcodec.cpp
index c0ace7bb24..7120f9691e 100644
--- a/daemon/src/audio/codecs/gsmcodec.cpp
+++ b/daemon/src/audio/codecs/gsmcodec.cpp
@@ -64,7 +64,7 @@ class Gsm : public sfl::AudioCodec {
 
         Gsm& operator= (const Gsm&);
 
-        virtual ~Gsm(void) {
+        virtual ~Gsm() {
             gsm_destroy(decode_gsmhandle_);
             gsm_destroy(encode_gsmhandle_);
         }
diff --git a/daemon/src/audio/noisesuppress.cpp b/daemon/src/audio/noisesuppress.cpp
index e0b5cc64ee..e89190f2f0 100644
--- a/daemon/src/audio/noisesuppress.cpp
+++ b/daemon/src/audio/noisesuppress.cpp
@@ -32,37 +32,37 @@
 #include "noisesuppress.h"
 
 NoiseSuppress::NoiseSuppress(int smplPerFrame, int samplingRate)
-    : _smplPerFrame(smplPerFrame)
+    : smplPerFrame_(smplPerFrame)
 {
-    _noiseState = speex_preprocess_state_init(_smplPerFrame, samplingRate);
+    noiseState_ = speex_preprocess_state_init(smplPerFrame_, samplingRate);
     int i=1;
-    speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_DENOISE, &i);
+    speex_preprocess_ctl(noiseState_, SPEEX_PREPROCESS_SET_DENOISE, &i);
     i=-20;
-    speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &i);
+    speex_preprocess_ctl(noiseState_, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &i);
     i=0;
-    speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_AGC, &i);
+    speex_preprocess_ctl(noiseState_, SPEEX_PREPROCESS_SET_AGC, &i);
     i=8000;
-    speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_AGC_TARGET, &i);
+    speex_preprocess_ctl(noiseState_, SPEEX_PREPROCESS_SET_AGC_TARGET, &i);
     i=16000;
-    speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_AGC_LEVEL, &i);
+    speex_preprocess_ctl(noiseState_, SPEEX_PREPROCESS_SET_AGC_LEVEL, &i);
     i=0;
-    speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_DEREVERB, &i);
+    speex_preprocess_ctl(noiseState_, SPEEX_PREPROCESS_SET_DEREVERB, &i);
     float f=0.0;
-    speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &f);
+    speex_preprocess_ctl(noiseState_, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &f);
     f=0.0;
-    speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f);
+    speex_preprocess_ctl(noiseState_, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f);
     i = 0;
-    speex_preprocess_ctl(_noiseState, SPEEX_PREPROCESS_SET_VAD, &i);
+    speex_preprocess_ctl(noiseState_, SPEEX_PREPROCESS_SET_VAD, &i);
 }
 
 
 NoiseSuppress::~NoiseSuppress()
 {
-    speex_preprocess_state_destroy(_noiseState);
+    speex_preprocess_state_destroy(noiseState_);
 }
 
 void NoiseSuppress::process(SFLDataFormat *data, int samples)
 {
-    assert(_smplPerFrame == samples);
-    speex_preprocess_run(_noiseState, data);
+    assert(smplPerFrame_ == samples);
+    speex_preprocess_run(noiseState_, data);
 }
diff --git a/daemon/src/audio/noisesuppress.h b/daemon/src/audio/noisesuppress.h
index 07c00a1436..34815dd4ca 100644
--- a/daemon/src/audio/noisesuppress.h
+++ b/daemon/src/audio/noisesuppress.h
@@ -36,18 +36,14 @@
 
 class NoiseSuppress {
     public:
-
         NoiseSuppress(int smplPerFrame, int samplingRate);
-
-        ~NoiseSuppress(void);
-
+        ~NoiseSuppress();
         void process(SFLDataFormat *data, int samples);
 
     private:
 
-        SpeexPreprocessState *_noiseState;
-
-        int _smplPerFrame;
+        SpeexPreprocessState *noiseState_;
+        int smplPerFrame_;
 };
 
 #endif
-- 
GitLab