From ab81f8e37b459c15e57c29526920da6fe3f1d954 Mon Sep 17 00:00:00 2001 From: KimJeongYeon Date: Wed, 13 Jul 2016 16:33:26 +0900 Subject: [PATCH] pulsecore: Fix calculation of volume ramping methods 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 Change-Id: I48420d046ce9801265172f61376a40ce8c0fb53f --- packaging/pulseaudio.spec | 2 +- src/pulsecore/mix.c | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/packaging/pulseaudio.spec b/packaging/pulseaudio.spec index 4a4f38d..fe38629 100644 --- a/packaging/pulseaudio.spec +++ b/packaging/pulseaudio.spec @@ -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 diff --git a/src/pulsecore/mix.c b/src/pulsecore/mix.c index c1e0c18..79dca5d 100644 --- a/src/pulsecore/mix.c +++ b/src/pulsecore/mix.c @@ -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 *); -- 2.7.4