if (reacquisition_changed) {
if (!victim_node->reacquisition) {
for (list = g_focus_node_list; list != NULL; list = list->next) {
- node = (focus_node_t *)list->data;
- if (node && (node->taken_by_id[i].pid == victim_node->pid)) {
+ if (!(node = (focus_node_t *)list->data))
+ continue;
+ if (node->taken_by_id[i].pid == victim_node->pid) {
UPDATE_FOCUS_TAKEN_INFO(backup, node, node->taken_by_id[i].pid, node->taken_by_id[i].handle_id, node->taken_by_id[i].by_session);
UPDATE_FOCUS_TAKEN_INFO(by_id, node, taken_pid, taken_hid, taken_by_session);
} else if (!list->next) {
}
} else {
for (list = g_focus_node_list; list != NULL; list = list->next) {
- node = (focus_node_t *)list->data;
- if (node && (node->taken_backup[i].pid == victim_node->pid)) {
+ if (!(node = (focus_node_t *)list->data))
+ continue;
+ 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) {
debug_log("================================================ focus 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) {
+ if ((node = (focus_node_t *)list->data) && !node->is_for_watch) {
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,
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) {
+ if ((node = (focus_node_t *)list->data) && node->is_for_watch)
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");
if (!param->reacquisition) {
for (list = g_focus_node_list; list != NULL; list = list->next) {
- node = (focus_node_t *)list->data;
+ if (!(node = (focus_node_t *)list->data))
+ continue;
for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
- if (node && (node->taken_by_id[i].pid == param->pid)) {
+ if (node->taken_by_id[i].pid == param->pid) {
/* victim node : append my node's taken info to my victim node */
if (my_node->taken_by_id[i].pid != 0) {
UPDATE_FOCUS_TAKEN_INFO(backup, node, node->taken_by_id[i].pid, node->taken_by_id[i].handle_id, node->taken_by_id[i].by_session);
}
} else {
for (list = g_focus_node_list; list != NULL; list = list->next) {
- node = (focus_node_t *)list->data;
+ if (!(node = (focus_node_t *)list->data))
+ continue;
for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
/* rollback and reset backup info. */
- if (node && (node->taken_backup[i].pid == param->pid)) {
+ if (node->taken_by_id[i].pid && (node->taken_by_id[i].pid == my_node->taken_backup[i].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) {
/* 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)) {
+ if (!(node = (focus_node_t *)list->data))
+ continue;
+ if (!node->is_for_watch && (node->status & focus_type)) {
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;
*option = node->option[focus_type-1];
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) {
- node = (focus_node_t *)list->data;
- if (node && (node->pid == param->pid) && (node->handle_id == param->handle_id) && node->is_for_watch) {
+ if (!(node = (focus_node_t *)list->data))
+ continue;
+ if ((node->pid == param->pid) && (node->handle_id == param->handle_id) && node->is_for_watch) {
debug_error("the node of pid[%d]/handle_id[%d] for watch focus is already created\n", param->pid, param->handle_id);
ret = MM_ERROR_INVALID_ARGUMENT;
goto FINISH;
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) {
- node = (focus_node_t *)list->data;
- if (node && (node->pid == param->pid) && (node->handle_id == param->handle_id) && (node->is_for_watch)) {
+ if (!(node = (focus_node_t *)list->data))
+ continue;
+ if ((node->pid == param->pid) && (node->handle_id == param->handle_id) && node->is_for_watch) {
debug_log("found the node of pid[%d]/handle_id[%d] for watch focus\n", param->pid, param->handle_id);
__clear_focus_pipe(node);
g_focus_node_list = g_list_remove(g_focus_node_list, node);
list = g_focus_node_list;
while (list) {
- node = (focus_node_t *)list->data;
- if (node && (node->pid == param->pid)) {
+ if (!(node = (focus_node_t *)list->data))
+ continue;
+ if (node->pid == param->pid) {
debug_log("found pid node");
if (node->is_for_watch) {
debug_log("clearing watch cb of pid(%d) handle(%d)", node->pid, node->handle_id);
my_node = node;
/* update info of nodes that are lost their focus by the process exited */
for (list_s = g_focus_node_list; list_s != NULL; list_s = list_s->next) {
- node = (focus_node_t *)list_s->data;
+ if (!(node = (focus_node_t *)list_s->data))
+ continue;
for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
- if (node && (node->taken_by_id[i].pid == param->pid)) {
+ if (node->taken_by_id[i].pid == param->pid) {
if (my_node->taken_by_id[i].pid) {
UPDATE_FOCUS_TAKEN_INFO(by_id, node, my_node->taken_by_id[i].pid, my_node->taken_by_id[i].handle_id, my_node->taken_by_id[i].by_session);
} else {
param_s.handle_id = my_node->handle_id;
param_s.request_type = my_node->status;
for (list_s = g_focus_node_list; list_s != NULL; list_s = list_s->next) {
- node = (focus_node_t *)list_s->data;
- if (!node || my_node->pid == node->pid || node->is_for_watch) {
- /* skip */
- } else {
- for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
- if (my_node->status & (i+1)) {
- if (node->taken_by_id[i].pid == param_s.pid && node->taken_by_id[i].handle_id == param_s.handle_id) {
- /* do callback for resumption */
- ret = _mm_sound_mgr_focus_do_callback(FOCUS_COMMAND_ACQUIRE, node, ¶m_s, my_node->stream_type);
- if (ret) {
- debug_error("Fail to _focus_do_callback for COMMAND ACQUIRE to node[%x], ret[0x%x]\n", node, ret);
- }
- if (!strncmp(my_node->stream_type, node->stream_type, MAX_STREAM_TYPE_LEN)) {
- need_to_trigger_watch_cb = false;
- }
+ if (!(node = (focus_node_t *)list_s->data))
+ continue;
+ if (my_node->pid == node->pid || node->is_for_watch)
+ continue;
+ for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
+ if (my_node->status & (i+1)) {
+ if (node->taken_by_id[i].pid == param_s.pid && node->taken_by_id[i].handle_id == param_s.handle_id) {
+ /* do callback for resumption */
+ ret = _mm_sound_mgr_focus_do_callback(FOCUS_COMMAND_ACQUIRE, node, ¶m_s, my_node->stream_type);
+ if (ret) {
+ debug_error("Fail to _focus_do_callback for COMMAND ACQUIRE to node[%x], ret[0x%x]\n", node, ret);
+ }
+ if (!strncmp(my_node->stream_type, node->stream_type, MAX_STREAM_TYPE_LEN)) {
+ need_to_trigger_watch_cb = false;
}
}
}