Add new functions to acquire/release focus with option 07/81707/7
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 28 Jul 2016 04:12:47 +0000 (13:12 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 20 Sep 2016 08:09:14 +0000 (17:09 +0900)
 - mm_sound_acquire_focus_with_option()
 - mm_sound_release_focus_with_option()
 - rename additional_info to ext_info
 - add a new parameter to mm_sound_focus_changed_cb() and mm_sound_mgr_focus_get_stream_type_of_acquired_focus()

[Version] 0.10.52
[Profile] Common
[Issue Type] Feature enhancement

Change-Id: I92664847e51cab8612b272e8bdca450be38fb24f
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
16 files changed:
focus_server/include/mm_sound_mgr_focus.h
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_focus.h
include/mm_sound_proxy.h
mm_sound_client.c
mm_sound_focus.c
mm_sound_proxy.c
packaging/libmm-sound.spec
server/include/mm_sound_mgr_focus.h [new file with mode: 0644]
server/mm_sound_mgr_codec.c
server/mm_sound_mgr_focus_ipc.c [new file with mode: 0644]
testsuite/mm_sound_testsuite_simple.c

index e8b687e..d592971 100644 (file)
@@ -53,8 +53,9 @@ typedef struct {
        int pid;
        int handle_id;
        char stream_type[MAX_STREAM_TYPE_LEN];
-       char option[MM_SOUND_NAME_NUM];
+       char ext_info[MM_SOUND_NAME_NUM];
        focus_type_e request_type;
+       int option;
        void *callback;
        void *cbdata;
        bool reacquisition;
@@ -75,7 +76,8 @@ typedef struct {
        int priority;
        bool is_for_watch;
        char stream_type[MAX_STREAM_TYPE_LEN];
-       char option[NUM_OF_STREAM_IO_TYPE][MM_SOUND_NAME_NUM];
+       char ext_info[NUM_OF_STREAM_IO_TYPE][MM_SOUND_NAME_NUM];
+       int option[NUM_OF_STREAM_IO_TYPE];
        focus_status_e status;
        _focus_taken_by_id_t taken_by_id[NUM_OF_STREAM_IO_TYPE];
        _focus_taken_by_id_t taken_backup[NUM_OF_STREAM_IO_TYPE];
@@ -92,7 +94,7 @@ int MMSoundMgrFocusFini(void);
 int mm_sound_mgr_focus_create_node (const _mm_sound_mgr_focus_param_t *param);
 int mm_sound_mgr_focus_destroy_node (const _mm_sound_mgr_focus_param_t *param);
 int mm_sound_mgr_focus_set_reacquisition (const _mm_sound_mgr_focus_param_t *param);
-int mm_sound_mgr_focus_get_stream_type_of_acquired_focus(focus_type_e focus_type, char **stream_type, char **additional_info);
+int mm_sound_mgr_focus_get_stream_type_of_acquired_focus(focus_type_e focus_type, char **stream_type, int *option, char **ext_info);
 int mm_sound_mgr_focus_request_acquire (const _mm_sound_mgr_focus_param_t *param);
 int mm_sound_mgr_focus_request_release (const _mm_sound_mgr_focus_param_t *param);
 int mm_sound_mgr_focus_set_watch_cb (const _mm_sound_mgr_focus_param_t *param);
index d0d446d..b637904 100644 (file)
 #include <stdbool.h>
 
 int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, const char* stream_type, bool is_for_session);
-int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, bool is_for_session);
 int __mm_sound_mgr_focus_ipc_set_focus_reacquisition(int pid, int handle_id, bool reacquisition);
-int __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info);
-int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, const char* name );
-int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, const char* name);
+int __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(int focus_type, char **stream_type, int *option, char **ext_info);
+int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info);
+int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info);
+int __mm_sound_mgr_focus_ipc_watch_focus(int pid, int handle_id, int focus_type, bool is_for_session);
 int __mm_sound_mgr_focus_ipc_unwatch_focus(int pid, int handle_id);
 int __mm_sound_mgr_focus_ipc_unregister_focus(int pid, int handle_id);
 int __mm_sound_mgr_focus_ipc_emergent_exit(int pid);
index ef6ef36..ce6dde2 100644 (file)
@@ -52,8 +52,9 @@ typedef struct {
        int handle;
        int type;
        int state;
-       char stream_type [MAX_STREAM_TYPE_LEN];
-       char name [MM_SOUND_NAME_NUM];
+       char stream_type[MAX_STREAM_TYPE_LEN];
+       char ext_info[MM_SOUND_NAME_NUM];
+       int option;
 } focus_cb_data;
 
 #define CLEAR_DEAD_NODE_LIST(x)  do { \
@@ -160,8 +161,7 @@ static int _mm_sound_mgr_focus_get_priority_from_stream_type(int *priority, cons
        return ret;
 }
 
