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..33c8937f3d3fa36d46769e094a0085956baca03d 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 powf(volume_level, 0.5f * log2(10.0f)); |
+} |
+ |
+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 |