Fix -Werror=format for toolchain upgrade 46/110346/1 accepted/tizen/common/20170116.181605 accepted/tizen/ivi/20170116.090505 accepted/tizen/mobile/20170116.090410 accepted/tizen/tv/20170116.090430 accepted/tizen/wearable/20170116.090450 submit/tizen/20170116.062507
authorSeungbae Shin <seungbae.shin@samsung.com>
Wed, 11 Jan 2017 13:13:43 +0000 (22:13 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Mon, 16 Jan 2017 04:45:35 +0000 (13:45 +0900)
Change-Id: Ic2d1f8e552438e43271d1e8bf9411f22a2de9687

include/CAudioInfo.h
src/cpp/CAudioInfo.cpp

index 00236a7e3ec76b04336006075ddf86186776b716..81afdef3fdbf0dbd4f0a4aed25685109b082514f 100644 (file)
 
 #ifdef __cplusplus
 
+#include <type_traits>
 
 namespace tizen_media_audio {
 
+    template<typename E>
+    constexpr auto to_integral(E e) -> typename std::underlying_type<E>::type {
+        return static_cast<typename std::underlying_type<E>::type>(e);
+    }
 
     /**
      * Audio Information
index 47791a717228c52efe6512c8cb797050b5e60496..3429c7e92f40f416546c80f6ff17e140e7b9984e 100644 (file)
@@ -42,19 +42,19 @@ CAudioInfo::CAudioInfo(unsigned int sampleRate, EChannel channel, ESampleType sa
     __mAudioIndex(audioIndex) {
     // Check to invalid AudioInfo
     if (sampleRate < CAudioInfo::MIN_SYSTEM_SAMPLERATE || sampleRate > CAudioInfo::MAX_SYSTEM_SAMPLERATE) {
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "The sampleRate is invalid [sampleRate:%d]", sampleRate);
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "The sampleRate is invalid [sampleRate:%u]", sampleRate);
     }
 
     if (channel < CAudioInfo::EChannel::CHANNEL_MONO || channel >= CAudioInfo::EChannel::CHANNEL_MAX) {
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "The channel is invalid [channel:%d]", channel);
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "The channel is invalid [channel:%u]", to_integral(channel));
     }
 
     if (sampleType < CAudioInfo::ESampleType::SAMPLE_TYPE_U8 || sampleType >= CAudioInfo::ESampleType::SAMPLE_TYPE_MAX) {
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "The sampleType is invalid [sampleType:%d]", sampleType);
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "The sampleType is invalid [sampleType:%u]", to_integral(sampleType));
     }
 
     if (audioType < CAudioInfo::EAudioType::AUDIO_IN_TYPE_MEDIA || audioType >= CAudioInfo::EAudioType::AUDIO_TYPE_MAX) {
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "The audioType is invalid [audioType:%d]", audioType);
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "The audioType is invalid [audioType:%u]", to_integral(audioType));
     }
 }
 
@@ -123,7 +123,8 @@ int CAudioInfo::getSampleSize() {
 
 void CAudioInfo::convertAudioType2StreamType(CAudioInfo::EAudioType audioType, char **streamType) {
     if (audioType < CAudioInfo::EAudioType::AUDIO_IN_TYPE_MEDIA || audioType >= CAudioInfo::EAudioType::AUDIO_TYPE_MAX) {
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE, "The audioType is not supported [audioType:%d]", audioType);
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE,
+                              "The audioType is not supported [audioType:%u]", to_integral(audioType));
     }
     *streamType = (char *)__STREAM_TYPE_TABLE[(unsigned int)audioType];
     return;