Get pid from the client for session related focus interface 51/47751/7 accepted/tizen/common/20160108.084011 submit/tizen_common/20160104.190333
authorinhyeok <i_bc.kim@samsung.com>
Tue, 8 Sep 2015 05:03:17 +0000 (14:03 +0900)
committerinhyeok <i_bc.kim@samsung.com>
Mon, 14 Sep 2015 04:56:59 +0000 (13:56 +0900)
[Version] Release 0.9.259
[Profile] Common
[Issue Type] Add feature

Change-Id: I9b7ede6dc054e40f94e99e3d953da40259aec794
Signed-off-by: inhyeok <i_bc.kim@samsung.com>
12 files changed:
focus_server/include/mm_sound_mgr_focus_ipc.h
focus_server/mm_sound_mgr_focus.c
focus_server/mm_sound_mgr_focus_dbus.c
focus_server/mm_sound_mgr_focus_ipc.c
include/mm_sound_client.h
include/mm_sound_client_dbus.h
include/mm_sound_focus.h
mm_sound_client.c
mm_sound_client_dbus.c
mm_sound_focus.c
packaging/libmm-sound.spec
testsuite/mm_sound_testsuite_simple.c

index 1f783c4..8d8eed8 100644 (file)
@@ -46,9 +46,9 @@ int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_typ
 int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, const char* name);
 //int __mm_sound_mgr_ipc_set_focus_watch_cb(mm_ipc_msg_t *msg);
 #ifdef SUPPORT_CONTAINER
-int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, const char* container_name, int container_pid);
+int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, bool is_for_session, const char* container_name, int container_pid);
 #else
-int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type);
+int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, bool is_for_session);
 #endif
 //int __mm_sound_mgr_ipc_unset_focus_watch_cb(mm_ipc_msg_t *msg);
 int __mm_sound_mgr_focus_ipc_unwatch_focus(int pid, int handle_id);
index cf94541..1338e86 100644 (file)
@@ -581,14 +581,14 @@ static int _mm_sound_mgr_focus_watch_list_dump ()
        GList *list = NULL;
        focus_node_t *node = NULL;
 
-       debug_log("========================================== focus watch node list : start =============================================\n");
+       debug_log("============================================= focus watch node list : start =================================================\n");
        for (list = g_focus_node_list; list != NULL; list = list->next) {
                node = (focus_node_t *)list->data;
                if (node && node->is_for_watch) {
-                       debug_log("*** pid[%5d]/handle_id[%d]/watch on focus status[%s]\n", node->pid, node->handle_id, focus_status_str[node->status]);
+                       debug_log("*** pid[%5d]/handle_id[%d]/watch on focus status[%s]/for_session[%d]\n", node->pid, node->handle_id, focus_status_str[node->status], node->is_for_session);
                }
        }
-       debug_log("========================================== focus watch node list : end ===============================================\n");
+       debug_log("============================================= focus watch node list : end ===================================================\n");
 
        return ret;
 }
index ac22b3e..931b9b3 100644 (file)
   "    <method name='UnregisterFocus'>"
   "      <arg name='pid' type='i' direction='in'/>"
   "      <arg name='handle_id' type='i' direction='in'/>"
+  "      <arg name='is_for_session' type='b' direction='in'/>"
   "    </method>"
   "    <method name='AcquireFocus'>"
   "      <arg name='pid' type='i' direction='in'/>"
   "      <arg name='handle_id' type='i' direction='in'/>"
   "      <arg name='focus_type' type='i' direction='in'/>"
   "      <arg name='name' type='s' direction='in'/>"
+  "      <arg name='is_for_session' type='b' direction='in'/>"
   "    </method>"
   "    <method name='ReleaseFocus'>"
   "      <arg name='pid' type='i' direction='in'/>"
   "      <arg name='handle_id' type='i' direction='in'/>"
   "      <arg name='focus_type' type='i' direction='in'/>"
   "      <arg name='name' type='s' direction='in'/>"
