From b2953e1a5ed5ec4792ce5d27cc965374c43149b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kara=C5=9B?= <s176030@student.pg.edu.pl> Date: Wed, 22 Sep 2021 19:06:28 +0200 Subject: [PATCH] ALSA_support: add other log improvements 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/Makefile.linux | 2 +- src/cpp/ALSA_support.cpp | 31 +++++++++---------------------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/Makefile.linux b/src/Makefile.linux index 695337d..920c8cd 100644 --- a/src/Makefile.linux +++ b/src/Makefile.linux @@ -24,7 +24,7 @@ INCLUDES_RLS := -I./src/include -I./src/include/rls LIBS := -lasound # \TODO is DEVCPP ok or is it unnecessary -DFLAGS = -DLINUX -DDEVCPP -DINCLUDE_DSPE_EXAMPLES -DAUDIO_DEBUG_MESSAGES_ON +DFLAGS = -DLINUX -DDEVCPP -DINCLUDE_DSPE_EXAMPLES # -DAUDIO_DEBUG_MESSAGES_ON CFLAGS_release = $(comflag) -std=c++0x -O3 -Wall -c -fmessage-length=0 -fno-strict-aliasing CFLAGS_debug = $(comflag) -std=c++0x -O0 -g3 -Wall -c -fmessage-length=0 -W -Wshadow -Wconversion -fstrict-aliasing -fmax-errors=5 # -U__STRICT_ANSI__ jest potrzebne do kompilacji debug_new.cpp, jeďż˝eli pomin�� ten plik to moďż˝na rďż˝wnieďż˝ wyrzuciďż˝ tďż˝ opcjďż˝ diff --git a/src/cpp/ALSA_support.cpp b/src/cpp/ALSA_support.cpp index 73cf407..5ee7bcf 100644 --- a/src/cpp/ALSA_support.cpp +++ b/src/cpp/ALSA_support.cpp @@ -1,7 +1,7 @@ /*! \file ALSA_support.cpp * ALSA support code file * - * \author Marek Blok + * \authors Damian KaraĹ, Marek Blok */ #include <ALSA_support.h> @@ -175,7 +175,6 @@ int DSP::ALSA_object_t::open_alsa_device(snd_pcm_stream_t stream_type) if (rc < 0) { DSP::log << "Unable to open pcm device: " << snd_strerror(rc) << endl; - return -1; } @@ -210,7 +209,8 @@ int DSP::ALSA_object_t::open_alsa_device(snd_pcm_stream_t stream_type) snd_pcm_uframes_t requested_audio_inbuffer_size_in_frames = audio_inbuffer_size_in_frames; - if (rc < 0) { + if (rc < 0) + { DSP::log << "Buffer size set with error code: " << rc << endl; } @@ -237,7 +237,6 @@ int DSP::ALSA_object_t::open_alsa_device(snd_pcm_stream_t stream_type) DSP::log << "Closing ALSA device" << endl; close_alsa_device(); - return -2; } /*! Make a copy of hardware parameters. */ @@ -417,7 +416,6 @@ int DSP::ALSA_object_t::open_alsa_device(snd_pcm_stream_t stream_type) default: DSP::log << "Unsupported no of bytes in channel" << endl; - return -1; break; } @@ -428,10 +426,7 @@ int DSP::ALSA_object_t::open_alsa_device(snd_pcm_stream_t stream_type) if (rc < 0) { - #ifdef AUDIO_DEBUG_MESSAGES_ON - DSP::log << "Unable to set blocking mode" << endl; - #endif // AUDIO_DEBUG_MESSAGES_ON - + DSP::log << "Unable to set blocking mode" << endl; return -1; } } @@ -441,10 +436,7 @@ int DSP::ALSA_object_t::open_alsa_device(snd_pcm_stream_t stream_type) rc = snd_pcm_nonblock(alsa_handle, 1); if (rc < 0) { - #ifdef AUDIO_DEBUG_MESSAGES_ON - DSP::log << "Unable to set non blocking mode" << endl; - #endif // AUDIO_DEBUG_MESSAGES_ON - + DSP::log << "Unable to set non blocking mode" << endl; return -1; } } @@ -568,10 +560,7 @@ int DSP::ALSA_object_t::set_snd_pcm_format(snd_pcm_hw_params_t *params) break; default: - #ifdef AUDIO_DEBUG_MESSAGES_ON - DSP::log << "Unsupported no of bytes in channel" << endl; - #endif // AUDIO_DEBUG_MESSAGES_ON - + DSP::log << "Unsupported no of bytes in channel" << endl; return -1; break; } @@ -598,6 +587,7 @@ long DSP::ALSA_object_t::open_PCM_device_4_output(const int &no_of_channels, int else { + DSP::log << "Device has not been opened." << endl; return -1; } } @@ -620,6 +610,7 @@ long DSP::ALSA_object_t::open_PCM_device_4_input(const int &no_of_channels, int } else { + DSP::log << "Device has not been opened." << endl; return -1; } } @@ -704,9 +695,7 @@ long DSP::ALSA_object_t::append_playback_buffer(DSP::Float_vector &float_buffer) break; default: - #ifdef AUDIO_DEBUG_MESSAGES_ON - DSP::log << "Unsupported no of bytes in channel" << endl; - #endif // AUDIO_DEBUG_MESSAGES_ON + DSP::log << "Unsupported no of bytes in channel" << endl; break; // converting samples ends @@ -913,12 +902,10 @@ void DSP::ALSA_object_t::close_alsa_device(bool do_drain, bool use_log) } } - #ifdef AUDIO_DEBUG_MESSAGES_ON if (use_log == true) { DSP::log << "ALSA PCM sound closed" << endl; } - #endif // AUDIO_DEBUG_MESSAGES_ON IsDeviceInputOpen = false; IsDeviceOutputOpen = false; -- GitLab