Merge branch 'tizen' into tizen_line_coverage
[platform/core/api/audio-io.git] / src / cpp / CPulseAudioClient.cpp
index db411b4..4423dda 100644 (file)
@@ -84,6 +84,7 @@ void CPulseAudioClient::__contextStateChangeCb(pa_context* c, void* user_data) {
     }
 }
 
+//LCOV_EXCL_START
 void CPulseAudioClient::__successContextCb(pa_context* c, int success, void* user_data) {
     AUDIO_IO_LOGD("pa_context[%p], success[%d], user_data[%p]", c, success, user_data);
     assert(c);
@@ -113,6 +114,7 @@ static bool __is_microphone_restricted(void) {
 #endif
     return (state ? false : true);
 }
+//LCOV_EXCL_STOP
 
 void CPulseAudioClient::__streamStateChangeCb(pa_stream* s, void* user_data) {
     assert(s);
@@ -131,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");
@@ -238,6 +242,7 @@ void CPulseAudioClient::__streamUnderflowCb(pa_stream* s, void* user_data) {
     pClient->__mIsStarted = false;
 }
 
+//LCOV_EXCL_START
 void CPulseAudioClient::__streamEventCb(pa_stream* s, const char *name, pa_proplist *pl, void *user_data) {
     assert(s);
     assert(user_data);
@@ -249,7 +254,7 @@ void CPulseAudioClient::__streamEventCb(pa_stream* s, const char *name, pa_propl
         pa_operation_unref(pa_stream_cork(pClient->__mpStream, 1, NULL, NULL));
     }
 }
-
+//LCOV_EXCL_STOP
 
 void CPulseAudioClient::__successStreamCb(pa_stream* s, int success, void* user_data) {
     AUDIO_IO_LOGD("pa_stream[%p], success[%d], user_data[%p]", s, success, user_data);
@@ -262,6 +267,7 @@ void CPulseAudioClient::__successStreamCb(pa_stream* s, int success, void* user_
     pa_threaded_mainloop_signal(pClient->__mpMainloop, 0);
 }
 
+//LCOV_EXCL_START
 void CPulseAudioClient::__successDrainCbInThread(pa_stream* s, int success, void* user_data) {
     AUDIO_IO_LOGD("pa_stream[%p], success[%d], user_data[%p]", s, success, user_data);
     assert(s);
@@ -271,6 +277,7 @@ void CPulseAudioClient::__successDrainCbInThread(pa_stream* s, int success, void
     pClient->__mIsOperationSuccess = static_cast<bool>(success);
     pClient->__mIsDraining = false;
 }
+//LCOV_EXCL_STOP
 
 void CPulseAudioClient::__successDrainCb(pa_stream* s, int success, void* user_data) {
     AUDIO_IO_LOGD("pa_stream[%p], success[%d], user_data[%p]", s, success, user_data);
@@ -296,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
@@ -317,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
@@ -331,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
@@ -340,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
@@ -355,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 */
@@ -370,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
@@ -410,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) {
@@ -430,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
                 }
             }
 
@@ -547,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;
@@ -580,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
@@ -631,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;
@@ -663,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;
@@ -718,7 +731,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;
@@ -886,6 +899,7 @@ bool CPulseAudioClient::isInThread() {
     return static_cast<bool>(ret);
 }
 
+//LCOV_EXCL_START
 size_t CPulseAudioClient::getReadableSize() {
     if (__mIsInit == false) {
         THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient");
@@ -1054,3 +1068,4 @@ CPulseAudioClient::EStreamDirection CPulseAudioClient::getStreamDirection() {
 CPulseStreamSpec CPulseAudioClient::getStreamSpec() {
     return __mSpec;
 }
+//LCOV_EXCL_STOP