+  "      <arg name='is_for_session' type='b' direction='in'/>"
   "    </method>"
   "    <method name='WatchFocus'>"
 #ifdef SUPPORT_CONTAINER
   "      <arg name='pid' type='i' direction='in'/>"
   "      <arg name='handle_id' type='i' direction='in'/>"
   "      <arg name='focus_type' type='i' direction='in'/>"
+  "      <arg name='is_for_session' type='b' direction='in'/>"
   "    </method>"
   "    <method name='UnwatchFocus'>"
   "      <arg name='pid' type='i' direction='in'/>"
   "      <arg name='handle_id' type='i' direction='in'/>"
+  "      <arg name='is_for_session' type='b' direction='in'/>"
   "    </method>"
   "    <method name='EmergentExitFocus'>"
   "      <arg name='pid' type='i' direction='in'/>"
@@ -317,6 +322,7 @@ static void handle_method_unregister_focus(GDBusMethodInvocation* invocation)
 
        int ret = MM_ERROR_NONE;
        int pid = 0, handle_id = 0;
+       gboolean is_for_session;
        GVariant *params = NULL;
 
        debug_fenter();
@@ -327,8 +333,8 @@ static void handle_method_unregister_focus(GDBusMethodInvocation* invocation)
                goto send_reply;
        }
 
-       g_variant_get(params, "(ii)", &pid, &handle_id);
-       ret = __mm_sound_mgr_focus_ipc_unregister_focus(_get_sender_pid(invocation), handle_id);
+       g_variant_get(params, "(iib)", &pid, &handle_id, &is_for_session);
+       ret = __mm_sound_mgr_focus_ipc_unregister_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id);
 
 send_reply:
        if (ret == MM_ERROR_NONE) {
@@ -345,6 +351,7 @@ static void handle_method_acquire_focus(GDBusMethodInvocation* invocation)
        int ret = MM_ERROR_NONE;
        int pid = 0, handle_id = 0, focus_type = 0;
        const char* name = NULL;
+       gboolean is_for_session;
        GVariant *params = NULL;
 
        debug_fenter();
@@ -355,8 +362,8 @@ static void handle_method_acquire_focus(GDBusMethodInvocation* invocation)
                goto send_reply;
        }
 
-       g_variant_get(params, "(iiis)", &pid, &handle_id, &focus_type, &name);
-       ret = __mm_sound_mgr_focus_ipc_acquire_focus(_get_sender_pid(invocation), handle_id, focus_type, name);
+       g_variant_get(params, "(iiisb)", &pid, &handle_id, &focus_type, &name, &is_for_session);
+       ret = __mm_sound_mgr_focus_ipc_acquire_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id, focus_type, name);
 
 send_reply:
        if (ret == MM_ERROR_NONE) {
@@ -373,6 +380,7 @@ static void handle_method_release_focus(GDBusMethodInvocation* invocation)
        int ret = MM_ERROR_NONE;
        int pid = 0, handle_id = 0, focus_type = 0;
        const char* name = NULL;
+       gboolean is_for_session;
        GVariant *params = NULL;
 
        debug_fenter();
@@ -383,8 +391,8 @@ static void handle_method_release_focus(GDBusMethodInvocation* invocation)
                goto send_reply;
        }
 
