| OLD | NEW |
| 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 Loading... |
| 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 powf(volume_level, 0.5f * log2(10.0f)); |
| 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 |
| OLD | NEW |