Implementation of isSkipSession() in CAudioSessionHandler.c 63/113063/1
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 6 Feb 2017 02:38:40 +0000 (11:38 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 6 Feb 2017 02:38:40 +0000 (11:38 +0900)
[Version] 0.3.63
[Profile] Common
[Issue Type] Backward compatibility

Change-Id: I38ce75d25980de795d91375af40397b76768ef4c
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/CAudioSessionHandler.h
packaging/capi-media-audio-io.spec
src/cpp/CAudioIO.cpp
src/cpp/CAudioInput.cpp
src/cpp/CAudioOutput.cpp
src/cpp/CAudioSessionHandler.cpp

index 1c56af8..4117360 100644 (file)
@@ -47,7 +47,7 @@ namespace tizen_media_audio {
         virtual void initialize() throw(CAudioError);
         virtual void finalize();
 
-        bool isSkipSessionEvent() throw(CAudioError);
+        bool isSkipSession() throw(CAudioError);
 
         void registerSound() throw(CAudioError);
         void unregisterSound() throw(CAudioError);
index 9035ac0..6f632fb 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.62
+Version:        0.3.63
 Release:        0
 Group:          Multimedia/API
 License:        Apache-2.0
index 1afcac2..8b6c1b0 100644 (file)
@@ -477,7 +477,7 @@ void CAudioIO::ignoreSession() throw(CAudioError) {
         if (mpPulseAudioClient != NULL && mState == CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING)
             THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_OPERATION, "An Operation is not permitted while started");
 
-        bool isSkip = mpAudioSessionHandler->isSkipSessionEvent();
+        bool isSkip = mpAudioSessionHandler->isSkipSession();
         if (isSkip == false && mpAudioSessionHandler->getId() >= 0)
             mpAudioSessionHandler->unregisterSound();
 
index 1e0c593..565024f 100644 (file)
@@ -261,7 +261,7 @@ void CAudioInput::prepare() throw(CAudioError) {
 
         if (mpAudioSessionHandler->getId() < 0) {  // Did not registerSound()
             // Check session to skip registration
-            if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSessionEvent() == false) {
+            if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false) {
                 // Register ASM Listener
                 AUDIO_IO_LOGD("Register ASM Listener");
                 mpAudioSessionHandler->registerSound();
@@ -283,10 +283,8 @@ void CAudioInput::prepare() throw(CAudioError) {
         // Initialize PulseAudio Handler
         mpPulseAudioClient->initialize();
 
-        if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSessionEvent() == false) {
-            /* Updates ASM to PLAYING */
+        if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
             mpAudioSessionHandler->updatePlaying();
-        }
 
         internalUnlock();
 
@@ -310,7 +308,6 @@ void CAudioInput::unprepare() throw(CAudioError) {
     }
 
     try {
-        // Do unprepare
         CAudioIO::unprepare();
 
         internalLock();
@@ -319,15 +316,11 @@ void CAudioInput::unprepare() throw(CAudioError) {
         SAFE_DELETE(mpPulseAudioClient);
 
         if (mpAudioSessionHandler->getId() >= 0) {
-            /* Updates ASM to STOP */
-            if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSessionEvent() == false) {
+            if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
                 mpAudioSessionHandler->updateStop();
-            }
 
-            bool isSkip = mpAudioSessionHandler->isSkipSessionEvent();
-            if (isSkip == false) {
+            if (mpAudioSessionHandler->isSkipSession() ==  false)
                 mpAudioSessionHandler->unregisterSound();
-            }
         }
 
         internalUnlock();
@@ -360,7 +353,7 @@ void CAudioInput::pause() throw(CAudioError) {
         internalLock();
 
         /* Updates ASM to STOP */
-        if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSessionEvent() == false) {
+        if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false) {
             mpAudioSessionHandler->updateStop();
         }
 
@@ -391,10 +384,8 @@ void CAudioInput::resume() throw(CAudioError) {
     try {
         internalLock();
 
-        if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSessionEvent() == false) {
-            /* Updates ASM to PLAYING */
+        if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
             mpAudioSessionHandler->updatePlaying();
-        }
 
         internalUnlock();
 
index e6a7d94..4300fea 100644 (file)
@@ -153,7 +153,7 @@ void CAudioOutput::prepare() throw(CAudioError) {
         }
 
         if (mpAudioSessionHandler->getId() < 0) {  // Did not registerSound()
-            if (isForceIgnore() == false) {
+            if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false) {
                 // Register ASM Listener
                 AUDIO_IO_LOGD("Register ASM Listener");
                 mpAudioSessionHandler->registerSound();
@@ -175,11 +175,8 @@ void CAudioOutput::prepare() throw(CAudioError) {
         // Initialize PulseAudio Handler
         mpPulseAudioClient->initialize();
 
-        if (isForceIgnore() == false &&
-            mpAudioSessionHandler->isSkipSessionEvent() == false) {
-            /* Updates ASM to PLAYING */
+        if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
             mpAudioSessionHandler->updatePlaying();
-        }
 
         internalUnlock();
 
@@ -210,16 +207,11 @@ void CAudioOutput::unprepare() throw(CAudioError) {
         SAFE_DELETE(mpPulseAudioClient);
 
         if (mpAudioSessionHandler->getId() >= 0) {
-            /* Updates ASM to STOP */
-            if (isForceIgnore() == false &&
-                mpAudioSessionHandler->isSkipSessionEvent() == false) {
+            if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
                 mpAudioSessionHandler->updateStop();
-            }
 
-            bool isSkip = mpAudioSessionHandler->isSkipSessionEvent();
-            if (isSkip == false) {
+            if (mpAudioSessionHandler->isSkipSession() == false)
                 mpAudioSessionHandler->unregisterSound();
-            }
         }
 
         internalUnlock();
@@ -252,10 +244,8 @@ void CAudioOutput::pause() throw(CAudioError) {
         internalLock();
 
         /* Updates ASM to STOP */
-        if (isForceIgnore() == false &&
-            mpAudioSessionHandler->isSkipSessionEvent() == false) {
+        if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
             mpAudioSessionHandler->updateStop();
-        }
 
         internalUnlock();
 
@@ -284,11 +274,8 @@ void CAudioOutput::resume() throw(CAudioError) {
     try {
         internalLock();
 
-        if (isForceIgnore() == false &&
-            mpAudioSessionHandler->isSkipSessionEvent() == false) {
-            /* Updates ASM to PLAYING */
+        if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
             mpAudioSessionHandler->updatePlaying();
-        }
 
         internalUnlock();
 
index 5a6dbaf..904bf93 100644 (file)
@@ -274,45 +274,16 @@ void CAudioSessionHandler::finalize() {
     __mIsInit = false;
 }
 
-bool CAudioSessionHandler::isSkipSessionEvent() throw(CAudioError) {
-    bool ret = false;
-
-    // To be regarded...
-#if 0
-    /* Only Support below Event */
-    if (mEvent != ASM_EVENT_CALL              && mEvent != ASM_EVENT_VOIP              &&
-        mEvent != ASM_EVENT_VIDEOCALL         && mEvent != ASM_EVENT_VOICE_RECOGNITION &&
-        mEvent != ASM_EVENT_MMCAMCORDER_AUDIO && mEvent != ASM_EVENT_MMCAMCORDER_VIDEO) {
-        // Check AudioType
-        switch (__mAudioInfo.getAudioType()) {
-        case CAudioInfo::AUDIO_IN_TYPE_MEDIA:
-        case CAudioInfo::AUDIO_IN_TYPE_VOICECONTROL:
-            ret = false;
-            break;
-
-        case CAudioInfo::AUDIO_IN_TYPE_MIRRORING:
-        case CAudioInfo::AUDIO_IN_TYPE_LOOPBACK:
-            ret = true;
-            break;
-
-        default:
-            return false;
-        }
-
-        if (ret == true) {
-            int captureCount = CAudioSessionHandler::__pcmCaptureCountGet();
-            if (captureCount == 1) {/* If this is last one */
-                /* Recover session information to MEDIA */
-                int sessionResult = _mm_session_util_write_information(-1, MM_SESSION_TYPE_MEDIA, __mOptions);
-                if (sessionResult != 0) {
-                    THROW_ERROR_MSG_FORMAT(CAudioError::ERROR_INTERNAL_OPERATION, "Failed _mm_session_util_write_information() ret:%d", sessionResult);
-                }
-            }
-        }
+bool CAudioSessionHandler::isSkipSession() throw(CAudioError) {
+    if (__mMultimediaSession == MM_SESSION_TYPE_REPLACED_BY_STREAM ||
+        __mMultimediaSession == MM_SESSION_TYPE_VOIP ||
+        __mMultimediaSession == MM_SESSION_TYPE_CALL ||
+        __mMultimediaSession == MM_SESSION_TYPE_VIDEOCALL) {
+        AUDIO_IO_LOGD("__mMultimediaSession is [%d], skip session", __mMultimediaSession);
+        return true;
     }
-#endif
 
-    return ret;
+    return false;
 }
 
 void CAudioSessionHandler::__sound_pcm_focus_cb(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, int option, const char *additional_info, void *user_data) {