-       g_variant_get(params, "(iiis)", &pid, &handle_id, &focus_type, &name);
-       ret = __mm_sound_mgr_focus_ipc_release_focus(_get_sender_pid(invocation), handle_id, focus_type, name);
+       g_variant_get(params, "(iiisb)", &pid, &handle_id, &focus_type, &name, &is_for_session);
+       ret = __mm_sound_mgr_focus_ipc_release_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id, focus_type, name);
 
 send_reply:
        if (ret == MM_ERROR_NONE) {
@@ -400,6 +408,7 @@ static void handle_method_watch_focus(GDBusMethodInvocation* invocation)
 {
        int ret = MM_ERROR_NONE;
        int handle_id = 0, focus_type = 0;
+       gboolean is_for_session;
        GVariant *params = NULL;
 #ifdef SUPPORT_CONTAINER
        int container_pid = -1;
@@ -421,20 +430,20 @@ static void handle_method_watch_focus(GDBusMethodInvocation* invocation)
 
 #ifdef SUPPORT_CONTAINER
 #ifdef USE_SECURITY
-       g_variant_get(params, "(@ayiii)", &cookie_data, &container_pid, &handle_id, &focus_type);
+       g_variant_get(params, "(@ayiiib)", &cookie_data, &container_pid, &handle_id, &focus_type, &is_for_session);
        container = _get_container_from_cookie(cookie_data);
-       ret = __mm_sound_mgr_focus_ipc_watch_focus(_get_sender_pid(invocation), handle_id, focus_type, container, container_pid);
+       ret = __mm_sound_mgr_focus_ipc_watch_focus(_get_sender_pid(invocation), handle_id, focus_type, is_for_session, container, container_pid);
 
        if (container)
                free(container);
 #else /* USE_SECURITY */
-       g_variant_get(params, "(siii)", &container, &container_pid, &handle_id, &focus_type);
-       ret = __mm_sound_mgr_focus_ipc_watch_focus(_get_sender_pid(invocation), handle_id, focus_type, container, container_pid);
+       g_variant_get(params, "(siiib)", &container, &container_pid, &handle_id, &focus_type, &is_for_session);
+       ret = __mm_sound_mgr_focus_ipc_watch_focus(_get_sender_pid(invocation), handle_id, focus_type, is_for_session, container, container_pid);
 
 #endif /* USE_SECURITY */
 #else /* SUPPORT_CONTAINER */
-       g_variant_get(params, "(iii)", &pid, &handle_id, &focus_type);
-       ret = __mm_sound_mgr_focus_ipc_watch_focus(_get_sender_pid(invocation), handle_id, focus_type);
+       g_variant_get(params, "(iiib)", &pid, &handle_id, &focus_type, &is_for_session);
+       ret = __mm_sound_mgr_focus_ipc_watch_focus(_get_sender_pid(invocation), handle_id, focus_type, is_for_session);
 
 #endif /* SUPPORT_CONTAINER */
 
@@ -453,6 +462,7 @@ static void handle_method_unwatch_focus (GDBusMethodInvocation* invocation)
        int ret = MM_ERROR_NONE;
        int pid = 0;
        int handle_id = 0;
+       gboolean is_for_session;
        GVariant *params = NULL;
 
        debug_fenter();
@@ -463,8 +473,8 @@ static void handle_method_unwatch_focus (GDBusMethodInvocation* invocation)
                goto send_reply;
        }
 
-       g_variant_get(params, "(ii)", &pid, &handle_id);
-       ret = __mm_sound_mgr_focus_ipc_unwatch_focus(_get_sender_pid(invocation), handle_id);
+       g_variant_get(params, "(iib)", &pid, &handle_id, &is_for_session);
+       ret = __mm_sound_mgr_focus_ipc_unwatch_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id);
 
 send_reply:
        if (ret == MM_ERROR_NONE) {
index 9e1ab1a..e238cc2 100644 (file)
@@ -51,13 +51,17 @@ int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, const
        int ret = MM_ERROR_NONE;
 
        memset(&param, 0x00, sizeof(_mm_sound_mgr_focus_param_t));
-       param.pid = client_pid;
+       if(is_for_session)
+               param.pid = container_pid;
+       else
+               param.pid = client_pid;
        param.handle_id = handle_id;
        param.is_for_session = is_for_session;
        memcpy(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
        ret = mm_sound_mgr_focus_create_node(&param);
 
-       mm_sound_mgr_focus_update_container_data(client_pid, handle_id, container_name, container_pid);
+       /* FIX ME : Notice that it needs to be improved by the time when mused and container actually work togeter */
+       mm_sound_mgr_focus_update_container_data((is_for_session) ? container_pid : client_pid, handle_id, container_name, container_pid);
 
        return ret;
 }
@@ -129,23 +133,29 @@ int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_typ
 
 #ifdef SUPPORT_CONTAINER
 // method + add callback
-int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, const char* container_name, int container_pid)
+int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, bool is_for_session, const char* container_name, int container_pid)
 {
        _mm_sound_mgr_focus_param_t param;
        int ret = MM_ERROR_NONE;
 
        memset(&param, 0x00, sizeof(_mm_sound_mgr_focus_param_t));
-       param.pid = pid;
+       if(is_for_session)
+               param.pid = container_pid;
+       else
+               param.pid = pid;
        param.handle_id = handle_id;
        param.request_type = focus_type;
+       param.is_for_session = is_for_session;
 
        ret = mm_sound_mgr_focus_set_watch_cb(&param);
-       mm_sound_mgr_focus_update_container_data(pid, -1, container_name, container_pid);
+
+       /* FIX ME : Notice that it needs to be improved by the time when mused and container actually work togeter */
+       mm_sound_mgr_focus_update_container_data((is_for_session) ? container_pid : pid, handle_id, container_name, container_pid);
 
        return ret;
 }
 #else
