Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc

Issue 2073223003: [Chromecast] Use perceptually linear scaling for stream volumes (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698