Update coverage exception macros
[platform/core/api/audio-io.git] / src / cpp / CPulseAudioClient.cpp
index ef7ddb3..c3f68c9 100644 (file)
@@ -125,8 +125,8 @@ void CPulseAudioClient::__streamStateChangeCb(pa_stream* s, void* user_data) {
         pa_threaded_mainloop_signal(pClient->__mpMainloop, 0);
         break;
 
-    case PA_STREAM_FAILED:
 //LCOV_EXCL_START
+    case PA_STREAM_FAILED:
         AUDIO_IO_LOGD("The stream is failed");
         pClient->__mpListener->onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE,
                                               __is_microphone_restricted());
@@ -328,8 +328,10 @@ void CPulseAudioClient::initialize() {
 
         // Start mainloop
         if (pa_threaded_mainloop_start(__mpMainloop) < 0) {
+//LCOV_EXCL_START
             pa_threaded_mainloop_unlock(__mpMainloop);
-            THROW_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_threaded_mainloop_start()"); //LCOV_EXCL_LINE
+            THROW_ERROR_MSG(CAudioError::EError::ERROR_FAILED_OPERATION, "Failed pa_threaded_mainloop_start()");
+//LCOV_EXCL_STOP
         }
 
         // Connection process is asynchronously
@@ -435,8 +437,10 @@ void CPulseAudioClient::initialize() {
 
         // __mIsInit = true;  // Moved to __streamStateChangeCb()
     } catch (const CAudioError& e) {
+//LCOV_EXCL_START
         finalize();
         throw;
+//LCOV_EXCL_END
     }
 }
 
@@ -498,15 +502,15 @@ void CPulseAudioClient::finalize() {
 
 int CPulseAudioClient::read(void* buffer, size_t length) {
     if (!__mIsInit)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient"); //LCOV_EXCL_LINE
 
     checkRunningState();
 
     if (!buffer)
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "The parameter is invalid : buffer[%p]", buffer);
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "The parameter is invalid : buffer[%p]", buffer); //LCOV_EXCL_LINE
 
     if (__mDirection == EStreamDirection::STREAM_DIRECTION_PLAYBACK)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "The Playback client couldn't use this function");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "The Playback client couldn't use this function"); //LCOV_EXCL_LINE
 
     size_t lengthIter = length;
     int ret = 0;
@@ -522,7 +526,7 @@ int CPulseAudioClient::read(void* buffer, size_t length) {
             while (!__mpSyncReadDataPtr) {
                 ret = pa_stream_peek(__mpStream, &__mpSyncReadDataPtr, &__mSyncReadLength);
                 if (ret != 0)
-                    THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pa_stream_peek() : ret[%d]", ret);
+                    THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pa_stream_peek() : ret[%d]", ret); //LCOV_EXCL_LINE
 
                 if (__mSyncReadLength <= 0) {
 #ifdef _AUDIO_IO_DEBUG_TIMING_
@@ -530,10 +534,12 @@ int CPulseAudioClient::read(void* buffer, size_t length) {
 #endif
                     pa_threaded_mainloop_wait(__mpMainloop);
                 } else if (!__mpSyncReadDataPtr) {
+// LCOV_EXCL_START
                     // 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); //LCOV_EXCL_LINE
+                        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INTERNAL_OPERATION, "Failed pa_stream_drop() : ret[%d]", ret);
+//LCOV_EXCL_STOP
                 } else {
                     __mSyncReadIndex = 0;
                 }
@@ -573,9 +579,11 @@ int CPulseAudioClient::read(void* buffer, size_t length) {
         pa_threaded_mainloop_unlock(__mpMainloop);
         __mIsUsedSyncRead = false;
     } catch (const CAudioError& e) {
+// LCOV_EXCL_START
         pa_threaded_mainloop_unlock(__mpMainloop);
         __mIsUsedSyncRead = false;
         throw;
+// LCOV_EXCL_STOP
     }
 
     return length;
@@ -583,15 +591,16 @@ int CPulseAudioClient::read(void* buffer, size_t length) {
 
 int CPulseAudioClient::peek(const void** buffer, size_t* length) {
     if (!__mIsInit)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient"); // LCOV_EXCL_LINE
 
     checkRunningState();
 
     if (!buffer || !length)
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "The parameter is invalid : buffer[%p], length[%p]", buffer, length);
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT,                          // LCOV_EXCL_LINE
+                               "The parameter is invalid : buffer[%p], length[%p]", buffer, length); // LCOV_EXCL_LINE
 
     if (__mDirection == EStreamDirection::STREAM_DIRECTION_PLAYBACK)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "The Playback client couldn't use this function");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "The Playback client couldn't use this function"); // LCOV_EXCL_LINE
 
     int ret = 0;
 
