From 662d992f52aa041dbc44e1d0cad3bab578fa2cf3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Damian=20Kara=C5=9B?= <s176030@student.pg.edu.pl>
Date: Tue, 16 Nov 2021 22:32:50 +0100
Subject: [PATCH] ALSA_support: applied suggested changes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Damian Karaś <s176030@student.pg.edu.pl>
---
 src/cpp/ALSA_support.cpp   | 8 ++++----
 src/include/ALSA_support.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/cpp/ALSA_support.cpp b/src/cpp/ALSA_support.cpp
index f067c58..d1be06b 100644
--- a/src/cpp/ALSA_support.cpp
+++ b/src/cpp/ALSA_support.cpp
@@ -322,13 +322,13 @@ int DSP::ALSA_object_t::open_alsa_device(snd_pcm_stream_t stream_type)
     if (stream_type == SND_PCM_STREAM_PLAYBACK)
     {
       snd_pcm_hw_params_get_period_size(hw_params, &audio_outbuffer_size_in_frames, &dir);
-      DSP::log << "period size = " << (int) audio_outbuffer_size_in_frames << " frames" << endl;
+      DSP::log << "period size = " << audio_outbuffer_size_in_frames << " frames" << endl;
     }
 
     else // stream_type == SND_PCM_STREAM_CAPTURE
     {
       snd_pcm_hw_params_get_period_size(hw_params, &audio_inbuffer_size_in_frames, &dir);
-      DSP::log << "period size = " << (int) audio_inbuffer_size_in_frames << " frames" << endl;
+      DSP::log << "period size = " << audio_inbuffer_size_in_frames << " frames" << endl;
     }
 
     snd_pcm_hw_params_get_buffer_time(hw_params, &val, &dir);
@@ -478,12 +478,12 @@ int DSP::ALSA_object_t::open_alsa_device(snd_pcm_stream_t stream_type)
     pcm_buffer.resize(1);
     pcm_buffer_size_in_frames.resize(1);
     
-    capture_buffer.resize(size_b / no_of_bytes_in_channel);
+    capture_buffer.resize(size_b);
 
     for(unsigned int ind = 0; ind < pcm_buffer.size(); ind++)
     {
       pcm_buffer[ind] = (uint8_t *)(capture_buffer.data());
-      pcm_buffer_size_in_frames[ind] = (snd_pcm_sframes_t) capture_buffer.size() / no_of_channels_alsa;
+      pcm_buffer_size_in_frames[ind] = (snd_pcm_sframes_t) capture_buffer.size() / no_of_bytes_in_channel / no_of_channels_alsa;
     }
 
     switch (no_of_bytes_in_channel)
diff --git a/src/include/ALSA_support.h b/src/include/ALSA_support.h
index 0c7b59e..b262272 100644
--- a/src/include/ALSA_support.h
+++ b/src/include/ALSA_support.h
@@ -58,7 +58,7 @@ namespace DSP {
         std::vector<std::vector<double>> buffers_64bit;
 
         //! inbuffer
-        std::vector<int8_t> capture_buffer;
+        std::vector<uint8_t> capture_buffer;
         
         //! samples are integers rather than float values  
         bool IsHigherQualityMode;
-- 
GitLab