From d243f8a5507c23dc06a025f09030dff4e564d876 Mon Sep 17 00:00:00 2001
From: Ohtokani Pinzon <ohtokani.pinzon@nxp.com>
Date: Tue, 24 May 2022 09:52:46 -0700
Subject: [PATCH] fix of XRUN issue when using period size 240

Signed-off-by: Ohtokani Pinzon <ohtokani.pinzon@nxp.com>
---
 src/AudioStream/AudioStream.cpp               |   6 +-
 .../SignalProcessorAbstraction.cpp            |  38 +-
 .../SignalProcessorAbstraction.h              |  37 +-
 .../SignalProcessorImplementation.h           | 300 ++++++++--------
 src/SignalProcessor/SignalProcessor_Dummy.cpp | 339 ++++++++----------
 src/SignalProcessor/SignalProcessor_Dummy.h   | 176 +++------
 src/SignalProcessor/build/bin/libdummyimpl.so |   1 +
 .../build/bin/libdummyimpl.so.1.0             | Bin 0 -> 371344 bytes
 .../build/deps/SignalProcessor_Dummy.d        |   5 +
 .../build/obj/SignalProcessor_Dummy.o         | Bin 0 -> 658056 bytes
 src/SignalProcessor/makefile                  |  74 ++--
 src/main.cpp                                  |  33 +-
 12 files changed, 448 insertions(+), 561 deletions(-)
 create mode 120000 src/SignalProcessor/build/bin/libdummyimpl.so
 create mode 100755 src/SignalProcessor/build/bin/libdummyimpl.so.1.0
 create mode 100644 src/SignalProcessor/build/deps/SignalProcessor_Dummy.d
 create mode 100644 src/SignalProcessor/build/obj/SignalProcessor_Dummy.o
 mode change 100644 => 100755 src/SignalProcessor/makefile