@@ -615,7 +624,7 @@ int CPulseAudioClient::peek(const void** buffer, size_t* length) {
 
 int CPulseAudioClient::drop() {
     if (!__mIsInit)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient"); // LCOV_EXCL_LINE
 
 #ifdef _AUDIO_IO_DEBUG_TIMING_
     AUDIO_IO_LOGD("");
@@ -624,7 +633,7 @@ int CPulseAudioClient::drop() {
     checkRunningState();
 
     if (__mDirection == EStreamDirection::STREAM_DIRECTION_PLAYBACK)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "The Playback client couldn't use this function");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "The Playback client couldn't use this function"); // LCOV_EXCL_LINE
 
     int ret = 0;
 
@@ -644,10 +653,10 @@ int CPulseAudioClient::drop() {
 
 int CPulseAudioClient::write(const void* data, size_t length) {
     if (!data)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_ARGUMENT, "The parameter is invalid");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_ARGUMENT, "The parameter is invalid"); // LCOV_EXCL_LINE
 
     if (__mDirection == EStreamDirection::STREAM_DIRECTION_RECORD)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "The Playback client couldn't use this function");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "The Playback client couldn't use this function"); // LCOV_EXCL_LINE
 
     int ret = 0;
 
@@ -665,6 +674,7 @@ int CPulseAudioClient::write(const void* data, size_t length) {
         ret = pa_stream_write(__mpStream, data, length, NULL, 0LL, PA_SEEK_RELATIVE);
         pa_threaded_mainloop_unlock(__mpMainloop);
     } else {
+// LCOV_EXCL_START
         if (pa_stream_is_corked(__mpStream)) {
             AUDIO_IO_LOGW("stream is corked...do uncork here first!!!!");
             pa_operation_unref(pa_stream_cork(__mpStream, 0, NULL, this));
@@ -686,6 +696,7 @@ int CPulseAudioClient::write(const void* data, size_t length) {
                           length, prebuf, (length < prebuf) ? prebuf - length : 0);
         }
         ret = pa_stream_write(__mpStream, data, length, NULL, 0LL, PA_SEEK_RELATIVE);
+// LCOV_EXCL_STOP
     }
 
     if (ret < 0)
@@ -698,10 +709,10 @@ void CPulseAudioClient::cork(bool cork) {
     AUDIO_IO_LOGD("cork[%d]", cork);
 
     if (!__mIsInit)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient"); // LCOV_EXCL_LINE
 
     if (isInThread())
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "This operation is not supported in callback");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "This operation is not supported in callback"); // LCOV_EXCL_LINE
 
     checkRunningState();
 
@@ -720,7 +731,7 @@ void CPulseAudioClient::cork(bool cork) {
 
 bool CPulseAudioClient::isCorked() {
     if (!__mIsInit)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient"); // LCOV_EXCL_LINE
 
     checkRunningState();
 
@@ -742,7 +753,7 @@ bool CPulseAudioClient::isCorked() {
 
 bool CPulseAudioClient::drain() {
     if (!__mIsInit)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient"); // LCOV_EXCL_LINE
 
     checkRunningState();
 
@@ -783,7 +794,7 @@ bool CPulseAudioClient::drain() {
 
 bool CPulseAudioClient::flush() {
     if (!__mIsInit)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient"); // LCOV_EXCL_LINE
 
     checkRunningState();
 
@@ -802,12 +813,12 @@ bool CPulseAudioClient::flush() {
 
 size_t CPulseAudioClient::getWritableSize() {
     if (!__mIsInit)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CPulseAudioClient"); // LCOV_EXCL_LINE
 
     checkRunningState();
 
     if (__mDirection != EStreamDirection::STREAM_DIRECTION_PLAYBACK)
-        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "This client is used for Playback");
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_SUPPORTED, "This client is used for Playback"); // LCOV_EXCL_LINE
 
     size_t ret = 0;
 
@@ -824,13 +835,16 @@ size_t CPulseAudioClient::getWritableSize() {
 
 void CPulseAudioClient::checkRunningState() {
     if (!__mpContext || !PA_CONTEXT_IS_GOOD(pa_context_get_state(__mpContext)))
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_INITIALIZED, "The context[%p] is not created or not good state", __mpContext);
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_INITIALIZED,                       // LCOV_EXCL_LINE
+                               "The context[%p] is not created or not good state", __mpContext); // LCOV_EXCL_LINE
 
     if (!__mpStream || !PA_STREAM_IS_GOOD(pa_stream_get_state(__mpStream)))
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_INITIALIZED, "The stream[%p] is not created or not good state", __mpStream);
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_INITIALIZED,                     // LCOV_EXCL_LINE
+                               "The stream[%p] is not created or not good state", __mpStream); // LCOV_EXCL_LINE
 
     if (pa_context_get_state(__mpContext) != PA_CONTEXT_READY || pa_stream_get_state(__mpStream) != PA_STREAM_READY)
-        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_INITIALIZED, "The context[%p] or stream[%p] state is not ready", __mpContext, __mpStream);
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_INITIALIZED,                                   // LCOV_EXCL_LINE
+                               "The context[%p] or stream[%p] state is not ready", __mpContext, __mpStream); // LCOV_EXCL_LINE
 
 #ifdef _AUDIO_IO_DEBUG_TIMING_
     AUDIO_IO_LOGD("This client is running");