-int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type)
+int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, bool is_for_session, int focus_type)
 {
        _mm_sound_mgr_focus_param_t param;
        int ret = MM_ERROR_NONE;
@@ -154,6 +164,7 @@ int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type)
        param.pid = pid;
        param.handle_id = handle_id;
        param.request_type = focus_type;
+       param.is_for_session = is_for_session;
 
        ret = mm_sound_mgr_focus_set_watch_cb(&param);
 
index 5aa9dc1..3f1512d 100644 (file)
@@ -58,11 +58,11 @@ int mm_sound_client_remove_device_info_changed_callback(unsigned int subs_id);
 int mm_sound_client_set_session_interrupt_callback(mm_sound_focus_session_interrupt_cb callback, void* user_data);
 int mm_sound_client_unset_session_interrupt_callback(void);
 int mm_sound_client_get_uniq_id(int *id);
-int mm_sound_client_register_focus(int id, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* user_data);
+int mm_sound_client_register_focus(int id, int pid, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* user_data);
 int mm_sound_client_unregister_focus(int id);
 int mm_sound_client_acquire_focus(int id, mm_sound_focus_type_e type, const char *option);
 int mm_sound_client_release_focus(int id, mm_sound_focus_type_e type, const char *option);
-int mm_sound_client_set_focus_watch_callback(mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, void* user_data, int *id);
+int mm_sound_client_set_focus_watch_callback(int pid, mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, bool is_for_session, void* user_data, int *id);
 int mm_sound_client_unset_focus_watch_callback(int id);
 #endif
 
