Inform pulseaudio of the focus status that affects the routing 75/45575/3
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 7 Aug 2015 11:17:43 +0000 (20:17 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 10 Aug 2015 05:35:56 +0000 (14:35 +0900)
[Version] Release 0.3.16
[profile] Common
[Issue Type] Enhance feature

Change-Id: I2d92a65706144b9084ea9e15c654e0e23126f857
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/sound_manager_private.h
packaging/capi-media-sound-manager.spec
src/sound_manager.c
src/sound_manager_private.c

index 26ba0b665653118358d702a74ec383e759fd2ef4..000753a2602b14df0e42a23500a504fca2ed3ea7 100644 (file)
@@ -231,6 +231,8 @@ int __get_volume_max_level (const char *direction, const char *volume_type, unsi
 
 int __get_current_volume_type (const char *direction, char **volume_type);
 
+void __update_focus_status (unsigned int index, unsigned int acquired_focus_status);
+
 void _pa_context_state_cb (pa_context *c, void *userdata);
 
 void _pa_stream_state_cb (pa_stream *s, void * userdata);
index 4e06888d230df4e08a71e414b964c449f554ce02..60b590aa843cd6bafce95f7c36c9714743956ca3 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-sound-manager
 Summary:    Sound Manager library
-Version:    0.3.15
+Version:    0.3.16
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index f7419ac851c8f9cb9f55d8d6384a1821e1060ff4..6c81a442b068ce3751e6f976e78837d9c9745170 100644 (file)
@@ -430,6 +430,7 @@ int sound_manager_acquire_focus (sound_stream_info_h stream_info, sound_stream_f
        ret = mm_sound_acquire_focus(stream_h->index, (mm_sound_focus_type_e)focus_mask, additional_info);
        if (ret == MM_ERROR_NONE) {
                stream_h->acquired_focus |= focus_mask;
+               __update_focus_status(stream_h->index, (unsigned int)stream_h->acquired_focus);
        }
 
        LOGI("<< leave : ret(%p)", ret);
@@ -449,6 +450,7 @@ int sound_manager_release_focus (sound_stream_info_h stream_info, sound_stream_f
        ret = mm_sound_release_focus(stream_h->index, (mm_sound_focus_type_e)focus_mask, additional_info);
        if (ret == MM_ERROR_NONE) {
                stream_h->acquired_focus &= ~focus_mask;
+               __update_focus_status(stream_h->index, (unsigned int)stream_h->acquired_focus);
        }
 
        LOGI("<< leave : ret(%p)", ret);
index 6fd3fdf7c6fa8575fee2258c89ccf04e14787d82..99449d7cb187ce8905a59f8f779f9edbc929125e 100644 (file)
@@ -26,6 +26,7 @@
 #define PA_STREAM_MANAGER_METHOD_NAME_SET_STREAM_ROUTE_OPTION  "SetStreamRouteOption"
 #define PA_STREAM_MANAGER_METHOD_NAME_GET_VOLUME_MAX_LEVEL      "GetVolumeMaxLevel"
 #define PA_STREAM_MANAGER_METHOD_NAME_GET_CURRENT_VOLUME_TYPE   "GetCurrentVolumeType"
+#define PA_STREAM_MANAGER_METHOD_NAME_UPDATE_FOCUS_STATUS       "UpdateFocusStatus"
 
 extern _session_interrupt_info_s g_session_interrupt_cb_table;
 extern _session_mode_e g_cached_session_mode;
@@ -493,7 +494,8 @@ int __get_stream_conf_info (const char *stream_type, stream_conf_info_s *info)
                                                        NULL,
                                                        &err);
        if (!result && err) {
-               LOGE("g_dbus_connection_call_sync() error (%s)", err->message);
+               LOGE("g_dbus_connection_call_sync() for GET_STREAM_INFO error (%s)", err->message);
+               g_error_free (err);
                ret = MM_ERROR_SOUND_INTERNAL;
        } else {
                GVariantIter iter;
@@ -633,7 +635,8 @@ int __set_manual_route_info (unsigned int index, manual_route_info_s *info)
                                                        NULL,
                                                        &err);
        if (!result && err) {
-               LOGE("g_dbus_connection_call_sync() error (%s)", err->message);
+               LOGE("g_dbus_connection_call_sync() for SET_STREAM_ROUTE_DEVICES error (%s)", err->message);
+               g_error_free (err);
                ret = MM_ERROR_SOUND_INTERNAL;
        } else {
                const gchar *dbus_ret = NULL;
@@ -684,7 +687,8 @@ int __set_route_option (unsigned int index, const char *name, int value)
                                                        NULL,
                                                        &err);
        if (!result && err) {
-               LOGE("g_dbus_connection_call_sync() error (%s)", err->message);
+               LOGE("g_dbus_connection_call_sync() for SET_STREAM_ROUTE_OPTION error (%s)", err->message);
+               g_error_free (err);
                ret = MM_ERROR_SOUND_INTERNAL;
        } else {
                const gchar *dbus_ret = NULL;
@@ -732,7 +736,8 @@ int __get_volume_max_level (const char *direction, const char *volume_type, unsi
                                                        NULL,
                                                        &err);
        if (!result && err) {
-               LOGE("g_dbus_connection_call_sync() error (%s)", err->message);
+               LOGE("g_dbus_connection_call_sync() for GET_VOLUME_MAX_LEVEL error (%s)", err->message);
+               g_error_free (err);
                ret = MM_ERROR_SOUND_INTERNAL;
        } else {
                const gchar *dbus_ret = NULL;
@@ -777,7 +782,8 @@ int __get_current_volume_type (const char *direction, char **volume_type)
                                                        NULL,
                                                        &err);
        if (!result && err) {
-               LOGE("g_dbus_connection_call_sync() error (%s)", err->message);
+               LOGE("g_dbus_connection_call_sync() for GET_CURRENT_VOLUME_TYPE error (%s)", err->message);
+               g_error_free (err);
                ret = MM_ERROR_SOUND_INTERNAL;
        } else {
                const gchar *dbus_volume_type = NULL;
@@ -798,6 +804,45 @@ int __get_current_volume_type (const char *direction, char **volume_type)
        return ret;
 }
 
+void __update_focus_status (unsigned int index, unsigned int acquired_focus_status)
+{
+       GVariant *result = NULL;
+       GDBusConnection *conn = NULL;
+       GError *err = NULL;
+
+       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+       if (!conn && err) {
+               LOGE("g_bus_get_sync() error (%s)", err->message);
+               g_error_free (err);
+               return;
+       }
+
+       result = g_dbus_connection_call_sync (conn,
+                                                       PA_BUS_NAME,
+                                                       PA_STREAM_MANAGER_OBJECT_PATH,
+                                                       PA_STREAM_MANAGER_INTERFACE,
+                                                       PA_STREAM_MANAGER_METHOD_NAME_UPDATE_FOCUS_STATUS,
+                                                       g_variant_new ("(uu)", index, acquired_focus_status),
+                                                       G_VARIANT_TYPE("(s)"),
+                                                       G_DBUS_CALL_FLAGS_NONE,
+                                                       2000,
+                                                       NULL,
+                                                       &err);
+       if (!result && err) {
+               LOGE("g_dbus_connection_call_sync() for UPDATE_FOCUS_STATUS error (%s)", err->message);
+               g_error_free (err);
+       } else {
+               const gchar *dbus_ret = NULL;
+               g_variant_get(result, "(&s)", &dbus_ret);
+               LOGI("g_dbus_connection_call_sync() success, method return value is (%s)", dbus_ret);
+               if (strncmp("STREAM_MANAGER_RETURN_OK", dbus_ret, strlen(dbus_ret))) {
+               }
+               g_variant_unref(result);
+       }
+       g_object_unref(conn);
+       return;
+}
+
 void __session_interrupt_cb (session_msg_t msg, session_event_t event, void *user_data){
        if( g_session_interrupt_cb_table.user_cb ){
                sound_session_interrupted_code_e e = SOUND_SESSION_INTERRUPTED_COMPLETED;