Forward stream state change callback with "policy = true" when it is caused by Device... 94/67894/7
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 28 Apr 2016 07:57:36 +0000 (16:57 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 3 May 2016 05:03:15 +0000 (14:03 +0900)
[Version] 0.3.31
[Profile] Common
[Issue Type] Feature enhancement

Change-Id: I39e97c0818d9fe7fec1978a9f84f0b261e98b225
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
CMakeLists.txt
include/IPulseStreamListener.h
packaging/capi-media-audio-io.spec
src/cpp/CPulseAudioClient.cpp

index d74b4524fab3556101c39f1120eeae68d4e09138..4eceba8b303f8b6fc6c986137b4243c4ab26d10b 100644 (file)
@@ -9,7 +9,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 SET(INC_DIR include)
 INCLUDE_DIRECTORIES(${INC_DIR})
 
-SET(dependents "dlog mm-sound capi-base-common capi-media-sound-manager mm-common mm-session libpulse vconf")
+SET(dependents "dlog mm-sound capi-base-common capi-media-sound-manager mm-common mm-session libpulse vconf dpm")
 SET(pc_dependents "capi-base-common capi-media-sound-manager")
 
 INCLUDE(FindPkgConfig)
@@ -31,6 +31,7 @@ ENDIF("${ARCH}" STREQUAL "arm")
 
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DTIZEN_DEBUG")
+ADD_DEFINITIONS("-DENABLE_DPM")
 #ADD_DEFINITIONS("-D_AUDIO_IO_DEBUG_TIMING_")
 
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
index 3a2e75d5a81faf33c7d17049f97036739ab95747..5f55b332f5bba8df3b1c29323c7e2f18dc464723 100644 (file)
@@ -35,6 +35,7 @@ namespace tizen_media_audio {
     public:
         virtual void onStream(CPulseAudioClient* pClient, size_t length) = 0;
         virtual void onStateChanged(CAudioInfo::EAudioIOState state) = 0;
+        virtual void onStateChanged(CAudioInfo::EAudioIOState state, bool policy) = 0;
     };
 
 
index 3fc298a34b5e0263788224f9ec7ae97d8a29a74e..a28f416079a1a750ad31473d1d869a83ecb24e5c 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.30
+Version:        0.3.31
 Release:        0
 Group:          Multimedia/API
 License:        Apache-2.0
@@ -15,6 +15,7 @@ BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(capi-media-sound-manager)
 BuildRequires:  pkgconfig(capi-base-common)
 BuildRequires:  pkgconfig(libpulse)
+BuildRequires:  pkgconfig(dpm)
 
 %description
 An Audio Input & Audio Output library in Tizen Native API
index ed065cb43c6c68052d291ebaec8830307369cea5..ca3eb6132af979ed181ddbcf2fc6c2a9508170cb 100644 (file)
 
 #include <mm.h>
 #include "CAudioIODef.h"
-
+#ifdef ENABLE_DPM
+#include <dpm/context.h>
+#include <dpm/restriction.h>
+#endif
 
 using namespace std;
 using namespace tizen_media_audio;
@@ -87,6 +90,28 @@ void CPulseAudioClient::__successContextCb(pa_context* c, int success, void* use
     pa_threaded_mainloop_signal(pClient->__mpMainloop, 0);
 }
 
+static bool __is_microphone_restricted(void) {
+    int state = 1;
+#ifdef ENABLE_DPM
+    dpm_context_h dpm_ctx_h;
+    dpm_restriction_policy_h dpm_policy_h;
+    int ret = 0;
+
+    if ((dpm_ctx_h = dpm_context_create())) {
+        if ((dpm_policy_h = dpm_context_acquire_restriction_policy(dpm_ctx_h))) {
+            /* state: 0(disallowed), 1(allowed) */
+            if ((ret = dpm_restriction_get_microphone_state(dpm_policy_h, &state)))
+                AUDIO_IO_LOGE("Failed to dpm_restriction_get_microphone_state(), ret(0x%x)", ret);
+            dpm_context_release_restriction_policy(dpm_ctx_h, dpm_policy_h);
+        } else
+            AUDIO_IO_LOGE("Failed to dpm_context_acquire_restriction_policy()");
+        dpm_context_destroy(dpm_ctx_h);
+    } else
+        AUDIO_IO_LOGE("Failed to dpm_context_create()");
+#endif
+    return (state ? false : true);
+}
+
 void CPulseAudioClient::__streamStateChangeCb(pa_stream* s, void* user_data) {
     assert(s);
     assert(user_data);
@@ -102,7 +127,8 @@ void CPulseAudioClient::__streamStateChangeCb(pa_stream* s, void* user_data) {
 
     case PA_STREAM_FAILED:
         AUDIO_IO_LOGD("The stream is failed");
-        pClient->__mpListener->onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE);
+        pClient->__mpListener->onStateChanged(CAudioInfo::EAudioIOState::AUDIO_IO_STATE_IDLE,
+                                              __is_microphone_restricted());
         pa_threaded_mainloop_signal(pClient->__mpMainloop, 0);
         break;