Add DBUS interface for this API.
Modify codes to keep and update the additional info. for each focus node when acquiring/releasing/trigerring callback.
[Version] Release 0.9.276
[Profile] Common
[Issue Type] Add feature
Change-Id: I3cba21eab259d284d81fc7532eb8bd5ced31a9df
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
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];
void *callback;
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_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_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);
/* 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. */
+ 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);
+ }
} else {
/* client will gain the lost focus */
for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
}
cb_data.type = flag_for_focus_type & assaulter_param->request_type;
cb_data.state = !FOCUS_STATUS_DEACTIVATED;
+ /* copy additional 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);
+ }
}
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);
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]\n",
+ 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",
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->taken_by_id[1].handle_id, node->taken_by_id[1].by_session, node->is_for_session, node->option[0], node->option[1]);
}
}
debug_log("================================================ focus node list : end =====================================================\n");
return ret;
}
-int mm_sound_mgr_focus_request_acquire (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 ret = MM_ERROR_SOUND_NO_DATA;
+ GList *list = NULL;
+ focus_node_t *node = NULL;
+
+ debug_fenter();
+
+ if (focus_type == FOCUS_TYPE_BOTH) /* focus_type should be "playback" or "capture" */
+ return MM_ERROR_INVALID_ARGUMENT;
+ if (!stream_type)
+ return MM_ERROR_INVALID_ARGUMENT;
+
+ MMSOUND_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_focus_node_list_mutex, MM_ERROR_SOUND_INTERNAL);
+
+ /* Update list for dead process */
+ g_list_foreach (g_focus_node_list, (GFunc)_clear_focus_node_list_func, NULL);
+
+ /* Find node to set reacquisition */
+ 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);
+ *stream_type = node->stream_type;
+ if (additional_info)
+ *additional_info = node->option;
+ ret = MM_ERROR_NONE;
+ break;
+ }
+ }
+
+ MMSOUND_LEAVE_CRITICAL_SECTION(&g_focus_node_list_mutex);
+
+ debug_fleave();
+
+ return ret;
+}
+
+int mm_sound_mgr_focus_request_acquire(const _mm_sound_mgr_focus_param_t *param)
{
int ret = MM_ERROR_NONE;
GList *list = NULL;
}
if (ret != MM_ERROR_POLICY_BLOCKED) {
+ /* copy additional 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);
+ }
/* update status */
my_node->status |= param->request_type;
/* do watch callback due to the status of mine */
focus_node_t *my_node = NULL;
bool need_to_trigger_watch_cb = true;
bool need_to_trigger_cb = true;
+ int i = 0;
debug_fenter();
if (node == my_node || node->is_for_watch) {
/* skip */
} else {
- int i = 0;
for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
if (param_s->request_type & (i+1)) {
if (node && (node->taken_by_id[i].pid == param_s->pid && (node->taken_by_id[i].handle_id == param_s->handle_id || node->taken_by_id[i].by_session))) {
}
/* update status */
my_node->status &= ~(param->request_type);
+ /* remove additional 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);
+ }
/* do watch callback due to the status of mine */
if (need_to_trigger_watch_cb)
_mm_sound_mgr_focus_do_watch_callback((focus_type_e)param->request_type, FOCUS_COMMAND_RELEASE, my_node, param);
" <arg name='handle_id' type='i' direction='in'/>"
" <arg name='reacquisition' type='b' direction='in'/>"
" </method>"
+ " <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'/>"
+ " </method>"
" <method name='AcquireFocus'>"
" <arg name='pid' type='i' direction='in'/>"
" <arg name='handle_id' type='i' direction='in'/>"
static void handle_method_register_focus(GDBusMethodInvocation* invocation);
static void handle_method_unregister_focus(GDBusMethodInvocation* invocation);
static void handle_method_set_focus_reacquisition(GDBusMethodInvocation* invocation);
+static void handle_method_get_acquired_focus_stream_type(GDBusMethodInvocation* invocation);
static void handle_method_acquire_focus(GDBusMethodInvocation* invocation);
static void handle_method_release_focus(GDBusMethodInvocation* invocation);
static void handle_method_watch_focus(GDBusMethodInvocation* invocation);
},
.handler = handle_method_set_focus_reacquisition
},
+ [METHOD_CALL_GET_ACQUIRED_FOCUS_STREAM_TYPE] = {
+ .info = {
+ .name = "GetAcquiredFocusStreamType",
+ },
+ .handler = handle_method_get_acquired_focus_stream_type
+ },
[METHOD_CALL_ACQUIRE_FOCUS] = {
.info = {
.name = "AcquireFocus",
debug_fleave();
}
+static void handle_method_get_acquired_focus_stream_type(GDBusMethodInvocation* invocation)
+{
+ int ret = MM_ERROR_NONE;
+ int focus_type = 0;
+ char *stream_type = NULL;
+ char *additional_info = NULL;
+ GVariant *params = NULL;
+
+ debug_fenter();
+
+ if (!(params = g_dbus_method_invocation_get_parameters(invocation))) {
+ debug_error("Parameter for Method is NULL");
+ ret = MM_ERROR_SOUND_INTERNAL;
+ goto send_reply;
+ }
+
+ g_variant_get(params, "(i)", &focus_type);
+ ret = __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(focus_type, &stream_type, &additional_info);
+
+send_reply:
+ if (ret == MM_ERROR_NONE) {
+ _method_call_return_value(invocation, g_variant_new("(ss)", stream_type, additional_info));
+ } else {
+ _method_call_return_error(invocation, ret);
+ }
+
+ debug_fleave();
+}
+
static void handle_method_acquire_focus(GDBusMethodInvocation* invocation)
{
int ret = MM_ERROR_NONE;
return ret;
}
+// method
+int __mm_sound_mgr_focus_ipc_get_acquired_focus_stream_type(int focus_type, char **stream_type, 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, &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 )
+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;
#ifdef USE_FOCUS
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_get_unique_id(int *id);
int mm_sound_client_is_focus_cb_thread(GThread *mine, bool *result);
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_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_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_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_client_dbus_unregister_focus(int instance, int id, bool is_for_session);
int mm_sound_client_dbus_set_foucs_reacquisition(int instance, int id, bool reacquisition);
+int mm_sound_client_dbus_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info);
int mm_sound_client_dbus_acquire_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session);
int mm_sound_client_dbus_release_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session);
int mm_sound_client_dbus_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_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);
METHOD_CALL_REGISTER_FOCUS,
METHOD_CALL_UNREGISTER_FOCUS,
METHOD_CALL_SET_FOCUS_REACQUISITION,
+ METHOD_CALL_GET_ACQUIRED_FOCUS_STREAM_TYPE,
METHOD_CALL_ACQUIRE_FOCUS,
METHOD_CALL_RELEASE_FOCUS,
METHOD_CALL_WATCH_FOCUS,
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 name[MM_SOUND_NAME_NUM];
} focus_cb_data_lib;
typedef struct {
if (ret == MM_ERROR_NONE)
debug_msg("[Client] Success to emergnet_exit_focus\n");
else
- debug_error("[Client] Error occurred : %d \n",ret);
+ debug_error("[Client] Error occurred : 0x%x \n",ret);
sigprocmask(SIG_SETMASK, &old_mask, NULL);
/* signal unblock */
}
}
} else {
- debug_error("[Client] Error occurred : %d \n",ret);
+ debug_error("[Client] Error occurred : 0x%x \n",ret);
g_focus_sound_handle[index].is_used = false;
goto cleanup;
}
if (ret == MM_ERROR_NONE)
debug_msg("[Client] Success to unregister focus\n");
else
- debug_error("[Client] Error occurred : %d \n",ret);
+ debug_error("[Client] Error occurred : 0x%x \n",ret);
g_mutex_unlock(&g_focus_sound_handle[index].focus_lock);
if (ret == MM_ERROR_NONE) {
debug_msg("[Client] Success to set focus reacquisition\n");
} else {
- debug_error("[Client] Error occurred : %d \n",ret);
+ debug_error("[Client] Error occurred : 0x%x \n",ret);
goto cleanup;
}
} else {
return ret;
}
+int mm_sound_client_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info)
+{
+ int ret = MM_ERROR_NONE;
+
+ debug_fenter();
+
+ ret = mm_sound_client_dbus_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
+ 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 ret = MM_ERROR_NONE;
if (ret == MM_ERROR_NONE)
debug_msg("[Client] Success to acquire focus\n");
else
- debug_error("[Client] Error occurred : %d \n",ret);
+ debug_error("[Client] Error occurred : 0x%x \n",ret);
debug_fleave();
return ret;
if (ret == MM_ERROR_NONE)
debug_msg("[Client] Success to release focus\n");
else
- debug_error("[Client] Error occurred : %d \n",ret);
+ debug_error("[Client] Error occurred : 0x%x \n",ret);
debug_fleave();
}
}
} else {
- debug_error("[Client] Error occurred : %d",ret);
+ debug_error("[Client] Error occurred : 0x%x",ret);
goto cleanup;
}
if (ret == MM_ERROR_NONE)
debug_msg("[Client] Success to unwatch focus\n");
else
- debug_error("[Client] Error occurred : %d \n",ret);
+ debug_error("[Client] Error occurred : 0x%x \n",ret);
g_mutex_unlock(&g_focus_sound_handle[index].focus_lock);
[METHOD_CALL_SET_FOCUS_REACQUISITION] = {
.name = "SetFocusReacquisition",
},
+ [METHOD_CALL_GET_ACQUIRED_FOCUS_STREAM_TYPE] = {
+ .name = "GetAcquiredFocusStreamType",
+ },
[METHOD_CALL_ACQUIRE_FOCUS] = {
.name = "AcquireFocus",
},
return ret;
}
+int mm_sound_client_dbus_get_acquired_focus_stream_type(int focus_type, char **stream_type, char **additional_info)
+{
+ int ret = MM_ERROR_NONE;
+ GVariant* params = NULL, *result = NULL;
+
+ debug_fenter();
+
+ params = g_variant_new("(i)", focus_type);
+ if (params) {
+ if ((ret = _dbus_method_call_to(DBUS_TO_FOCUS_SERVER, METHOD_CALL_GET_ACQUIRED_FOCUS_STREAM_TYPE, params, &result)) != MM_ERROR_NONE) {
+ debug_error("dbus get stream type of acquired focus failed");
+ }
+ } else {
+ debug_error("Construct Param for method call failed");
+ }
+
+ if (ret == MM_ERROR_NONE && result)
+ g_variant_get(result, "(ss)", stream_type, additional_info);
+ else
+ g_variant_unref(result);
+
+ debug_fleave();
+ return ret;
+}
+
int mm_sound_client_dbus_acquire_focus(int instance, int id, mm_sound_focus_type_e type, const char *option, bool is_for_session)
{
int ret = MM_ERROR_NONE;
}
EXPORT_API
+int mm_sound_get_stream_type_of_acquired_focus(int focus_type, char **stream_type, char **additional_info)
+{
+ int ret = MM_ERROR_NONE;
+
+ debug_fenter();
+
+ if (stream_type == NULL) {
+ debug_error("argument is not valid\n");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
+
+ ret = mm_sound_client_get_acquired_focus_stream_type(focus_type, stream_type, additional_info);
+
+ if (ret) {
+ debug_error("Could not get acquired focus stream type, ret[0x%x]\n", ret);
+ }
+
+ debug_fleave();
+
+ return ret;
+}
+
+EXPORT_API
int mm_sound_acquire_focus(int id, mm_sound_focus_type_e focus_type, const char *additional_info)
{
int ret = MM_ERROR_NONE;
Name: libmm-sound
Summary: MMSound Package contains client lib and sound_server binary
-Version: 0.9.275
+Version: 0.9.276
Release: 0
Group: System/Libraries
License: Apache-2.0