Return invalid operation error if read/write called not in running state 66/109066/1 accepted/tizen/3.0/common/20170109.195808 accepted/tizen/3.0/ivi/20170109.003427 accepted/tizen/3.0/mobile/20170109.003340 accepted/tizen/3.0/tv/20170109.003401 accepted/tizen/3.0/wearable/20170109.003411 submit/tizen_3.0/20170106.062231
authorSeungbae Shin <seungbae.shin@samsung.com>
Sat, 7 Jan 2017 06:13:01 +0000 (15:13 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Sat, 7 Jan 2017 06:13:01 +0000 (15:13 +0900)
[Version] 0.3.51
[Profile] Common
[Issue Type] Bug

Change-Id: I618317840b846fdd1b9451c585d476b60cf593f4

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

index 9db7e23..98f2b0d 100644 (file)
@@ -97,6 +97,8 @@ namespace tizen_media_audio {
 
         void ignoreSession() throw(CAudioError);
 
+        CAudioInfo::EAudioIOState getState();
+
     protected:
         /* Protected Methods */
         virtual void setInit(bool flag);
index 6351a45..f91925c 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.50
+Version:        0.3.51
 Release:        0
 Group:          Multimedia/API
 License:        Apache-2.0
index e1dd7a2..e7b4095 100644 (file)
@@ -199,6 +199,10 @@ void CAudioIO::onStateChanged(CAudioInfo::EAudioIOState state) {
     onStateChanged(state, false);
 }
 
+CAudioInfo::EAudioIOState CAudioIO::getState() {
+    return mState;
+}
+
 void CAudioIO::onInterrupt(CAudioSessionHandler* pHandler, int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info) {
     assert(pHandler);
 
index 760c834..1e53881 100644 (file)
@@ -425,7 +425,10 @@ size_t CAudioInput::read(void* buffer, size_t length) throw(CAudioError) {
     if (buffer == NULL) {
         THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameters are NULL buffer:%p", buffer);
     }
-
+    if (CAudioIO::getState() != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING) {
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_OPERATION,
+                        "Can't read if not in Running state");
+    }
     /* Checks synchronous flag */
     if (__mIsUsedSyncRead == false) {
         THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_OPERATION, "Invalid operation of read() if receive stream callback");
index e0524f6..fbbe8ea 100644 (file)
@@ -314,6 +314,10 @@ size_t CAudioOutput::write(const void* buffer, size_t length) throw(CAudioError)
     if (buffer == NULL) {
         THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_ARGUMENT, "Parameters are invalid - buffer:%p, length:%zu", buffer, length);
     }
+    if (CAudioIO::getState() != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING) {
+        THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_OPERATION,
+                        "Can't write if not in Running state");
+    }
 
     /* When write() is called in PulseAudio callback, bypass a pcm data to CPulseAudioClient (For Asynchronous) */
     if (mpPulseAudioClient->isInThread() == true) {