Exclude more coverage check which can't be covered by this module 65/191365/1
authorSeungbae Shin <seungbae.shin@samsung.com>
Tue, 16 Oct 2018 08:53:10 +0000 (17:53 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Tue, 16 Oct 2018 08:55:42 +0000 (17:55 +0900)
As following errors can't be covered by audio-io testcase itself, exclude from coverage scope
- pthread mutex errors
- sound_manager errors
- pulseaudio errors except policy restriction
- constructors which is not in use

Change-Id: I58d02dc65c16419b2c7eee95670f169327093109

src/cpp/CAudioIO.cpp
src/cpp/CAudioInput.cpp
src/cpp/CAudioOutput.cpp
src/cpp/CPulseAudioClient.cpp
src/cpp/CPulseStreamSpec.cpp

index 93e192f..1d44607 100644 (file)
@@ -27,6 +27,7 @@ using namespace tizen_media_audio;
 /**
  * class CAudioIO
  */
+//LCOV_EXCL_START
 CAudioIO::CAudioIO() :
     mpPulseAudioClient(NULL),
     __mMutex(PTHREAD_MUTEX_INITIALIZER),
@@ -38,6 +39,7 @@ CAudioIO::CAudioIO() :
     mStatePrev = CAudioInfo::EAudioIOState::AUDIO_IO_STATE_NONE;
     mByPolicy = false;
 }
+//LCOV_EXCL_STOP
 
 CAudioIO::CAudioIO(CAudioInfo& audioInfo) :
     mpPulseAudioClient(NULL),
@@ -73,7 +75,7 @@ void CAudioIO::internalLock() {
         THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
 
     if (pthread_mutex_lock(&__mMutex) != 0)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pthread_mutex_lock()");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pthread_mutex_lock()"); //LCOV_EXCL_LINE
 
 #ifdef _AUDIO_IO_DEBUG_TIMING_
     AUDIO_IO_LOGD(COLOR_RED "%p LOCKED" COLOR_END, &__mMutex);
@@ -85,7 +87,7 @@ void CAudioIO::internalUnlock() {
         THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Doesn't initialize CAudioIO");
 
     if (pthread_mutex_unlock(&__mMutex) != 0)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pthread_mutex_lock()");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pthread_mutex_lock()"); //LCOV_EXCL_LINE
 
 #ifdef _AUDIO_IO_DEBUG_TIMING_
     AUDIO_IO_LOGD(COLOR_GREEN "%p UNLOCKED" COLOR_END, &__mMutex);
@@ -126,11 +128,11 @@ void CAudioIO::initialize() {
 
     int ret = pthread_mutex_init(&__mMutex, NULL);
     if (ret != 0)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pthread_mutex_init()");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pthread_mutex_init()"); //LCOV_EXCL_LINE
 
     ret = pthread_cond_init(&__mCond, NULL);
     if (ret != 0)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pthread_cond_init()");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pthread_cond_init()"); //LCOV_EXCL_LINE
 
     __mIsInit = true;
 }
