From: Seungbae Shin Date: Fri, 21 Feb 2020 11:11:47 +0000 (+0900) Subject: use auto for constexpr whenever possible X-Git-Tag: accepted/tizen/unified/20200414.034825^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dd3afbfd568c2b0b61c6d9e13fe16c0d9d5d0f51;p=platform%2Fcore%2Fapi%2Faudio-io.git use auto for constexpr whenever possible Change-Id: I0afca45754dc2487ed23d7bb63f2c5293f426f46 --- diff --git a/include/CAudioError.h b/include/CAudioError.h index e6c98eb..a054eb9 100644 --- a/include/CAudioError.h +++ b/include/CAudioError.h @@ -62,7 +62,7 @@ class CAudioError : public std::exception { }; /* Constants Definition */ - static constexpr unsigned int MSG_LENGTH = 512; + static constexpr auto MSG_LENGTH = 512; /* Constructor & Destructor */ CAudioError(EError err, const char* msg, const char* file, const char* func, int line); diff --git a/include/CAudioInfo.h b/include/CAudioInfo.h index 6f89ccc..06c3925 100644 --- a/include/CAudioInfo.h +++ b/include/CAudioInfo.h @@ -111,11 +111,12 @@ namespace tizen_media_audio { AUDIO_DIRECTION_MAX }; - static constexpr unsigned int MIN_SYSTEM_SAMPLERATE = 8000; - static constexpr unsigned int MAX_SYSTEM_SAMPLERATE = 192000; + static constexpr auto MIN_SYSTEM_SAMPLERATE = 8000; + static constexpr auto MAX_SYSTEM_SAMPLERATE = 192000; - static constexpr double MIN_RECORD_VOLUME = 0.0; - static constexpr double MAX_RECORD_VOLUME = 2.0; + static constexpr auto MIN_RECORD_VOLUME = 0.0; + static constexpr auto MAX_RECORD_VOLUME = 2.0; + static constexpr auto DEFAULT_RECORD_VOLUME = 1.0; /* Constructors */ CAudioInfo(); diff --git a/src/cpp/CAudioInput.cpp b/src/cpp/CAudioInput.cpp index ee5f3b6..cf607d4 100644 --- a/src/cpp/CAudioInput.cpp +++ b/src/cpp/CAudioInput.cpp @@ -34,7 +34,7 @@ CAudioInput::CAudioInput(CAudioInfo& info) : CAudioIO(info), __mIsUsedSyncRead(true), __mIsInit(false), - __mVolume(1.0) { + __mVolume(CAudioInfo::DEFAULT_RECORD_VOLUME) { mDirection = CAudioInfo::EAudioDirection::AUDIO_DIRECTION_IN; } @@ -103,7 +103,7 @@ void CAudioInput::finalize() { CAudioIO::finalize(); __setInit(false); - __mVolume = 1.0; + __mVolume = CAudioInfo::DEFAULT_RECORD_VOLUME; } void CAudioInput::prepare() { diff --git a/src/cpp/CPulseAudioClient.cpp b/src/cpp/CPulseAudioClient.cpp index ed65bf1..5c434cf 100644 --- a/src/cpp/CPulseAudioClient.cpp +++ b/src/cpp/CPulseAudioClient.cpp @@ -34,8 +34,8 @@ using namespace tizen_media_audio; * class CPulseAudioClient */ const char* CPulseAudioClient::CLIENT_NAME = "AUDIO_IO_PA_CLIENT"; -static constexpr unsigned int drain_wait_interval = 10000; -static constexpr unsigned int drain_wait_max_count = 30; +static constexpr auto drain_wait_interval = 10000; +static constexpr auto drain_wait_max_count = 30; CPulseAudioClient::CPulseAudioClient( EStreamDirection direction, diff --git a/src/cpp/cpp_audio_io.cpp b/src/cpp/cpp_audio_io.cpp index 223eed7..283cb84 100644 --- a/src/cpp/cpp_audio_io.cpp +++ b/src/cpp/cpp_audio_io.cpp @@ -277,8 +277,8 @@ static audio_io_state_e __convert_state_type(const CAudioInfo::EAudioIOState src } static void __check_audio_param(int sample_rate, audio_channel_e channel, audio_sample_type_e type, bool is_output) { - if (sample_rate < static_cast(CAudioInfo::MIN_SYSTEM_SAMPLERATE) || - sample_rate > static_cast(CAudioInfo::MAX_SYSTEM_SAMPLERATE)) + if (sample_rate < CAudioInfo::MIN_SYSTEM_SAMPLERATE || + sample_rate > CAudioInfo::MAX_SYSTEM_SAMPLERATE) THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Invalid sample rate :%d", sample_rate); if (channel < AUDIO_CHANNEL_MONO ||