fixup! stream-manager: Do not apply tizen group volume to a stream belongs to a netwo... 33/208533/1 accepted/tizen/unified/20190626.114510 submit/tizen/20190626.013326 submit/tizen/20190626.053216
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 25 Jun 2019 23:47:52 +0000 (08:47 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 25 Jun 2019 23:48:02 +0000 (08:48 +0900)
Change-Id: If63666f1dadf4826649d0442b6c653d70d201461
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
src/stream-manager-volume.c

index 06e0536..837aa7a 100644 (file)
@@ -265,67 +265,72 @@ int32_t update_mute_vconf(const char *type, unsigned int mute)
 }
 
 void apply_individual_ratio(pa_stream_manager *m, pa_object *stream, double volume_linear, pa_cvolume *result) {
-        bool is_sink_input = false;
-        double result_linear;
-        double individual_ratio;
-        double master_ratio;
-        double group_ratio;
-        double result_ratio;
-        pa_volume_t volume;
-        uint32_t index;
-        unsigned channels;
-        io_direction_t io_direction;
-        const char *role;
-        const char *volume_type;
-        pa_hashmap *volumes = NULL;
-        volume_info *v = NULL;
-        stream_type_t stream_type;
-        stream_direction_t stream_direction;
-
-        pa_assert(m);
-        pa_assert(stream);
-        pa_assert(result);
-
-        is_sink_input = pa_sink_input_isinstance(stream);
-        individual_ratio = is_sink_input ? ((pa_sink_input*)stream)->individual_volume_ratio :
-                                            ((pa_source_output*)stream)->individual_volume_ratio;
-        channels = is_sink_input ? ((pa_sink_input*)stream)->sample_spec.channels :
-                                    ((pa_source_output*)stream)->sample_spec.channels;
-
-        volume = pa_sw_volume_from_linear(volume_linear) * individual_ratio;
-        result = pa_cvolume_set(result, channels, volume);
-        result_linear = pa_sw_volume_to_linear(volume);
-        stream_type = is_sink_input ? STREAM_SINK_INPUT : STREAM_SOURCE_OUTPUT;
-        index = GET_STREAM_INDEX(stream, stream_type);
-
-        pa_log_info("apply the individual ratio[%f] to stream[idx:%u], result volume linear[%f]",
+    bool is_sink_input = false;
+    double result_linear;
+    double individual_ratio;
+    double master_ratio;
+    double group_ratio;
+    double result_ratio;
+    pa_volume_t volume;
+    uint32_t index;
+    unsigned channels;
+    io_direction_t io_direction;
+    const char *role;
+    const char *volume_type;
+    pa_hashmap *volumes = NULL;
+    volume_info *v = NULL;
+    stream_type_t stream_type;
+    stream_direction_t stream_direction;
+
+    pa_assert(m);
+    pa_assert(stream);
+    pa_assert(result);
+
+    is_sink_input = pa_sink_input_isinstance(stream);
+
+    /* If this stream belongs to a network device, do not apply tizen group volume */
+    if (is_active_device_of_stream(stream, is_sink_input ? STREAM_SINK_INPUT : STREAM_SOURCE_OUTPUT, DEVICE_TYPE_NETWORK))
+        volume_linear = 1.0;
+
+    individual_ratio = is_sink_input ? ((pa_sink_input*)stream)->individual_volume_ratio :
+                                        ((pa_source_output*)stream)->individual_volume_ratio;
+    channels = is_sink_input ? ((pa_sink_input*)stream)->sample_spec.channels :
+                                ((pa_source_output*)stream)->sample_spec.channels;
+
+    volume = pa_sw_volume_from_linear(volume_linear) * individual_ratio;
+    result = pa_cvolume_set(result, channels, volume);
+    result_linear = pa_sw_volume_to_linear(volume);
+    stream_type = is_sink_input ? STREAM_SINK_INPUT : STREAM_SOURCE_OUTPUT;
+    index = GET_STREAM_INDEX(stream, stream_type);
+
+    pa_log_info("apply the individual ratio[%f] to stream[idx:%u], result volume linear[%f]",
                 individual_ratio, index, result_linear);
 
-        /* Here's calculation before calling HAL API */
-        if (!(volume_type = pa_proplist_gets(GET_STREAM_PROPLIST(stream, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE))) {
-            pa_log_error("no volume type");
-            return;
-        }
-        role = pa_proplist_gets(GET_STREAM_PROPLIST(stream, stream_type), PA_PROP_MEDIA_ROLE);
-        stream_direction = is_sink_input ? STREAM_DIRECTION_OUT : STREAM_DIRECTION_IN;
-        volumes = m->volume_infos;
-        if (!(v = pa_hashmap_get(volumes, MASTER_VOLUME_TYPE))) {
-            pa_log_error("could not get volume_info, volume_type[%s]", MASTER_VOLUME_TYPE);
-            return;
-        }
-        master_ratio = v->is_hal_volume_type ? 1.0 : (double)v->values[stream_direction].current_level / MASTER_VOLUME_LEVEL_MAX;
-        if (!(v = pa_hashmap_get(volumes, volume_type))) {
-            pa_log_error("could not get volume_info, volume_type[%s]", volume_type);
-            return;
-        }
-        group_ratio = v->is_hal_volume_type ? 1.0 : (double)v->values[stream_direction].current_level / (pa_idxset_size(v->values[stream_direction].idx_volume_values) - 1);
-        result_ratio = master_ratio * group_ratio * individual_ratio;
-        pa_log_debug("role(%s), volume_type(%s) : master_ratio(%f), group_ratio(%f), individual_ratio(%f) => result_ratio(%f) to HAL",
-                    role, volume_type, master_ratio, group_ratio, individual_ratio, result_ratio);
+    /* Here's calculation before calling HAL API */
+    if (!(volume_type = pa_proplist_gets(GET_STREAM_PROPLIST(stream, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE))) {
+        pa_log_error("no volume type");
+        return;
+    }
+    role = pa_proplist_gets(GET_STREAM_PROPLIST(stream, stream_type), PA_PROP_MEDIA_ROLE);
+    stream_direction = is_sink_input ? STREAM_DIRECTION_OUT : STREAM_DIRECTION_IN;
+    volumes = m->volume_infos;
+    if (!(v = pa_hashmap_get(volumes, MASTER_VOLUME_TYPE))) {
+        pa_log_error("could not get volume_info, volume_type[%s]", MASTER_VOLUME_TYPE);
+        return;
+    }
+    master_ratio = v->is_hal_volume_type ? 1.0 : (double)v->values[stream_direction].current_level / MASTER_VOLUME_LEVEL_MAX;
+    if (!(v = pa_hashmap_get(volumes, volume_type))) {
+        pa_log_error("could not get volume_info, volume_type[%s]", volume_type);
+        return;
+    }
+    group_ratio = v->is_hal_volume_type ? 1.0 : (double)v->values[stream_direction].current_level / (pa_idxset_size(v->values[stream_direction].idx_volume_values) - 1);
+    result_ratio = master_ratio * group_ratio * individual_ratio;
+    pa_log_debug("role(%s), volume_type(%s) : master_ratio(%f), group_ratio(%f), individual_ratio(%f) => result_ratio(%f) to HAL",
+                role, volume_type, master_ratio, group_ratio, individual_ratio, result_ratio);
 
-        io_direction = is_sink_input ? DIRECTION_OUT : DIRECTION_IN;
+    io_direction = is_sink_input ? DIRECTION_OUT : DIRECTION_IN;
 
-        pa_hal_interface_set_volume_ratio(m->hal, role, io_direction, index, result_ratio);
+    pa_hal_interface_set_volume_ratio(m->hal, role, io_direction, index, result_ratio);
 }
 
 int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type, const char *volume_type, uint32_t volume_level) {
@@ -665,10 +670,6 @@ int32_t set_volume_ratio_by_idx(pa_stream_manager *m, stream_type_t stream_type,
     else
         ((pa_source_output*)s)->individual_volume_ratio = ratio;
 
-    /* In case of network device, do not apply tizen group volume */
-    if (is_active_device_of_stream(s, stream_type, DEVICE_TYPE_NETWORK))
-        volume_linear = 1.0;
-
     apply_individual_ratio(m, s, volume_linear, &cv);
 
     if (stream_type == STREAM_SINK_INPUT)