CONVERT_TO_DEVICE_DIRECTION(data->stream_type),
data->device_role);
if (use_internal_codec) {
- /* set other device's state to deactivated */
+ /* set other device's state to be deactivated */
PA_IDXSET_FOREACH(_device, conn_devices, conn_idx) {
if (device == _device)
continue;
/* set device state to activated */
set_device_state_if_using_internal_codec(latest_device, data->stream_type, DM_DEVICE_STATE_ACTIVATED);
- /* set other device's state to deactivated */
+ /* set other device's state to be deactivated */
PA_IDXSET_FOREACH(device, conn_devices, conn_idx) {
if (latest_device == device)
continue;
}
if (data->route_type == STREAM_ROUTE_TYPE_AUTO_ALL && route_info.num_of_devices) {
- /* set other device's state to deactivated */
+ /* set other device's state to be deactivated */
PA_IDXSET_FOREACH(_device, conn_devices, conn_idx) {
bool need_to_deactive = true;
dm_device_id = pa_device_manager_get_device_id(_device);
route_info.device_infos[route_info.num_of_devices-1].type = dm_device_type;
route_info.device_infos[route_info.num_of_devices-1].direction = CONVERT_TO_HAL_DIRECTION(data->stream_type);
route_info.device_infos[route_info.num_of_devices-1].id = *device_id;
- pa_log_info(" ** found a matched device and set state to ACTIVATED: type[%-16s], direction[0x%x], id[%u]",
+ pa_log_info(" ** found a matched device and set state to be ACTIVATED: type[%-16s], direction[0x%x], id[%u]",
route_info.device_infos[route_info.num_of_devices-1].type, dm_device_direction, *device_id);
- /* set device state to activated */
+ /* set device state to be activated */
set_device_state_if_using_internal_codec(device, data->stream_type, DM_DEVICE_STATE_ACTIVATED);
} else
pa_log_debug(" -- it does not use internal audio codec, skip it");
const char *role = NULL;
const char *device_type = NULL;
const char *cur_device_type = NULL;
- const char *init_device_type = NULL;
+ const char *new_device_type = NULL;
dm_device *next_device = NULL;
dm_device *_device = NULL;
stream_route_type_t route_type;
} else if (!is_connected) {
/* DISCONNECTED: find a connected device that has the next priority */
if (sink && (sink == ((pa_sink_input*)s)->sink)) {
- init_device_type = device_type;
find_next_device_for_auto_route(m, route_type, role, stream_type, device_type, &next_device);
- pa_log_debug(" -- prev_device(%s), new_device(%p)", device_type, next_device);
if (next_device) {
if ((next_sink = pa_device_manager_get_sink(next_device, DEVICE_ROLE_NORMAL))) {
- device_type = pa_device_manager_get_device_type(next_device);
+ new_device_type = pa_device_manager_get_device_type(next_device);
/* update activated device */
- pa_proplist_sets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, device_type);
+ pa_proplist_sets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, new_device_type);
set_device_state_if_using_internal_codec(next_device, stream_type, DM_DEVICE_STATE_ACTIVATED);
- cached_prev_dev_list[cnt++].device_type = init_device_type;
+ cached_prev_dev_list[cnt++].device_type = device_type;
/* trigger to update routing path if the next device uses internal audio codec */
if (next_sink->use_internal_codec)
process_stream_as_device_change_for_auto_route(m, s, stream_type, is_connected, next_sink->use_internal_codec);
pa_sink_input_move_to(s, next_sink, false);
pa_log_debug(" -- *** sink-input(%p,%u) moves to sink(%p,%s), new device(%s)",
- s, ((pa_sink_input*)s)->index, next_sink, next_sink->name, device_type);
+ s, ((pa_sink_input*)s)->index, next_sink, next_sink->name, new_device_type);
}
}
}
} else if (source && (source == ((pa_source_output*)s)->source)) {
- init_device_type = device_type;
find_next_device_for_auto_route(m, route_type, role, stream_type, device_type, &next_device);
- pa_log_debug(" -- prev_device(%s), new_device(%p)", device_type, next_device);
if (next_device) {
if ((next_source = pa_device_manager_get_source(next_device, DEVICE_ROLE_NORMAL))) {
- device_type = pa_device_manager_get_device_type(next_device);
+ new_device_type = pa_device_manager_get_device_type(next_device);
/* update activated device */
- pa_proplist_sets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, device_type);
+ pa_proplist_sets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, new_device_type);
set_device_state_if_using_internal_codec(next_device, stream_type, DM_DEVICE_STATE_ACTIVATED);
- cached_prev_dev_list[cnt++].device_type = init_device_type;
+ cached_prev_dev_list[cnt++].device_type = device_type;
/* trigger to update routing path if the next device uses internal audio codec */
if (next_source->use_internal_codec)
process_stream_as_device_change_for_auto_route(m, s, stream_type, is_connected, next_source->use_internal_codec);
pa_source_output_move_to(s, next_source, false);
pa_log_debug(" -- *** source-output(%p,%u) moves to source(%p,%s), new device(%s)",
- s, ((pa_source_output*)s)->index, next_source, next_source->name, device_type);
+ s, ((pa_source_output*)s)->index, next_source, next_source->name, new_device_type);
}
}
if (!next_device || !next_source) {
}
}
- /* set device state to deactivated */
+ /* set device state to be deactivated */
if (cnt) {
+ if (stream_type == STREAM_SINK_INPUT) {
+ combine_sink = (pa_sink*)pa_namereg_get(m->core, SINK_NAME_COMBINED, PA_NAMEREG_SINK);
+ if (combine_sink && pa_idxset_size(combine_sink->inputs)) {
+ pa_log_warn(" -- combine sink has streams, skip it..");
+ return;
+ }
+ }
+ /* retrieve all the streams for checking current activated device */
PA_IDXSET_FOREACH(s, streams, s_idx) { /* streams: core->source_outputs/core->sink_inputs */
if ((cur_device_type = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV))) {
for (cnt = 0; cached_prev_dev_list[cnt].device_type; cnt++) {
- pa_log_warn(" -- cur_device(%s), cached_device(%s)", cur_device_type, cached_prev_dev_list[cnt].device_type);
if (pa_streq(cur_device_type, cached_prev_dev_list[cnt].device_type))
cached_prev_dev_list[cnt].count++;
}
}
}
- if (stream_type == STREAM_SINK_INPUT) {
- combine_sink = (pa_sink*)pa_namereg_get(m->core, SINK_NAME_COMBINED, PA_NAMEREG_SINK);
- if (combine_sink && pa_idxset_size(combine_sink->inputs)) {
- pa_log_warn(" -- combine sink has streams, skip it..");
- return;
- }
- }
+ /* if there's no activated device marked in previous device list, set it to be deactivated */
for (cnt = 0; cached_prev_dev_list[cnt].device_type; cnt++) {
if (cached_prev_dev_list[cnt].count == 0) {
- pa_log_debug(" -- device_type(%s)", cached_prev_dev_list[cnt].device_type);
if ((_device = pa_device_manager_get_device(m->dm, cached_prev_dev_list[cnt].device_type)))
set_device_state_if_using_internal_codec(_device, stream_type, DM_DEVICE_STATE_DEACTIVATED);
- else
- pa_log_warn(" -- _device is null");
}
}
}
return -1;
}
- pa_log_debug("stream(%p), origins_from_new_data(%d), stream_type(%d): route_type(%d)",
- stream, origins_from_new_data, stream_type, *stream_route_type);
-
return 0;
}