pa_assert(data);
pa_assert(u);
- pa_log_info("[SELECT] select_proper_sink_or_source_hook_cb is called. (%p), stream_type(%d), stream_role(%s), route_type(%d)",
- data, data->stream_type, data->stream_role, data->route_type);
+ pa_log_info("[SELECT] select_proper_sink_or_source_hook_cb is called. (%p), stream_type(%d), stream_role(%s), device_role(%s), route_type(%d)",
+ data, data->stream_type, data->stream_role, data->device_role, data->route_type);
null_sink = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_NULL, PA_NAMEREG_SINK);
null_source = (pa_source*)pa_namereg_get(u->core, SOURCE_NAME_NULL, PA_NAMEREG_SOURCE);
return PA_HOOK_OK;
}
+ /* check if the current occupying role is related to call.
+ * some targets use several pcm card as per their purpose.
+ * e.g) using a specific pcm card during voice call. */
+ if (data->occupying_role) {
+ if (pa_streq(data->occupying_role, STREAM_ROLE_CALL_VOICE)) {
+ data->device_role = DEVICE_ROLE_CALL_VOICE;
+ pa_log_info("[SELECT] current occupying stream role is [%s], set deivce role to [%s]", data->occupying_role, data->device_role);
+ }
+ }
+
if ((data->route_type <= STREAM_ROUTE_TYPE_AUTO_ALL) && data->idx_avail_devices) {
/* get current connected devices */
conn_devices = pa_device_manager_get_device_list(u->device_manager);
*(data->proper_sink) = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_COMBINED, PA_NAMEREG_SINK);
pa_log_debug(" -- found the combine-sink, set it to the sink");
} else
- *(data->proper_sink) = pa_device_manager_get_sink(device, DEVICE_ROLE_NORMAL);
+ *(data->proper_sink) = pa_device_manager_get_sink(device, data->device_role);
} else
- *(data->proper_source) = pa_device_manager_get_source(device, DEVICE_ROLE_NORMAL);
+ *(data->proper_source) = pa_device_manager_get_source(device, data->device_role);
break;
}
}
/* update active device info. */
if (latest_device) {
if (data->stream_type == STREAM_SINK_INPUT)
- *(data->proper_sink) = pa_device_manager_get_sink(latest_device, DEVICE_ROLE_NORMAL);
+ *(data->proper_sink) = pa_device_manager_get_sink(latest_device, data->device_role);
else
- *(data->proper_source) = pa_device_manager_get_source(latest_device, DEVICE_ROLE_NORMAL);
+ *(data->proper_source) = pa_device_manager_get_source(latest_device, data->device_role);
pa_proplist_sets(GET_STREAM_NEW_PROPLIST(data->stream, data->stream_type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, dm_device_type);
}
pa_log_info(" ** found a matched device: type[%-16s], direction[0x%x]", device_type, dm_device_direction);
if (data->stream_type == STREAM_SINK_INPUT) {
if ((*(data->proper_sink)) == null_sink)
- pa_sink_input_move_to((pa_sink_input*)(data->stream), pa_device_manager_get_sink(device, DEVICE_ROLE_NORMAL), FALSE);
+ pa_sink_input_move_to((pa_sink_input*)(data->stream), pa_device_manager_get_sink(device, data->device_role), FALSE);
else
- *(data->proper_sink) = pa_device_manager_get_sink(device, DEVICE_ROLE_NORMAL);
+ *(data->proper_sink) = pa_device_manager_get_sink(device, data->device_role);
} else {
if ((*(data->proper_source)) == null_source)
- pa_source_output_move_to((pa_source_output*)(data->stream), pa_device_manager_get_source(device, DEVICE_ROLE_NORMAL), FALSE);
+ pa_source_output_move_to((pa_source_output*)(data->stream), pa_device_manager_get_source(device, data->device_role), FALSE);
else
- *(data->proper_source) = pa_device_manager_get_source(device, DEVICE_ROLE_NORMAL);
+ *(data->proper_source) = pa_device_manager_get_source(device, data->device_role);
}
}
}
/* Change the route setting according to the data from argument.
* This function is called only when it needs to change routing path via HAL.
- * - role is "reset"
+ * - stream is null
* 1. It will be received when it is needed to terminate playback
* or capture routing path.
* 2. Update the state of the device to be deactivated.
- * 3. Call HAL API to reset routing.
+ * 3. Call HAL API to "reset" routing.
* - ROUTE_TYPE_AUTO
* 1. Find the proper sink/source comparing between avail_devices
* and current connected devices.
dm_device_direction_t dm_device_direction = DM_DEVICE_DIRECTION_NONE;
io_direction_t hal_direction;
void *s = NULL;
+ pa_idxset *streams = NULL;
pa_sink *sink = NULL;
+ pa_sink *dst_sink = NULL;
pa_source *source = NULL;
+ pa_source *dst_source = NULL;
pa_idxset *conn_devices = NULL;
pa_sink *combine_sink_arg1 = NULL;
pa_sink *combine_sink_arg2 = NULL;
route_info.role = data->stream_role;
- if (pa_streq(data->stream_role, "reset")) {
+ if (data->stream == NULL) {
/* update BT SCO: close */
set_bt_sco_state(u->device_manager, FALSE);
set_device_state_if_using_internal_codec(device, data->stream_type, DM_DEVICE_STATE_DEACTIVATED);
}
}
+ route_info.role = "reset";
route_info.num_of_devices = 1;
route_info.device_infos = pa_xmalloc0(sizeof(hal_device_info)*route_info.num_of_devices);
route_info.device_infos[0].direction = (data->stream_type == STREAM_SINK_INPUT) ? DIRECTION_OUT : DIRECTION_IN;
dm_device_type, dm_device_subtype, dm_device_direction, dm_device_id);
if (pa_streq(device_type, dm_device_type) && IS_AVAILABLE_DIRECTION(data->stream_type, dm_device_direction)) {
pa_log_debug(" ** found a matched device: type[%-16s], direction[0x%x]", dm_device_type, dm_device_direction);
- use_internal_codec = pa_device_manager_is_device_use_internal_codec(device, CONVERT_TO_DEVICE_DIRECTION(data->stream_type), DEVICE_ROLE_NORMAL);
+ use_internal_codec = pa_device_manager_is_device_use_internal_codec(device, CONVERT_TO_DEVICE_DIRECTION(data->stream_type), data->device_role);
if (use_internal_codec) {
hal_direction = (data->stream_type == STREAM_SINK_INPUT) ? DIRECTION_OUT : DIRECTION_IN;
route_info.num_of_devices++;
/* move sink-inputs/source-outputs if needed */
if (data->stream_type == STREAM_SINK_INPUT)
- sink = pa_device_manager_get_sink(device, DEVICE_ROLE_NORMAL);
+ sink = pa_device_manager_get_sink(device, data->device_role);
/* unload combine sink */
if (data->stream_type == STREAM_SINK_INPUT && u->module_combine_sink) {
sink = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_COMBINED, PA_NAMEREG_SINK);
pa_log_info("[ROUTE][AUTO_ALL] found the combine_sink already existed");
} else if (data->stream_type == STREAM_SINK_INPUT && !combine_sink_arg1) {
- sink = combine_sink_arg1 = pa_device_manager_get_sink(device, DEVICE_ROLE_NORMAL);
+ sink = combine_sink_arg1 = pa_device_manager_get_sink(device, data->device_role);
pa_log_debug("[ROUTE][AUTO_ALL] combine_sink_arg1[%s], combine_sink_arg2[%p]", sink->name, combine_sink_arg2);
} else if (data->stream_type == STREAM_SINK_INPUT && !combine_sink_arg2) {
- sink = combine_sink_arg2 = pa_device_manager_get_sink(device, DEVICE_ROLE_NORMAL);
+ sink = combine_sink_arg2 = pa_device_manager_get_sink(device, data->device_role);
if (sink && !pa_streq(sink->name, combine_sink_arg1->name)) {
pa_log_debug("[ROUTE][AUTO_ALL] combine_sink_arg2[%s]", sink->name);
/* load combine sink */
pa_log_error("[ROUTE][AUTO_ALL] could not get combine_sink");
}
} else if (data->stream_type == STREAM_SOURCE_OUTPUT)
- source = pa_device_manager_get_source(device, DEVICE_ROLE_NORMAL);
+ source = pa_device_manager_get_source(device, data->device_role);
if (data->origins_from_new_data) {
if (data->stream_type == STREAM_SINK_INPUT)
if (latest_device) {
dm_device_type = pa_device_manager_get_device_type(latest_device);
dm_device_id = pa_device_manager_get_device_id(latest_device);
- use_internal_codec = pa_device_manager_is_device_use_internal_codec(latest_device, CONVERT_TO_DEVICE_DIRECTION(data->stream_type), DEVICE_ROLE_NORMAL);
+ use_internal_codec = pa_device_manager_is_device_use_internal_codec(latest_device, CONVERT_TO_DEVICE_DIRECTION(data->stream_type), data->device_role);
if (use_internal_codec) {
hal_direction = (data->stream_type == STREAM_SINK_INPUT) ? DIRECTION_OUT : DIRECTION_IN;
route_info.num_of_devices++;
}
}
}
-
- /* move sink-inputs/source-outputs if needed */
- if (device && !data->origins_from_new_data) {
- if (data->stream_type == STREAM_SINK_INPUT)
- sink = pa_device_manager_get_sink(device, DEVICE_ROLE_NORMAL);
- else if (data->stream_type == STREAM_SOURCE_OUTPUT)
- source = pa_device_manager_get_source(device, DEVICE_ROLE_NORMAL);
- if (data->idx_streams) {
- PA_IDXSET_FOREACH(s, data->idx_streams, idx) {
- if (sink && (sink != ((pa_sink_input*)s)->sink)) {
- pa_sink_input_move_to(s, sink, FALSE);
- pa_log_debug("[ROUTE][MANUAL] *** sink-input(%p,%u) moves to sink(%p,%s)", s, ((pa_sink_input*)s)->index, sink, sink->name);
- } else if (source && (source != ((pa_source_output*)s)->source)) {
- pa_source_output_move_to(s, source, FALSE);
- pa_log_debug("[ROUTE][MANUAL] *** source-output(%p,%u) moves to source(%p,%s)", s, ((pa_source_output*)s)->index, source, source->name);
+ }
+ /* move streams to a proper sink/source if needed.
+ * some targets use several pcm card as per their purpose.
+ * e.g) using a specific pcm card during voice call.
+ * here is the code for roll-back. */
+ if (device && data->stream && !data->origins_from_new_data &&
+ data->route_type != STREAM_ROUTE_TYPE_MANUAL) {
+ if (data->stream_type == STREAM_SINK_INPUT)
+ sink = pa_device_manager_get_sink(device, data->device_role);
+ else if (data->stream_type == STREAM_SOURCE_OUTPUT)
+ source = pa_device_manager_get_source(device, data->device_role);
+ if (data->idx_streams) {
+ PA_IDXSET_FOREACH(s, data->idx_streams, idx) {
+ if (sink && sink != ((pa_sink_input*)s)->sink) {
+ pa_sink_input_move_to(s, sink, FALSE);
+ pa_log_debug("[ROUTE][ROLLBACK] *** sink-input(%p,%u) moves to sink(%p,%s)",
+ s, ((pa_sink_input*)s)->index, sink, sink->name);
+ } else if (source && source != ((pa_source_output*)s)->source) {
+ pa_source_output_move_to(s, source, FALSE);
+ pa_log_debug("[ROUTE][ROLLBACK] *** source-output(%p,%u) moves to source(%p,%s)",
+ s, ((pa_source_output*)s)->index, source, source->name);
+ }
+ }
+ }
+ }
+ /* move other streams that are belong to device of NORMAL role
+ * to a proper sink/source if needed */
+ if (device && data->stream && data->origins_from_new_data &&
+ data->route_type == STREAM_ROUTE_TYPE_MANUAL) {
+ if (pa_streq(data->stream_role, STREAM_ROLE_CALL_VOICE)) {
+ if (data->stream_type == STREAM_SINK_INPUT) {
+ if (!(sink = pa_device_manager_get_sink(device, DEVICE_ROLE_NORMAL)) ||
+ !(dst_sink = pa_device_manager_get_sink(device, DEVICE_ROLE_CALL_VOICE)) ||
+ sink == dst_sink)
+ pa_log_debug("[ROUTE][CALL-VOICE] no need to move streams, sink(%p), dst_sink(%p)", sink, dst_sink);
+ else
+ streams = sink->inputs;
+ } else if (data->stream_type == STREAM_SOURCE_OUTPUT) {
+ if (!(source = pa_device_manager_get_source(device, DEVICE_ROLE_NORMAL)) ||
+ !(dst_source = pa_device_manager_get_source(device, DEVICE_ROLE_CALL_VOICE)) ||
+ source == dst_source)
+ pa_log_debug("[ROUTE][CALL-VOICE] no need to move streams, source(%p), dst_source(%p)", source, dst_source);
+ else
+ streams = source->outputs;
+ }
+ if (streams) {
+ PA_IDXSET_FOREACH(s, streams, idx) {
+ if (data->stream_type == STREAM_SINK_INPUT) {
+ pa_sink_input_move_to(s, dst_sink, FALSE);
+ pa_log_debug("[ROUTE][CALL-VOICE] *** sink-input(%p,%u) moves to sink(%p,%s)",
+ s, ((pa_sink_input*)s)->index, dst_sink, dst_sink->name);
+ } else if (data->stream_type == STREAM_SOURCE_OUTPUT) {
+ pa_source_output_move_to(s, dst_source, FALSE);
+ pa_log_debug("[ROUTE][CALL-VOICE] *** source-output(%p,%u) moves to source(%p,%s)",
+ s, ((pa_source_output*)s)->index, dst_source, dst_source->name);
}
}
}
#endif
-#define STREAM_MANAGER_CLIENT_NAME "SOUND_MANAGER_STREAM_INFO"
+#define STREAM_MANAGER_CLIENT_NAME "SOUND_MANAGER_STREAM_INFO" /* The client via sound-manager */
+#define VIRTUAL_STREAM_NAME "VIRTUAL_STREAM" /* The virtual stream created by sound-manager */
#define DEFAULT_ROLE "media"
#define SKIP_ROLE "skip"
#define ACTIVE_DEV_REMOVED "removed"
int32_t value;
} stream_route_option;
-#define CONVERT_TO_DEVICE_DIRECTION(stream_type)\
+#define CONVERT_TO_DEVICE_DIRECTION(stream_type) \
((stream_type == STREAM_SINK_INPUT) ? DM_DEVICE_DIRECTION_OUT : DM_DEVICE_DIRECTION_IN)
+#define CONVERT_TO_DEVICE_ROLE(x_stream_role, x_device_role) { \
+ pa_assert(x_stream_role); \
+ if (pa_streq(x_stream_role, STREAM_ROLE_CALL_VOICE)) \
+ x_device_role = DEVICE_ROLE_CALL_VOICE; \
+ else if (pa_streq(x_stream_role, STREAM_ROLE_CALL_VIDEO)) \
+ x_device_role = DEVICE_ROLE_CALL_VIDEO; \
+ else if (pa_streq(x_stream_role, STREAM_ROLE_VOIP)) \
+ x_device_role = DEVICE_ROLE_VOIP; \
+ else \
+ x_device_role = DEVICE_ROLE_NORMAL; \
+} \
+
+#define SET_NEW_DATA_STREAM_TO_NULL_SINK_SOURCE(x_m, x_stream, x_stream_type) { \
+ pa_sink *null_sink; \
+ pa_source *null_source; \
+ if (x_stream_type == STREAM_SINK_INPUT && \
+ (!((pa_sink_input_new_data*)x_stream)->sink)) { \
+ if ((null_sink = (pa_sink*)pa_namereg_get(x_m->core, SINK_NAME_NULL, PA_NAMEREG_SINK))) \
+ ((pa_sink_input_new_data*)x_stream)->sink = null_sink; \
+ else \
+ pa_log_warn("could not get null_sink"); \
+ } else if (x_stream_type == STREAM_SOURCE_OUTPUT && \
+ (!((pa_source_output_new_data*)x_stream)->source)) { \
+ if ((null_source = (pa_source*)pa_namereg_get(x_m->core, SOURCE_NAME_NULL, PA_NAMEREG_SOURCE))) \
+ ((pa_source_output_new_data*)x_stream)->source = null_source; \
+ else \
+ pa_log_warn("could not get null_source"); \
+ } \
+} \
+
static void do_notify(pa_stream_manager *m, notify_command_type_t command, stream_type_t type, pa_bool_t is_new_data, void *user_data);
static process_stream_result_t process_stream(pa_stream_manager *m, void *stream, stream_type_t type, process_command_type_t command, pa_bool_t is_new_data);
pa_log_error(" avail-frameworks, out of range, [%d]", idx);
}
info->num_of_frameworks = pa_idxset_size(s->idx_avail_frameworks);
+ } else {
+ /* set variables for error */
+ info->priority = -1;
+ info->num_of_in_devices = info->num_of_out_devices = info->num_of_frameworks = 1;
+ info->volume_types[0] = info->volume_types[1] = dbus_str_none;
+ info->avail_in_devices[0] = dbus_str_none;
+ info->avail_out_devices[0] = dbus_str_none;
+ info->avail_frameworks[0] = dbus_str_none;
+ pa_log_error("could not find the stream_role : %s", stream_role);
+ return -1;
}
} else {
pa_log_error("stream_map is not initialized..");
memset(&info, 0, sizeof(stream_info_per_type));
pa_assert_se((reply = dbus_message_new_method_return(msg)));
dbus_message_iter_init_append(reply, &msg_iter);
- if (!get_stream_info(m, type, &info)) {
- pa_dbus_append_basic_variant(&msg_iter, DBUS_TYPE_INT32, &info.priority);
- pa_dbus_append_basic_variant(&msg_iter, DBUS_TYPE_INT32, &info.route_type);
- pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_STRING, &info.volume_types, STREAM_DIRECTION_MAX);
- pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_STRING, &info.avail_in_devices, info.num_of_in_devices);
- pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_STRING, &info.avail_out_devices, info.num_of_out_devices);
- pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_STRING, &info.avail_frameworks, info.num_of_frameworks);
- } else {
- pa_dbus_append_basic_variant(&msg_iter, DBUS_TYPE_INT32, 0);
- pa_dbus_append_basic_variant(&msg_iter, DBUS_TYPE_INT32, 0);
- pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_STRING, NULL, 0);
- pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_STRING, NULL, 0);
- pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_STRING, NULL, 0);
- pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_STRING, NULL, 0);
- }
+ get_stream_info(m, type, &info);
+ pa_dbus_append_basic_variant(&msg_iter, DBUS_TYPE_INT32, &info.priority);
+ pa_dbus_append_basic_variant(&msg_iter, DBUS_TYPE_INT32, &info.route_type);
+ pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_STRING, &info.volume_types, STREAM_DIRECTION_MAX);
+ pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_STRING, &info.avail_in_devices, info.num_of_in_devices);
+ pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_STRING, &info.avail_out_devices, info.num_of_out_devices);
+ pa_dbus_append_basic_array_variant(&msg_iter, DBUS_TYPE_STRING, &info.avail_frameworks, info.num_of_frameworks);
+
pa_assert_se(dbus_connection_send(conn, reply, NULL));
dbus_message_unref(reply);
}
pa_assert(stream);
if (command == PROCESS_COMMAND_PREPARE && is_new_data) {
- name = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_NAME);
- if (name) {
+ if ((name = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_NAME))) {
for (i = 0; i < NAME_FOR_SKIP_MAX; i++)
if (pa_streq(name, stream_manager_media_names_for_skip[i])) {
ret = TRUE;
pa_proplist_sets(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_ROLE, SKIP_ROLE);
break;
}
- pa_log_info("name is [%s], skip(%d)", name, ret);
+ pa_log_info("name is [%s], skip(%d) command(%s)", name, ret, process_command_type_str[command]);
}
} else {
if (is_new_data)
else
role = pa_proplist_gets(GET_STREAM_PROPLIST(stream, type), PA_PROP_MEDIA_ROLE);
- if (role && pa_streq(role, "skip"))
+ if (role && pa_streq(role, SKIP_ROLE))
ret = TRUE;
}
return ret;
}
+static pa_bool_t check_name_is_vstream(pa_stream_manager *m, process_command_type_t command, void *stream, stream_type_t type, pa_bool_t is_new_data) {
+ pa_bool_t ret = FALSE;
+ const char *name = NULL;
+
+ pa_assert(m);
+ pa_assert(stream);
+
+ if (command == PROCESS_COMMAND_PREPARE) {
+ if (is_new_data)
+ name = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_NAME);
+ else
+ name = pa_proplist_gets(GET_STREAM_PROPLIST(stream, type), PA_PROP_MEDIA_NAME);
+ if (name) {
+ if (pa_streq(name, VIRTUAL_STREAM_NAME)) {
+ ret = TRUE;
+ pa_log_info("name is [%s]", name);
+ }
+ }
+ } else
+ pa_log_warn("not supported command(%d)", command);
+
+ return ret;
+}
+
static pa_bool_t update_priority_of_stream(pa_stream_manager *m, void *stream, stream_type_t type, const char *role, pa_bool_t is_new_data) {
pa_bool_t ret = FALSE;
stream_info *s = NULL;
static pa_bool_t update_focus_status_of_stream(pa_stream_manager *m, void *stream, stream_type_t type, pa_bool_t is_new_data) {
const char *p_idx;
- uint32_t parent_idx;
+ uint32_t parent_idx = 0;
stream_parent *sp = NULL;
pa_assert(m);
else
p_idx = pa_proplist_gets(GET_STREAM_PROPLIST(stream, type), PA_PROP_MEDIA_PARENT_ID);
if (p_idx && !pa_atou(p_idx, &parent_idx)) {
- pa_log_debug("p_idx(%s), idx(%u)", p_idx, parent_idx);
sp = pa_hashmap_get(m->stream_parents, (const void*)parent_idx);
if (sp) {
if (is_new_data)
pa_proplist_setf(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_FOCUS_STATUS, "%u", sp->focus_status);
else
pa_proplist_setf(GET_STREAM_PROPLIST(stream, type), PA_PROP_MEDIA_FOCUS_STATUS, "%u", sp->focus_status);
+ pa_log_debug("p_idx(%s), idx(%u), focus_status(0x%x, 0x1:playback 0x2:capture 0x3:both)", p_idx, parent_idx, sp->focus_status);
} else {
pa_log_error("could not find matching client for this parent_id(%u)", parent_idx);
return FALSE;
}
- } else {
- pa_log_warn("p_idx(%s) or idx(%u) is not valid", p_idx, parent_idx);
- return FALSE;
}
return TRUE;
pa_log_error("could not find matching client for this parent_id(%u)", parent_idx);
return FALSE;
}
- } else {
- pa_log_warn("p_idx(%s) or idx(%u) is not valid", p_idx, parent_idx);
+ } else
return FALSE;
- }
+
return TRUE;
}
const char *route_type_str = NULL;
stream_route_type_t route_type;
const char *focus_status_str = NULL;
+ const char *active_dev = NULL;
void *cur_max_stream = NULL;
void *cur_max_stream_tmp = NULL;
const int32_t *cur_max_priority = NULL;
*need_to_update = TRUE;
pa_log_debug("update cur_highest to mine(%s)", role);
} else {
- /* no need to trigger */
+ /* no need to trigger,
+ * update active device info if possible */
+ if ((active_dev = pa_proplist_gets(GET_STREAM_PROPLIST(cur_max_stream, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV))) {
+ if (is_new_data)
+ pa_proplist_sets(GET_STREAM_NEW_PROPLIST(mine, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, active_dev);
+ else
+ pa_proplist_sets(GET_STREAM_PROPLIST(mine, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, active_dev);
+ }
return TRUE;
}
}
cur_max_priority = priority;
cur_max_focus_status = focus_status;
cur_max_stream_tmp = i;
+ cur_max_role = _role;
}
if (cur_max_priority && priority) {
if (IS_FOCUS_ACQUIRED(cur_max_focus_status, type) ||
cur_max_priority = priority;
cur_max_focus_status = focus_status;
cur_max_stream_tmp = i;
+ cur_max_role = _role;
}
}
}
if (cur_max_stream_tmp) {
if (type == STREAM_SINK_INPUT) {
m->cur_highest_priority.sink_input = cur_max_stream_tmp;
+ m->cur_highest_priority.role_si = cur_max_role;
} else if (type == STREAM_SOURCE_OUTPUT) {
m->cur_highest_priority.source_output = cur_max_stream_tmp;
+ m->cur_highest_priority.role_so = cur_max_role;
}
} else {
if (type == STREAM_SINK_INPUT) {
m->cur_highest_priority.sink_input = NULL;
+ m->cur_highest_priority.role_si = NULL;
} else if (type == STREAM_SOURCE_OUTPUT) {
m->cur_highest_priority.source_output = NULL;
+ m->cur_highest_priority.role_so = NULL;
}
}
*need_to_update = TRUE;
- pa_log_info("need to update: type(%d), cur_highest_priority(sink_input=%p/source_output=%p)",
- type, (void*)m->cur_highest_priority.sink_input, (void*)m->cur_highest_priority.source_output);
+ pa_log_info("need to update: type(%d), cur_highest_priority(sink_input=%p[%s]/source_output=%p[%s])",
+ type, (void*)m->cur_highest_priority.sink_input, m->cur_highest_priority.role_si,
+ (void*)m->cur_highest_priority.source_output, m->cur_highest_priority.role_so);
} else {
/* no need to trigger */
+ pa_log_info("no need to update: type(%d), cur_highest_priority(sink_input=%p[%s]/source_output=%p[%s])",
+ type, (void*)m->cur_highest_priority.sink_input, m->cur_highest_priority.role_si,
+ (void*)m->cur_highest_priority.source_output, m->cur_highest_priority.role_so);
return TRUE;
}
}
fill_device_info_to_hook_data(m, &hook_call_select_data, command, type, s, is_new_data);
hook_call_select_data.sample_spec = GET_STREAM_NEW_SAMPLE_SPEC(s, type);
if (type == STREAM_SINK_INPUT) {
+ hook_call_select_data.occupying_role = m->cur_highest_priority.role_si;
hook_call_select_data.proper_sink = &(((pa_sink_input_new_data*)s)->sink);
/* need to check modifier_gain, because we do not skip a stream that is from module-sound-player */
modifier_gain = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(s, type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE);
break;
}
} else if (type == STREAM_SOURCE_OUTPUT) {
+ hook_call_select_data.occupying_role = m->cur_highest_priority.role_si;
hook_call_select_data.proper_source = &(((pa_source_output_new_data*)s)->source);
if (((pa_source_output_new_data*)s)->source) {
pa_log_info(" - source(%s) has been already selected, skip selecting source",
else if (type == STREAM_SOURCE_OUTPUT)
hook_call_select_data.proper_source = &(((pa_source_output*)s)->source);
}
+ CONVERT_TO_DEVICE_ROLE(hook_call_select_data.stream_role, hook_call_select_data.device_role);
pa_hook_fire(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_SELECT_INIT_SINK_OR_SOURCE), &hook_call_select_data);
}
break;
}
hook_call_route_data.stream_type = type;
hook_call_route_data.stream_role = role;
+ CONVERT_TO_DEVICE_ROLE(hook_call_route_data.stream_role, hook_call_route_data.device_role);
fill_device_info_to_hook_data(m, &hook_call_route_data, command, type, s, is_new_data);
if (hook_call_route_data.route_type >= STREAM_ROUTE_TYPE_MANUAL) {
if (hook_call_route_data.idx_manual_devices && !pa_idxset_size(hook_call_route_data.idx_manual_devices)) {
s = (type == STREAM_SINK_INPUT) ? (void*)(m->cur_highest_priority.sink_input) :
(void*)(m->cur_highest_priority.source_output);
if (s) {
- role = pa_proplist_gets(GET_STREAM_PROPLIST(s, type), PA_PROP_MEDIA_ROLE);
hook_call_route_data.stream = s;
hook_call_route_data.stream_type = type;
- hook_call_route_data.stream_role = role;
+ hook_call_route_data.stream_role = (type == STREAM_SINK_INPUT) ? (m->cur_highest_priority.role_si) :
+ (m->cur_highest_priority.role_so);
+ CONVERT_TO_DEVICE_ROLE(hook_call_route_data.stream_role, hook_call_route_data.device_role);
hook_call_route_data.sample_spec = GET_STREAM_SAMPLE_SPEC(s, type);
hook_call_route_data.idx_streams = (type == STREAM_SINK_INPUT) ? ((pa_sink_input*)s)->sink->inputs :
((pa_source_output*)s)->source->outputs;
fill_device_info_to_hook_data(m, &hook_call_route_data, command, type, s, is_new_data);
} else {
pa_log_info("no stream for this type(%d), need to unset route", type);
+ hook_call_route_data.stream = NULL;
hook_call_route_data.stream_type = type;
- hook_call_route_data.stream_role = "reset";
}
pa_hook_fire(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_CHANGE_ROUTE), &hook_call_route_data);
break;
s = (type == STREAM_SINK_INPUT) ? (void*)(m->cur_highest_priority.sink_input) :
(void*)(m->cur_highest_priority.source_output);
if (s) {
- role = pa_proplist_gets(GET_STREAM_PROPLIST(s, type), PA_PROP_MEDIA_ROLE);
- hook_call_option_data.stream_role = role;
+ hook_call_option_data.stream_role = (type == STREAM_SINK_INPUT) ? (m->cur_highest_priority.role_si) :
+ (m->cur_highest_priority.role_so);
hook_call_option_data.name = ((stream_route_option*)user_data)->name;
hook_call_option_data.value = ((stream_route_option*)user_data)->value;
pa_hook_fire(pa_communicator_hook(m->comm.comm, PA_COMMUNICATOR_HOOK_UPDATE_ROUTE_OPTION), &hook_call_option_data);
if (check_name_to_skip(m, command, stream, type, is_new_data)) {
result = PROCESS_STREAM_RESULT_SKIP;
+ /* set it to null sink/source */
+ if (is_new_data)
+ SET_NEW_DATA_STREAM_TO_NULL_SINK_SOURCE(m, stream, type);
goto FAILURE;
}
}
}
- /* notify to select sink or source */
- do_notify(m, NOTIFY_COMMAND_SELECT_PROPER_SINK_OR_SOURCE_FOR_INIT, type, TRUE, stream);
+ /* check if it is a virtual stream */
+ if (check_name_is_vstream(m, command, stream, type, is_new_data)) {
+ pa_log_debug("skip notifying for selecting sink/source, rather set it to null sink/source");
+ /* set it to null sink/source */
+ if (is_new_data)
+ SET_NEW_DATA_STREAM_TO_NULL_SINK_SOURCE(m, stream, type);
+
+ } else {
+ /* notify to select sink or source */
+ do_notify(m, NOTIFY_COMMAND_SELECT_PROPER_SINK_OR_SOURCE_FOR_INIT, type, TRUE, stream);
+ }
} else if (command == PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_STARTED) {
if (is_new_data) {
m->cur_highest_priority.need_to_update_so = TRUE;
} else {
do_notify(m, NOTIFY_COMMAND_CHANGE_ROUTE_START, type, FALSE, stream);
- if (type == STREAM_SINK_INPUT)
+ if (type == STREAM_SINK_INPUT) {
m->cur_highest_priority.sink_input = stream;
- else
+ m->cur_highest_priority.role_si = role;
+ } else {
m->cur_highest_priority.source_output = stream;
+ m->cur_highest_priority.role_so = role;
+ }
}
}
if (!is_new_data)
if (command == PROCESS_COMMAND_ADD_PARENT_ID) {
if (type == STREAM_SINK_INPUT && m->cur_highest_priority.need_to_update_si) {
m->cur_highest_priority.sink_input = stream;
+ m->cur_highest_priority.role_si = role;
m->cur_highest_priority.need_to_update_si = FALSE;
}
if (type == STREAM_SOURCE_OUTPUT && m->cur_highest_priority.need_to_update_so) {
m->cur_highest_priority.source_output = stream;
+ m->cur_highest_priority.role_so = role;
m->cur_highest_priority.need_to_update_so = FALSE;
}
do_notify(m, NOTIFY_COMMAND_INFORM_STREAM_CONNECTED, type, FALSE, stream);
/* update parent stream info. */
ret = update_stream_parent_info(m, command, type, stream);
if (ret == FALSE) {
- pa_log_warn("could not update the parent information of this stream");
+ pa_log_debug("could not update the parent information of this stream");
//return PROCESS_STREAM_RESULT_STOP;
}
}
return;
}
name = pa_proplist_gets(client->proplist, PA_PROP_APPLICATION_NAME);
- if (name && strncmp(name, STREAM_MANAGER_CLIENT_NAME, strlen(STREAM_MANAGER_CLIENT_NAME))) {
+ if (name && !pa_streq(name, STREAM_MANAGER_CLIENT_NAME)) {
pa_log_warn(" - this is not a client(%s) that we should take care of, skip it", name);
return;
}