Check state and isInThread when pause/resume 57/109757/3 accepted/tizen/3.0/common/20170113.182103 accepted/tizen/3.0/ivi/20170113.080305 accepted/tizen/3.0/mobile/20170113.080219 accepted/tizen/3.0/tv/20170113.080232 accepted/tizen/3.0/wearable/20170113.080250 submit/tizen_3.0/20170111.132101
authorJeongho Mok <jho.mok@samsung.com>
Wed, 11 Jan 2017 11:08:34 +0000 (20:08 +0900)
committerJeongho Mok <jho.mok@samsung.com>
Wed, 11 Jan 2017 12:53:37 +0000 (21:53 +0900)
[Version] 0.3.53
[Profile] Common
[Issue Type] SVACE

Change-Id: I72c8ab825741283dc930646bfaa530b6e49f57fa

include/CAudioError.h
packaging/capi-media-audio-io.spec
src/cpp/CAudioError.cpp
src/cpp/CAudioInput.cpp
src/cpp/CAudioOutput.cpp
src/cpp/cpp_audio_io.cpp

index e683c6c..43ec587 100644 (file)
@@ -40,6 +40,7 @@ namespace tizen_media_audio {
             ERROR_INVALID_FORMAT,
             ERROR_INVALID_POINTER,
             ERROR_INVALID_OPERATION,
+            ERROR_INVALID_STATE,
 
             ERROR_NOT_INITIALIZED,
             ERROR_NOT_SUPPORTED,
index 1be2102..039871a 100644 (file)
@@ -1,6 +1,6 @@
 Name:           capi-media-audio-io
 Summary:        An Audio Input & Audio Output library in Tizen Native API
-Version:        0.3.52
+Version:        0.3.53
 Release:        0
 Group:          Multimedia/API
 License:        Apache-2.0
index d429f66..ed61465 100644 (file)
@@ -88,6 +88,7 @@ const char* CAudioError::__convertErrorToString(EError err) {
     case EError::ERROR_INVALID_FORMAT:      return COLOR_RED   "ERROR_INVALID_FORMAT"     COLOR_END;
     case EError::ERROR_INVALID_POINTER:     return COLOR_RED   "ERROR_INVALID_POINTER"    COLOR_END;
     case EError::ERROR_INVALID_OPERATION:   return COLOR_RED   "ERROR_INVALID_OPERATION"  COLOR_END;
+    case EError::ERROR_INVALID_STATE:       return COLOR_RED   "ERROR_INVALID_STATE"      COLOR_END;
     case EError::ERROR_NOT_INITIALIZED:     return COLOR_RED   "ERROR_NOT_INITIALIZED"    COLOR_END;
     case EError::ERROR_NOT_SUPPORTED:       return COLOR_RED   "ERROR_NOT_SUPPORTED"      COLOR_END;
     case EError::ERROR_NOT_SUPPORTED_TYPE:  return COLOR_RED   "ERROR_NOT_SUPPORTED_TYPE" COLOR_END;
index 1e53881..3887ddb 100644 (file)
@@ -333,6 +333,15 @@ void CAudioInput::pause() throw(CAudioError) {
         THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioInput");
     }
 
+    if (CAudioIO::getState() != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING) {
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_STATE,
+                        "Can't pause if not in Running state");
+    }
+
+    if (mpPulseAudioClient->isInThread() == true) {
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_OPERATION, "Can't pause in thread");
+    }
+
     try {
         CAudioIO::pause();
 
@@ -357,6 +366,15 @@ void CAudioInput::resume() throw(CAudioError) {
         THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioInput");
     }
 
+    if (CAudioIO::getState() != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_PAUSED) {
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_STATE,
+                        "Can't resume if not in Paused state");
+    }
+
+    if (mpPulseAudioClient->isInThread() == true) {
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_OPERATION, "Can't resume in thread");
+    }
+
     try {
         internalLock();
 
index fbbe8ea..19de90f 100644 (file)
@@ -230,6 +230,15 @@ void CAudioOutput::pause() throw(CAudioError) {
         THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioOutput");
     }
 
+    if (CAudioIO::getState() != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING) {
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_STATE,
+                        "Can't pause if not in Running state");
+    }
+
+    if (mpPulseAudioClient->isInThread() == true) {
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_OPERATION, "Can't pause in thread");
+    }
+
     try {
         CAudioIO::pause();
 
@@ -254,6 +263,15 @@ void CAudioOutput::resume() throw(CAudioError) {
         THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize or prepare CAudioOutput");
     }
 
+    if (CAudioIO::getState() != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_PAUSED) {
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_STATE,
+                        "Can't resume if not in Paused state");
+    }
+
+    if (mpPulseAudioClient->isInThread() == true) {
+        THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_OPERATION, "Can't resume in thread");
+    }
+
     try {
         internalLock();
 
index 902107e..bbb30b6 100644 (file)
@@ -133,6 +133,9 @@ static audio_io_error_e __convert_CAudioError(CAudioError& error) {
     case CAudioError::EError::ERROR_INVALID_OPERATION:
         ret = AUDIO_IO_ERROR_INVALID_OPERATION;
         break;
+    case CAudioError::EError::ERROR_INVALID_STATE:
+        ret = AUDIO_IO_ERROR_INVALID_STATE;
+        break;
     case CAudioError::EError::ERROR_OUT_OF_MEMORY:
     case CAudioError::EError::ERROR_INVALID_POINTER:
         ret = AUDIO_IO_ERROR_INVALID_BUFFER;