-static int _mm_sound_mgr_focus_do_watch_callback(focus_type_e focus_type, focus_command_e command,
-                                                                                               focus_node_t *my_node, const _mm_sound_mgr_focus_param_t *param)
+static int _mm_sound_mgr_focus_do_watch_callback(focus_type_e focus_type, focus_command_e command, focus_node_t *my_node, const _mm_sound_mgr_focus_param_t *param)
 {
        char *filename = NULL;
        char *filename2 = NULL;
@@ -192,7 +192,7 @@ static int _mm_sound_mgr_focus_do_watch_callback(focus_type_e focus_type, focus_
                                cb_data.type = focus_type & node->status;
                                cb_data.state = (command == FOCUS_COMMAND_ACQUIRE) ? !FOCUS_STATUS_DEACTIVATED : FOCUS_STATUS_DEACTIVATED;
                                MMSOUND_STRNCPY(cb_data.stream_type, my_node->stream_type, MAX_STREAM_TYPE_LEN);
-                               MMSOUND_STRNCPY(cb_data.name, param->option, MM_SOUND_NAME_NUM);
+                               MMSOUND_STRNCPY(cb_data.ext_info, param->ext_info, MM_SOUND_NAME_NUM);
 
                                /* Set start time */
                                gettimeofday(&time, NULL);
@@ -335,10 +335,12 @@ int _mm_sound_mgr_focus_do_callback(focus_command_e command, focus_node_t *victi
                /* client will lost the acquired focus */
                cb_data.type= assaulter_param->request_type & victim_node->status;
                cb_data.state= FOCUS_STATUS_DEACTIVATED;
-               /* remove additional info. */
+               /* remove ext info. */
                for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
-                       if (cb_data.type & (i+1))
-                               memset(victim_node->option[i], 0x0, MM_SOUND_NAME_NUM);
+                       if (cb_data.type & (i+1)) {
+                               memset(victim_node->ext_info[i], 0x0, MM_SOUND_NAME_NUM);
+                               victim_node->option[i] = 0;
+                       }
                }
        } else {
                /* client will gain the lost focus */
@@ -349,14 +351,17 @@ int _mm_sound_mgr_focus_do_callback(focus_command_e command, focus_node_t *victi
                }
                cb_data.type = flag_for_focus_type & assaulter_param->request_type;
                cb_data.state = !FOCUS_STATUS_DEACTIVATED;
-               /* copy additional info. */
+               /* copy ext info. */
                for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
-                       if (cb_data.type & (i+1))
-                               MMSOUND_STRNCPY(victim_node->option[i], assaulter_param->option, MM_SOUND_NAME_NUM);
+                       if (cb_data.type & (i+1)) {
+                               MMSOUND_STRNCPY(victim_node->ext_info[i], assaulter_param->ext_info, MM_SOUND_NAME_NUM);
+                               victim_node->option[i] = assaulter_param->option;
+                       }
                }
        }
        MMSOUND_STRNCPY(cb_data.stream_type, assaulter_stream_type, MAX_STREAM_TYPE_LEN);
-       MMSOUND_STRNCPY(cb_data.name, assaulter_param->option, MM_SOUND_NAME_NUM);
+       MMSOUND_STRNCPY(cb_data.ext_info, assaulter_param->ext_info, MM_SOUND_NAME_NUM);
+       cb_data.option = assaulter_param->option;
 
        /* Set start time */
        gettimeofday(&time, NULL);
@@ -542,10 +547,10 @@ static int _mm_sound_mgr_focus_list_dump ()
        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]/[%15s]:priority[%2d],status[%s],taken_by[P(%5d/%2d/%2d)C(%5d/%2d/%2d)],for_session[%d],add.info[%s/%s]\n",
+                       debug_log("*** pid[%5d]/handle_id[%2d]/[%14s]:priority[%2d],status[%s],taken_by[P(%5d/%2d/%2d)C(%5d/%2d/%2d)],session[%d],option[0x%x/0x%x],ext_info[%s/%s]\n",
                                        node->pid, node->handle_id, node->stream_type, node->priority, focus_status_str[node->status],
                                        node->taken_by_id[0].pid, node->taken_by_id[0].handle_id, node->taken_by_id[0].by_session, node->taken_by_id[1].pid,
-                                       node->taken_by_id[1].handle_id, node->taken_by_id[1].by_session, node->is_for_session, node->option[0], node->option[1]);
+                                       node->taken_by_id[1].handle_id, node->taken_by_id[1].by_session, node->is_for_session, node->option[0], node->option[1], node->ext_info[0], node->ext_info[1]);
                }
        }
        debug_log("================================================ focus node list : end =====================================================\n");
@@ -798,7 +803,7 @@ FINISH:
        return ret;
 }
 
-int mm_sound_mgr_focus_get_stream_type_of_acquired_focus(focus_type_e focus_type, char **stream_type, char **additional_info)
+int mm_sound_mgr_focus_get_stream_type_of_acquired_focus(focus_type_e focus_type, char **stream_type, int *option, char **ext_info)
 {
        int ret = MM_ERROR_SOUND_NO_DATA;
        GList *list = NULL;
@@ -820,10 +825,11 @@ int mm_sound_mgr_focus_get_stream_type_of_acquired_focus(focus_type_e focus_type
        for (list = g_focus_node_list; list != NULL; list = list->next) {
                node = (focus_node_t *)list->data;
                if (node && !node->is_for_watch && (node->status & focus_type)) {
-                       debug_msg("found a node : request_focus_type(%d), stream_type(%s)/additional info(%s) of acquired focus\n", focus_type, node->stream_type, node->option);
+                       debug_msg("found a node : request_focus_type(%d), stream_type(%s)/ext info(%s) of acquired focus\n", focus_type, node->stream_type, node->ext_info);
                        *stream_type = node->stream_type;
-                       if (additional_info)
-                               *additional_info = node->option[focus_type-1];
+                       *option = node->option[focus_type-1];
+                       if (ext_info)
+                               *ext_info = node->ext_info[focus_type-1];
                        ret = MM_ERROR_NONE;
                        break;
                }
@@ -922,10 +928,12 @@ int mm_sound_mgr_focus_request_acquire(const _mm_sound_mgr_focus_param_t *param)
        }
 
        if (ret != MM_ERROR_POLICY_BLOCKED) {
-               /* copy additional info. */
+               /* copy ext info. */
                for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
-                       if (param->request_type & (i+1))
-                               MMSOUND_STRNCPY(my_node->option[i], param->option, MM_SOUND_NAME_NUM);
+                       if (param->request_type & (i+1)) {
+                               MMSOUND_STRNCPY(my_node->ext_info[i], param->ext_info, MM_SOUND_NAME_NUM);
+                               my_node->option[i] = param->option;
+                       }
                }
                /* update status */
                my_node->status |= param->request_type;
@@ -1036,10 +1044,12 @@ int mm_sound_mgr_focus_request_release(const _mm_sound_mgr_focus_param_t *param)
        }
        /* update status */
        my_node->status &= ~(param->request_type);
-       /* remove additional info. */
+       /* remove ext info. */
        for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
-               if (!(my_node->status & (i+1)))
-                       memset(my_node->option[i], 0x0, MM_SOUND_NAME_NUM);
+               if (!(my_node->status & (i+1))) {
+                       memset(my_node->ext_info[i], 0x0, MM_SOUND_NAME_NUM);
+                       my_node->option[i] = 0;
+               }
        }
        /* do watch callback due to the status of mine */
        if (need_to_trigger_watch_cb)
