pulsecore: Fix calculation of volume ramping methods 40/79840/7 accepted/tizen/common/20160719.172001 accepted/tizen/ivi/20160718.104830 accepted/tizen/mobile/20160718.104910 accepted/tizen/tv/20160718.104635 accepted/tizen/wearable/20160718.104756 submit/tizen/20160718.052709
authorKimJeongYeon <jeongyeon.kim@samsung.com>
Wed, 13 Jul 2016 07:33:26 +0000 (16:33 +0900)
committerKimJeongYeon <jeongyeon.kim@samsung.com>
Mon, 18 Jul 2016 01:55:16 +0000 (10:55 +0900)
While do volume ramping with logarithmic method, suddenly it returns NaN.
Therefore, no volume effect processed anymore.
This patch fixed NaN error by simpler calculation than before.

[Version] 5.0-81
[Profile] Common
[Issue Type] Bug

Signed-off-by: KimJeongYeon <jeongyeon.kim@samsung.com>
Change-Id: I48420d046ce9801265172f61376a40ce8c0fb53f

packaging/pulseaudio.spec
src/pulsecore/mix.c

index 4a4f38d..fe38629 100644 (file)
@@ -10,7 +10,7 @@
 Name:             pulseaudio
 Summary:          Improved Linux sound server
 Version:          5.0
-Release:          80
+Release:          81
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
 URL:              http://pulseaudio.org
index c1e0c18..79dca5d 100644 (file)
@@ -791,7 +791,7 @@ static float calc_volume_ramp_linear(pa_volume_ramp_int_t *ramp) {
 }
 
 static float calc_volume_ramp_logarithmic(pa_volume_ramp_int_t *ramp) {
-    float x_val, s, e;
+    float s, e;
     long temp;
 
     pa_assert(ramp);
@@ -807,14 +807,12 @@ static float calc_volume_ramp_logarithmic(pa_volume_ramp_int_t *ramp) {
         e = ramp->end;
     }
 
-    x_val = temp == 0 ? 0.0 : powf(temp, 10);
-
     /* base 10 logarithmic interpolation */
-    return s + x_val * (e - s) / powf(ramp->length, 10);
+    return s + (e - s) * powf((float) temp / (float) ramp->length, 10);
 }
 
 static float calc_volume_ramp_cubic(pa_volume_ramp_int_t *ramp) {
-    float x_val, s, e;
+    float s, e;
     long temp;
 
     pa_assert(ramp);
@@ -830,10 +828,8 @@ static float calc_volume_ramp_cubic(pa_volume_ramp_int_t *ramp) {
         e = ramp->end;
     }
 
-    x_val = temp == 0 ? 0.0 : cbrtf(temp);
-
     /* cubic interpolation */
-    return s + x_val * (e - s) / cbrtf(ramp->length);
+    return s + (e - s) * cbrtf((float) temp / (float) ramp->length);
 }
 
 typedef float (*pa_calc_volume_ramp_func_t) (pa_volume_ramp_int_t *);