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);
- if(sink && !pa_streq(sink->name, combine_sink_arg1->name)) {
+ 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 */
if (!u->module_combine_sink) {
u->module_combine_sink = pa_module_load(u->core, MODULE_COMBINE_SINK, args);
pa_xfree(args);
}
- sink = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_COMBINED, PA_NAMEREG_SINK);
- PA_IDXSET_FOREACH (s, combine_sink_arg1->inputs, s_idx) {
- if (s == data->stream) {
- pa_sink_input_move_to(s, sink, FALSE);
- pa_log_debug("[ROUTE][AUTO_ALL] *** sink-#if 0input(%p,%u) moves to sink(%p,%s)", s, ((pa_sink_input*)s)->index, sink, sink->name);
+ if ((sink = (pa_sink*)pa_namereg_get(u->core, SINK_NAME_COMBINED, PA_NAMEREG_SINK))) {
+ PA_IDXSET_FOREACH (s, combine_sink_arg1->inputs, s_idx) {
+ if (s == data->stream) {
+ pa_sink_input_move_to(s, sink, FALSE);
+ pa_log_debug("[ROUTE][AUTO_ALL] *** sink-nput(%p,%u) moves to sink(%p,%s)",
+ s, ((pa_sink_input*)s)->index, sink, sink->name);
+ }
}
- }
+ } else
+ 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);
/* move sink-inputs/source-outputs if needed */
if (data->idx_streams) {
PA_IDXSET_FOREACH (s, data->idx_streams, s_idx) { /* data->idx_streams: null_sink */
- if ((sink && (sink != ((pa_sink_input*)s)->sink)) || (source && (source != ((pa_source_output*)s)->source))) {
- if (!pa_stream_manager_get_route_type(s, FALSE, data->stream_type, &route_type) && (route_type == STREAM_ROUTE_TYPE_AUTO_ALL)) {
- if (data->stream_type == STREAM_SINK_INPUT) {
- pa_sink_input_move_to(s, sink, FALSE);
- pa_log_debug("[ROUTE][AUTO_ALL] *** sink-input(%p,%u) moves to sink(%p,%s)",
- s, ((pa_sink_input*)s)->index, sink, sink->name);
- } else if (data->stream_type == STREAM_SOURCE_OUTPUT) {
- pa_source_output_move_to(s, source, FALSE);
- pa_log_debug("[ROUTE][AUTO_ALL] *** source-output(%p,%u) moves to source(%p,%s)",
- s, ((pa_source_output*)s)->index, source, source->name);
- }
+ if (!pa_stream_manager_get_route_type(s, FALSE, data->stream_type, &route_type) &&
+ (route_type == STREAM_ROUTE_TYPE_AUTO_ALL)) {
+ if ((data->stream_type == STREAM_SINK_INPUT) && (sink && (sink != ((pa_sink_input*)s)->sink))) {
+ pa_sink_input_move_to(s, sink, FALSE);
+ pa_log_debug("[ROUTE][AUTO_ALL] *** sink-input(%p,%u) moves to sink(%p,%s)",
+ s, ((pa_sink_input*)s)->index, sink, sink->name);
+ } else if ((data->stream_type == STREAM_SOURCE_OUTPUT) && (source && (source != ((pa_source_output*)s)->source))) {
+ pa_source_output_move_to(s, source, FALSE);
+ pa_log_debug("[ROUTE][AUTO_ALL] *** source-output(%p,%u) moves to source(%p,%s)",
+ s, ((pa_source_output*)s)->index, source, source->name);
}
}
}
return 0;
fail:
- if (ma)
- pa_modargs_free(ma);
-
pa__done(m);
return -1;
if (sp->focus_status != (acquired_focus_status & (STREAM_FOCUS_ACQUIRED_PLAYBACK|STREAM_FOCUS_ACQUIRED_CAPTURE))) {
/* need to update */
sp->focus_status = acquired_focus_status & (STREAM_FOCUS_ACQUIRED_PLAYBACK|STREAM_FOCUS_ACQUIRED_CAPTURE);
- if (sp->idx_sink_inputs)
+ if (sp->idx_sink_inputs) {
count = pa_idxset_size(sp->idx_sink_inputs);
- PA_IDXSET_FOREACH(stream, sp->idx_sink_inputs, idx) {
- pa_proplist_sets(GET_STREAM_PROPLIST(stream, STREAM_SINK_INPUT), PA_PROP_MEDIA_FOCUS_STATUS,
- IS_FOCUS_ACQUIRED(sp->focus_status, STREAM_SINK_INPUT)?STREAM_FOCUS_PLAYBACK:STREAM_FOCUS_NONE);
+ PA_IDXSET_FOREACH(stream, sp->idx_sink_inputs, idx) {
+ pa_proplist_sets(GET_STREAM_PROPLIST(stream, STREAM_SINK_INPUT), PA_PROP_MEDIA_FOCUS_STATUS,
+ IS_FOCUS_ACQUIRED(sp->focus_status, STREAM_SINK_INPUT)?STREAM_FOCUS_PLAYBACK:STREAM_FOCUS_NONE);
if (--count == 0)
process_stream(m, stream, STREAM_SINK_INPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_FOCUS_CHANGED, FALSE);
}
- if (sp->idx_source_outputs)
+ }
+ if (sp->idx_source_outputs) {
count = pa_idxset_size(sp->idx_source_outputs);
PA_IDXSET_FOREACH(stream, sp->idx_source_outputs, idx) {
pa_proplist_sets(GET_STREAM_PROPLIST(stream, STREAM_SOURCE_OUTPUT), PA_PROP_MEDIA_FOCUS_STATUS,
- IS_FOCUS_ACQUIRED(sp->focus_status, STREAM_SOURCE_OUTPUT)?STREAM_FOCUS_CAPTURE:STREAM_FOCUS_NONE);
+ IS_FOCUS_ACQUIRED(sp->focus_status, STREAM_SOURCE_OUTPUT)?STREAM_FOCUS_CAPTURE:STREAM_FOCUS_NONE);
if (--count == 0)
process_stream(m, stream, STREAM_SOURCE_OUTPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_FOCUS_CHANGED, FALSE);
}
+ }
} else
pa_log_debug("same as before, skip updating focus status[0x%x]", acquired_focus_status);
switch (command) {
case NOTIFY_COMMAND_SELECT_PROPER_SINK_OR_SOURCE_FOR_INIT: {
select_data = (pa_stream_manager_hook_data_for_select*)hook_data;
- si = pa_hashmap_get(m->stream_infos, select_data->stream_role);
- select_data->route_type = si->route_type;
- avail_devices = (type == STREAM_SINK_INPUT) ? si->idx_avail_out_devices : si->idx_avail_in_devices;
- list_len = pa_idxset_size(avail_devices);
- device_none = pa_idxset_get_by_data(avail_devices, "none", NULL);
- if (list_len == 0 || device_none) {
- pa_log_warn(" -- there is no available device, stream_type(%d)", type);
- break;
- }
- select_data->idx_avail_devices = avail_devices;
- select_data->origins_from_new_data = is_new_data;
- if (si->route_type >= STREAM_ROUTE_TYPE_MANUAL) {
+ if ((si = pa_hashmap_get(m->stream_infos, select_data->stream_role))) {
+ select_data->route_type = si->route_type;
+ avail_devices = (type == STREAM_SINK_INPUT) ? si->idx_avail_out_devices : si->idx_avail_in_devices;
+ list_len = pa_idxset_size(avail_devices);
+ device_none = pa_idxset_get_by_data(avail_devices, "none", NULL);
+
+ if (list_len == 0 || device_none) {
+ pa_log_warn(" -- there is no available device, stream_type(%d)", type);
+ break;
+ }
+ select_data->idx_avail_devices = avail_devices;
+ select_data->origins_from_new_data = is_new_data;
+ if (si->route_type >= STREAM_ROUTE_TYPE_MANUAL) {
+ if (is_new_data)
+ p_idx = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_PARENT_ID);
+ 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)) {
+ /* find parent idx, it's device info. and it's stream idxs */
+ sp = pa_hashmap_get(m->stream_parents, (const void*)parent_idx);
+ if (sp)
+ select_data->idx_manual_devices = (type == STREAM_SINK_INPUT) ? (sp->idx_route_out_devices) : (sp->idx_route_in_devices);
+ else
+ pa_log_warn(" -- failed to get the stream parent of idx(%u)", parent_idx);
+ } else
+ pa_log_warn(" -- could not get the parent id of this stream, but keep going...");
+ }
+ } else
+ pa_log_error(" -- could not find (%s)", route_data->stream_role);
+
+ break;
+ }
+ case NOTIFY_COMMAND_CHANGE_ROUTE_START:
+ case NOTIFY_COMMAND_CHANGE_ROUTE_END: {
+ route_data = (pa_stream_manager_hook_data_for_route*)hook_data;
+ if ((si = pa_hashmap_get(m->stream_infos, route_data->stream_role))) {
+ avail_devices = (type == STREAM_SINK_INPUT) ? si->idx_avail_out_devices : si->idx_avail_in_devices;
+ route_data->route_type = si->route_type;
+ list_len = pa_idxset_size(avail_devices);
+ device_none = pa_idxset_get_by_data(avail_devices, "none", NULL);
+
+ if (list_len == 0 || device_none) {
+ pa_log_warn(" -- there is no available device, stream_type(%d)", type);
+ break;
+ }
if (is_new_data)
p_idx = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_PARENT_ID);
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)) {
- /* find parent idx, it's device info. and it's stream idxs */
sp = pa_hashmap_get(m->stream_parents, (const void*)parent_idx);
- if (sp)
- select_data->idx_manual_devices = (type == STREAM_SINK_INPUT) ? (sp->idx_route_out_devices) : (sp->idx_route_in_devices);
- else
+ if (!sp)
pa_log_warn(" -- failed to get the stream parent of idx(%u)", parent_idx);
} else
- pa_log_warn(" -- could not get the parent id of this stream, but keep going...");
- }
- break;
- }
- case NOTIFY_COMMAND_CHANGE_ROUTE_START:
- case NOTIFY_COMMAND_CHANGE_ROUTE_END: {
- route_data = (pa_stream_manager_hook_data_for_route*)hook_data;
- si = pa_hashmap_get(m->stream_infos, route_data->stream_role);
- avail_devices = (type == STREAM_SINK_INPUT) ? si->idx_avail_out_devices : si->idx_avail_in_devices;
- route_data->route_type = si->route_type;
- list_len = pa_idxset_size(avail_devices);
- device_none = pa_idxset_get_by_data(avail_devices, "none", NULL);
-
- if (is_new_data)
- p_idx = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_PARENT_ID);
- 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)) {
- sp = pa_hashmap_get(m->stream_parents, (const void*)parent_idx);
- if (!sp)
- pa_log_warn(" -- failed to get the stream parent of idx(%u)", parent_idx);
+ pa_log_warn(" -- could not get the parent id of this stream, but keep going...");
+
+ route_data->idx_avail_devices = avail_devices;
+ if (si->route_type >= STREAM_ROUTE_TYPE_MANUAL) {
+ if (sp) {
+ route_data->idx_manual_devices = (type == STREAM_SINK_INPUT) ? (sp->idx_route_out_devices) : (sp->idx_route_in_devices);
+ route_data->idx_streams = (type == STREAM_SINK_INPUT) ? (sp->idx_sink_inputs) : (sp->idx_source_outputs);
+ } else
+ pa_log_warn(" -- failed to get the stream parent of idx(%u)", parent_idx);
+ }
} else
- pa_log_warn(" -- could not get the parent id of this stream, but keep going...");
+ pa_log_error(" -- could not find (%s)", route_data->stream_role);
- if (list_len == 0 || device_none) {
- pa_log_warn(" -- there is no available device, stream_type(%d)", type);
- break;
- }
- route_data->idx_avail_devices = avail_devices;
- if (si->route_type >= STREAM_ROUTE_TYPE_MANUAL) {
- if (sp) {
- route_data->idx_manual_devices = (type == STREAM_SINK_INPUT) ? (sp->idx_route_out_devices) : (sp->idx_route_in_devices);
- route_data->idx_streams = (type == STREAM_SINK_INPUT) ? (sp->idx_sink_inputs) : (sp->idx_source_outputs);
- } else
- pa_log_warn(" -- failed to get the stream parent of idx(%u)", parent_idx);
- }
break;
}
default:
((route_type == STREAM_ROUTE_TYPE_AUTO) || (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED))) {
/* remove activated device info. if it has the AUTO route type */
active_dev = pa_proplist_gets(GET_STREAM_PROPLIST(s, STREAM_SOURCE_OUTPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV);
- if (pa_streq(active_dev, device_type))
+ if (active_dev && pa_streq(active_dev, device_type))
pa_proplist_sets(GET_STREAM_PROPLIST(s, STREAM_SOURCE_OUTPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, ACTIVE_DEV_REMOVED);
}
}
((route_type == STREAM_ROUTE_TYPE_AUTO) || (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED))) {
/* remove activated device info. if it has the AUTO route type */
active_dev = pa_proplist_gets(GET_STREAM_PROPLIST(s, STREAM_SINK_INPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV);
- if (pa_streq(active_dev, device_type))
+ if (active_dev && pa_streq(active_dev, device_type))
pa_proplist_sets(GET_STREAM_PROPLIST(s, STREAM_SINK_INPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, ACTIVE_DEV_REMOVED);
}
}
return;
}
name = pa_proplist_gets(client->proplist, PA_PROP_APPLICATION_NAME);
- if (strncmp (name, STREAM_MANAGER_CLIENT_NAME, strlen(STREAM_MANAGER_CLIENT_NAME))) {
+ if (name && strncmp (name, STREAM_MANAGER_CLIENT_NAME, strlen(STREAM_MANAGER_CLIENT_NAME))) {
pa_log_warn(" - this is not a client(%s) that we should take care of, skip it", name);
return;
}