index bf23e28..3819280 100644 (file)
@@ -42,20 +42,23 @@ static const gchar introspection_xml[] =
   "    <method name='GetAcquiredFocusStreamType'>"
   "      <arg name='focus_type' type='i' direction='in'/>"
   "      <arg name='stream_type' type='s' direction='out'/>"
-  "      <arg name='additional_info' type='s' direction='out'/>"
+  "      <arg name='option' type='i' direction='out'/>"
+  "      <arg name='ext_info' type='s' direction='out'/>"
   "    </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='option' type='i' direction='in'/>"
+  "      <arg name='ext_info' 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='option' type='i' direction='in'/>"
+  "      <arg name='ext_info' type='s' direction='in'/>"
   "      <arg name='is_for_session' type='b' direction='in'/>"
   "    </method>"
   "    <method name='WatchFocus'>"
@@ -348,7 +351,8 @@ static void handle_method_get_acquired_focus_stream_type(GDBusMethodInvocation*
        int ret = MM_ERROR_NONE;
        int focus_type = 0;
        char *stream_type = NULL;
-       char *additional_info = NULL;
+       int option = 0;
+       char *ext_info = NULL;
        GVariant *params = NULL;
 
        debug_fenter();
@@ -360,11 +364,11 @@ static void handle_method_get_acquired_focus_stream_type(GDBusMethodInvocation*
        }
 
        g_variant_get(params, "(i)", &focus_type);
-       ret = __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(focus_type, &stream_type, &additional_info);
+       ret = __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(focus_type, &stream_type, &option, &ext_info);
 
 send_reply:
        if (ret == MM_ERROR_NONE) {
-               _method_call_return_value(invocation, g_variant_new("(ss)", stream_type, additional_info));
+               _method_call_return_value(invocation, g_variant_new("(sis)", stream_type, option, ext_info));
        } else {
                _method_call_return_error(invocation, ret);
        }
@@ -375,8 +379,8 @@ send_reply:
 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;
+       int pid = 0, handle_id = 0, focus_type = 0, option = 0;
+       const char* ext_info = NULL;
        gboolean is_for_session;
        GVariant *params = NULL;
 
@@ -388,8 +392,8 @@ static void handle_method_acquire_focus(GDBusMethodInvocation* invocation)
                goto send_reply;
        }
 
-       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);
+       g_variant_get(params, "(iiiisb)", &pid, &handle_id, &focus_type, &option, &ext_info, &is_for_session);
+       ret = __mm_sound_mgr_focus_ipc_acquire_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id, focus_type, option, ext_info);
 
 send_reply:
        if (ret == MM_ERROR_NONE) {
@@ -404,8 +408,8 @@ send_reply:
 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;
+       int pid = 0, handle_id = 0, focus_type = 0, option = 0;
+       const char* ext_info = NULL;
        gboolean is_for_session;
        GVariant *params = NULL;
 
@@ -417,8 +421,8 @@ static void handle_method_release_focus(GDBusMethodInvocation* invocation)
                goto send_reply;
        }
 
-       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);
+       g_variant_get(params, "(iiiisb)", &pid, &handle_id, &focus_type, &option, &ext_info, &is_for_session);
+       ret = __mm_sound_mgr_focus_ipc_release_focus((is_for_session) ? pid : _get_sender_pid(invocation), handle_id, focus_type, option, ext_info);
 
 send_reply:
        if (ret == MM_ERROR_NONE) {
index c062364..ed3a679 100644 (file)
@@ -77,27 +77,27 @@ int __mm_sound_mgr_focus_ipc_set_focus_reacquisition(int pid, int handle_id, boo
 }
 
 // method
-int __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info)
+int __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(int focus_type, char **stream_type, int *option, char **ext_info)
 {
        int ret = MM_ERROR_NONE;
        char *stream_type_str = NULL;
-       char *additional_info_str = NULL;
+       char *ext_info_str = NULL;
 
        if (!stream_type)
                return MM_ERROR_INVALID_ARGUMENT;
 
-       ret = mm_sound_mgr_focus_get_stream_type_of_acquired_focus(focus_type, &stream_type_str, &additional_info_str);
+       ret = mm_sound_mgr_focus_get_stream_type_of_acquired_focus(focus_type, &stream_type_str, option, &ext_info_str);
        if (ret == MM_ERROR_NONE) {
                *stream_type = stream_type_str;
-               if (additional_info)
-                       *additional_info = additional_info_str;
+               if (ext_info)
+                       *ext_info = ext_info_str;
        }
 
        return ret;
 }
 
 // method -> callback
-int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, const char* name)
+int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info)
 {
        _mm_sound_mgr_focus_param_t param;
        int ret = MM_ERROR_NONE;
@@ -106,7 +106,8 @@ int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_typ
        param.pid = pid;
        param.handle_id = handle_id;
        param.request_type = focus_type;
-       MMSOUND_STRNCPY(param.option, name, MM_SOUND_NAME_NUM);
+       param.option = option;
+       MMSOUND_STRNCPY(param.ext_info, ext_info, MM_SOUND_NAME_NUM);
 
        ret = mm_sound_mgr_focus_request_acquire(&param);
 
@@ -114,7 +115,7 @@ int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_typ
 }
 
 // method -> callback
