}
}
*next_device = latest_device;
- pa_log_debug("found next device[%s, %p], creation_time[%llu]", device_type, *next_device, latest_creation_time);
+ pa_log_debug("found next device[%p], creation_time[%llu]", *next_device, latest_creation_time);
}
pa_log_debug("next_device is [%p] for role[%s]/route_type[%d]/stream_type[%d]", *next_device, role, route_type, stream_type);
pa_log_debug("is new_device[%s] available for role[%s]/stream_type[%d]:%d", new_device_type, role, stream_type, *available);
}
+static bool is_active_device_of_stream(const void *stream, stream_type_t stream_type, const char *device_type) {
+ const char *active_dev;
+
+ pa_assert(stream);
+ pa_assert(device_type);
+
+ active_dev = pa_proplist_gets(GET_STREAM_PROPLIST(stream, stream_type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV);
+ if (pa_safe_streq(active_dev, device_type)) {
+ pa_log_info("stream(%p)'s active_dev(%s) is same as device_type(%s)", stream, active_dev, device_type);
+ return true;
+ }
+
+ return false;
+}
+
/* Re-trigger for routing update for streams using auto route type */
static void process_stream_as_device_change_for_auto_route(pa_stream_manager *m, void *stream, stream_type_t stream_type,
bool is_connected, bool use_internal_codec) {
} else if (!is_connected) {
/* DISCONNECTED: find a connected device that has the next priority */
if ((sink && (sink == ((pa_sink_input*)s)->sink))) {
+ if (!is_active_device_of_stream(s, stream_type, device_type))
+ continue;
find_next_device_for_auto_route(m, route_type, role, stream_type, device_type, &next_device);
if (next_device) {
if ((next_sink = pa_tz_device_get_sink(next_device, DEVICE_ROLE_NORMAL))) {
}
} else if (source && (source == ((pa_source_output*)s)->source)) {
+ if (!is_active_device_of_stream(s, stream_type, device_type))
+ continue;
find_next_device_for_auto_route(m, route_type, role, stream_type, device_type, &next_device);
if (next_device) {
if ((next_source = pa_tz_device_get_source(next_device, DEVICE_ROLE_NORMAL))) {
pa_assert(all_streams);
pa_assert(applied_streams);
- pa_log_debug("apply_volume_factor_to_streams is called");
+ pa_log_info("apply_volume_factor_to_streams is called");
vol.channels = 1;
pa_parse_volume("0%", &vol.values[0]);
*applied_streams = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
PA_IDXSET_FOREACH(i, all_streams, idx) {
- stream_route_type_t route_type = STREAM_ROUTE_TYPE_AUTO;
- /* skip in case of auto-all type or manual-ext type */
- if (!get_route_type(i, STREAM_SINK_INPUT, false, &route_type) &&
- (route_type == STREAM_ROUTE_TYPE_AUTO_ALL || route_type == STREAM_ROUTE_TYPE_MANUAL_EXT))
- continue;
-
pa_log_info("found a stream(%p, %u) that should be muted.", i, i->index);
/* remove MUTE_KEY before adding to avoid abort-case in pa_sink_input_add_volume_factor */
pa_hashmap_remove(i->volume_factor_items, MUTE_KEY);
pa_assert(applied_streams);
- pa_log_debug("clear_volume_factor_from_streams is called");
+ pa_log_info("clear_volume_factor_from_streams is called");
PA_IDXSET_FOREACH(i, applied_streams, idx) {
pa_idxset_remove_by_data(applied_streams, i, NULL);
m->time_event_for_unmute = NULL;
}
+static int active_device_filter_func(const void *i, const void *device_type) {
+ pa_assert(i);
+ pa_assert(device_type);
+
+ if (is_active_device_of_stream(i, STREAM_SINK_INPUT, (const char *)device_type))
+ return 1;
+
+ return 0;
+}
+
+static pa_idxset* get_streams_for_matching_active_device(pa_idxset *streams, const char *device_type) {
+ pa_idxset *filtered_streams;
+
+ pa_assert(streams);
+
+ filtered_streams = pa_idxset_filtered_copy(streams, NULL, active_device_filter_func, device_type);
+
+ return filtered_streams;
+}
+
static void mute_sink_inputs_as_device_disconnection(pa_stream_manager *m, uint32_t event_id, bool need_to_mute, pa_idxset *streams_of_disconnected_device) {
pa_idxset *applied_streams;
/* mute all the streams belong to this device, those will be un-muted in event_fully_handled_hook_cb */
if (!data->is_connected && (device_direction & DM_DEVICE_DIRECTION_OUT)) {
- if ((sink = pa_tz_device_get_sink(data->device, DEVICE_ROLE_NORMAL)))
- mute_sink_inputs_as_device_disconnection(m, data->event_id, true, sink->inputs);
+ if ((sink = pa_tz_device_get_sink(data->device, DEVICE_ROLE_NORMAL))) {
+ pa_idxset *filtered_streams = get_streams_for_matching_active_device(sink->inputs, device_type);
+ mute_sink_inputs_as_device_disconnection(m, data->event_id, true, filtered_streams);
+ pa_xfree(filtered_streams);
+ }
/* If Earjack is disconnected, search for sink-input which has radio role,
if found, let radio mute to avoid intermediate noise */