Abandon internal focus if it exists when setStreamInfo() is called 73/117173/1
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 28 Feb 2017 08:55:27 +0000 (17:55 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 3 Mar 2017 05:57:05 +0000 (21:57 -0800)
[Version] 0.3.70
[Profile] Common
[Issue Type] Enhancement

Change-Id: I88bea331681cbb64a74b43d6a823807622892bed
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
(cherry picked from commit 4098ee97917ff77c60236be096cbbf5b451dccd0)

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

index 0f9557e..ebfea6b 100644 (file)
@@ -134,6 +134,8 @@ namespace tizen_media_audio {
         pthread_cond_t        __mCond;
         bool                  __mIsInit;
         bool                  __mForceIgnore;
+
+        void abandonInternalFocus() throw(CAudioError); /* this is for session backward compatibility and will be removed later */
     };
 
 
index 054403d..3d360a8 100644 (file)
@@ -49,7 +49,7 @@ namespace tizen_media_audio {
         virtual void initialize() throw(CAudioError);
         virtual void finalize();
 
-        bool isSkipSession() throw(CAudioError);
+        bool isSkipSession();
 
         void registerSound() throw(CAudioError);
         void unregisterSound() throw(CAudioError);
index 37f800d..68a0dab 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.69
+Version:        0.3.70
 Release:        0
 Group:          Multimedia/API
 License:        Apache-2.0
index 4b16771..87758c8 100644 (file)
@@ -476,12 +476,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->isSkipSession();
-        if (isSkip == false && mpAudioSessionHandler->getId() >= 0)
-            mpAudioSessionHandler->unregisterSound();
-
-        mpAudioSessionHandler->finalize();
-        __mForceIgnore = true;
+        abandonInternalFocus();
 
         internalUnlock();
     } catch (CAudioError e) {
@@ -501,6 +496,8 @@ void CAudioIO::setStreamInfo(sound_stream_info_h stream_info) throw(CAudioError)
         if (mState != CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE)
             THROW_ERROR_MSG(CAudioError::EError::ERROR_INVALID_STATE, "it is not permitted while started");
 
+        abandonInternalFocus();
+
         int errorCode = SOUND_MANAGER_ERROR_NONE;
         CAudioInfo::EAudioType audioType = CAudioInfo::EAudioType::AUDIO_IN_TYPE_MEDIA;
         char *type = NULL;
@@ -552,3 +549,18 @@ void CAudioIO::setInternalStreamInfo() throw(CAudioError) {
         throw e;
     }
 }
+
+void CAudioIO::abandonInternalFocus() throw(CAudioError) {
+    bool isSkip = mpAudioSessionHandler->isSkipSession();
+    int id = mpAudioSessionHandler->getId();
+
+    try {
+        if (isSkip == false && id >= 0)
+            mpAudioSessionHandler->unregisterSound();
+
+        mpAudioSessionHandler->finalize();
+        __mForceIgnore = true;
+    } catch (CAudioError e) {
+        throw e;
+    }
+}
index dd1cd8d..1f2e04b 100644 (file)
@@ -237,7 +237,7 @@ void CAudioSessionHandler::initialize() throw(CAudioError) {
                                        errorCode, __mSubscribeId);
             }
 
-            AUDIO_IO_LOGD("Subscribed mm_sound signal");
+            AUDIO_IO_LOGD("Subscribed mm_sound signal [id:%d]", __mSubscribeId);
 
             sessionOptions = 0;  // Mix with others by default
             __mUseFocus = true;
@@ -278,6 +278,7 @@ void CAudioSessionHandler::finalize() {
     }
 
     if (__mSubscribeId > 0) {
+        AUDIO_IO_LOGD("Unsubscribed mm_sound signal [id:%d]", __mSubscribeId);
         mm_sound_unsubscribe_signal(__mSubscribeId);
         __mSubscribeId = 0;
     }
@@ -287,7 +288,7 @@ void CAudioSessionHandler::finalize() {
     __mIsInit = false;
 }
 
-bool CAudioSessionHandler::isSkipSession() throw(CAudioError) {
+bool CAudioSessionHandler::isSkipSession() {
     if (__mMultimediaSession == MM_SESSION_TYPE_REPLACED_BY_STREAM ||
         __mMultimediaSession == MM_SESSION_TYPE_VOIP ||
         __mMultimediaSession == MM_SESSION_TYPE_CALL ||