index 6534f76..63c61cc 100644 (file)
@@ -46,11 +46,11 @@ int mm_sound_client_dbus_get_audio_path(mm_sound_device_in *device_in, mm_sound_
 #ifdef USE_FOCUS
 int mm_sound_client_dbus_set_session_interrupt_callback(mm_sound_focus_session_interrupt_cb callback, void* user_data);
 int mm_sound_client_dbus_unset_session_interrupt_callback(void);
-int mm_sound_client_dbus_register_focus(int id, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* user_data);
+int mm_sound_client_dbus_register_focus(int id, int pid, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* user_data);
 int mm_sound_client_dbus_unregister_focus(int id);
 int mm_sound_client_dbus_acquire_focus(int id, mm_sound_focus_type_e type, const char *option);
 int mm_sound_client_dbus_release_focus(int id, mm_sound_focus_type_e type, const char *option);
-int mm_sound_client_dbus_set_focus_watch_callback(mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, void* user_data, int *id);
+int mm_sound_client_dbus_set_focus_watch_callback(int pid, mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, bool is_for_session, void* user_data, int *id);
 int mm_sound_client_dbus_unset_focus_watch_callback(int id);
 #endif
 
index bed6ec7..71aecb1 100644 (file)
@@ -49,13 +49,14 @@ int mm_sound_focus_get_id(int *id);
 
 typedef void (*mm_sound_focus_changed_cb) (int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data);
 int mm_sound_register_focus(int id, const char *stream_type, mm_sound_focus_changed_cb callback, void *user_data);
-int mm_sound_register_focus_for_session(int id, const char *stream_type, mm_sound_focus_changed_cb callback, void *user_data);
+int mm_sound_register_focus_for_session(int id, int pid, const char *stream_type, mm_sound_focus_changed_cb callback, void *user_data);
 int mm_sound_unregister_focus(int id);
 int mm_sound_acquire_focus(int id, mm_sound_focus_type_e focus_type, const char *additional_info);
 int mm_sound_release_focus(int id, mm_sound_focus_type_e focus_type, const char *additional_info);
 
 typedef void (*mm_sound_focus_changed_watch_cb) (int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data);
 int mm_sound_set_focus_watch_callback(mm_sound_focus_type_e focus_type, mm_sound_focus_changed_watch_cb callback, void *user_data, int *id);
+int mm_sound_set_focus_watch_callback_for_session(int pid, mm_sound_focus_type_e focus_type, mm_sound_focus_changed_watch_cb callback, void *user_data, int *id);
 int mm_sound_unset_focus_watch_callback(int id);
 
 typedef void (*mm_sound_focus_session_interrupt_cb) (mm_sound_focus_state_e state, const char *reason_for_change, bool is_wcb, void *user_data);
index 60d8b41..9457fb0 100644 (file)
@@ -672,12 +672,12 @@ int mm_sound_client_get_uniq_id(int *id)
        return ret;
 }
 
