From ccbbdd0298982189047924663d6812aa451380ae Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Fri, 8 Aug 2014 13:26:42 +0200 Subject: [PATCH] Bug 1046592 - Fix volume computation in cubeb's opensl backend. r=kinetik --- media/libcubeb/src/cubeb_opensl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/media/libcubeb/src/cubeb_opensl.c b/media/libcubeb/src/cubeb_opensl.c index 178c683e2bc..d0c84e0715f 100644 --- a/media/libcubeb/src/cubeb_opensl.c +++ b/media/libcubeb/src/cubeb_opensl.c @@ -752,11 +752,13 @@ opensl_stream_set_volume(cubeb_stream * stm, float volume) return CUBEB_ERROR; } - /* convert to millibels */ - millibels = lroundf(2000.f * log10f(volume)); + millibels = SL_MILLIBEL_MIN + (float)(max_level - SL_MILLIBEL_MIN) * volume; + /* clamp to supported range */ if (millibels > max_level) { millibels = max_level; + } else if (millibels < SL_MILLIBEL_MIN) { + millibels = SL_MILLIBEL_MIN; } res = (*stm->volume)->SetVolumeLevel(stm->volume, millibels);