From 5a99ea86e6be12be1c8e2f061cbf8a303441bd0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kara=C5=9B?= <s176030@student.pg.edu.pl> Date: Mon, 15 Nov 2021 20:46:08 +0100 Subject: [PATCH] ALSA_support: moved InSampleType choice to open_alsa_device 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 | 45 +++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/src/cpp/ALSA_support.cpp b/src/cpp/ALSA_support.cpp index 996fd3d..d7726de 100644 --- a/src/cpp/ALSA_support.cpp +++ b/src/cpp/ALSA_support.cpp @@ -499,6 +499,37 @@ int DSP::ALSA_object_t::open_alsa_device(snd_pcm_stream_t stream_type) return -6; break; } + + switch (no_of_bytes_in_channel) + { + case 1: + InSampleTypeALSA = DSP::e::SampleType::ST_uchar; + break; + + case 2: + InSampleTypeALSA = DSP::e::SampleType::ST_short; + break; + + case 3: + InSampleTypeALSA = DSP::e::SampleType::ST_int; + break; + + case 4: + if (IsHigherQualityMode) + InSampleTypeALSA = DSP::e::SampleType::ST_int; + else + InSampleTypeALSA = DSP::e::SampleType::ST_float; + break; + + case 8: + InSampleTypeALSA = DSP::e::SampleType::ST_double; + break; + + default: + DSP::log << "Unsupported no of bytes in channel" << endl; + return -9; + break; + } } if (non_blocking_mode == false) @@ -677,20 +708,6 @@ long DSP::ALSA_object_t::open_PCM_device_4_input(const int &no_of_channels, int sampling_rate_alsa = (unsigned int) sampling_rate; audio_inbuffer_size_in_frames = (snd_pcm_uframes_t) audio_inbuffer_size; - switch (no_of_bytes_in_channel) - { - case 1: - InSampleTypeALSA = DSP::e::SampleType::ST_uchar; - break; - case 2: - InSampleTypeALSA = DSP::e::SampleType::ST_short; - break; - default: - InSampleTypeALSA = DSP::e::SampleType::ST_short; - no_of_bytes_in_channel = 2; - break; - } - rc = open_alsa_device(SND_PCM_STREAM_CAPTURE); if(rc > 0) -- GitLab