Bug 1046592 - Fix volume computation in cubeb's opensl backend. r=kinetik

This commit is contained in:
Paul Adenot 2014-08-08 13:26:42 +02:00
parent a5628808a9
commit ccbbdd0298

View File

@ -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);