Avoid deadlock situation between onInterrupt() and unprepare() 44/113844/1 accepted/tizen/3.0/common/20170213.160902 accepted/tizen/3.0/ivi/20170213.035336 accepted/tizen/3.0/mobile/20170213.035222 accepted/tizen/3.0/tv/20170213.035258 accepted/tizen/3.0/wearable/20170213.035322 submit/tizen_3.0/20170210.094941
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 9 Feb 2017 04:47:38 +0000 (13:47 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 9 Feb 2017 04:47:38 +0000 (13:47 +0900)
[Version] 0.3.66
[Profile] Common
[Issue Type] Bug fix

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

index cf2e0c5d8b38aa8fb52624dc5de8c5e893fc2b4b..9f5316a9413f9d60997733bb877990c76d14c304 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.65
+Version:        0.3.66
 Release:        0
 Group:          Multimedia/API
 License:        Apache-2.0
index 71f38fe64071bfee3eef4433f459181238e3cc8c..4991b80fb44d38322185ff8e05b9b0104eb22889 100644 (file)
@@ -222,10 +222,10 @@ void CAudioIO::onInterrupt(CAudioSessionHandler* pHandler, int id, mm_sound_focu
         if (state == FOCUS_IS_RELEASED) {
             // Focus handle(id) of the other application was released, do resume if possible
             internalLock();
-
-            mpPulseAudioClient->cork(false);
-            onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING);
-
+            if (mpPulseAudioClient) {
+                mpPulseAudioClient->cork(false);
+                onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING);
+            }
             internalUnlock();
 
             // Focus watch callback doesn't have focus handle, but it need to convert & report to application for convenience
@@ -233,16 +233,15 @@ void CAudioIO::onInterrupt(CAudioSessionHandler* pHandler, int id, mm_sound_focu
         } else if (state == FOCUS_IS_ACQUIRED) {
             // Focus handle(id) of the other application was acquired, do pause if possible
             internalLock();
-
-            if (mpPulseAudioClient->getStreamDirection() == CPulseAudioClient::EStreamDirection::STREAM_DIRECTION_PLAYBACK) {
-                if (mpPulseAudioClient->drain() == false) {
-                    AUDIO_IO_LOGE("Failed CPulseAudioClient::drain()");
+            if (mpPulseAudioClient) {
+                if (mpPulseAudioClient->getStreamDirection() == CPulseAudioClient::EStreamDirection::STREAM_DIRECTION_PLAYBACK) {
+                    if (mpPulseAudioClient->drain() == false) {
+                        AUDIO_IO_LOGE("Failed CPulseAudioClient::drain()");
+                    }
                 }
+                mpPulseAudioClient->cork(true);
+                onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_PAUSED);
             }
-
-            mpPulseAudioClient->cork(true);
-            onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_PAUSED);
-
             internalUnlock();
 
             // Focus watch callback doesn't have focus handle, but it need to convert & report to application for convenience
@@ -265,26 +264,25 @@ void CAudioIO::onInterrupt(CAudioSessionHandler* pHandler, int id, mm_sound_focu
         if (state == FOCUS_IS_RELEASED) {
             // Focus handle(id) was released, do pause here
             internalLock();
-
-            if (mpPulseAudioClient->getStreamDirection() == CPulseAudioClient::EStreamDirection::STREAM_DIRECTION_PLAYBACK) {
-                if (mpPulseAudioClient->drain() == false) {
-                    AUDIO_IO_LOGE("Failed CPulseAudioClient::drain()");
+            if (mpPulseAudioClient) {
+                if (mpPulseAudioClient->getStreamDirection() == CPulseAudioClient::EStreamDirection::STREAM_DIRECTION_PLAYBACK) {
+                    if (mpPulseAudioClient->drain() == false) {
+                        AUDIO_IO_LOGE("Failed CPulseAudioClient::drain()");
+                    }
                 }
+                mpPulseAudioClient->cork(true);
+                onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_PAUSED);
             }
-
-            mpPulseAudioClient->cork(true);
-            onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_PAUSED);
-
             internalUnlock();
         } else if (state == FOCUS_IS_ACQUIRED) {
             // Focus handle(id) was acquired again,
             // check reason_for_change ("call-voice","call-video","voip","alarm","notification", ...)
             // do resume here and call interrupt completed callback to application.
             internalLock();
-
-            mpPulseAudioClient->cork(false);
-            onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING);
-
+            if (mpPulseAudioClient) {
+                mpPulseAudioClient->cork(false);
+                onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_RUNNING);
+            }
             internalUnlock();
         }
     }
index 2e489d29907a632678b1ebc1d81340a0d2c24ad1..2ca4d0af5f0250ca2c92ecb96dfafc156a364e35 100644 (file)
@@ -320,6 +320,8 @@ void CAudioInput::unprepare() throw(CAudioError) {
         SAFE_FINALIZE(mpPulseAudioClient);
         SAFE_DELETE(mpPulseAudioClient);
 
+        internalUnlock();
+
         if (mpAudioSessionHandler->getId() >= 0) {
             if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
                 mpAudioSessionHandler->updateStop();
@@ -328,8 +330,6 @@ void CAudioInput::unprepare() throw(CAudioError) {
                 mpAudioSessionHandler->unregisterSound();
         }
 
-        internalUnlock();
-
         CAudioIO::onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE);
     } catch (CAudioError e) {
         internalUnlock();
index 0fdcdc2f70e02f31c3121b9b6c3c67d24b669859..75fbed4815501b4095d9efd9bfa30ed03d1c5d31 100644 (file)
@@ -211,6 +211,8 @@ void CAudioOutput::unprepare() throw(CAudioError) {
         SAFE_FINALIZE(mpPulseAudioClient);
         SAFE_DELETE(mpPulseAudioClient);
 
+        internalUnlock();
+
         if (mpAudioSessionHandler->getId() >= 0) {
             if (isForceIgnore() == false && mpAudioSessionHandler->isSkipSession() == false)
                 mpAudioSessionHandler->updateStop();
@@ -219,8 +221,6 @@ void CAudioOutput::unprepare() throw(CAudioError) {
                 mpAudioSessionHandler->unregisterSound();
         }
 
-        internalUnlock();
-
         CAudioIO::onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE);
     } catch (CAudioError e) {
         internalUnlock();