@@ -144,20 +146,24 @@ void CAudioIO::finalize() {
     bool error_occured = false;
     int ret = pthread_mutex_destroy(&__mMutex);
     if (ret != 0) {
-        AUDIO_IO_LOGE("Failed pthread_mutex_destroy(%p) errno:%d", &__mMutex, ret);
+        AUDIO_IO_LOGE("Failed pthread_mutex_destroy(%p) errno:%d", &__mMutex, ret); //LCOV_EXCL_LINE
         error_occured = true;
     }
 
     ret = pthread_mutex_destroy(&__mCondMutex);
     if (ret != 0) {
+//LCOV_EXCL_START
         AUDIO_IO_LOGE("Failed cond pthread_mutex_destroy(%p) errno:%d", &__mCondMutex, ret);
         error_occured = true;
+//LCOV_EXCL_STOP
     }
 
     ret = pthread_cond_destroy(&__mCond);
     if (ret != 0) {
+//LCOV_EXCL_START
         AUDIO_IO_LOGE("Failed pthread_cond_destroy(%p) errno:%d", &__mCond, ret);
         error_occured = true;
+//LCOV_EXCL_STOP
     }
 
     if (error_occured)
@@ -347,7 +353,7 @@ void CAudioIO::setStreamInfo(sound_stream_info_h stream_info) {
             THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE, "Input stream is not supported");
 
         if ((errorCode = sound_manager_get_type_from_stream_information(stream_info, &type)) != SOUND_MANAGER_ERROR_NONE)
-            THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->stream_type is invalid [ret:%d]", errorCode);
+            THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->stream_type is invalid [ret:%d]", errorCode); //LCOV_EXCL_LINE
         if (mDirection == CAudioInfo::EAudioDirection::AUDIO_DIRECTION_IN)
             getAudioInfo().convertInputStreamType2AudioType(type, &audioType);
         else
@@ -355,7 +361,7 @@ void CAudioIO::setStreamInfo(sound_stream_info_h stream_info) {
         getAudioInfo().setAudioType(audioType);
 
         if ((errorCode = sound_manager_get_index_from_stream_information(stream_info, &index)) != SOUND_MANAGER_ERROR_NONE)
-            THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->index is invalid [ret:%d]", errorCode);
+            THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameter stream_info->index is invalid [ret:%d]", errorCode); //LCOV_EXCL_LINE
         getAudioInfo().setAudioIndex(index);
 
     } catch (CAudioError& e) {
index 40521fb..4d6e804 100644 (file)
@@ -42,6 +42,7 @@ CAudioInput::CAudioInput(CAudioInfo& info) :
     mDirection = CAudioInfo::EAudioDirection::AUDIO_DIRECTION_IN;
 }
 
+//LCOV_EXCL_START
 CAudioInput::CAudioInput(
         unsigned int            sampleRate,
         CAudioInfo::EChannel    channel,
@@ -52,6 +53,7 @@ CAudioInput::CAudioInput(
     mDirection = CAudioInfo::EAudioDirection::AUDIO_DIRECTION_IN;
     mAudioInfo = CAudioInfo(sampleRate, channel, type, audioType, -1);
 }
+//LCOV_EXCL_STOP
 
 CAudioInput::~CAudioInput() {
 }
@@ -135,22 +137,22 @@ static bool __IsPrivilegeAllowed() {
 
     prData.paMainloop = pa_threaded_mainloop_new();
     if (prData.paMainloop == NULL)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_threaded_mainloop_new()");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_threaded_mainloop_new()"); //LCOV_EXCL_LINE
 
     c = pa_context_new(pa_threaded_mainloop_get_api(prData.paMainloop), CLIENT_NAME);
     if (c == NULL)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_new()");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_new()"); //LCOV_EXCL_LINE
 
     pa_context_set_state_callback(c, __contextStateChangeCb, prData.paMainloop);
 
     if (pa_context_connect(c, NULL, PA_CONTEXT_NOFLAGS, NULL) < 0)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_connect()");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_connect()"); //LCOV_EXCL_LINE
 
     pa_threaded_mainloop_lock(prData.paMainloop);
 
     if (pa_threaded_mainloop_start(prData.paMainloop) < 0) {
         pa_threaded_mainloop_unlock(prData.paMainloop);
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_threaded_mainloop_start()");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_threaded_mainloop_start()"); //LCOV_EXCL_LINE
     }
 
     while (true) {
@@ -161,10 +163,12 @@ static bool __IsPrivilegeAllowed() {
             break;
 
         if (!PA_CONTEXT_IS_GOOD(state)) {
+//LCOV_EXCL_START
             err = pa_context_errno(c);
             pa_threaded_mainloop_unlock(prData.paMainloop);
             THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION,
                                    "pa_context's state is not good : err[%d]", err);
+//LCOV_EXCL_STOP
         }
 
         /* Wait until the context is ready */
@@ -173,8 +177,10 @@ static bool __IsPrivilegeAllowed() {
 
     o = pa_context_check_privilege(c, RECORDER_PRIVILEGE, __checkPrivilegeCb, &prData);
     if (!o) {
+//LCOV_EXCL_START
         pa_threaded_mainloop_unlock(prData.paMainloop);
         THROW_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed to pa_context_check_privilege()");
+//LCOV_EXCL_STOP
     }
     while (pa_operation_get_state(o) == PA_OPERATION_RUNNING)
         pa_threaded_mainloop_wait(prData.paMainloop);
index 96b7531..996cdc5 100644 (file)
@@ -33,6 +33,7 @@ CAudioOutput::CAudioOutput(CAudioInfo& info) :
     mDirection = CAudioInfo::EAudioDirection::AUDIO_DIRECTION_OUT;
 }
 
+//LCOV_EXCL_START
 CAudioOutput::CAudioOutput(
         unsigned int            sampleRate,
         CAudioInfo::EChannel    channel,
@@ -43,6 +44,7 @@ CAudioOutput::CAudioOutput(
     mDirection = CAudioInfo::EAudioDirection::AUDIO_DIRECTION_OUT;
     mAudioInfo = CAudioInfo(sampleRate, channel, sampleType, audioType, -1);
 }
+//LCOV_EXCL_STOP
 
 CAudioOutput::~CAudioOutput() {
 }
@@ -308,8 +310,8 @@ size_t CAudioOutput::write(const void* buffer, size_t length) {
 
             int ret = mpPulseAudioClient->write(buffer, l);
             if (ret < 0)
-                THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION,
-                                       "The written result is invalid ret:%d", ret);
+                THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION,//LCOV_EXCL_LINE
+                                       "The written result is invalid ret:%d", ret); //LCOV_EXCL_LINE
 
             buffer = static_cast<const uint8_t*>(buffer) + l;
             lengthIter -= l;
index 19201ef..32a6e85 100644 (file)
@@ -133,11 +133,13 @@ void CPulseAudioClient::__streamStateChangeCb(pa_stream* s, void* user_data) {
         break;
 
     case PA_STREAM_FAILED:
+//LCOV_EXCL_START
         AUDIO_IO_LOGD("The stream is failed");
         pClient->__mpListener->onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE,
                                               __is_microphone_restricted());
         pa_threaded_mainloop_signal(pClient->__mpMainloop, 0);
         break;
+//LCOV_EXCL_STOP
 
     case PA_STREAM_TERMINATED:
         AUDIO_IO_LOGD("The stream is terminated");
@@ -301,7 +303,7 @@ void CPulseAudioClient::initialize() {
         // Allocates PA proplist
         __mpPropList = pa_proplist_new();
         if (__mpPropList == NULL) {
-            THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_proplist_new()");
+            THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_proplist_new()"); //LCOV_EXCL_LINE
         }
 
         // Adds values on proplist for delivery to PULSEAUDIO
@@ -322,13 +324,13 @@ void CPulseAudioClient::initialize() {
         // Allocates PA mainloop
         __mpMainloop = pa_threaded_mainloop_new();
         if (__mpMainloop == NULL) {
-            THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_threaded_mainloop_new()");
+            THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_threaded_mainloop_new()"); //LCOV_EXCL_LINE
         }
 
         // Allocates PA context
         __mpContext = pa_context_new(pa_threaded_mainloop_get_api(__mpMainloop), CLIENT_NAME);
         if (__mpContext == NULL) {
-            THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_new()");
+            THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_new()"); //LCOV_EXCL_LINE
         }
 
         // Sets context state changed callback
@@ -336,7 +338,7 @@ void CPulseAudioClient::initialize() {
 
         // Connects this client with PA server
         if (pa_context_connect(__mpContext, NULL, PA_CONTEXT_NOFLAGS, NULL) < 0) {
-            THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_connect()");
+            THROW_ERROR_MSG(CAudioError::EError::ERROR_OUT_OF_MEMORY, "Failed pa_context_connect()"); //LCOV_EXCL_LINE
         }
 
         // LOCK for synchronous connection
@@ -345,7 +347,7 @@ void CPulseAudioClient::initialize() {
         // Start mainloop
         if (pa_threaded_mainloop_start(__mpMainloop) < 0) {
             pa_threaded_mainloop_unlock(__mpMainloop);
-            THROW_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_threaded_mainloop_start()");
+            THROW_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_threaded_mainloop_start()"); //LCOV_EXCL_LINE
         }
 
         // Connection process is asynchronously
@@ -360,9 +362,11 @@ void CPulseAudioClient::initialize() {
             }
 
             if (!PA_CONTEXT_IS_GOOD(state)) {
+//LCOV_EXCL_START
                 err = pa_context_errno(__mpContext);
                 pa_threaded_mainloop_unlock(__mpMainloop);
                 THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "pa_context's state is not good : err[%d]", err);
+//LCOV_EXCL_STOP
             }
 
             /* Wait until the context is ready */
@@ -375,8 +379,10 @@ void CPulseAudioClient::initialize() {
 
         __mpStream = pa_stream_new_with_proplist(__mpContext, __mSpec.getStreamName(), &ss, &map, __mpPropList);
         if (__mpStream == NULL) {
+//LCOV_EXCL_START
             pa_threaded_mainloop_unlock(__mpMainloop);
             THROW_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_new_with_proplist()");
+//LCOV_EXCL_STOP
         }
 
         // Sets stream callbacks
@@ -415,9 +421,11 @@ void CPulseAudioClient::initialize() {
         }
 
         if (ret != 0) {
+//LCOV_EXCL_START
             err = pa_context_errno(__mpContext);
             pa_threaded_mainloop_unlock(__mpMainloop);
             THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_connect() : err[%d]", err);
+//LCOV_EXCL_STOP
         }
 
         while (true) {
@@ -435,7 +443,7 @@ void CPulseAudioClient::initialize() {
                 if (err == PA_ERR_ACCESS) {
                     THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_DEVICE_POLICY_RESTRICTION, "pa_stream's state is not good : err[%d]", err);
                 } else {
-                    THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "pa_stream's state is not good : err[%d]", err);
+                    THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "pa_stream's state is not good : err[%d]", err); //LCOV_EXCL_LINE
                 }
             }
 
@@ -552,7 +560,7 @@ int CPulseAudioClient::read(void* buffer, size_t length) {
                     // Data peeked, but it doesn't have any data
                     ret = pa_stream_drop(__mpStream);
                     if (ret != 0) {
-                        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pa_stream_drop() : ret[%d]", ret);
+                        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pa_stream_drop() : ret[%d]", ret); //LCOV_EXCL_LINE
                     }
                 } else {
                     __mSyncReadIndex = 0;
@@ -585,7 +593,7 @@ int CPulseAudioClient::read(void* buffer, size_t length) {
 #endif
                 ret = pa_stream_drop(__mpStream);
                 if (ret != 0) {
-                    THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pa_stream_drop() : ret[%d]", ret);
+                    THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pa_stream_drop() : ret[%d]", ret); //LCOV_EXCL_LINE
                 }
 
                 // Reset the internal pointer
@@ -636,7 +644,7 @@ int CPulseAudioClient::peek(const void** buffer, size_t* length) {
 #endif
 
     if (ret < 0) {
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_peek() : err[%d]", ret);
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_peek() : err[%d]", ret); //LCOV_EXCL_LINE
     }
 
     return ret;
@@ -668,7 +676,7 @@ int CPulseAudioClient::drop() {
     }
 
     if (ret < 0) {
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_drop() : err[%d]", ret);
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_drop() : err[%d]", ret); //LCOV_EXCL_LINE
     }
 
     return ret;
@@ -717,7 +725,7 @@ int CPulseAudioClient::write(const void* data, size_t length) {
     }
 
     if (ret < 0) {
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_write() : err[%d]", ret);
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_stream_write() : err[%d]", ret); //LCOV_EXCL_LINE
     }
 
     return ret;
index 93b10ec..2702130 100644 (file)
@@ -42,12 +42,13 @@ static const char* STREAM_LATENCY_VOIP    = "voip";
 static const char* STREAM_LATENCY_DEFAULT = "default";
 static const char* STREAM_LATENCY_DEFAULT_ASYNC = "default-async";
 
-
+//LCOV_EXCL_START
 CPulseStreamSpec::CPulseStreamSpec():
     __mLatency(EStreamLatency::STREAM_LATENCY_INPUT_DEFAULT),
     __mStreamName(NULL) {
     __adjustSpec();
 }
+//LCOV_EXCL_STOP
 
 CPulseStreamSpec::CPulseStreamSpec(EStreamLatency latency, CAudioInfo& audioInfo) :
     __mLatency(latency),
@@ -56,12 +57,14 @@ CPulseStreamSpec::CPulseStreamSpec(EStreamLatency latency, CAudioInfo& audioInfo
     __adjustSpec();
 }
 
+//LCOV_EXCL_START
 CPulseStreamSpec::CPulseStreamSpec(EStreamLatency latency, CAudioInfo& audioInfo, int customLatency) :
     __mLatency(latency),
     __mAudioInfo(audioInfo),
     __mStreamName(NULL) {
     __adjustSpec();
 }
+//LCOV_EXCL_STOP
 
 CPulseStreamSpec::~CPulseStreamSpec() {
 }