-int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, const char* name)
+int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, int option, const char *ext_info)
 {
        _mm_sound_mgr_focus_param_t param;
        int ret = MM_ERROR_NONE;
@@ -123,7 +124,8 @@ int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_typ
        param.pid = pid;
        param.handle_id = handle_id;
        param.request_type = focus_type;
-       MMSOUND_STRNCPY(param.option, name, MM_SOUND_NAME_NUM);
+       param.option = option;
+       MMSOUND_STRNCPY(param.ext_info, ext_info, MM_SOUND_NAME_NUM);
 
        ret = mm_sound_mgr_focus_request_release(&param);
 
index 7422e4e..6c1f612 100644 (file)
@@ -54,9 +54,9 @@ int mm_sound_client_register_focus(int id, int pid, const char *stream_type, mm_
 int mm_sound_client_unregister_focus(int id);
 int mm_sound_client_set_focus_reacquisition(int id, bool reacquisition);
 int mm_sound_client_get_focus_reacquisition(int id, bool *reacquisition);
-int mm_sound_client_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info);
-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_get_acquired_focus_stream_type(int focus_type, char **stream_type, int *option, char **ext_info);
+int mm_sound_client_acquire_focus(int id, mm_sound_focus_type_e type, int option, const char *ext_info);
+int mm_sound_client_release_focus(int id, mm_sound_focus_type_e type, int option, const char *ext_info);
 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 a361409..7fa6962 100644 (file)
@@ -49,17 +49,19 @@ typedef enum {
 int mm_sound_focus_get_id(int *id);
 int mm_sound_focus_is_cb_thread(bool *result);
 
-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);
+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, int option, const char *ext_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, 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_set_focus_reacquisition(int id, bool reacquisition);
 int mm_sound_get_focus_reacquisition(int id, bool *reacquisition);
-int mm_sound_get_stream_type_of_acquired_focus(int focus_type, char **stream_type, char **additional_info);
-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);
+int mm_sound_get_stream_type_of_acquired_focus(int focus_type, char **stream_type, int *option, char **ext_info);
+int mm_sound_acquire_focus(int id, mm_sound_focus_type_e focus_type, const char *ext_info);
+int mm_sound_release_focus(int id, mm_sound_focus_type_e focus_type, const char *ext_info);
+int mm_sound_acquire_focus_with_option(int id, mm_sound_focus_type_e focus_type, int option, const char *ext_info);
+int mm_sound_release_focus_with_option(int id, mm_sound_focus_type_e focus_type, int option, const char *ext_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);
+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 *ext_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);
index 898437e..c2fea6f 100644 (file)
@@ -68,9 +68,9 @@ int mm_sound_proxy_get_unique_id(int *id);
 int mm_sound_proxy_register_focus(int id, int instance, const char *stream_type, mm_sound_focus_changed_cb callback, bool is_for_session, void* user_data);
 int mm_sound_proxy_unregister_focus(int instance, int id, bool is_for_session);
 int mm_sound_proxy_set_foucs_reacquisition(int instance, int id, bool reacquisition);
-int mm_sound_proxy_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info);
-int mm_sound_proxy_acquire_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session);
-int mm_sound_proxy_release_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session);
+int mm_sound_proxy_get_acquired_focus_stream_type(int focus_type, char **stream_type, int *option, char **ext_info);
+int mm_sound_proxy_acquire_focus(int instance, int id, mm_sound_focus_type_e type, int option, const char *ext_info, bool is_for_session);
+int mm_sound_proxy_release_focus(int instance, int id, mm_sound_focus_type_e type, int option, const char *ext_info, bool is_for_session);
 int mm_sound_proxy_set_focus_watch_callback(int instance, int handle, mm_sound_focus_type_e type, mm_sound_focus_changed_watch_cb callback, bool is_for_session, void *user_data);
 int mm_sound_proxy_unset_focus_watch_callback(int focus_tid, int handle, bool is_for_session);
 #endif
