summaryrefslogtreecommitdiffstats
path: root/chromeos/audio
diff options
context:
space:
mode:
authorrkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-22 08:37:35 +0000
committerrkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-22 08:37:35 +0000
commitaa2d7587784da5790d84525230d0c0267ce8bcb2 (patch)
treea33da0be92e37e01d75eaaeef726ee800dd54b45 /chromeos/audio
parentd190eea8280153c69c28c1e731cb88cf5763bda7 (diff)
downloadchromium_src-aa2d7587784da5790d84525230d0c0267ce8bcb2.zip
chromium_src-aa2d7587784da5790d84525230d0c0267ce8bcb2.tar.gz
chromium_src-aa2d7587784da5790d84525230d0c0267ce8bcb2.tar.bz2
Remove input gain switching and sanity checks.
Do not set input gain when switching the active device. Also do not sanitize input gain values to be between 0-100. Since some places the handling is commong, this CL adds output volume sanitization when we set the output volume, and when we read the volume from preferences. R=jennyz@chromium.org BUG=273872 Review URL: https://chromiumcodereview.appspot.com/23205025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218957 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/audio')
-rw-r--r--chromeos/audio/cras_audio_handler.cc22
1 files changed, 13 insertions, 9 deletions
diff --git a/chromeos/audio/cras_audio_handler.cc b/chromeos/audio/cras_audio_handler.cc
index 15911ed..3fa81cb 100644
--- a/chromeos/audio/cras_audio_handler.cc
+++ b/chromeos/audio/cras_audio_handler.cc
@@ -199,10 +199,10 @@ void CrasAudioHandler::SetOutputVolumePercent(int volume_percent) {
FOR_EACH_OBSERVER(AudioObserver, observers_, OnOutputVolumeChanged());
}
+// TODO: Rename the 'Percent' to something more meaningful.
void CrasAudioHandler::SetInputGainPercent(int gain_percent) {
- gain_percent = min(max(gain_percent, 0), 100);
- if (gain_percent <= kMuteThresholdPercent)
- gain_percent = 0;
+ // NOTE: We do not sanitize input gain values since the range is completely
+ // dependent on the device.
input_gain_ = gain_percent;
if (const AudioDevice* device = GetDeviceFromId(active_input_node_id_))
@@ -268,12 +268,14 @@ void CrasAudioHandler::SetVolumeGainPercentForDevice(uint64 device_id,
return;
}
- value = min(max(value, 0), 100);
- if (value <= kMuteThresholdPercent)
- value = 0;
-
- if (const AudioDevice* device = GetDeviceFromId(device_id))
+ if (const AudioDevice* device = GetDeviceFromId(device_id)) {
+ if (!device->is_input) {
+ value = min(max(value, 0), 100);
+ if (value <= kMuteThresholdPercent)
+ value = 0;
+ }
audio_pref_handler_->SetVolumeGainValue(*device, value);
+ }
}
void CrasAudioHandler::SetMuteForDevice(uint64 device_id, bool mute_on) {
@@ -379,7 +381,8 @@ void CrasAudioHandler::SetupAudioInputState() {
input_mute_on_ = audio_pref_handler_->GetMuteValue(*device);
input_gain_ = audio_pref_handler_->GetVolumeGainValue(*device);
SetInputMuteInternal(input_mute_on_);
- SetInputNodeGain(active_input_node_id_, input_gain_);
+ // TODO(rkc,jennyz): Set input gain once we decide on how to store
+ // the gain values since the range and step are both device specific.
}
void CrasAudioHandler::SetupAudioOutputState() {
@@ -391,6 +394,7 @@ void CrasAudioHandler::SetupAudioOutputState() {
}
output_mute_on_ = audio_pref_handler_->GetMuteValue(*device);
output_volume_ = audio_pref_handler_->GetVolumeGainValue(*device);
+
SetOutputMuteInternal(output_mute_on_);
SetOutputNodeVolume(active_output_node_id_, output_volume_);
}