return -1;
PA_IDXSET_FOREACH(s, stream_type == STREAM_SINK_INPUT ? m->core->sink_inputs : m->core->source_outputs, idx) {
- if (!(volume_type_str = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE)))
- continue;
-
/* Update volume level of stream if it has requested the volume type */
- if (!pa_safe_streq(volume_type_str, volume_type))
+ if (!(volume_type_str = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE)) ||
+ !pa_safe_streq(volume_type_str, volume_type))
continue;
/* Get modifier for gain */
modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE);
- if (modifier_gain && m->volume_modifiers) {
- if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) {
- volume_linear *= (*modifier_gain_value);
- pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]",
- modifier_gain, *modifier_gain_value, volume_linear);
- }
+ if (modifier_gain && m->volume_modifiers &&
+ (modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) {
+ volume_linear *= (*modifier_gain_value);
+ pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]",
+ modifier_gain, *modifier_gain_value, volume_linear);
}
apply_individual_ratio(m, s, volume_linear, &cv);
if (stream_type == STREAM_SINK_INPUT)
pa_sink_input_set_volume((pa_sink_input*)s, &cv, true, true);
- else if (stream_type == STREAM_SOURCE_OUTPUT)
+ else
pa_source_output_set_volume((pa_source_output*)s, &cv, true, true);
}
} else {
PA_IDXSET_FOREACH(s, stream_type == STREAM_SINK_INPUT ? m->core->sink_inputs : m->core->source_outputs, idx) {
- if (!(volume_type_str = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE)))
- continue;
-
/* Get volume level of this type */
- if (!(v = pa_hashmap_get(volumes, volume_type_str)))
+ if (!(volume_type_str = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE)) ||
+ !(v = pa_hashmap_get(volumes, volume_type_str)))
continue;
+
volume_level = v->values[stream_type].current_level;
/* Get volume value */
/* Get modifier for gain */
modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE);
- if (modifier_gain && m->volume_modifiers) {
- if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) {
+ if (modifier_gain && m->volume_modifiers &&
+ (modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) {
volume_linear *= (*modifier_gain_value);
pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]",
modifier_gain, *modifier_gain_value, volume_linear);
- }
}
apply_individual_ratio(m, s, volume_linear, &cv);
if (stream_type == STREAM_SINK_INPUT)
pa_sink_input_set_volume((pa_sink_input*)s, &cv, true, true);
- else if (stream_type == STREAM_SOURCE_OUTPUT)
+ else
pa_source_output_set_volume((pa_source_output*)s, &cv, true, true);
}
}
/* from HAL */
if (pa_hal_interface_get_volume_level(m->hal, volume_type, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level))
return -1;
- } else {
- /* from stream-manager */
- if (!(v = pa_hashmap_get(volumes, volume_type))) {
- pa_log_error("could not get volume_info, stream_type[%d], volume_type[%s]", stream_type, volume_type);
- return -1;
- }
- *volume_level = v->values[stream_type].current_level;
-
+ return 0;
}
+ /* from stream-manager */
+ if (!(v = pa_hashmap_get(volumes, volume_type))) {
+ pa_log_error("could not get volume_info, stream_type[%d], volume_type[%s]", stream_type, volume_type);
+ return -1;
+ }
+ *volume_level = v->values[stream_type].current_level;
+
} else if (command == GET_VOLUME_MAX_LEVEL) {
/* If it is the master volume type */
if (pa_safe_streq(volume_type, MASTER_VOLUME_TYPE)) {
*volume_level = MASTER_VOLUME_LEVEL_MAX;
+ return 0;
+ }
+ /* Get max level */
+ if (is_hal_volume) {
+ /* from HAL */
+ if (pa_hal_interface_get_volume_level_max(m->hal, volume_type, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level))
+ return -1;
+ return 0;
+ }
+ /* from stream-manager */
+ v = pa_hashmap_get(volumes, volume_type);
+ if (v && v->values[stream_type].idx_volume_values) {
+ *volume_level = pa_idxset_size(v->values[stream_type].idx_volume_values);
} else {
- /* Get max level */
- if (is_hal_volume) {
- /* from HAL */
- if (pa_hal_interface_get_volume_level_max(m->hal, volume_type, CONVERT_TO_HAL_DIRECTION(stream_type), volume_level))
- return -1;
- } else {
- /* from stream-manager */
- v = pa_hashmap_get(volumes, volume_type);
- if (v && v->values[stream_type].idx_volume_values)
- *volume_level = pa_idxset_size(v->values[stream_type].idx_volume_values);
- else {
- pa_log_error("could not get volume_info, stream_type[%d], volume_type[%s]", stream_type, volume_type);
- return -1;
- }
- }
+ pa_log_error("could not get volume_info, stream_type[%d], volume_type[%s]", stream_type, volume_type);
+ return -1;
}
}
if (stream_type == STREAM_SINK_INPUT)
pa_sink_input_set_volume((pa_sink_input*)s, &cv, true, true);
- else if (stream_type == STREAM_SOURCE_OUTPUT)
+ else
pa_source_output_set_volume((pa_source_output*)s, &cv, true, true);
pa_log_debug("stream_type[%d], idx[%u]=>volume_type[%s], level[%u], value[%f]",
/* Get modifier for gain */
modifier_gain = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(stream, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE);
- if (modifier_gain && m->volume_modifiers) {
- if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) {
- volume_linear *= (*modifier_gain_value);
- pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]",
- modifier_gain, *modifier_gain_value, volume_linear);
- }
+ if (modifier_gain && m->volume_modifiers &&
+ (modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) {
+ volume_linear *= (*modifier_gain_value);
+ pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]",
+ modifier_gain, *modifier_gain_value, volume_linear);
}
pa_cvolume_set(&cv, GET_STREAM_NEW_SAMPLE_SPEC(stream, stream_type).channels, pa_sw_volume_from_linear(volume_linear));
if (stream_type == STREAM_SINK_INPUT)
pa_sink_input_new_data_set_volume((pa_sink_input_new_data*)stream, &cv);
- else if (stream_type == STREAM_SOURCE_OUTPUT)
+ else
pa_source_output_new_data_set_volume((pa_source_output_new_data*)stream, &cv);
pa_log_debug("stream_type[%d], volume_type[%s], level[%u], value[%f]",
/* Get modifier for gain */
modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE);
- if (modifier_gain && m->volume_modifiers) {
- if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) {
- volume_linear *= (*modifier_gain_value);
- pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]",
- modifier_gain, *modifier_gain_value, volume_linear);
- }
+ if (modifier_gain && m->volume_modifiers &&
+ (modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) {
+ volume_linear *= (*modifier_gain_value);
+ pa_log_info("apply the modifier for the gain value[%s=>%f], result volume_linear[%f]",
+ modifier_gain, *modifier_gain_value, volume_linear);
}
- if (stream_type == STREAM_SINK_INPUT)
+ if (stream_type == STREAM_SINK_INPUT) {
((pa_sink_input*)s)->individual_volume_ratio = ratio;
- else
- ((pa_source_output*)s)->individual_volume_ratio = ratio;
-
- apply_individual_ratio(m, s, volume_linear, &cv);
-
- if (stream_type == STREAM_SINK_INPUT)
+ apply_individual_ratio(m, s, volume_linear, &cv);
pa_sink_input_set_volume((pa_sink_input*)s, &cv, true, true);
- else if (stream_type == STREAM_SOURCE_OUTPUT)
+ } else {
+ ((pa_source_output*)s)->individual_volume_ratio = ratio;
+ apply_individual_ratio(m, s, volume_linear, &cv);
pa_source_output_set_volume((pa_source_output*)s, &cv, true, true);
+ }
pa_log_debug("stream_type[%d], idx[%u]=>volume_type[%s], level[%u], ratio[%f], value[%f]",
stream_type, idx, volume_type_str, volume_level, ratio, volume_linear);
v->values[stream_type].is_muted = volume_mute;
PA_IDXSET_FOREACH(s, (stream_type == STREAM_SINK_INPUT) ? m->core->sink_inputs : m->core->source_outputs, idx) {
- if (!(volume_type_str = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE))) {
- continue;
- }
-
/* Update mute of stream if it has requested the volume type */
- if (pa_safe_streq(volume_type_str, volume_type)) {
- if (stream_type == STREAM_SINK_INPUT)
- pa_sink_input_set_mute((pa_sink_input*)s, volume_mute, true);
- else if (stream_type == STREAM_SOURCE_OUTPUT)
- pa_source_output_set_mute((pa_source_output*)s, volume_mute, true);
+ if (!(volume_type_str = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE)) ||
+ !pa_safe_streq(volume_type_str, volume_type)) {
+ continue;
}
+ if (stream_type == STREAM_SINK_INPUT)
+ pa_sink_input_set_mute((pa_sink_input*)s, volume_mute, true);
+ else
+ pa_source_output_set_mute((pa_source_output*)s, volume_mute, true);
}
pa_log_info("stream_type[%d], volume_type[%s], mute[%d]", stream_type, volume_type, volume_mute);
if (stream_idx == idx) {
if (stream_type == STREAM_SINK_INPUT)
pa_sink_input_set_mute((pa_sink_input*)s, volume_mute, true);
- else if (stream_type == STREAM_SOURCE_OUTPUT)
+ else
pa_source_output_set_mute((pa_source_output*)s, volume_mute, true);
break;
}
if (stream_idx == idx) {
if (stream_type == STREAM_SINK_INPUT)
*volume_mute = ((pa_sink_input*)s)->muted;
- else if (stream_type == STREAM_SOURCE_OUTPUT)
+ else
*volume_mute = ((pa_source_output*)s)->muted;
break;
}
if (stream_type == STREAM_SINK_INPUT)
pa_sink_input_new_data_set_muted((pa_sink_input_new_data*)stream, volume_mute);
- else if (stream_type == STREAM_SOURCE_OUTPUT)
+ else
pa_source_output_new_data_set_muted((pa_source_output_new_data*)stream, volume_mute);
return 0;