From 028175995a8ba46792a725145614105c478b3ccd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Damian=20Kara=C5=9B?= <s176030@student.pg.edu.pl>
Date: Fri, 19 Nov 2021 16:01:32 +0100
Subject: [PATCH] ALSA_support: corrected the capture algorithm
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 | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/cpp/ALSA_support.cpp b/src/cpp/ALSA_support.cpp
index ce1f65d..8ecc999 100644
--- a/src/cpp/ALSA_support.cpp
+++ b/src/cpp/ALSA_support.cpp
@@ -904,8 +904,6 @@ bool DSP::ALSA_object_t::get_wave_in_raw_buffer(DSP::e::SampleType &InSampleType
 
   snd_pcm_sframes_t rc;
 
-  wave_in_raw_buffer.resize(capture_buffer.size());
-
   for (unsigned int ind = 0; ind < pcm_buffer.size(); ind++)
   {
     while (pcm_buffer_size_in_frames[ind])
@@ -945,8 +943,15 @@ bool DSP::ALSA_object_t::get_wave_in_raw_buffer(DSP::e::SampleType &InSampleType
 
             if (pcm_buffer_size_in_frames[ind] == 0)
             {
+              wave_in_raw_buffer.resize(capture_buffer.size());
               std::swap(wave_in_raw_buffer, capture_buffer);
-              DSP::log << "Inbuffer is full." << endl;
+              
+              #ifdef AUDIO_DEBUG_MESSAGES_ON
+                DSP::log << "Inbuffer is full." << endl;
+              #endif // AUDIO_DEBUG_MESSAGES_ON
+
+              pcm_buffer[ind] = (uint8_t *)(capture_buffer.data());
+              pcm_buffer_size_in_frames[ind] = (snd_pcm_sframes_t) capture_buffer.size() / no_of_bytes_in_channel / no_of_channels_alsa;
 
               return true;
             }
-- 
GitLab