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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.h" 5 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 } 472 }
473 DCHECK_GE(fade_frames_remaining_, 0); 473 DCHECK_GE(fade_frames_remaining_, 0);
474 474
475 if (state_ == kStateFadingOut) { 475 if (state_ == kStateFadingOut) {
476 // Tell the mixer that some more data might be available (since when fading 476 // Tell the mixer that some more data might be available (since when fading
477 // out, we can drain the queue completely). 477 // out, we can drain the queue completely).
478 mixer_->OnFramesQueued(); 478 mixer_->OnFramesQueued();
479 } 479 }
480 } 480 }
481 481
482 void StreamMixerAlsaInputImpl::SetVolumeMultiplier(float multiplier) { 482 static float VolumeToScaleFactor(float volume_level) {
483 RUN_ON_MIXER_THREAD(SetVolumeMultiplier, multiplier); 483 volume_level = std::max(0.0f, std::min(volume_level, 1.0f));
484 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.
485 }
486
487 void StreamMixerAlsaInputImpl::SetVolumeMultiplier(float volume_level) {
488 RUN_ON_MIXER_THREAD(SetVolumeMultiplier, volume_level);
484 DCHECK(!IsDeleting()); 489 DCHECK(!IsDeleting());
485 if (multiplier > 1.0f) 490 volume_multiplier_ = VolumeToScaleFactor(volume_level);
486 multiplier = 1.0f;
487 if (multiplier < 0.0f)
488 multiplier = 0.0f;
489 volume_multiplier_ = multiplier;
490 } 491 }
491 492
492 } // namespace media 493 } // namespace media
493 } // namespace chromecast 494 } // namespace chromecast
OLDNEW
« 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