index 8f772c1..48da082 100644 (file)
@@ -104,7 +104,8 @@ typedef struct {
        int type;
        int state;
        char stream_type[MAX_STREAM_TYPE_LEN];
-       char name[MM_SOUND_NAME_NUM];
+       char ext_info[MM_SOUND_NAME_NUM];
+       int option;
 } focus_cb_data_lib;
 
 typedef struct {
@@ -1031,13 +1032,13 @@ static gboolean _focus_callback_handler(gpointer d)
 
                if (changed_state != -1) {
                        debug_error("Got and start CB : TID(%d), handle(%d), type(%d), state(%d,(DEACTIVATED(0)/ACTIVATED(1)), trigger(%s)", tid, cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type);
-                       if (g_focus_sound_handle[focus_index].focus_callback== NULL) {
+                       if (g_focus_sound_handle[focus_index].focus_callback == NULL) {
                                        debug_error("callback is null..");
                                        g_mutex_unlock(&g_focus_sound_handle[focus_index].focus_lock);
                                        return FALSE;
                        }
                        debug_error("[CALLBACK(%p) START]",g_focus_sound_handle[focus_index].focus_callback);
-                       (g_focus_sound_handle[focus_index].focus_callback)(cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type, cb_data.name, g_focus_sound_handle[focus_index].user_data);
+                       (g_focus_sound_handle[focus_index].focus_callback)(cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type, cb_data.option, cb_data.ext_info, g_focus_sound_handle[focus_index].user_data);
                        debug_error("[CALLBACK END]");
                        if (g_focus_session_interrupt_info.user_cb) {
                                debug_error("sending session interrupt callback(%p)", g_focus_session_interrupt_info.user_cb);
@@ -1117,7 +1118,7 @@ static gboolean _focus_watch_callback_handler(gpointer d)
                        debug_msg("callback is null..");
                } else {
                        debug_msg("[CALLBACK(%p) START]",g_focus_sound_handle[focus_index].watch_callback);
-                       (g_focus_sound_handle[focus_index].watch_callback)(cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type, cb_data.name, g_focus_sound_handle[focus_index].user_data);
+                       (g_focus_sound_handle[focus_index].watch_callback)(cb_data.handle, cb_data.type, cb_data.state, cb_data.stream_type, cb_data.ext_info, g_focus_sound_handle[focus_index].user_data);
                        debug_msg("[CALLBACK END]");
                        if (g_focus_session_interrupt_info.user_cb) {
                                debug_error("sending session interrupt callback(%p)", g_focus_session_interrupt_info.user_cb);
@@ -1616,23 +1617,27 @@ cleanup:
        return ret;
 }
 
-int mm_sound_client_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info)
+int mm_sound_client_get_acquired_focus_stream_type(int focus_type, char **stream_type, int *option, char **ext_info)
 {
        int ret = MM_ERROR_NONE;
+       char *ext_str = NULL;
 
        debug_fenter();
 
-       ret = mm_sound_proxy_get_acquired_focus_stream_type(focus_type, stream_type, additional_info);
-       if (ret == MM_ERROR_NONE)
-               debug_msg("[Client] Success to get stream type of acquired focus, stream_type(%s), additional_info(%s)\n", *stream_type, *additional_info);
-       else
+       ret = mm_sound_proxy_get_acquired_focus_stream_type(focus_type, stream_type, option, &ext_str);
+       if (ret == MM_ERROR_NONE) {
+               debug_msg("[Client] Success to get stream type of acquired focus, stream_type(%s), ext_info(%s)\n", *stream_type, ext_str);
+               *ext_info = strdup(ext_str);
+               g_free(ext_str);
+       } else {
                debug_error("[Client] Error occurred : 0x%x \n",ret);
+       }
 
        debug_fleave();
        return ret;
 }
 
-int mm_sound_client_acquire_focus(int id, mm_sound_focus_type_e type, const char *option)
+int mm_sound_client_acquire_focus(int id, mm_sound_focus_type_e type, int option, const char *ext_info)
 {
        int ret = MM_ERROR_NONE;
        int instance;
@@ -1649,8 +1654,7 @@ int mm_sound_client_acquire_focus(int id, mm_sound_focus_type_e type, const char
        }
        instance = g_focus_sound_handle[index].focus_tid;
 
-       ret = mm_sound_proxy_acquire_focus(instance, id, type, option, g_focus_sound_handle[index].is_for_session);
-
+       ret = mm_sound_proxy_acquire_focus(instance, id, type, option, ext_info, g_focus_sound_handle[index].is_for_session);
        if (ret == MM_ERROR_NONE)
                debug_msg("[Client] Success to acquire focus\n");
        else
@@ -1662,7 +1666,7 @@ cleanup:
        return ret;
 }
 
-int mm_sound_client_release_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, int option, const char *ext_info)
 {
        int ret = MM_ERROR_NONE;
        int instance;
@@ -1679,8 +1683,7 @@ int mm_sound_client_release_focus(int id, mm_sound_focus_type_e type, const char
        }
        instance = g_focus_sound_handle[index].focus_tid;
 
-       ret = mm_sound_proxy_release_focus(instance, id, type, option, g_focus_sound_handle[index].is_for_session);
-
+       ret = mm_sound_proxy_release_focus(instance, id, type, option, ext_info, g_focus_sound_handle[index].is_for_session);
        if (ret == MM_ERROR_NONE)
                debug_msg("[Client] Success to release focus\n");
        else
index 73d7e72..f8dab30 100644 (file)
@@ -105,7 +105,7 @@ int mm_sound_focus_is_cb_thread(bool *result)
        ret = mm_sound_client_is_focus_cb_thread(g_thread_self(), result);
        if (!ret) {
                if (*result)
-                       debug_error("it might be called in the thread of focus callback, it is not allowed\n");
+                       debug_msg("it might be called in the thread of focus callback\n");
        }
 
        debug_fleave();
@@ -221,7 +221,6 @@ int mm_sound_get_focus_reacquisition(int id, bool *reacquisition)
        }
 
        ret = mm_sound_client_get_focus_reacquisition(id, reacquisition);
-
        if (ret) {
                debug_error("Could not get focus reacquisition, ret[0x%x]\n", ret);
        }
@@ -232,7 +231,7 @@ int mm_sound_get_focus_reacquisition(int id, bool *reacquisition)
 }
 
 EXPORT_API
-int mm_sound_get_stream_type_of_acquired_focus(int focus_type, char **stream_type, char **additional_info)
+int mm_sound_get_stream_type_of_acquired_focus(int focus_type, char **stream_type, int *option, char **ext_info)
 {
        int ret = MM_ERROR_NONE;
 
@@ -243,8 +242,7 @@ int mm_sound_get_stream_type_of_acquired_focus(int focus_type, char **stream_typ
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       ret = mm_sound_client_get_acquired_focus_stream_type(focus_type, stream_type, additional_info);
-
+       ret = mm_sound_client_get_acquired_focus_stream_type(focus_type, stream_type, option, ext_info);
        if (ret) {
                debug_error("Could not get acquired focus stream type, ret[0x%x]\n", ret);
        }
@@ -255,7 +253,7 @@ int mm_sound_get_stream_type_of_acquired_focus(int focus_type, char **stream_typ
 }
 
 EXPORT_API
-int mm_sound_acquire_focus(int id, mm_sound_focus_type_e focus_type, const char *additional_info)
+int mm_sound_acquire_focus(int id, mm_sound_focus_type_e focus_type, const char *ext_info)
 {
        int ret = MM_ERROR_NONE;
 
@@ -272,7 +270,7 @@ int mm_sound_acquire_focus(int id, mm_sound_focus_type_e focus_type, const char
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       ret = mm_sound_client_acquire_focus(id, focus_type, additional_info);
+       ret = mm_sound_client_acquire_focus(id, focus_type, 0, ext_info);
        if (ret) {
                debug_error("Could not acquire focus, ret[0x%x]\n", ret);
        }
@@ -283,7 +281,7 @@ int mm_sound_acquire_focus(int id, mm_sound_focus_type_e focus_type, const char
 }
 
 EXPORT_API
-int mm_sound_release_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 *ext_info)
 {
        int ret = MM_ERROR_NONE;
 
@@ -300,7 +298,75 @@ int mm_sound_release_focus(int id, mm_sound_focus_type_e focus_type, const char
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
-       ret = mm_sound_client_release_focus(id, focus_type, additional_info);
+       ret = mm_sound_client_release_focus(id, focus_type, 0, ext_info);
+       if (ret) {
+               debug_error("Could not release focus, ret[0x%x]\n", ret);
+       }
+
+       debug_fleave();
+
+       return ret;
+}
+
+EXPORT_API
+int mm_sound_acquire_focus_with_option(int id, mm_sound_focus_type_e focus_type, int option, const char *ext_info)
+{
+       int ret = MM_ERROR_NONE;
+
+       debug_fenter();
+
+       RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
+
+       if (id < 0) {
+               debug_error("id is not valid\n");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       if (option < 0) {
+               debug_error("option is not valid\n");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       if (focus_type < FOCUS_FOR_PLAYBACK || focus_type > FOCUS_FOR_BOTH) {
+               debug_error("focus type is not valid\n");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       ret = mm_sound_client_acquire_focus(id, focus_type, option, ext_info);
+       if (ret) {
+               debug_error("Could not acquire focus, ret[0x%x]\n", ret);
+       }
+
+       debug_fleave();
+
+       return ret;
+}
+
+EXPORT_API
+int mm_sound_release_focus_with_option(int id, mm_sound_focus_type_e focus_type, int option, const char *ext_info)
+{
+       int ret = MM_ERROR_NONE;
+
+       debug_fenter();
+
+       RETURN_ERROR_IF_FOCUS_CB_THREAD(g_thread_self());
+
+       if (id < 0) {
+               debug_error("id is not valid\n");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       if (option < 0) {
+               debug_error("option is not valid\n");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       if (focus_type < FOCUS_FOR_PLAYBACK || focus_type > FOCUS_FOR_BOTH) {
+               debug_error("focus type is not valid\n");
+               return MM_ERROR_INVALID_ARGUMENT;
+       }
+
+       ret = mm_sound_client_release_focus(id, focus_type, option, ext_info);
        if (ret) {
                debug_error("Could not release focus, ret[0x%x]\n", ret);
        }
index d14e35c..17294e9 100644 (file)
@@ -763,7 +763,7 @@ int mm_sound_proxy_set_foucs_reacquisition(int instance, int id, bool reacquisit
        return ret;
 }
 
-int mm_sound_proxy_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info)
+int mm_sound_proxy_get_acquired_focus_stream_type(int focus_type, char **stream_type, int *option, char **ext_info)
 {
        int ret = MM_ERROR_NONE;
        GVariant *params = NULL, *result = NULL;
@@ -777,7 +777,7 @@ int mm_sound_proxy_get_acquired_focus_stream_type(int focus_type, char **stream_
 
        if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_GET_ACQUIRED_FOCUS_STREAM_TYPE, params, &result)) == MM_ERROR_NONE) {
                if (result) {
-                       g_variant_get(result, "(ss)", stream_type, additional_info);
+                       g_variant_get(result, "(sis)", stream_type, option, ext_info);
                        g_variant_unref(result);
                }
        } else {
@@ -788,14 +788,14 @@ int mm_sound_proxy_get_acquired_focus_stream_type(int focus_type, char **stream_
        return ret;
 }
 
-int mm_sound_proxy_acquire_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session)
+int mm_sound_proxy_acquire_focus(int instance, int id, mm_sound_focus_type_e type, int option, const char *ext_info, bool is_for_session)
 {
        int ret = MM_ERROR_NONE;
        GVariant *params = NULL, *result = NULL;
 
        debug_fenter();
 
-       params = g_variant_new("(iiisb)", instance, id, type, option ? option : "", is_for_session);
+       params = g_variant_new("(iiiisb)", instance, id, type, option, ext_info ? ext_info : "", is_for_session);
        if (params) {
                if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_ACQUIRE_FOCUS, params, &result)) != MM_ERROR_NONE) {
                        debug_error("dbus acquire focus failed");
@@ -813,14 +813,14 @@ int mm_sound_proxy_acquire_focus(int instance, int id, mm_sound_focus_type_e typ
        return ret;
 }
 
-int mm_sound_proxy_release_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session)
+int mm_sound_proxy_release_focus(int instance, int id, mm_sound_focus_type_e type, int option, const char *ext_info, bool is_for_session)
 {
        int ret = MM_ERROR_NONE;
        GVariant *params = NULL, *result = NULL;
 
        debug_fenter();
 
-       params = g_variant_new("(iiisb)", instance, id, type, option ? option : "", is_for_session);
+       params = g_variant_new("(iiiisb)", instance, id, type, option, ext_info ? ext_info : "", is_for_session);
        if (params) {
                if ((ret = mm_sound_dbus_method_call_to(AUDIO_PROVIDER_FOCUS_SERVER, AUDIO_METHOD_RELEASE_FOCUS, params, &result)) != MM_ERROR_NONE) {
                        debug_error("dbus release focus failed");
index e7653fc..df8deb6 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-sound
 Summary:    MMSound Package contains client lib and sound_server binary
-Version:    0.10.51
+Version:    0.10.52
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
diff --git a/server/include/mm_sound_mgr_focus.h b/server/include/mm_sound_mgr_focus.h
new file mode 100644 (file)
index 0000000..2b91bc6
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * libmm-sound
+ *
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Sangchul Lee <sc11.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __MM_SOUND_MGR_FOCUS_H__
+#define __MM_SOUND_MGR_FOCUS_H__
+
+#include "../include/mm_sound.h"
+#include "../include/mm_sound_focus.h"
+#include "../include/mm_sound_stream.h"
+#include "../include/mm_ipc.h"
+#include "mm_sound_mgr_focus_ipc.h"
+
+typedef enum
+{
+       FOCUS_COMMAND_RELEASE,
+       FOCUS_COMMAND_ACQUIRE,
+} focus_command_e;
+
+typedef enum
+{
+       FOCUS_TYPE_PLAYBACK = 1,
+       FOCUS_TYPE_CAPTURE,
+       FOCUS_TYPE_BOTH,
+} focus_type_e;
+
+typedef enum
+{
+       FOCUS_STATUS_DEACTIVATED,
+       FOCUS_STATUS_ACTIVATED_PLAYBACK,
+       FOCUS_STATUS_ACTIVATED_CAPTURE,
+       FOCUS_STATUS_ACTIVATED_BOTH,
+} focus_status_e;
+
+typedef struct {
+       int pid;
+       int handle_id;
+       char stream_type[MAX_STREAM_TYPE_LEN];
+       char option[MM_SOUND_NAME_NUM];
+       focus_type_e request_type;
+       void *callback;
+       void *cbdata;
+       bool reacquisition;
+
+       bool is_for_session;    /* will be removed when the session concept is completely left out*/
+} _mm_sound_mgr_focus_param_t;
+
+typedef struct _taken_by_id
+{
+       int pid;
+       int handle_id;
+       bool by_session;
+} _focus_taken_by_id_t;
+
+typedef struct {
+       int pid;
+       int handle_id;
+       int priority;
+       bool is_for_watch;
+       char stream_type[MAX_STREAM_TYPE_LEN];
+       char option[NUM_OF_STREAM_IO_TYPE][MM_SOUND_NAME_NUM];
+       focus_status_e status;
+       _focus_taken_by_id_t taken_by_id[NUM_OF_STREAM_IO_TYPE];
+       _focus_taken_by_id_t taken_backup[NUM_OF_STREAM_IO_TYPE];
+       void *callback;
+       void *cbdata;
+       bool reacquisition;
+
+       bool is_for_session;    /* will be removed when the session concept is completely left out*/
+
+#ifdef SUPPORT_CONTAINER
+       container_info_t container;
+#endif
+} focus_node_t;
+
+int MMSoundMgrFocusInit(void);
+int MMSoundMgrFocusFini(void);
+int mm_sound_mgr_focus_create_node (const _mm_sound_mgr_focus_param_t *param);
+int mm_sound_mgr_focus_destroy_node (const _mm_sound_mgr_focus_param_t *param);
+int mm_sound_mgr_focus_set_reacquisition (const _mm_sound_mgr_focus_param_t *param);
+int mm_sound_mgr_focus_get_stream_type_of_acquired_focus(focus_type_e focus_type, char **stream_type, int *option, char **additional_info);
+int mm_sound_mgr_focus_request_acquire (const _mm_sound_mgr_focus_param_t *param);
+int mm_sound_mgr_focus_request_release (const _mm_sound_mgr_focus_param_t *param);
+int mm_sound_mgr_focus_set_watch_cb (const _mm_sound_mgr_focus_param_t *param);
+int mm_sound_mgr_focus_unset_watch_cb (const _mm_sound_mgr_focus_param_t *param);
+int mm_sound_mgr_focus_emergent_exit(const _mm_sound_mgr_focus_param_t *param);
+#ifdef SUPPORT_CONTAINER
+void mm_sound_mgr_focus_update_container_data(int pid,int handle, const char* container_name, int container_pid);
+#endif
+
+
+#endif /* __MM_SOUND_MGR_FOCUS_H__ */
+
index 30a4382..691a787 100644 (file)
@@ -83,7 +83,7 @@ static int _MMSoundMgrCodecRegisterInterface(MMSoundPluginType *plugin);
 
 #ifdef FOCUS_INTEGRATION
 
-void sound_codec_focus_callback(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state, const char *reason_for_change, const char *additional_info, void *user_data)
+void sound_codec_focus_callback(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state, const char *reason_for_change, int option, const char *ext_info, void *user_data)
 {
 
        int slotid = (int)user_data;
@@ -107,7 +107,7 @@ void sound_codec_focus_callback(int id, mm_sound_focus_type_e focus_type, mm_sou
        return;
 }
 
-void sound_codec_focus_watch_callback(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state, const char *reason_for_change, const char* additional_info, void *user_data)
+void sound_codec_focus_watch_callback(int id, mm_sound_focus_type_e focus_type, mm_sound_focus_state_e focus_state, const char *reason_for_change, const char* ext_info, void *user_data)
 {
        int slotid = (int)user_data;
        int result = MM_ERROR_NONE;
diff --git a/server/mm_sound_mgr_focus_ipc.c b/server/mm_sound_mgr_focus_ipc.c
new file mode 100644 (file)
index 0000000..b56a535
--- /dev/null
@@ -0,0 +1,229 @@
+/*
+ * libmm-sound
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Seungbae Shin <seungbae.shin@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "include/mm_sound_mgr_focus_ipc.h"
+#include "include/mm_sound_mgr_focus_dbus.h"
+
+#include "../include/mm_sound_common.h"
+#include "include/mm_sound_mgr_focus.h"
+#include <mm_debug.h>
+
+#ifdef USE_FOCUS
+
+#ifdef SUPPORT_CONTAINER
+// method + add callback
+int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, const char* stream_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));
+       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;
+       MMSOUND_STRNCPY(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
+
+       ret = mm_sound_mgr_focus_create_node(&param);
+
+       /* 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;
+}
+#else
+int __mm_sound_mgr_focus_ipc_register_focus(int client_pid, int handle_id, const char* stream_type, bool is_for_session)
+{
+       _mm_sound_mgr_focus_param_t param;
+       int ret = MM_ERROR_NONE;
+
+       memset(&param, 0x00, sizeof(_mm_sound_mgr_focus_param_t));
+       param.pid = client_pid;
+       param.handle_id = handle_id;
+       param.is_for_session = is_for_session;
+       MMSOUND_STRNCPY(param.stream_type, stream_type, MAX_STREAM_TYPE_LEN);
+
+       ret = mm_sound_mgr_focus_create_node(&param);
+
+       return ret;
+}
+#endif
+
+// method + remove callback
+int __mm_sound_mgr_focus_ipc_unregister_focus(int pid, int handle_id)
+{
+       _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;
+       param.handle_id = handle_id;
+
+       ret = mm_sound_mgr_focus_destroy_node(&param);
+
+       return ret;
+}
+
+// method -> callback
+int __mm_sound_mgr_focus_ipc_set_focus_reacquisition(int pid, int handle_id, bool reacquisition)
+{
+       _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;
+       param.handle_id = handle_id;
+       param.reacquisition = reacquisition;
+
+       ret = mm_sound_mgr_focus_set_reacquisition(&param);
+
+       return ret;
+}
+
+// method
+int __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(int focus_type, char **stream_type, int *option, char **additional_info)
+{
+       int ret = MM_ERROR_NONE;
+       char *stream_type_str = NULL;
+       char *additional_info_str = NULL;
+
+       if (!stream_type)
+               return MM_ERROR_INVALID_ARGUMENT;
+
+       ret = mm_sound_mgr_focus_get_stream_type_of_acquired_focus(focus_type, &stream_type_str, option, &additional_info_str);
+       if (ret == MM_ERROR_NONE) {
+               *stream_type = stream_type_str;
+               if (additional_info)
+                       *additional_info = additional_info_str;
+       }
+
+       return ret;
+}
+
+// method -> callback
+int __mm_sound_mgr_focus_ipc_acquire_focus(int pid, int handle_id, int focus_type, const char* name)
+{
+       _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;
+       param.handle_id = handle_id;
+       param.request_type = focus_type;
+       MMSOUND_STRNCPY(param.option, name, MM_SOUND_NAME_NUM);
+
+       ret = mm_sound_mgr_focus_request_acquire(&param);
+
+       return ret;
+}
+
+// method -> callback
+int __mm_sound_mgr_focus_ipc_release_focus(int pid, int handle_id, int focus_type, const char* name)
+{
+       _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;
+       param.handle_id = handle_id;
+       param.request_type = focus_type;
+       MMSOUND_STRNCPY(param.option, name, MM_SOUND_NAME_NUM);
+
+       ret = mm_sound_mgr_focus_request_release(&param);
+
+       return ret;
+}
+
+#ifdef SUPPORT_CONTAINER
+// method + add callback
+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));
+       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);
+
+       /* 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, bool is_for_session, int focus_type)
+{
+       _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;
+       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);
+
+       return ret;
+}
+#endif
+
+// method + remove callback
+int __mm_sound_mgr_focus_ipc_unwatch_focus(int pid, int handle_id)
+{
+       _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;
+       param.handle_id = handle_id;
+
+       ret = mm_sound_mgr_focus_unset_watch_cb(&param);
+
+       return ret;
+}
+
+int __mm_sound_mgr_focus_ipc_emergent_exit(int 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;
+
+       ret = mm_sound_mgr_focus_emergent_exit(&param);
+
+       return ret;
+}
+#endif
+
index 2362214..98eb3ea 100755 (executable)
@@ -163,35 +163,35 @@ void device_info_changed_cb (MMSoundDevice_t device_h, int changed_info_type, vo
        debug_log("*** --- type[%d], id[%d], io_direction[%d], state[%d], name[%s]\n", device_type, id, io_direction, state, name);
 }
 #ifdef USE_FOCUS
-void focus_cb0 (int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data)
+void focus_cb0(int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, int option, const char *ext_info, void *user_data)
 {
        char *_state = NULL;
        if (state == FOCUS_IS_RELEASED)
                _state = "RELEASED";
        else
                _state = "ACQUIRED";
-       debug_log("*** focus_cb0 is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], additional_info[%s], user_data[%s]\n",
-                       index, type, _state, reason_for_change, additional_info, (char*)user_data);
+       debug_log("*** focus_cb0 is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], option[0x%x], ext_info[%s], user_data[%s]\n",
+                       index, type, _state, reason_for_change, option, ext_info, (char*)user_data);
 }
-void focus_cb1 (int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data)
+void focus_cb1(int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, int option, const char *ext_info, void *user_data)
 {
        char *_state = NULL;
        if (state == FOCUS_IS_RELEASED)
                _state = "RELEASED";
        else
                _state = "ACQUIRED";
-       debug_log("*** focus_cb1 is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], additional_info[%s], user_data[%s]\n",
-                       index, type, _state, reason_for_change, additional_info, (char*)user_data);
+       debug_log("*** focus_cb1 is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], option[0x%x], ext_info[%s], user_data[%s]\n",
+                       index, type, _state, reason_for_change, option, ext_info, (char*)user_data);
 }
-void focus_watch_cb (int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, const char *additional_info, void *user_data)
+void focus_watch_cb(int index, mm_sound_focus_type_e type, mm_sound_focus_state_e state, const char *reason_for_change, const char *ext_info, void *user_data)
 {
        char *_state = NULL;
        if (state == FOCUS_IS_RELEASED)
                _state = "RELEASED";
        else
                _state = "ACQUIRED";
-       debug_log("*** focus_watch_cb is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], additional_info[%s], user_data[%s]\n",
-                       index, type, _state, reason_for_change, additional_info, (char*)user_data);
+       debug_log("*** focus_watch_cb is called, index[%d], focus_type[%d], state[%s], reason_for_change[%s], ext_info[%s], user_data[%s]\n",
+                       index, type, _state, reason_for_change, ext_info, (char*)user_data);
 }
 #endif
 void quit_program()