diff --git a/src/AudioStream/AudioStream.cpp b/src/AudioStream/AudioStream.cpp
index 8b3c649..f8eb5b7 100755
--- a/src/AudioStream/AudioStream.cpp
+++ b/src/AudioStream/AudioStream.cpp
@@ -236,6 +236,7 @@ namespace AudioStreamWrapper
         snd_pcm_sframes_t availableFrames = snd_pcm_avail_update(this->_handle);
         if (availableFrames < 0) {
             if (availableFrames == -EPIPE) {
+		std::cout << "** readFrames1 XRUN ***" << std::endl;
                 availableFrames = snd_pcm_recover(this->_handle, availableFrames, 1);
                 if (availableFrames < 0)
                     throw AudioStreamException(snd_strerror(availableFrames), this->_streamName.c_str(), __FILE__, __LINE__, -1);
@@ -251,6 +252,7 @@ namespace AudioStreamWrapper
             int err = snd_pcm_readi(this->_handle, buffer, this->_periodSizeFrames);
             if (err < 0) {
                 if (err == -EPIPE) {
+		    std::cout << "** readFrames2 XRUN ***" << std::endl;
                     err = snd_pcm_recover(this->_handle, err, 1);
                     if (err < 0)
                         throw AudioStreamException(snd_strerror(err), this->_streamName.c_str(), __FILE__, __LINE__, -1);
@@ -280,6 +282,7 @@ namespace AudioStreamWrapper
         snd_pcm_sframes_t availableFrames = snd_pcm_avail_update(this->_handle);
         if (availableFrames < 0) {
             if (availableFrames == -EPIPE) {
+		std::cout << "** writeFrames1 XRUN ***" << std::endl;
                 availableFrames = snd_pcm_recover(this->_handle, availableFrames, 1);
                 if (availableFrames < 0)
                     throw AudioStreamException(snd_strerror(availableFrames), this->_streamName.c_str(), __FILE__, __LINE__, -1);
@@ -295,6 +298,7 @@ namespace AudioStreamWrapper
             int err = snd_pcm_writei(this->_handle, buffer, this->_periodSizeFrames);
             if (err < 0) {
                 if (err == -EPIPE) {
+		    std::cout << "** writeFrames2 XRUN ***" << std::endl;
                     err = snd_pcm_recover(this->_handle, err, 1);
                     if (err < 0)
                         throw AudioStreamException(snd_strerror(err), this->_streamName.c_str(), __FILE__, __LINE__, -1);
@@ -340,4 +344,4 @@ namespace AudioStreamWrapper
         std::cout << std::endl;
     }
 
-}   /* namespace AudioStream */
\ No newline at end of file
+}   /* namespace AudioStream */
diff --git a/src/SignalProcessor/SignalProcessorAbstraction.cpp b/src/SignalProcessor/SignalProcessorAbstraction.cpp
index bc3b9f7..73de932 100755
--- a/src/SignalProcessor/SignalProcessorAbstraction.cpp
+++ b/src/SignalProcessor/SignalProcessorAbstraction.cpp
@@ -1,46 +1,38 @@
-// Copyright 2020-2021 NXP
-// SPDX-License-Identifier: BSD-3-Clause
+/*----------------------------------------------------------------------------
+    Copyright 2020-2021 NXP
+    SPDX-License-Identifier: BSD-3-Clause
+----------------------------------------------------------------------------*/
+
 #include <exception>
 using namespace std;
 
 #include "SignalProcessor/SignalProcessorAbstraction.h"
 #include "SignalProcessor/SignalProcessorImplementation.h"
 
-namespace SignalProcessor
-{
+namespace SignalProcessor{
 
-    SignalProcessorAbstraction::SignalProcessorAbstraction(SignalProcessorImplementation *implementation)
-    {
+    SignalProcessorAbstraction::SignalProcessorAbstraction(SignalProcessorImplementation *implementation){
         setImplementation(implementation);
     }
 
-    int SignalProcessorAbstraction::setImplementation(SignalProcessorImplementation *implementation)
-    {
+    int SignalProcessorAbstraction::setImplementation(SignalProcessorImplementation *implementation){
         this->_implementation = implementation;
         return 0;
     }
 
-    int
-    SignalProcessorAbstraction::openProcessor(const void * settings)
-    {
+    int SignalProcessorAbstraction::openProcessor(const void * settings){
         return this->_implementation->openProcessor(settings);
     }
 
-    int
-    SignalProcessorAbstraction::processSignal(
+    int SignalProcessorAbstraction::processSignal(
             const char * nChannelMicBuffer, size_t micBuffer,
             const char * nChannelRefBuffer, size_t refBufferSize,
-            char * cleanMicBuffer, size_t cleanMicBufferSize)
-    {
-        return this->_implementation->processSignal(
-            nChannelMicBuffer, micBuffer,
-            nChannelRefBuffer, refBufferSize,
-            cleanMicBuffer, cleanMicBufferSize);
+            char * cleanMicBuffer, size_t cleanMicBufferSize){
+
+        return this->_implementation->processSignal(nChannelMicBuffer, micBuffer, nChannelRefBuffer, refBufferSize, cleanMicBuffer, cleanMicBufferSize);
     }
 
-    int
-    SignalProcessorAbstraction::closeProcessor(void)
-    {
+    int SignalProcessorAbstraction::closeProcessor() {
         return this->_implementation->closeProcessor();
     }
-}   /* namespace SignalProcessor */
+}/* namespace SignalProcessor */
diff --git a/src/SignalProcessor/SignalProcessorAbstraction.h b/src/SignalProcessor/SignalProcessorAbstraction.h
index 024ae19..8f035c8 100755
--- a/src/SignalProcessor/SignalProcessorAbstraction.h
+++ b/src/SignalProcessor/SignalProcessorAbstraction.h
@@ -2,6 +2,7 @@
     Copyright 2020-2021 NXP
     SPDX-License-Identifier: BSD-3-Clause
 ----------------------------------------------------------------------------*/
+
 #include <exception>
 using namespace std;
 
@@ -11,27 +12,21 @@ using namespace std;
 // #include "AudioFrontEnd/AudioFrontEnd.h"
 #include "SignalProcessor/SignalProcessorImplementation.h"
 
-namespace SignalProcessor
-{
-    class SignalProcessorAbstraction
-    {
-        public:
-            SignalProcessorAbstraction(SignalProcessor::SignalProcessorImplementation *signalProcessor);
-            virtual int
-            openProcessor(const void * settings);
-            virtual int
-            processSignal(
-                const char * nChannelMicBuffer, size_t micBuffer,
-                const char * nChannelRefBuffer, size_t refBufferSize,
-                char * cleanMicBuffer, size_t cleanMicBufferSize);
-            virtual int
-            closeProcessor(void);
-            virtual int
-            setImplementation(SignalProcessor::SignalProcessorImplementation *implementation);
+namespace SignalProcessor{
+
+    class SignalProcessorAbstraction{
+    protected:
+        SignalProcessor::SignalProcessorImplementation* _implementation;
 
-        protected:
-            SignalProcessor::SignalProcessorImplementation* _implementation;
+    public:
+        SignalProcessorAbstraction(SignalProcessor::SignalProcessorImplementation *signalProcessor);
+        virtual int openProcessor(const void * settings);
+        virtual int processSignal(
+            const char * nChannelMicBuffer, size_t micBuffer,
+            const char * nChannelRefBuffer, size_t refBufferSize,
+            char * cleanMicBuffer, size_t cleanMicBufferSize);
+        virtual int closeProcessor(void);
+        virtual int setImplementation(SignalProcessor::SignalProcessorImplementation *implementation);
     };
 }
-
-#endif
+#endif
\ No newline at end of file
diff --git a/src/SignalProcessor/SignalProcessorImplementation.h b/src/SignalProcessor/SignalProcessorImplementation.h
index 6d6010d..a9a118a 100755
--- a/src/SignalProcessor/SignalProcessorImplementation.h
+++ b/src/SignalProcessor/SignalProcessorImplementation.h
@@ -2,6 +2,7 @@
     Copyright 2020-2021 NXP
     SPDX-License-Identifier: BSD-3-Clause
 ----------------------------------------------------------------------------*/
+
 #include <string>
 #include <unordered_map>
 #include <vector>
@@ -9,168 +10,153 @@
 #ifndef __SignalProcessor__SignalProcessorImplementation_h__
 #define __SignalProcessor__SignalProcessorImplementation_h__
 
-namespace SignalProcessor
-{
+namespace SignalProcessor{
     #define GET_MAJOR_VERSION(version)      (uint32_t)((0xFF000000u & version) >> 24u)
     #define GET_MINOR_VERSION(version)      (uint32_t)((0x00FF0000u & version) >> 16u)
     #define GET_PATCH_VERSION(version)      (uint32_t)((0x0000FF00u & version) >> 8u)
 
-    class SignalProcessorImplementation
-    {
-        public:
-            virtual
-            ~SignalProcessorImplementation() {};
-            /**
-             * @brief This function should return the configured sample rate.
-             * 
-             * @retval Configured sample rate in Hz.
-             * @retval -1 = any value is acceptable
-             * 
-             * @warning The function should be invoked after the signal processor has been
-             * opened. Invoking the function prior signal processor opening returns -1.
-             * 
-             * @remark To be able to configure the audio HW in conjunction with a given signal processor implementation,
-             * this function should be used so the SW can automatically configure the sample rate of given audio streams.
-             */
-            virtual int
-            getSampleRate(void) const = 0;
-            /**
-             * @brief This function should return the configured sample format.
-             * 
-             * @retval Configured sample format.
-             * @retval -1 = any value is acceptable
-             * 
-             * @remark The format numbering must correspond to ALSA format numbering.
-             * 
-             * \par To be able to configure the audio HW in conjunction with a given signal processor implementation,
-             * this function should be used so the SW can automatically configure the sample format of given audio streams.
-             */
-            virtual const char *
-            getSampleFormat(void) const = 0;
-            /**
-             * @brief This function should return configured buffer period.
-             * 
-             * @retval Configured buffer period.
-             * @retval -1 = any value is acceptable
-             * 
-             * @warning The function should be invoked after the signal processor has been
-             * opened. Invoking the function prior signal processor opening returns -1.
-             * 
-             * @remark To be able to configure the audio HW in conjunction with a given signal processor implementation,
-             * this function should be used so the SW can automatically configure the buffer period of given audio streams.
-             */
-            virtual int
-            getPeriodSize(void) const = 0;
-            /**
-             * @brief This function should return the count of configured input channels.
-             *
-             * @retval Configured input channels count.
-             * @retval -1 = any value is acceptable
-             *
-             * @warning The function should be invoked after the signal processor has been
-             * opened. Invoking the function prior signal processor opening returns -1.
-             * 
-             * @remark To be able to configure the audio HW in conjunction with a given signal processor implementation,
-             * this function should be used so the SW can automatically configure the number of input channels of given stream.
-             */
-            virtual int
-            getInputChannelsCount(void) const = 0;
-            /**
-             * @brief This function should return the count of configured reference channels.
-             * 
-             * @retval Configured reference channels count.
-             * @retval -1 = any value is acceptable
-             * 
-             * @warning The function should be invoked after the signal processor has been
-             * opened. Invoking the function prior signal processor opening returns -1.
-             * 
-             * @remark To be able to configure the audio HW in conjunction with a given signal processor implementation,
-             * this function should be used so the SW can automatically configure the number of reference channels of given audio stream.
-             */
-            virtual int
-            getReferenceChannelsCount(void) const = 0;
-            /**
-             * Returns the implementation version number
-             * @details The version number should be stored in a 32 bit long variable.
-             * Bits 0 - 7 are reserved
-             * Bits 8 - 15 hold the patch version
-             * Bits 16 - 23 hold the minor version
-             * Bits 24 - 31 hold the major version
-             */
-            virtual uint32_t
-            getVersionNumber(void) const = 0;
-            /**
-             * @details Responsibility of this function is to allocate all resources
-             * required by the signal processor and initialize the signal processor
-             * according to input settings.\n
-             * The input settings may differ from vendor to vendor, thus an unordered map
-             * is provided for flexibility.\n
-             * Its also possible not to provide the settings. In such case default settings
-             * are used as defined by the specialized implementing class.
-             * 
-             * @param[in] settings Signal processor configuration
-             * 
-             * @remark To have as generic as possible interface, we need to define the settings
-             * as unorderd map. The configuration will be provided as a key:value pair. From
-             * this perspective it may be unclear, what can be set by the user, thus it's
-             * mandatory to implement the getSettingsDefinition function which should
-             * print out the required key:value pairs.
-             * 
-             * @see setDefaultSettings, processSignal, closeProcessor, getJsonConfigurations
-             */
-            virtual int 
-            openProcessor(const std::unordered_map<std::string, std::string> * settings = nullptr) = 0;
-            /**
-             *  @details This function should deallocate all resources initialized
-             * during signal processor opening, revert settings back to default and close
-             * the signal processor.\n
-             * If there is nothing to be closed (processor has not been opened yet or so), 
-             * silently assume closing was successful returning ok status.
-             */
-            virtual int
-            closeProcessor(void) = 0;
-            /**
-             * @details This function should filter the mic buffer with the use of a reference
-             * buffer (playback buffer) and provide the result in clean mic buffer. The
-             * input signal format is dependent on the underlying signal processor implementation.\n
-             * This function should return error in case the signal processor has not been
-             * initialized yet.
-             *
-             * @param[in] nChannelMicBuffer Array of N-channels microphone signal. The sample format depends on the underlying implemnetation.
-             * @param[in] micBufferSize Microphone array size in bytes
-             * @param[in] nChannelRefBuffer Array of N-channels microphone signal. The sample format depends on the underlying implementation.
-             * @param[in] refBufferSize Reference array size in bytes
-             * @param[out] cleanMicBuffer Array of samples representing a filtered single microphone channel. The sample format depends on the underlying implementation.
-             * @param[in] cleanMicBufferSize Microphone output array size in bytes.
-             * 
-             * @note The frame size of all buffers is the same. However, the total number of
-             * samples (and thus bytes) will differ based on the number of channels per frame.
-             * 
-             * @warning Makre sure the number of microphone channels, reference channels and
-             * clean microphone channels provided as arrays matches the signal processor configuration.
-             * Otherwise the library may provide unexpected results or lead to segmentation fault.\n
-             */
-            virtual int 
-            processSignal(
-                const char* nChannelMicBuffer, size_t micBufferSize,
-                const char* nChannelRefBuffer, size_t refBufferSize,
-                char* cleanMicBuffer, size_t cleanMicBufferSize) = 0;
-
-            /**
-             * @brief Returns a string in JSON format describing the configurations and possible options.
-             * @details The string should contain all required parameters with possible options. These
-             * should be recognized by the openProcessor() function.
-             * 
-             * @see getSampleRate, getSampleFormat, getPeriodSize, getInputChannelsCount, getReferenceChannelsCount
-             */
-            virtual const std::string &
-            getJsonConfigurations(void) const = 0;
+    class SignalProcessorImplementation {
+    
+    protected:
+        virtual void setDefaultSettings() = 0; //A default settings should be set with this function.
 
-        protected:
-            /**
-             *  @details A default settings should be set with this function.
-             */
-            virtual void setDefaultSettings(void) = 0;
+    public:
+        virtual ~SignalProcessorImplementation() {};
+        /**
+         * @brief This function should return the configured sample rate.
+         * 
+         * @retval Configured sample rate in Hz.
+         * @retval -1 = any value is acceptable
+         * 
+         * @warning The function should be invoked after the signal processor has been
+         * opened. Invoking the function prior signal processor opening returns -1.
+         * 
+         * @remark To be able to configure the audio HW in conjunction with a given signal processor implementation,
+         * this function should be used so the SW can automatically configure the sample rate of given audio streams.
+         */
+        virtual int getSampleRate() const = 0;
+        /**
+         * @brief This function should return the configured sample format.
+         * 
+         * @retval Configured sample format.
+         * @retval -1 = any value is acceptable
+         * 
+         * @remark The format numbering must correspond to ALSA format numbering.
+         * 
+         * \par To be able to configure the audio HW in conjunction with a given signal processor implementation,
+         * this function should be used so the SW can automatically configure the sample format of given audio streams.
+         */
+        virtual const char* getSampleFormat() const = 0;
+        /**
+         * @brief This function should return configured buffer period.
+         * 
+         * @retval Configured buffer period.
+         * @retval -1 = any value is acceptable
+         * 
+         * @warning The function should be invoked after the signal processor has been
+         * opened. Invoking the function prior signal processor opening returns -1.
+         * 
+         * @remark To be able to configure the audio HW in conjunction with a given signal processor implementation,
+         * this function should be used so the SW can automatically configure the buffer period of given audio streams.
+         */
+        virtual int getPeriodSize() const = 0;
+        /**
+         * @brief This function should return the count of configured input channels.
+         *
+         * @retval Configured input channels count.
+         * @retval -1 = any value is acceptable
+         *
+         * @warning The function should be invoked after the signal processor has been
+         * opened. Invoking the function prior signal processor opening returns -1.
+         * 
+         * @remark To be able to configure the audio HW in conjunction with a given signal processor implementation,
+         * this function should be used so the SW can automatically configure the number of input channels of given stream.
+         */
+        virtual int getInputChannelsCount() const = 0;
+        /**
+         * @brief This function should return the count of configured reference channels.
+         * 
+         * @retval Configured reference channels count.
+         * @retval -1 = any value is acceptable
+         * 
+         * @warning The function should be invoked after the signal processor has been
+         * opened. Invoking the function prior signal processor opening returns -1.
+         * 
+         * @remark To be able to configure the audio HW in conjunction with a given signal processor implementation,
+         * this function should be used so the SW can automatically configure the number of reference channels of given audio stream.
+         */
+        virtual int getReferenceChannelsCount() const = 0;
+        /**
+         * Returns the implementation version number
+         * @details The version number should be stored in a 32 bit long variable.
+         * Bits 0 - 7 are reserved
+         * Bits 8 - 15 hold the patch version
+         * Bits 16 - 23 hold the minor version
+         * Bits 24 - 31 hold the major version
+         */
+        virtual uint32_t getVersionNumber() const = 0;
+        /**
+         * @details Responsibility of this function is to allocate all resources
+         * required by the signal processor and initialize the signal processor
+         * according to input settings.\n
+         * The input settings may differ from vendor to vendor, thus an unordered map
+         * is provided for flexibility.\n
+         * Its also possible not to provide the settings. In such case default settings
+         * are used as defined by the specialized implementing class.
+         * 
+         * @param[in] settings Signal processor configuration
+         * 
+         * @remark To have as generic as possible interface, we need to define the settings
+         * as unorderd map. The configuration will be provided as a key:value pair. From
+         * this perspective it may be unclear, what can be set by the user, thus it's
+         * mandatory to implement the getSettingsDefinition function which should
+         * print out the required key:value pairs.
+         * 
+         * @see setDefaultSettings, processSignal, closeProcessor, getJsonConfigurations
+         */
+        virtual int openProcessor(const std::unordered_map<std::string, std::string>* settings = nullptr) = 0;
+        /**
+         *  @details This function should deallocate all resources initialized
+         * during signal processor opening, revert settings back to default and close
+         * the signal processor.\n
+         * If there is nothing to be closed (processor has not been opened yet or so), 
+         * silently assume closing was successful returning ok status.
+         */
+        virtual int closeProcessor() = 0;
+        /**
+         * @details This function should filter the mic buffer with the use of a reference
+         * buffer (playback buffer) and provide the result in clean mic buffer. The
+         * input signal format is dependent on the underlying signal processor implementation.\n
+         * This function should return error in case the signal processor has not been
+         * initialized yet.
+         *
+         * @param[in] nChannelMicBuffer Array of N-channels microphone signal. The sample format depends on the underlying implemnetation.
+         * @param[in] micBufferSize Microphone array size in bytes
+         * @param[in] nChannelRefBuffer Array of N-channels microphone signal. The sample format depends on the underlying implementation.
+         * @param[in] refBufferSize Reference array size in bytes
+         * @param[out] cleanMicBuffer Array of samples representing a filtered single microphone channel. The sample format depends on the underlying implementation.
+         * @param[in] cleanMicBufferSize Microphone output array size in bytes.
+         * 
+         * @note The frame size of all buffers is the same. However, the total number of
+         * samples (and thus bytes) will differ based on the number of channels per frame.
+         * 
+         * @warning Make sure the number of microphone channels, reference channels and
+         * clean microphone channels provided as arrays matches the signal processor configuration.
+         * Otherwise the library may provide unexpected results or lead to segmentation fault.\n
+         */
+        virtual int processSignal(
+            const char* nChannelMicBuffer, size_t micBufferSize,
+            const char* nChannelRefBuffer, size_t refBufferSize,
+            char* cleanMicBuffer, size_t cleanMicBufferSize) = 0;
+        
+        /**
+         * @brief Returns a string in JSON format describing the configurations and possible options.
+         * @details The string should contain all required parameters with possible options. These
+         * should be recognized by the openProcessor() function.
+         * 
+         * @see getSampleRate, getSampleFormat, getPeriodSize, getInputChannelsCount, getReferenceChannelsCount
+         */
+        virtual const std::string& getJsonConfigurations() const = 0;
     };
 }
 #endif
diff --git a/src/SignalProcessor/SignalProcessor_Dummy.cpp b/src/SignalProcessor/SignalProcessor_Dummy.cpp
index a6fe8b0..76a7db3 100644
--- a/src/SignalProcessor/SignalProcessor_Dummy.cpp
+++ b/src/SignalProcessor/SignalProcessor_Dummy.cpp
@@ -1,18 +1,20 @@
-// Copyright 2020-2021 NXP
-// SPDX-License-Identifier: BSD-3-Clause
+/*----------------------------------------------------------------------------
+	Copyright 2020-2021 NXP
+	SPDX-License-Identifier: BSD-3-Clause
+----------------------------------------------------------------------------*/
+
 #include "SignalProcessor/SignalProcessor_Dummy.h"
 #include <string>
 #include <iostream>
 #include <exception>
 
-namespace SignalProcessor
-{
-    const std::string SignalProcessor_Dummy::_jsonConfigDescription =
-    "{\n\
+namespace SignalProcessor{
+	const std::string SignalProcessor_Dummy::_jsonConfigDescription =
+		"{\n\
         \"default_config\" : {\n\
             \"sample_rate\" : -1,\n\
             \"sample_format\" : S32_LE,\n\
-            \"period_size\" : 512,\n\
+            \"period_size\" : 240,\n\
             \"input_channels\" : 6,\n\
             \"ref_channels\" : -1,\n\
             \"channel2output\" : 0\n\
@@ -24,175 +26,142 @@ namespace SignalProcessor
             \"channel2output\" : [\"int\", \"range\", 0, \"input_channels_max\"]\n\
         }\n}";
 
-    SignalProcessor_Dummy::SignalProcessor_Dummy(void) : _state(DummySignalProcessorState::closed)
-    {
-        /* Initialize the _signalProcessorSettings to default values */
-        setDefaultSettings();
-    }
-
-    int
-    SignalProcessor_Dummy::openProcessor(const std::unordered_map<std::string, std::string> * settings)
-    {
-        int err;
-
-        if (DummySignalProcessorState::closed != this->_state)
-        {
-            /* Instance is already opened. Report error as the instance needs to be closed first. */
-            return -1;
-        }
-
-        /* Overwrite default settings in case the user provided his own configuration */
-        if (nullptr != settings)
-        {
-            std::string format = settings->at("sample_format");
-            snd_pcm_format_t formatValue = snd_pcm_format_value(format.c_str());
-            if (SND_PCM_FORMAT_UNKNOWN != formatValue)
-            {
-                this->_sampleFormat = formatValue;
-                /* Get the size of bytes for one sample for given format */
-                this->_sampleSize = snd_pcm_format_size(this->_sampleFormat, 1);
-            }
-            else
-            {
-                closeProcessor();
-                throw; /* TODO throw some meaningful exception */
-            }
-            this->_channel2output       = stoi(settings->at("channel2output"));
-            this->_inputChannelsCount   = stoi(settings->at("input_channels"));
-            this->_periodSize           = stoi(settings->at("period_size"));
-        }
-
-        /* We can check the validity of settings here */
-        /* Check that the selected output channel is in range of available channels */
-        if (this->_channel2output >= this->_inputChannelsCount)
-        {
-            throw; /* TODO throw some meaningful exception */
-        }
-
-        /* To avoid opening the signal processor multiple times, we set a "state" */
-        this->_state = DummySignalProcessorState::opened;
-
-        /* As this is a virtual signal processor, we don't have to call some internal open/init or so which
-        would return a handler. So from this perspective it's all. */
-
-        return 0;
-    }
-
-    int
-    SignalProcessor_Dummy::closeProcessor(void)
-    {
-        /* We can deallocate internal resources here, but as we don't have any, we just
-        revert all changes to mimic a fresh signal processor instace */
-        if (DummySignalProcessorState::filtering != this->_state)
-        {
-            setDefaultSettings();
-            this->_state = DummySignalProcessorState::closed;
-            return 0;
-        }
-        return -1;
-    }
-
-    int
-    SignalProcessor_Dummy::processSignal(
-                const char* nChannelMicBuffer, size_t micBufferSize,
-                const char* nChannelRefBuffer, size_t refBufferSize,
-                char* cleanMicBuffer, size_t cleanMicBufferSize)
-    {
-        /* lets check, that the size of buffer matches the input settings. The dummy processor supports any buffer size,
-        however, we need to check, that the provided size matches the configured. */
-        size_t expectedBufferSize = this->_inputChannelsCount * this->_periodSize * this->_sampleSize;
-        if (micBufferSize != expectedBufferSize)
-        {
-            std::cout << "input buffer size doesn't match; expected: " << expectedBufferSize << "; got: " << micBufferSize << std::endl;
-            return -1;
-        }
-        expectedBufferSize = this->_periodSize * this->_sampleSize;
-        if (cleanMicBufferSize != expectedBufferSize)
-        {
-            std::cout << "output buffer size doesn't match" << std::endl;
-            return -2;
-        }
-
-        /* Let's process the signal - meaning copy the selected channel to output. */
-        this->_state = DummySignalProcessorState::filtering;
-        int shift = this->_inputChannelsCount * this->_sampleSize;
-
-        for (int i = 0; i < this->_periodSize; i++)
-        {
-            memcpy(cleanMicBuffer + i * this->_sampleSize,
-                nChannelMicBuffer + this->_channel2output + i * shift,
-                this->_sampleSize);
-        }
-        this->_state = DummySignalProcessorState::opened;
-        return 0;
-    }
-
-    const std::string &
-    SignalProcessor_Dummy::getJsonConfigurations(void) const
-    {
-        return _jsonConfigDescription;
-    }
-
-    int
-    SignalProcessor_Dummy::getSampleRate(void) const
-    {
-        return this->_sampleRate;
-    }
-
-    const char *
-    SignalProcessor_Dummy::getSampleFormat(void) const
-    {
-        return snd_pcm_format_name(this->_sampleFormat);
-    }
-
-    int
-    SignalProcessor_Dummy::getPeriodSize(void) const
-    {
-        return this->_periodSize;
-    }
-
-    int
-    SignalProcessor_Dummy::getInputChannelsCount(void) const
-    {
-        return this->_inputChannelsCount;
-    }
-
-    int
-    SignalProcessor_Dummy::getReferenceChannelsCount(void) const
-    {
-        return this->_referenceChannelsCount;
-    }
-
-    uint32_t
-    SignalProcessor_Dummy::getVersionNumber(void) const
-    {
-        /* version 1.0.0 */
-        return (uint32_t)((uint32_t)1 << 24);
-    }
-    /*
-     *  Private section
-     */
-    void
-    SignalProcessor_Dummy::setDefaultSettings(void)
-    {
-        /* As we don't filter anything, we just copy samples from input to output,
-        we don't care about the sample rate meaning we support everything => -1. */
-        this->_sampleRate               = -1;
-        /* In general we support any format, but we need to specify which one, so we know the sample size */
-        this->_sampleFormat             = SND_PCM_FORMAT_S32_LE;
-        /* The default period size is 512 frames */
-        this->_periodSize               = 512;
-        /* The number of input channels by default is 6. */
-        this->_inputChannelsCount       = 6;
-        /* As we don't filter anything, we don't care about the number of reference channels,
-        from this perspective we support any number of channels, as they are not used anyweay. */
-        this->_referenceChannelsCount   = -1;
-        /* By default, we will use the first channel as output. */
-        this->_channel2output           = 0;
-        /* Derive the sample size from the sample format. We store the value to no compute the
-        sample size every time in our code we need it. */
-        this->_sampleSize = snd_pcm_format_size(this->_sampleFormat, 1);
-    }
+	SignalProcessor_Dummy::SignalProcessor_Dummy() : _state(DummySignalProcessorState::closed) {
+		//Initialize the _signalProcessorSettings to default values
+		setDefaultSettings();
+	}
+
+	int	SignalProcessor_Dummy::openProcessor(const std::unordered_map<std::string, std::string>* settings){
+		int err;
+
+		if (DummySignalProcessorState::closed != this->_state) {
+			//Instance is already opened. Report error as the instance needs to be closed first.
+			return -1;
+		}
+
+		// Overwrite default settings in case the user provided his own configuration
+		if (nullptr != settings) {
+			std::string format = settings->at("sample_format");
+			snd_pcm_format_t formatValue = snd_pcm_format_value(format.c_str());
+			if (SND_PCM_FORMAT_UNKNOWN != formatValue){
+				this->_sampleFormat = formatValue;
+				/* Get the size of bytes for one sample for given format */
+				this->_sampleSize = snd_pcm_format_size(this->_sampleFormat, 1);
+			}
+			else{
+				closeProcessor();
+				throw; /* TODO throw some meaningful exception */
+			}
+			this->_channel2output = stoi(settings->at("channel2output"));
+			this->_inputChannelsCount = stoi(settings->at("input_channels"));
+			this->_periodSize = stoi(settings->at("period_size"));
+		}
+
+		/* We can check the validity of settings here */
+		/* Check that the selected output channel is in range of available channels */
+		if (this->_channel2output >= this->_inputChannelsCount){
+			throw; /* TODO throw some meaningful exception */
+		}
+
+		/* To avoid opening the signal processor multiple times, we set a "state" */
+		this->_state = DummySignalProcessorState::opened;
+
+		/* As this is a virtual signal processor, we don't have to call some internal open/init or so which
+		would return a handler. So from this perspective it's all. */
+
+		return 0;
+	}
+
+	int	SignalProcessor_Dummy::closeProcessor(){
+		/* We can deallocate internal resources here, but as we don't have any, we just
+		revert all changes to mimic a fresh signal processor instace */
+		if (DummySignalProcessorState::filtering != this->_state) {
+			setDefaultSettings();
+			this->_state = DummySignalProcessorState::closed;
+			return 0;
+		}
+		return -1;
+	}
+
+	int SignalProcessor_Dummy::processSignal(
+			const char* nChannelMicBuffer, size_t micBufferSize,
+			const char* nChannelRefBuffer, size_t refBufferSize,
+			char* cleanMicBuffer, size_t cleanMicBufferSize){
+
+		/* lets check, that the size of buffer matches the input settings. The dummy processor supports any buffer size,
+		however, we need to check, that the provided size matches the configured. */
+		size_t expectedBufferSize = this->_inputChannelsCount * this->_periodSize * this->_sampleSize;
+		if (micBufferSize != expectedBufferSize) {
+			std::cout << "input buffer size doesn't match; expected: " << expectedBufferSize << "; got: " << micBufferSize << std::endl;
+			return -1;
+		}
+		expectedBufferSize = this->_periodSize * this->_sampleSize;
+		if (cleanMicBufferSize != expectedBufferSize){
+			std::cout << "output buffer size doesn't match" << std::endl;
+			return -2;
+		}
+
+		/* Let's process the signal - meaning copy the selected channel to output. */
+		this->_state = DummySignalProcessorState::filtering;
+		int shift = this->_inputChannelsCount * this->_sampleSize;
+
+		for (int i = 0; i < this->_periodSize; i++)
+			memcpy(cleanMicBuffer + i * this->_sampleSize, nChannelMicBuffer + this->_channel2output + i * shift, this->_sampleSize);
+
+		this->_state = DummySignalProcessorState::opened;
+		return 0;
+	}
+
+	const std::string& SignalProcessor_Dummy::getJsonConfigurations() const{
+		return _jsonConfigDescription;
+	}
+
+	int SignalProcessor_Dummy::getSampleRate() const{
+		return this->_sampleRate;
+	}
+
+	const char* SignalProcessor_Dummy::getSampleFormat() const{
+		return snd_pcm_format_name(this->_sampleFormat);
+	}
+
+	int SignalProcessor_Dummy::getPeriodSize() const{
+		return this->_periodSize;
+	}
+
+	int SignalProcessor_Dummy::getInputChannelsCount() const{
+		return this->_inputChannelsCount;
+	}
+
+	int SignalProcessor_Dummy::getReferenceChannelsCount() const{
+		return this->_referenceChannelsCount;
+	}
+
+	uint32_t SignalProcessor_Dummy::getVersionNumber() const{
+		/* version 1.0.0 */
+		return (uint32_t)((uint32_t)1 << 24);
+	}
+	/*
+	 *  Private section
+	 */
+	void SignalProcessor_Dummy::setDefaultSettings() {
+		/* As we don't filter anything, we just copy samples from input to output,
+		we don't care about the sample rate meaning we support everything => -1. */
+		this->_sampleRate = -1;
+		/* In general we support any format, but we need to specify which one, so we know the sample size */
+		this->_sampleFormat = SND_PCM_FORMAT_S32_LE;
+		/* The default period size is 512 frames */
+		this->_periodSize = 240;
+		/* The number of input channels by default is 6. */
+		this->_inputChannelsCount = 6;
+		/* As we don't filter anything, we don't care about the number of reference channels,
+		from this perspective we support any number of channels, as they are not used anyweay. */
+		this->_referenceChannelsCount = -1;
+		/* By default, we will use the first channel as output. */
+		this->_channel2output = 0;
+		/* Derive the sample size from the sample format. We store the value to no compute the
+		sample size every time in our code we need it. */
+		this->_sampleSize = snd_pcm_format_size(this->_sampleFormat, 1);
+	}
 
 }   /* namespace SignalProcessor */
 
@@ -204,13 +173,11 @@ instance, which can be used to invoke the rest of functions defined in the imple
 */
 extern "C"  /* !!!We need to define these functions as extern "C", so their names don't get mangeled and we can load them dynamically!!! */
 {
-    SignalProcessor::SignalProcessorImplementation * createProcessor(void)
-    {
-        return new SignalProcessor::SignalProcessor_Dummy();
-    }
-
-    void destroyProcessor(SignalProcessor::SignalProcessorImplementation * processorHandle)
-    {
-        delete processorHandle;
-    }
-}
\ No newline at end of file
+	SignalProcessor::SignalProcessorImplementation* createProcessor(){
+		return new SignalProcessor::SignalProcessor_Dummy();
+	}
+
+	void destroyProcessor(SignalProcessor::SignalProcessorImplementation* processorHandle){
+		delete processorHandle;
+	}
+}
diff --git a/src/SignalProcessor/SignalProcessor_Dummy.h b/src/SignalProcessor/SignalProcessor_Dummy.h
index 968ead3..c692b7b 100644
--- a/src/SignalProcessor/SignalProcessor_Dummy.h
+++ b/src/SignalProcessor/SignalProcessor_Dummy.h
@@ -1,7 +1,8 @@
 /*----------------------------------------------------------------------------
-    Copyright 2020-2021 NXP
-    SPDX-License-Identifier: BSD-3-Clause
+	Copyright 2020-2021 NXP
+	SPDX-License-Identifier: BSD-3-Clause
 ----------------------------------------------------------------------------*/
+
 #ifndef __SignalProcessor_Dummy_h__
 #define __SignalProcessor_Dummy_h__
 
@@ -12,137 +13,68 @@
 
 /*------------------------------------------
 Include your own header file here, if necessary:
-
 #include "my_super_duper_signal_processor.h"
-
 ------------------------------------------*/
 
-namespace SignalProcessor
-{
-    /**
-     * Demonstration of signal processor implementation 
-     * This class demonstrates, how a signal processor can be implemented according to given template. 
-     * As this is just a dummy signal procssor, it's responsbility is only to select one out of n available 
-     * channels on input and provide it as an output. No filtering is performed on the selected channel. The 
-     * reference channels are ignored. 
-     * This implementation demonstrates, how to possibly implement your signal processor following defined 
-     * interface in the SignalProcessorImplementation base class.
-     */
-    class SignalProcessor_Dummy: public SignalProcessor::SignalProcessorImplementation
-    {
-        enum class DummySignalProcessorState
-        {
-            closed,
-            opened,
-            filtering
-        };
+namespace SignalProcessor {
+	/**
+	 * Demonstration of signal processor implementation
+	 * This class demonstrates, how a signal processor can be implemented according to given template.
+	 * As this is just a dummy signal procssor, it's responsbility is only to select one out of n available
+	 * channels on input and provide it as an output. No filtering is performed on the selected channel. The
+	 * reference channels are ignored.
+	 * This implementation demonstrates, how to possibly implement your signal processor following defined
+	 * interface in the SignalProcessorImplementation base class.
+	 */
+	class SignalProcessor_Dummy : public SignalProcessor::SignalProcessorImplementation {
 
-    public:
-        /**
-         * Construtor, initializes internal resources
-         */
-        SignalProcessor_Dummy(void);
-        /**
-         * This set of functions comes from the base class and we need to implement them all
-         * @{ */
-        int
-        openProcessor(const std::unordered_map<std::string, std::string> *settings = nullptr);
-        int
-        closeProcessor(void);
-        int
-        processSignal(
-            const char *nChannelMicBuffer, size_t micBufferSize,
-            const char *nChannelRefBuffer, size_t refBufferSize,
-            char *cleanMicBuffer, size_t cleanMicBufferSize);
-        /*
-          Returns the complete configuration space in JSON fromat
-        */
-        const std::string &
-        getJsonConfigurations(void) const override;
+		enum class DummySignalProcessorState {
+			closed,
+			opened,
+			filtering
+		};
 
-        /*
-          Set of functions returning the basic features supported by the signal processor.
-        */
-        int
-        getSampleRate(void) const override;
+		/*****************************************************************************************
+		 * Here comes a dummy signal processor customization, we "need" these for the implementation
+		*****************************************************************************************/
+		static const std::string _jsonConfigDescription; //JSON configuration
 
-        const char *
-        getSampleFormat(void) const override;
+		DummySignalProcessorState _state;	//State identifier
+		size_t _sampleSize;					//Size of samples in bytes. Parameter derived out of _sampleFormat variable
+		int _sampleRate;					//Selected sample rate
+		snd_pcm_format_t _sampleFormat = SND_PCM_FORMAT_S32_LE; //Sample format. The number should correspond to ALSA formats
+		int _periodSize;					//Selected period size
+		int _inputChannelsCount;			//Selected input channels count
+		int _referenceChannelsCount;		//Selected reference channels count
 
-        int
-        getPeriodSize(void) const override;
-        
-        int
-        getInputChannelsCount(void) const override;
+		//Select always the first channel to sent to output.
+		//Must be in range of _inputChannelsCount indexed from 0 to (_inputChannelsCount - 1)
+		int _channel2output; //Input channel selected as output. 
 
-        int
-        getReferenceChannelsCount(void) const override;
+		void setDefaultSettings(); //Sets the signal processors settings to default values.
 
-        uint32_t
-        getVersionNumber(void) const override;
-        /** @} */
+	public:
+		//Construtor
+		SignalProcessor_Dummy();
 
-    private:
-        /**
-         * Here comes a dummy signal processor customization, we "need" these for the implementation
-         * @{
-         */
-        /**
-         * JSON configuration
-         */
-        static const std::string _jsonConfigDescription;
-        /**
-         * State identifier.
-         */
-        DummySignalProcessorState _state;
-        /**
-         * Size of samples in bytes.
-         * 
-         * @remark This is a helper parameter derived out of _sampleFormat variable
-         */
-        size_t _sampleSize;
-        /**
-         * Selected sample rate.
-         */
-        int _sampleRate;
-        /**
-         * Selected sample format.
-         * 
-         * @remark The number should correspond to ALSA formats.
-         */
-        snd_pcm_format_t _sampleFormat = SND_PCM_FORMAT_S32_LE; // the signal processor has not been opened, report -1
-        /**
-         * Selected period size.
-         */
-        int _periodSize;
-        /**
-         * Selected input channels count.
-         */
-        int _inputChannelsCount;
-        /**
-         * Selected reference channels count.
-         */
-        int _referenceChannelsCount;
-        /**
-         * Input channel selected as output.
-         * 
-         * @warning Must be in range of _inputChannelsCount indexed from 0 to (_inputChannelsCount - 1)
-         */
-        int _channel2output;
-        /** @} */
+		//This set of functions comes from the base class and we need to implement them all
+		int openProcessor(const std::unordered_map<std::string, std::string>* settings = nullptr);
+		int closeProcessor();
+		int	processSignal(const char* nChannelMicBuffer, size_t micBufferSize,
+				const char* nChannelRefBuffer, size_t refBufferSize,
+				char* cleanMicBuffer, size_t cleanMicBufferSize);
+		
+		//Returns the complete configuration space in JSON fromat
+		const std::string& getJsonConfigurations() const override;
 
-        /**
-         * This set of functions comes from the base class and we need to implement them all
-         * @{ */
-        /**
-         * Sets the signal processors settings to default values.
-         *  
-         * @remark Select always the first channel to sent to output. 
-         */
-        void
-        setDefaultSettings(void);
-        /** @} */
-    };
+		//Set of functions returning the basic features supported by the signal processor
+		int getSampleRate() const override;
+		const char* getSampleFormat() const override;
+		int getPeriodSize() const override;
+		int getInputChannelsCount() const override;
+		int getReferenceChannelsCount() const override;
+		uint32_t getVersionNumber() const override;
+	};
 }
 
 #endif
\ No newline at end of file
diff --git a/src/SignalProcessor/build/bin/libdummyimpl.so b/src/SignalProcessor/build/bin/libdummyimpl.so
new file mode 120000
index 0000000..c36f820
--- /dev/null
+++ b/src/SignalProcessor/build/bin/libdummyimpl.so
@@ -0,0 +1 @@
+libdummyimpl.so.1.0
\ No newline at end of file
diff --git a/src/SignalProcessor/build/bin/libdummyimpl.so.1.0 b/src/SignalProcessor/build/bin/libdummyimpl.so.1.0
new file mode 100755
index 0000000000000000000000000000000000000000..aa80f54e711294ba529bdc997d572e87c3ae4419
GIT binary patch
diff --git a/src/SignalProcessor/build/deps/SignalProcessor_Dummy.d b/src/SignalProcessor/build/deps/SignalProcessor_Dummy.d
new file mode 100644
index 0000000..a834803
--- /dev/null
+++ b/src/SignalProcessor/build/deps/SignalProcessor_Dummy.d
@@ -0,0 +1,5 @@
+build/obj/SignalProcessor_Dummy.o: SignalProcessor_Dummy.cpp \
+ ../SignalProcessor/SignalProcessor_Dummy.h \
+ ../SignalProcessor/SignalProcessorImplementation.h
+../SignalProcessor/SignalProcessor_Dummy.h:
+../SignalProcessor/SignalProcessorImplementation.h:
diff --git a/src/SignalProcessor/build/obj/SignalProcessor_Dummy.o b/src/SignalProcessor/build/obj/SignalProcessor_Dummy.o
new file mode 100644
index 0000000000000000000000000000000000000000..ef36a8090105d2fb5a998233a1a78d4b2fd0c3ea
GIT binary patch
diff --git a/src/SignalProcessor/makefile b/src/SignalProcessor/makefile
old mode 100644
new mode 100755
index b874145..efef936
--- a/src/SignalProcessor/makefile
+++ b/src/SignalProcessor/makefile
@@ -1,39 +1,39 @@
 # MODIFIABLE PART
-PROGRAM		:= libs
-BUILDDIR 	:= build
-OBJDIR 		:= $(BUILDDIR)/obj
-BINDIR		:= $(BUILDDIR)/bin
-DEPDIR		:= $(BUILDDIR)/deps
-SRCDIR		:= 
-LDLIBS 		:= -lasound -ldl
-CPPFLAGS 	:= -I ..
-CXXFLAGS 	:= -g3 -O3 \
-				-Wall \
-				-Wextra \
-				-Wstrict-aliasing \
-				-pedantic \
-				-Werror \
-				-Wunreachable-code \
-				-Wcast-align \
-				-Wcast-qual \
-				-Wctor-dtor-privacy \
-				-Winit-self \
-				-Wlogical-op \
-				-Wmissing-include-dirs \
-				-Wnoexcept \
-				-Woverloaded-virtual \
-				-Wredundant-decls \
-				-Wshadow \
-				-Wsign-promo \
-				-Wstrict-null-sentinel \
-				-Wswitch-default \
-				-Wundef \
-				-Wno-unused \
-				-Wno-parentheses \
-				-fdiagnostics-show-option
-
-VERSION		:= 1.0
-PROGRAM		:= build/bin/libdummyimpl.so
+PROGRAM         := libs
+BUILDDIR        := build
+OBJDIR          := $(BUILDDIR)/obj
+BINDIR          := $(BUILDDIR)/bin
+DEPDIR          := $(BUILDDIR)/deps
+SRCDIR          := 
+LDLIBS          := -lasound -ldl
+CPPFLAGS        := -I ..
+CXXFLAGS        := -g3 -O3 \
+                                -Wall \
+                                -Wextra \
+                                -Wstrict-aliasing \
+                                -pedantic \
+                                -Werror \
+                                -Wunreachable-code \
+                                -Wcast-align \
+                                -Wcast-qual \
+                                -Wctor-dtor-privacy \
+                                -Winit-self \
+                                -Wlogical-op \
+                                -Wmissing-include-dirs \
+                                -Wnoexcept \
+                                -Woverloaded-virtual \
+                                -Wredundant-decls \
+                                -Wshadow \
+                                -Wsign-promo \
+                                -Wstrict-null-sentinel \
+                                -Wswitch-default \
+                                -Wundef \
+                                -Wno-unused \
+                                -Wno-parentheses \
+                                -fdiagnostics-show-option
+
+VERSION         := 1.0
+PROGRAM         := build/bin/libdummyimpl.so
 
 # Write down all the source files here used to compile the final app
 _SOURCES += SignalProcessor_Dummy.cpp
@@ -48,7 +48,7 @@ LIBRARIES += build/bin/libdummyimpl.so.$(VERSION)
 # DON'T TOUCH THE REST OF THIS SCIRPT, IF YOU DON'T KNOW, WHAT YOU ARE DOING
 #
 # additional flags to generate header dependencies files
-DEPFLAGS 	= -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
+DEPFLAGS        = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
 # postcompile command to move the newly generated dependency files
 # so they won't get deleted after build finishes
 POSTCOMPILE = mv -f $(DEPDIR)/$(*F).Td $(DEPDIR)/$(*F).d && touch $@
@@ -109,4 +109,4 @@ $(DEPFILES):
 
 # include the content of all generated DEPFILES containing
 # dependancy on header files
-include $(wildcard $(DEPFILES))
\ No newline at end of file
+include $(wildcard $(DEPFILES))
diff --git a/src/main.cpp b/src/main.cpp
index e9ea82a..8e066f6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -46,17 +46,17 @@ static const char * playbackLoopbackInputName	= "prloop";
 static snd_pcm_format_t format 					= SND_PCM_FORMAT_S32_LE;
 static const StreamType acc 					= StreamType::eInterleaved;
 static const int playbackOutputChannels			= 2;
-static int rate 								= 16000;
-static int period_size 							= 512;
-static int buffer_size 							= period_size * 4;
-
-static const snd_pcm_format_t formatPlaybackLoop = SND_PCM_FORMAT_S32_LE; 
- 
-static const char * playbackOutputName 	= "spk";
-static const char * captureInputName 	= "mic";
-static const int captureInputChannels 	= 6;
-static const char * captureLoopbackOutputName 	= "cwloop";
-static const int captureOutputChannels  = 1;
+static int rate									= 48000; // TODO: 48hz -> ASRC -> 16Khz
+static int period_size							= 240;
+static int buffer_size							= period_size * 4;
+
+static const snd_pcm_format_t formatPlaybackLoop = SND_PCM_FORMAT_S32_LE;
+
+static const char* playbackOutputName			= "spk";
+static const char* captureInputName				= "mic";
+static const int captureInputChannels			= 4;
+static const char* captureLoopbackOutputName	= "cwloop";
+static const int captureOutputChannels			= 1;
 
 static const int outputStreamChannels = 1;
 
@@ -178,9 +178,14 @@ int main (int argc, char *argv[])
 	std::cout << impl->getSampleFormat() << std::endl;
 	
 	std::cout << "Opening signal processor...\n";
-	std::unordered_map<std::string, std::string> processorSettings = {{"sample_format", "S32_LE"}, {"channel2output", "0"}, {"input_channels", "6"}, {"period_size", "512"}};
-	//impl->openProcessor(&processorSettings);
-	impl->openProcessor();
+	std::unordered_map<std::string, std::string> processorSettings = {
+		{"sample_format", "S32_LE"},
+		{"channel2output", "0"},
+		{"input_channels", "4"},
+		{"period_size", "240"},
+		{"rate", "16000"} };
+
+	impl->openProcessor(&processorSettings);
 	std::cout << "Signal processor opened.\n";
 
 	int err;
-- 
2.25.1

