From 2eb9186d2cd1e90b1a4d07d369d8c1a36ac44dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kara=C5=9B?= <s176030@student.pg.edu.pl> Date: Wed, 10 Nov 2021 17:49:04 +0100 Subject: [PATCH] ALSA_support: add an interrupt in case of negative snd pcm set format code 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 | 7 +++++-- src/include/ALSA_support.h | 10 +--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/cpp/ALSA_support.cpp b/src/cpp/ALSA_support.cpp index 1ad6b1a..17bb157 100644 --- a/src/cpp/ALSA_support.cpp +++ b/src/cpp/ALSA_support.cpp @@ -144,7 +144,6 @@ int DSP::ALSA_object_t::open_alsa_device(snd_pcm_stream_t stream_type) { //! Errors controller int rc; - //! Errors controller int errc; snd_pcm_hw_params_t *params; @@ -161,7 +160,6 @@ int DSP::ALSA_object_t::open_alsa_device(snd_pcm_stream_t stream_type) #ifdef AUDIO_DEBUG_MESSAGES_ON DSP::log << "Opening ALSA device" << endl; - //! \TODO Test mode: Open mode (see SND_PCM_NONBLOCK, SND_PCM_ASYNC) if (stream_type == SND_PCM_STREAM_PLAYBACK) @@ -200,6 +198,11 @@ int DSP::ALSA_object_t::open_alsa_device(snd_pcm_stream_t stream_type) errc = DSP::ALSA_object_t::set_snd_pcm_format(params); + if (errc < 0) + { + return -4; + } + snd_pcm_hw_params_set_channels(alsa_handle, params, no_of_channels_alsa); snd_pcm_hw_params_set_rate_near(alsa_handle, params, &sampling_rate_alsa, &dir); diff --git a/src/include/ALSA_support.h b/src/include/ALSA_support.h index 90d1e97..4984d65 100644 --- a/src/include/ALSA_support.h +++ b/src/include/ALSA_support.h @@ -70,21 +70,13 @@ namespace DSP { //! just samples snd_pcm_uframes_t audio_inbuffer_size_in_frames; // M.B. more meaningful variable name - + //! We always use the non-blocking mode in DSPElib bool blocking_mode; //! buffer capacity int size_b; - /***************************************************/ - /****************AUDIO INPUT TEST*******************/ - //DSP::e::SampleType InSampleType; - //static void CALLBACK waveInProc(HWAVEIN hwi, UINT uMsg, uint32_t dwInstance, uint32_t dwParam1, uint32_t dwParam2); - //std::vector<std::vector<int8_t>> input_buffers; - /**********************END**************************/ - /***************************************************/ - /*! Open default PCM device and return 1 on success or negative error code stream_type = SND_PCM_STREAM_PLAYBACK or SND_PCM_STREAM_CAPTURE the rest of the parameters are set in the class -- GitLab