static pthread_mutex_t g_focus_node_list_mutex = PTHREAD_MUTEX_INITIALIZER;
stream_list_t g_stream_list;
-static const char* focus_status_str[] =
-{
+static const char* focus_status_str[] = {
"DEACTIVATED",
"P ACTIVATED",
"C ACTIVATED",
} focus_cb_data;
#define CLEAR_DEAD_NODE_LIST(x) do { \
- debug_warning("list = %p, node = %p, pid=[%d]", x, node, (node)? node->pid : -1); \
+ debug_warning("list = %p, node = %p, pid=[%d]", x, node, (node) ? node->pid : -1); \
if (x && node && (mm_sound_util_is_process_alive(node->pid) == FALSE)) { \
debug_warning("PID:%d does not exist now! remove from device cb list", node->pid); \
__clear_focus_pipe(node); \
- x = g_list_remove (x, node); \
- g_free (node); \
+ x = g_list_remove(x, node); \
+ g_free(node); \
} \
} while (0)
if (postfix) {
path2 = g_strconcat(path, postfix, NULL);
- g_free (path);
+ g_free(path);
path = NULL;
return path2;
}
debug_error("[RETCB] failed to get watch return pipe");
goto RELEASE;
}
- if ((fd_FOCUS_R= open(filename2, O_RDONLY|O_NONBLOCK)) == -1) {
+ if ((fd_FOCUS_R = open(filename2, O_RDONLY|O_NONBLOCK)) == -1) {
char str_error[256];
strerror_r(errno, str_error, sizeof(str_error));
debug_error("[RETCB] failed to open watch return pipe (%s, err:%s)", filename2, str_error);
/*******************************************
* Write Callback msg
*******************************************/
- if (write(fd_FOCUS, &cb_data ,sizeof(cb_data)) == -1) {
+ if (write(fd_FOCUS, &cb_data, sizeof(cb_data)) == -1) {
char str_error[256];
strerror_r(errno, str_error, sizeof(str_error));
debug_error("[CB] failed to write (err:%s)", str_error);
debug_msg("for pid(%d) handle(%d)", victim_node->pid, victim_node->handle_id);
memset(&cb_data, 0, sizeof(focus_cb_data));
- cb_data.pid= victim_node->pid;
- cb_data.handle= victim_node->handle_id;
+ cb_data.pid = victim_node->pid;
+ cb_data.handle = victim_node->handle_id;
if (command == FOCUS_COMMAND_RELEASE) {
/* client will lost the acquired focus */
- cb_data.type= assaulter_param->request_type & victim_node->status;
- cb_data.state= FOCUS_STATUS_DEACTIVATED;
+ cb_data.type = assaulter_param->request_type & victim_node->status;
+ cb_data.state = FOCUS_STATUS_DEACTIVATED;
/* remove ext info. */
for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
if (cb_data.type & (i+1)) {
res = -1;
goto RELEASE;
}
- if ((fd_FOCUS_R = open(filename2,O_RDONLY|O_NONBLOCK)) == -1) {
+ if ((fd_FOCUS_R = open(filename2, O_RDONLY|O_NONBLOCK)) == -1) {
char str_error[256];
strerror_r(errno, str_error, sizeof(str_error));
debug_error("[RETCB] failed to open return pipe (%s, err:%s)", filename2, str_error);
pfd.fd = fd_FOCUS_R;
pfd.events = POLLIN;
pfd.revents = 0;
- debug_msg("[RETCB] wait CALLBACK (client pid=%d, handle=%d, cmd=%d, timeout=%d(ms))",cb_data.pid, cb_data.handle, command, CALLBACK_TIMEOUT);
+ debug_msg("[RETCB] wait CALLBACK (client pid=%d, handle=%d, cmd=%d, timeout=%d(ms))", cb_data.pid, cb_data.handle, command, CALLBACK_TIMEOUT);
pret = poll(&pfd, 1, CALLBACK_TIMEOUT);
if (pret < 0) {
debug_error("[RETCB] poll failed (%d)", pret);
}
}
} else {
- for (list = g_focus_node_list; list != NULL; list = list->next) {
- CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
- if (node->taken_backup[i].pid == victim_node->pid) {
- UPDATE_FOCUS_TAKEN_INFO(by_id, node, node->taken_backup[i].pid, node->taken_backup[i].handle_id, node->taken_backup[i].by_session);
- UPDATE_FOCUS_TAKEN_INFO(backup, node, 0, 0, false);
- } else if (!list->next) {
- UPDATE_FOCUS_TAKEN_INFO(by_id, victim_node, taken_pid, taken_hid, taken_by_session);
- UPDATE_FOCUS_TAKEN_INFO(backup, victim_node, 0, 0, false);
- }
- }
+ UPDATE_FOCUS_TAKEN_INFO(by_id, victim_node, taken_pid, taken_hid, taken_by_session);
+ UPDATE_FOCUS_TAKEN_INFO(backup, victim_node, 0, 0, false);
}
} else {
if (victim_node->reacquisition)
fd_FOCUS = -1;
}
if (fd_FOCUS_R != -1) {
- close (fd_FOCUS_R);
+ close(fd_FOCUS_R);
fd_FOCUS_R = -1;
}
return res;
}
-static int _mm_sound_mgr_focus_list_dump ()
+static int _mm_sound_mgr_focus_list_dump()
{
int ret = MM_ERROR_NONE;
GList *list = NULL;
for (list = g_focus_node_list; list != NULL; list = list->next) {
if ((node = (focus_node_t *)list->data) && !node->is_for_watch) {
debug_msg("*** 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]",
- 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->ext_info[0], node->ext_info[1]);
+ 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->ext_info[0], node->ext_info[1]);
}
}
debug_msg("================================================ focus node list : end =====================================================");
for (list = g_focus_node_list; list != NULL; list = list->next) {
if ((node = (focus_node_t *)list->data) && node->is_for_watch)
debug_msg("*** pid[%5d]/handle_id[%d]/watch on focus status[%s]/for_session[%d]/for_monitor[%d]",
- node->pid, node->handle_id, focus_status_str[node->status], node->is_for_session, node->is_for_monitor);
+ node->pid, node->handle_id, focus_status_str[node->status], node->is_for_session, node->is_for_monitor);
}
debug_msg("============================================= focus watch node list : end ===================================================");
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);
+ g_list_foreach(g_focus_node_list, (GFunc)_clear_focus_node_list_func, NULL);
for (list = g_focus_node_list; list != NULL; list = list->next) {
CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
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);
+ g_list_foreach(g_focus_node_list, (GFunc)_clear_focus_node_list_func, NULL);
for (list = g_focus_node_list; list != NULL; list = list->next) {
CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
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);
+ 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) {
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);
+ 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) {
int index = (focus_type == FOCUS_TYPE_BOTH) ? FOCUS_TYPE_PLAYBACK - 1 : focus_type - 1;
debug_msg("found a node : request_focus_type(%d), stream_type(%s)/ext info(%s) of acquired focus",
- focus_type, node->stream_type, node->ext_info[index]);
+ focus_type, node->stream_type, node->ext_info[index]);
*stream_type = node->stream_type;
*option = node->option[index];
When invoking focus state changed callback for acquiring, state of the node will not be updated rather updated
when the next request to acquire. */
if (!strncmp("audio-io acquire focus", node->ext_info[direction], MM_SOUND_NAME_NUM) ||
- !strncmp("mm-player acquire focus", node->ext_info[direction], MM_SOUND_NAME_NUM) ||
- !strncmp("mm-camcorder acquire focus", node->ext_info[direction], MM_SOUND_NAME_NUM)) {
+ !strncmp("mm-player acquire focus", node->ext_info[direction], MM_SOUND_NAME_NUM) ||
+ !strncmp("mm-camcorder acquire focus", node->ext_info[direction], MM_SOUND_NAME_NUM)) {
debug_msg("this node[pid:%d, handle_id:%d] needs reacquisition with focus released state", node->pid, node->handle_id);
node->reacquisition_with_released_state = true;
}
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);
+ g_list_foreach(g_focus_node_list, (GFunc)_clear_focus_node_list_func, NULL);
for (list = g_focus_node_list; list != NULL; list = list->next) {
CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
}
_mm_sound_mgr_focus_list_dump();
- _mm_sound_mgr_focus_watch_list_dump ();
+ _mm_sound_mgr_focus_watch_list_dump();
FINISH:
if (!param->is_in_thread)
MMSOUND_LEAVE_CRITICAL_SECTION(&g_focus_node_list_mutex);
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);
+ g_list_foreach(g_focus_node_list, (GFunc)_clear_focus_node_list_func, NULL);
for (list = g_focus_node_list; list != NULL; list = list->next) {
CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
_mm_sound_mgr_focus_do_monitor_callback_outer((focus_type_e)param->request_type, FOCUS_COMMAND_ACQUIRE, my_node, param);
_mm_sound_mgr_focus_list_dump();
- _mm_sound_mgr_focus_watch_list_dump ();
+ _mm_sound_mgr_focus_watch_list_dump();
FINISH:
if (!param->is_in_thread)
MMSOUND_LEAVE_CRITICAL_SECTION(&g_focus_node_list_mutex);
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);
+ g_list_foreach(g_focus_node_list, (GFunc)_clear_focus_node_list_func, NULL);
for (list = g_focus_node_list; list != NULL; list = list->next) {
CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
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);
+ g_list_foreach(g_focus_node_list, (GFunc)_clear_focus_node_list_func, NULL);
for (list = g_focus_node_list; list != NULL; list = list->next) {
CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
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);
+ g_list_foreach(g_focus_node_list, (GFunc)_clear_focus_node_list_func, NULL);
for (list = g_focus_node_list; list != NULL; list = list->next) {
CONTINUE_IF_LIST_DATA_IS_NULL(src_node, list);
if ((src_node->pid == param->pid) && (src_node->handle_id == param->handle_id)) {
debug_log("SRC: found the node of pid[%d]/handle_id[%d] for watch focus",
- param->pid, param->handle_id);
+ param->pid, param->handle_id);
break;
}
}
if (src_node == NULL) {
debug_error("could not find the source node of param, pid[%d]/handle_id[%d]",
- param->pid, param->handle_id);
+ param->pid, param->handle_id);
ret = MM_ERROR_INVALID_ARGUMENT;
goto FINISH;
}
if (!(src_node->status & param->request_type)) {
debug_error("invalid request type(0x%x), src_node->status(0x%x)",
- param->request_type, src_node->status);
+ param->request_type, src_node->status);
ret = MM_ERROR_SOUND_INVALID_STATE;
goto FINISH;
}
CONTINUE_IF_LIST_DATA_IS_NULL(dst_node, list);
if ((dst_node->pid == param->pid) && (dst_node->handle_id == param->handle_id_dst)) {
debug_log("DST: found the destination node of param, pid[%d]/handle_id[%d]",
- param->pid, param->handle_id_dst);
+ param->pid, param->handle_id_dst);
break;
}
}
if (dst_node == NULL) {
debug_error("could not find the destination node of param, pid[%d]/handle_id[%d]",
- param->pid, param->handle_id_dst);
+ param->pid, param->handle_id_dst);
ret = MM_ERROR_INVALID_ARGUMENT;
goto FINISH;
}
for (list = g_focus_node_list; list != NULL; list = list->next) {
CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
if ((node->taken_by_id[i].pid == src_node->pid) &&
- (node->taken_by_id[i].handle_id == src_node->handle_id) &&
- (node->taken_by_id[i].by_session == false)) {
+ (node->taken_by_id[i].handle_id == src_node->handle_id) &&
+ (node->taken_by_id[i].by_session == false)) {
debug_log("found the node that focus was taken by this src node, update it",
- node->pid, node->handle_id);
+ node->pid, node->handle_id);
UPDATE_FOCUS_TAKEN_INFO(by_id, node, dst_node->pid, dst_node->handle_id, false);
}
if ((node->taken_backup[i].pid == src_node->pid) &&
- (node->taken_backup[i].handle_id == src_node->handle_id) &&
- (node->taken_backup[i].by_session == false)) {
+ (node->taken_backup[i].handle_id == src_node->handle_id) &&
+ (node->taken_backup[i].by_session == false)) {
debug_log("found the node that focus was taken by this src node and set reacquisition to false, update it",
- node->pid, node->handle_id);
+ node->pid, node->handle_id);
UPDATE_FOCUS_TAKEN_INFO(backup, node, dst_node->pid, dst_node->handle_id, false);
}
}
{
int ret = MM_ERROR_NONE;
GList *list = NULL;
- GList *list_s =NULL;
+ GList *list_s = NULL;
focus_node_t *node = NULL;
focus_node_t *my_node = NULL;
int i;
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);
+ g_list_foreach(g_focus_node_list, (GFunc)_clear_focus_node_list_func, NULL);
list = g_focus_node_list;
while (list) {
CONTINUE_IF_LIST_DATA_IS_NULL(node, list);
if (node->pid != param->pid) {
list = list->next;
- debug_log("node not found, next list = %p",list);
+ debug_log("node not found, next list = %p", list);
continue;
}
if (node->is_for_watch) {
}
_mm_sound_mgr_focus_list_dump();
- _mm_sound_mgr_focus_watch_list_dump ();
+ _mm_sound_mgr_focus_watch_list_dump();
MMSOUND_LEAVE_CRITICAL_SECTION(&g_focus_node_list_mutex);