-int mm_sound_client_register_focus(int id, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* user_data)
+int mm_sound_client_register_focus(int id, int pid, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* user_data)
 {
        int ret = MM_ERROR_NONE;
        debug_fenter();
 
-       ret = mm_sound_client_dbus_register_focus(id, stream_type, callback, is_for_session, user_data);
+       ret = mm_sound_client_dbus_register_focus(id, pid, stream_type, callback, is_for_session, user_data);
 
        debug_fleave();
        return ret;
@@ -716,12 +716,12 @@ int mm_sound_client_release_focus(int id, mm_sound_focus_type_e type, const char
        return ret;
 }
 
-int mm_sound_client_set_focus_watch_callback(mm_sound_focus_type_e focus_type, mm_sound_focus_changed_watch_cb callback, void* user_data, int *id)
+int mm_sound_client_set_focus_watch_callback(int pid, mm_sound_focus_type_e focus_type, mm_sound_focus_changed_watch_cb callback, bool is_for_session, void* user_data, int *id)
 {
        int ret = MM_ERROR_NONE;
        debug_fenter();
 
-       ret = mm_sound_client_dbus_set_focus_watch_callback(focus_type, callback, user_data, id);
+       ret = mm_sound_client_dbus_set_focus_watch_callback(pid, focus_type, callback, is_for_session, user_data, id);
 
        debug_fleave();
        return ret;
index cd60d4d..63bd122 100644 (file)
@@ -87,6 +87,7 @@ typedef struct {
        GPollFD* g_poll_fd;
        GSource* focus_src;
        bool is_used;
+       bool is_for_session;
        GMutex focus_lock;
        mm_sound_focus_changed_cb focus_callback;
        mm_sound_focus_changed_watch_cb watch_callback;
@@ -2073,7 +2074,7 @@ int mm_sound_client_dbus_unset_session_interrupt_callback(void)
        return MM_ERROR_NONE;
 }
 
-int mm_sound_client_dbus_register_focus(int id, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* user_data)
+int mm_sound_client_dbus_register_focus(int id, int pid, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* user_data)
 {
        int ret = MM_ERROR_NONE;
        int instance;
@@ -2087,7 +2088,7 @@ int mm_sound_client_dbus_register_focus(int id, const char *stream_type, mm_soun
 
 //     pthread_mutex_lock(&g_thread_mutex2);
 
-       instance = getpid();
+       instance = pid;
 
        for (index = 0; index < FOCUS_HANDLE_MAX; index++) {
                if (g_focus_sound_handle[index].is_used == false) {
@@ -2100,6 +2101,7 @@ int mm_sound_client_dbus_register_focus(int id, const char *stream_type, mm_soun
        g_focus_sound_handle[index].handle = id;
        g_focus_sound_handle[index].focus_callback = callback;
        g_focus_sound_handle[index].user_data = user_data;
+       g_focus_sound_handle[index].is_for_session = is_for_session;
 
 #ifdef SUPPORT_CONTAINER
 #ifdef USE_SECURITY
@@ -2171,8 +2173,8 @@ int mm_sound_client_dbus_unregister_focus(int id)
 
        //pthread_mutex_lock(&g_thread_mutex2);
 
-       instance = getpid();
        index = _focus_find_index_by_handle(id);
+       instance = g_focus_sound_handle[index].focus_tid;
 
 
        if (!g_mutex_trylock(&g_focus_sound_handle[index].focus_lock)) {
@@ -2184,7 +2186,7 @@ int mm_sound_client_dbus_unregister_focus(int id)
        }
 
 
-       params = g_variant_new("(ii)", instance, id);
+       params = g_variant_new("(iib)", instance, id, g_focus_sound_handle[index].is_for_session);
        if (params) {
                if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_UNREGISTER_FOCUS, params, &result)) != MM_ERROR_NONE) {
                        debug_error("dbus unregister focus failed");
@@ -2226,15 +2228,18 @@ int mm_sound_client_dbus_acquire_focus(int id, mm_sound_focus_type_e type, const
 {
        int ret = MM_ERROR_NONE;
        int instance;
+       int index = -1;
        GVariant* params = NULL, *result = NULL;
 
        debug_fenter();
 
        //pthread_mutex_lock(&g_thread_mutex2);
 
-       instance = getpid();
+       index = _focus_find_index_by_handle(id);
+       instance = g_focus_sound_handle[index].focus_tid;
+
 
-       params = g_variant_new("(iiis)", instance, id, type, option);
+       params = g_variant_new("(iiisb)", instance, id, type, option, g_focus_sound_handle[index].is_for_session);
        if (params) {
                if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_ACQUIRE_FOCUS, params, &result)) != MM_ERROR_NONE) {
                        debug_error("dbus acquire focus failed");
@@ -2266,15 +2271,18 @@ int mm_sound_client_dbus_release_focus(int id, mm_sound_focus_type_e type, const
 {
        int ret = MM_ERROR_NONE;
        int instance;
+       int index = -1;
        GVariant* params = NULL, *result = NULL;
 
        debug_fenter();
 
        //pthread_mutex_lock(&g_thread_mutex2);
 
-       instance = getpid();;
+       index = _focus_find_index_by_handle(id);
+       instance = g_focus_sound_handle[index].focus_tid;
+
 
-       params = g_variant_new("(iiis)", instance, id, type, option);
+       params = g_variant_new("(iiisb)", instance, id, type, option, g_focus_sound_handle[index].is_for_session);
        if (params) {
                if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_RELEASE_FOCUS, params, &result)) != MM_ERROR_NONE) {
                        debug_error("dbus release focus failed");
@@ -2302,7 +2310,7 @@ cleanup:
        return ret;
 }
 
-int mm_sound_client_dbus_set_focus_watch_callback(mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, void* user_data, int *id)
+int mm_sound_client_dbus_set_focus_watch_callback(int pid, mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, bool is_for_session, void* user_data, int *id)
 {
        int ret = MM_ERROR_NONE;
        int instance;
@@ -2319,7 +2327,7 @@ int mm_sound_client_dbus_set_focus_watch_callback(mm_sound_focus_type_e type, mm
 
        //pthread_mutex_lock(&g_thread_mutex2);
 
-       instance = getpid();
+       instance = pid;
 
        for (index = 0; index < FOCUS_HANDLE_MAX; index++) {
                if (g_focus_sound_handle[index].is_used == false) {
@@ -2332,18 +2340,19 @@ int mm_sound_client_dbus_set_focus_watch_callback(mm_sound_focus_type_e type, mm
        g_focus_sound_handle[index].handle = index + 1;
        g_focus_sound_handle[index].watch_callback = callback;
        g_focus_sound_handle[index].user_data = user_data;
+       g_focus_sound_handle[index].is_for_session = is_for_session;
 
 #ifdef SUPPORT_CONTAINER
 #ifdef USE_SECURITY
-       params = g_variant_new("(@ayiii)", _get_cookie_variant(), instance, g_focus_sound_handle[index].handle, type);
+       params = g_variant_new("(@ayiiib)", _get_cookie_variant(), instance, g_focus_sound_handle[index].handle, type, is_for_session);
 #else /* USE_SECURITY */
        gethostname(container, sizeof(container));
        debug_error("container = %s", container);
-       params = g_variant_new("(siii)", container, instance, g_focus_sound_handle[index].handle, type);
+       params = g_variant_new("(siiib)", container, instance, g_focus_sound_handle[index].handle, type, is_for_session);
 #endif /* USE_SECURITY */
 
 #else /* SUPPORT_CONTAINER */
-       params = g_variant_new("(iii)", instance, g_focus_sound_handle[index].handle, type);
+       params = g_variant_new("(iiib)", instance, g_focus_sound_handle[index].handle, type, is_for_session);
 
 #endif /* SUPPORT_CONTAINER */
 
@@ -2414,7 +2423,7 @@ int mm_sound_client_dbus_unset_focus_watch_callback(int id)
 
        g_mutex_lock(&g_focus_sound_handle[index].focus_lock);
 
-       params = g_variant_new("(ii)", g_focus_sound_handle[index].focus_tid, g_focus_sound_handle[index].handle);
+       params = g_variant_new("(iib)", g_focus_sound_handle[index].focus_tid, g_focus_sound_handle[index].handle, g_focus_sound_handle[index].is_for_session);
        if (params) {
                if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_UNWATCH_FOCUS, params, &result)) != MM_ERROR_NONE) {
                        debug_error("dbus unset watch focus failed");
index e9d1c5a..8863cdd 100644 (file)
@@ -92,7 +92,7 @@ int mm_sound_register_focus(int id, const char *stream_type, mm_sound_focus_chan
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       ret = mm_sound_client_register_focus(id, stream_type, callback, false, user_data);
+       ret = mm_sound_client_register_focus(id, getpid(), stream_type, callback, false, user_data);
        if (ret) {
                debug_error("Could not register focus, ret[0x%x]\n", ret);
        }
@@ -103,7 +103,7 @@ int mm_sound_register_focus(int id, const char *stream_type, mm_sound_focus_chan
 }
 
 EXPORT_API
-int mm_sound_register_focus_for_session(int id, const char *stream_type, mm_sound_focus_changed_cb callback, void *user_data)
+int mm_sound_register_focus_for_session(int id, int pid, const char *stream_type, mm_sound_focus_changed_cb callback, void *user_data)
 {
        int ret = MM_ERROR_NONE;
 
@@ -114,7 +114,7 @@ int mm_sound_register_focus_for_session(int id, const char *stream_type, mm_soun
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       ret = mm_sound_client_register_focus(id, stream_type, callback, true, user_data);
+       ret = mm_sound_client_register_focus(id, pid, stream_type, callback, true, user_data);
        if (ret) {
                debug_error("Could not register focus for session, ret[0x%x]\n", ret);
        }
@@ -210,7 +210,28 @@ int mm_sound_set_focus_watch_callback(mm_sound_focus_type_e focus_type, mm_sound
                debug_error("argument is not valid\n");
                return MM_ERROR_INVALID_ARGUMENT;
        }
-       ret = mm_sound_client_set_focus_watch_callback(focus_type, callback, user_data, id);
+       ret = mm_sound_client_set_focus_watch_callback(getpid(), focus_type, callback, false, user_data, id);
+       if (ret) {
+               debug_error("Could not set focus watch callback, ret[0x%x]\n", ret);
+       }
+
+       debug_fleave();
+
+       return ret;
+}
+
+EXPORT_API
+int mm_sound_set_focus_watch_callback_for_session(int pid, mm_sound_focus_type_e focus_type, mm_sound_focus_changed_watch_cb callback, void *user_data, int *id)
+{
+       int ret = MM_ERROR_NONE;
+
+       debug_fenter();
+
+       if (callback == NULL || id == NULL) {
+               debug_error("argument is not valid\n");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+       ret = mm_sound_client_set_focus_watch_callback(pid, focus_type, callback, true, user_data, id);
        if (ret) {
                debug_error("Could not set focus watch callback, ret[0x%x]\n", ret);
        }
index d4c64ba..4ba079b 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.9.258
+Version:    0.9.259
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index 9d32a2a..1df0f5e 100755 (executable)
@@ -287,6 +287,7 @@ static void displaymenu()
                g_print("AF : Acquire Focus\t");
                g_print("RF : Release Focus\n");
                g_print("WS : Set Focus Watch Callback\t");
+               g_print("WFS : Set Focus Watch Callback for session\t");
                g_print("WU : Unset Focus Watch Callback\n");
                g_print("==================================================================\n");
 #endif
@@ -583,7 +584,7 @@ static void interpret (char *cmd)
                                else if(flag_2 == '0') { stream_type = "voice-recognition"; }
                                else { stream_type = "media"; }
 
-                               ret = mm_sound_register_focus_for_session(id, stream_type, (id == 0)? focus_cb0 : focus_cb1, (void*)user_data);
+                               ret = mm_sound_register_focus_for_session(id, getpid(), stream_type, (id == 0)? focus_cb0 : focus_cb1, (void*)user_data);
                                if (ret) {
                                        g_print("failed to mm_sound_register_focus_for_session(), ret[0x%x]\n", ret);
                                } else {
@@ -674,6 +675,36 @@ static void interpret (char *cmd)
                                }
                        }
 
+                       else if(strncmp(cmd, "WFS", 3) ==0) {
+                               int ret = 0;
+                               char input_string[128];
+                               char flag_1;
+                               int type = 0;
+                               const char *user_data = "this is user data for watch";
+
+                               fflush(stdin);
+                               g_print ("1. playback\n");
+                               g_print ("2. recording\n");
+                               g_print ("3. both\n");
+                               g_print("> select interest focus type:");
+
+                               if (fgets(input_string, sizeof(input_string)-1, stdin)) {
+                                       g_print ("### fgets return  NULL\n");
+                               }
+                               flag_1 = input_string[0];
+
+                               if(flag_1 == '1') { type = 1; }
+                               else if(flag_1 == '2') { type = 2; }
+                               else if(flag_1 == '3') { type = 3; }
+                               else { type = 1; }
+                               ret = mm_sound_set_focus_watch_callback_for_session(getpid(), type, focus_watch_cb, (void*)user_data, &g_focus_watch_index);
+                               if (ret) {
+                                       g_print("failed to mm_sound_set_focus_watch_callback(), ret[0x%x]\n", ret);
+                               } else {
+                                       g_print("index[%d], type[%d], callback fun[%p]\n", g_focus_watch_index, type, focus_watch_cb);
+                               }
+                       }
+
                        else if(strncmp(cmd, "WS", 2) ==0) {
                                int ret = 0;
                                char input_string[128];