Chromium Code Reviews| Index: chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc |
| diff --git a/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc b/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc |
| index b85d1962f2ad52e662ec82025fd9347c4a6220e6..a68aad4955b6c754e8bd6b3c07742f6b58deef64 100644 |
| --- a/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc |
| +++ b/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc |
| @@ -479,14 +479,15 @@ void StreamMixerAlsaInputImpl::SetPaused(bool paused) { |
| } |
| } |
| -void StreamMixerAlsaInputImpl::SetVolumeMultiplier(float multiplier) { |
| - RUN_ON_MIXER_THREAD(SetVolumeMultiplier, multiplier); |
| +static float VolumeToScaleFactor(float volume_level) { |
| + volume_level = std::max(0.0f, std::min(volume_level, 1.0f)); |
| + return std::max(0.0f, std::min(powf(volume_level, 0.5f * log2(10.0f)), 1.0f)); |
|
kmackay
2016/06/17 21:59:54
Is it necessary to clamp the result? If 0 <= a <=
jyw
2016/06/20 16:53:02
Done.
|
| +} |
| + |
| +void StreamMixerAlsaInputImpl::SetVolumeMultiplier(float volume_level) { |
| + RUN_ON_MIXER_THREAD(SetVolumeMultiplier, volume_level); |
| DCHECK(!IsDeleting()); |
| - if (multiplier > 1.0f) |
| - multiplier = 1.0f; |
| - if (multiplier < 0.0f) |
| - multiplier = 0.0f; |
| - volume_multiplier_ = multiplier; |
| + volume_multiplier_ = VolumeToScaleFactor(volume_level); |
| } |
| } // namespace media |