stream-manager-volume: Revise codes to improve readability 54/202154/1
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 25 Mar 2019 08:49:41 +0000 (17:49 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 25 Mar 2019 08:53:05 +0000 (17:53 +0900)
[Version] 11.1.36
[Issue type] Refactoring

Change-Id: Ieb917f9e6b7b068cd934304bc923cb86bac35615
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/pulseaudio-modules-tizen.spec
src/stream-manager-volume.c

index 96f254c..bb0b593 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          11.1.35
+Version:          11.1.36
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index db3c4b7..99beaeb 100644 (file)
@@ -309,6 +309,7 @@ int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type
     }
 
     if (!pa_safe_streq(volume_type, MASTER_VOLUME_TYPE)) {
+        /* Get volume value */
         if (get_volume_value(m, stream_type, is_hal_volume, volume_type, volume_level, &volume_linear))
             return -1;
 
@@ -316,53 +317,50 @@ int32_t set_volume_level_by_type(pa_stream_manager *m, stream_type_t stream_type
             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))
+                continue;
+
             /* Get modifier for gain */
             modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE);
-
-            /* Update volume level of stream if it has requested the volume type */
-            if (pa_safe_streq(volume_type_str, volume_type)) {
-                if (modifier_gain) {
-                    if (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) {
+                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);
                 }
-                pa_cvolume_set(&cv, GET_STREAM_SAMPLE_SPEC(s, stream_type).channels, pa_sw_volume_from_linear(volume_linear));
-                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)
-                    pa_source_output_set_volume((pa_source_output*)s, &cv, true, true);
             }
+
+            pa_cvolume_set(&cv, GET_STREAM_SAMPLE_SPEC(s, stream_type).channels, pa_sw_volume_from_linear(volume_linear));
+            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)
+                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 modifier for gain */
-            modifier_gain = pa_proplist_gets(GET_STREAM_PROPLIST(s, stream_type), PA_PROP_MEDIA_TIZEN_VOLUME_GAIN_TYPE);
-
             /* Get volume level of this type */
             if (!(v = pa_hashmap_get(volumes, volume_type_str)))
                 continue;
-
             volume_level = v->values[stream_type].current_level;
 
+            /* Get volume value */
             if (get_volume_value(m, stream_type, is_hal_volume, volume_type_str, volume_level, &volume_linear))
                 continue;
 
-            if (modifier_gain) {
-                if (m->volume_modifiers) {
-                   if ((modifier_gain_value = pa_hashmap_get(m->volume_modifiers, modifier_gain))) {
-                        volume_linear *= (*modifier_gain_value);
-                        pa_log_info("set_volume_level_by_type() : apply the modifier for the gain value[%s=>%f], result volume_linear[%f]",
-                                    modifier_gain, *modifier_gain_value, volume_linear);
-                    }
+            /* 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("set_volume_level_by_type() : 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_SAMPLE_SPEC(s, stream_type).channels, pa_sw_volume_from_linear(volume_linear));
             if (stream_type == STREAM_SINK_INPUT)
                 pa_sink_input_set_volume((pa_sink_input*)s, &cv, true, true);