DBusMessage *reply = NULL;
pa_stream_manager *m = (pa_stream_manager*)userdata;
uint32_t idx = 0;
+ pa_idxset *streams = NULL;
pa_assert(conn);
pa_assert(msg);
pa_assert_se((reply = dbus_message_new_method_return(msg)));
- if (pa_streq(direction, "in"))
+ if (pa_streq(direction, "in")) {
stream_type = STREAM_SOURCE_OUTPUT;
- else if (pa_streq(direction, "out"))
+ streams = m->core->source_outputs;
+ } else if (pa_streq(direction, "out")) {
stream_type = STREAM_SINK_INPUT;
- else {
+ streams = m->core->sink_inputs;
+ } else {
pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &dbus_str_none, DBUS_TYPE_INVALID));
pa_assert_se(dbus_message_append_args(reply, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[RET_MSG_INDEX_ERROR], DBUS_TYPE_INVALID));
goto fail;
}
- if ((s = (stream_type == STREAM_SINK_INPUT) ? (void*)(m->cur_highest_priority.sink_input) : (void*)(m->cur_highest_priority.source_output)))
- type = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE);
- else {
- if (pa_idxset_size(m->core->sink_inputs)) {
- PA_IDXSET_FOREACH(s, m->core->sink_inputs, idx) {
- if ((type = pa_proplist_gets(GET_STREAM_PROPLIST(s, STREAM_SINK_INPUT), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE)))
- break;
+ /* Get a volume type of a stream that has the max priority role among all the running streams regardless of devices.
+ Note that it does not represent any focus status of a stream rather only checking the priority of it */
+ if (pa_idxset_size(streams)) {
+ int cur_max_priority = 0;
+ const char *cur_max_type = NULL;
+ const char *role = NULL;
+ stream_info *s_info;
+
+ PA_IDXSET_FOREACH(s, streams, idx) {
+ if (!CHECK_STREAM_RUNNING(s, stream_type))
+ continue;
+ if (!(type = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE)))
+ continue;
+ if (!(role = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_ROLE)))
+ continue;
+ if ((s_info = pa_hashmap_get(m->stream_infos, role))) {
+ if (s_info->priority >= cur_max_priority) {
+ cur_max_priority = s_info->priority;
+ cur_max_type = type;
+ pa_log_info("updated, volume type of the max priority stream(%u): %s", GET_STREAM_INDEX(s, stream_type), cur_max_type);
+ }
}
}
+ type = cur_max_type;
}
if (type) {