}
}
+static int determine_trigger_focus_cb(GList *glist, focus_node_t *my_node, focus_type_e request_type, bool *need_to_trigger)
+{
+ int ret = MM_ERROR_NONE;
+ GList *list = NULL;
+ focus_node_t *node = NULL;
+
+ if (!glist || !need_to_trigger || !my_node)
+ return MM_ERROR_INVALID_ARGUMENT;
+
+ /* check if the priority of any node is higher than its based on io direction */
+ for (list = glist; list != NULL; list = list->next) {
+ SET_NODE_FROM_LIST_DATA(node, list);
+ if (my_node == node || node->is_for_watch)
+ continue;
+ if (request_type == FOCUS_TYPE_BOTH || node->status == FOCUS_STATUS_ACTIVATED_BOTH ||
+ (node->status & request_type)) {
+ if (node->status <= FOCUS_STATUS_DEACTIVATED)
+ continue;
+
+ if ((my_node->priority < node->priority)) {
+ debug_warning("policy blocked by priority(%d < %d)", my_node->priority, node->priority);
+ ret = MM_ERROR_POLICY_BLOCKED;
+ *need_to_trigger = false;
+ break;
+ } else {
+ *need_to_trigger = true;
+ }
+ }
+ }
+
+ return ret;
+}
+
int mm_sound_mgr_focus_request_acquire(const _mm_sound_mgr_focus_param_t *param)
{
int ret = MM_ERROR_NONE;
goto FINISH;
}
- /* check if the priority of any node is higher than its based on io direction */
- for (list = g_focus_node_list; list != NULL; list = list->next) {
- SET_NODE_FROM_LIST_DATA(node, list);
- if (my_node == node || node->is_for_watch)
- continue;
- if (param->request_type == FOCUS_TYPE_BOTH || node->status == FOCUS_STATUS_ACTIVATED_BOTH ||
- (node->status & param->request_type)) {
- if (node->status <= FOCUS_STATUS_DEACTIVATED)
- continue;
-
- if ((my_node->priority < node->priority)) {
- ret = MM_ERROR_POLICY_BLOCKED;
- need_to_trigger_cb = false;
- break;
- } else {
- need_to_trigger_cb = true;
- }
- }
- }
+ ret = determine_trigger_focus_cb(g_focus_node_list, my_node, param->request_type, &need_to_trigger_cb);
if (need_to_trigger_cb) {
_mm_sound_mgr_focus_param_t *param_s = (_mm_sound_mgr_focus_param_t *)param;
(node->status & param_s->request_type)) {
if (node->status <= FOCUS_STATUS_DEACTIVATED)
continue;
- if (my_node->priority >= node->priority) {
- /* do callback for interruption */
- if ((ret = _mm_sound_mgr_focus_do_callback(FOCUS_COMMAND_RELEASE, node, param_s))) {
- debug_error("Fail to _focus_do_callback for COMMAND RELEASE to node[%p], ret[0x%x]", node, ret);
- /* but, keep going */
- ret = MM_ERROR_NONE;
- }
- if (!strncmp(my_node->stream_type, node->stream_type, MAX_STREAM_TYPE_LEN))
- need_to_trigger_watch_cb = false;
+ if (my_node->priority < node->priority)
+ continue;
+ /* do callback for interruption */
+ if ((ret = _mm_sound_mgr_focus_do_callback(FOCUS_COMMAND_RELEASE, node, param_s))) {
+ debug_error("Fail to _focus_do_callback for COMMAND RELEASE to node[%p], ret[0x%x]", node, ret);
+ /* but, keep going */
+ ret = MM_ERROR_NONE;
}
+ if (!strncmp(my_node->stream_type, node->stream_type, MAX_STREAM_TYPE_LEN))
+ need_to_trigger_watch_cb = false;
}
}
}
if (node == my_node || node->is_for_watch)
continue;
for (i = 0; i < NUM_OF_STREAM_IO_TYPE; i++) {
- if (param_s->request_type & (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 */
- if ((ret = _mm_sound_mgr_focus_do_callback(FOCUS_COMMAND_ACQUIRE, node, param_s)))
- debug_error("Fail to _focus_do_callback for COMMAND ACQUIRE to node[%p], ret[0x%x]", node, ret);
- if (!strncmp(my_node->stream_type, node->stream_type, MAX_STREAM_TYPE_LEN))
- need_to_trigger_watch_cb = false;
- }
+ if (!(param_s->request_type & (i+1)))
+ continue;
+ 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 */
+ if ((ret = _mm_sound_mgr_focus_do_callback(FOCUS_COMMAND_ACQUIRE, node, param_s)))
+ debug_error("Fail to _focus_do_callback for COMMAND ACQUIRE to node[%p], ret[0x%x]", node, ret);
+ if (!strncmp(my_node->stream_type, node->stream_type, MAX_STREAM_TYPE_LEN))
+ need_to_trigger_watch_cb = false;
}
}
}