switch (command) {
case NOTIFY_COMMAND_SELECT_PROPER_SINK_OR_SOURCE_FOR_INIT: {
select_data = (pa_stream_manager_hook_data_for_select*)hook_data;
- 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 || si->route_type == STREAM_ROUTE_TYPE_MANUAL_EXT) {
- 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_debug(" -- could not get the parent id of this stream, but keep going...");
- }
- } else
+ if (!(si = pa_hashmap_get(m->stream_infos, select_data->stream_role))) {
pa_log_error(" -- could not find (%s)", select_data->stream_role);
+ break;
+ }
+ 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 && si->route_type != STREAM_ROUTE_TYPE_MANUAL_EXT)
+ 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)) {
+ pa_log_debug(" -- could not get the parent id of this stream, but keep going...");
+ break;
+ }
+ /* find parent idx, it's device info. and it's stream idxs */
+ if ((sp = pa_hashmap_get(m->stream_parents, (const void*)parent_idx))) {
+ select_data->idx_manual_devices = (type == STREAM_SINK_INPUT) ? (sp->idx_route_out_devices) : (sp->idx_route_in_devices);
+ break;
+ }
+ pa_log_warn(" -- failed to get the stream parent of idx(%u)", parent_idx);
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)) {
- 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);
- } else
- 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 || si->route_type == STREAM_ROUTE_TYPE_MANUAL_EXT) {
- 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
+ if (!(si = pa_hashmap_get(m->stream_infos, route_data->stream_role))) {
pa_log_error(" -- could not find (%s)", route_data->stream_role);
+ break;
+ }
+ 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;
+ }
+ route_data->idx_avail_devices = avail_devices;
+
+ if (si->route_type != STREAM_ROUTE_TYPE_MANUAL && si->route_type != STREAM_ROUTE_TYPE_MANUAL_EXT)
+ 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)) {
+ pa_log_warn(" -- could not get the parent id of this stream, but keep going...");
+ break;
+ }
+ if (!(sp = pa_hashmap_get(m->stream_parents, (const void*)parent_idx))) {
+ pa_log_warn(" -- failed to get the stream parent of idx(%u)", parent_idx);
+ break;
+ }
+ 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);
break;
}
default: