diff options
author | rkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-17 20:47:19 +0000 |
---|---|---|
committer | rkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-17 20:47:19 +0000 |
commit | 30dca89c84bec4276bf9ad89b9fdbd18b8cf56a5 (patch) | |
tree | 670d75a726960eafb5f94696b0cfa98635bbd759 /chromeos | |
parent | 833ac110b28c8e91678ca506d8ec512e61998bef (diff) | |
download | chromium_src-30dca89c84bec4276bf9ad89b9fdbd18b8cf56a5.zip chromium_src-30dca89c84bec4276bf9ad89b9fdbd18b8cf56a5.tar.gz chromium_src-30dca89c84bec4276bf9ad89b9fdbd18b8cf56a5.tar.bz2 |
Add tests for the Audio Extension API.
Add basic test coverage for the audio extension API. This CL adds tests for the three methods in the Audio API testing various combinations of active and inactive devices. This CL also fixes two bugs that the tests found.
a.) We weren't updating the mute value for a device when getting them, fixed that.
b.) We were setting unsetting the mute for a device if it had a volume or a gain - this is incorrect since a device can have a volume and still be muted. When it gets unmuted, it would start playing at the volume it has.
Reviews requested,
owner's review: mpcomplete@
audio api changes: hshi@
cras changes: jennyz@
R=hshi@chromium.org, jennyz@chromium.org, mpcomplete@chromium.org
BUG=239227
TEST=Ran the tests to ensure that they pass.
Review URL: https://codereview.chromium.org/14945010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200879 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/audio/cras_audio_handler.cc | 26 | ||||
-rw-r--r-- | chromeos/audio/cras_audio_handler.h | 6 |
2 files changed, 22 insertions, 10 deletions
diff --git a/chromeos/audio/cras_audio_handler.cc b/chromeos/audio/cras_audio_handler.cc index b6a601d..0e4b26f 100644 --- a/chromeos/audio/cras_audio_handler.cc +++ b/chromeos/audio/cras_audio_handler.cc @@ -103,10 +103,24 @@ bool CrasAudioHandler::IsOutputMuted() { return output_mute_on_; } +bool CrasAudioHandler::IsOutputMutedForDevice(uint64 device_id) { + if (device_id == active_output_node_id_) + return output_mute_on_; + else + return audio_pref_handler_->GetMuteValue(device_id); +} + bool CrasAudioHandler::IsInputMuted() { return input_mute_on_; } +bool CrasAudioHandler::IsInputMutedForDevice(uint64 device_id) { + if (device_id == active_input_node_id_) + return input_mute_on_; + else + return audio_pref_handler_->GetMuteValue(device_id); +} + int CrasAudioHandler::GetOutputVolumePercent() { return output_volume_; } @@ -165,11 +179,6 @@ void CrasAudioHandler::SetOutputVolumePercent(int volume_percent) { if (volume_percent <= kMuteThresholdPercent) volume_percent = 0; SetOutputVolumeInternal(volume_percent); - - if (IsOutputMuted() && volume_percent > 0) - SetOutputMute(false); - if (!IsOutputMuted() && volume_percent == 0) - SetOutputMute(true); } void CrasAudioHandler::SetInputGainPercent(int gain_percent) { @@ -177,11 +186,6 @@ void CrasAudioHandler::SetInputGainPercent(int gain_percent) { if (gain_percent <= kMuteThresholdPercent) gain_percent = 0; SetInputGainInternal(gain_percent); - - if (IsInputMuted() && gain_percent > 0) - SetInputMute(false); - if (!IsInputMuted() && gain_percent == 0) - SetInputMute(true); } void CrasAudioHandler::AdjustOutputVolumeByPercent(int adjust_by_percent) { @@ -192,6 +196,7 @@ void CrasAudioHandler::SetOutputMute(bool mute_on) { if (output_mute_locked_) return; + output_mute_on_ = mute_on; audio_pref_handler_->SetMuteValue(active_output_node_id_, mute_on); chromeos::DBusThreadManager::Get()->GetCrasAudioClient()-> SetOutputMute(mute_on); @@ -209,6 +214,7 @@ void CrasAudioHandler::SetInputMute(bool mute_on) { if (input_mute_locked_) return; + input_mute_on_ = mute_on; audio_pref_handler_->SetMuteValue(active_input_node_id_, mute_on); chromeos::DBusThreadManager::Get()->GetCrasAudioClient()-> SetInputMute(mute_on); diff --git a/chromeos/audio/cras_audio_handler.h b/chromeos/audio/cras_audio_handler.h index 8c6469e..d7449de 100644 --- a/chromeos/audio/cras_audio_handler.h +++ b/chromeos/audio/cras_audio_handler.h @@ -96,9 +96,15 @@ class CHROMEOS_EXPORT CrasAudioHandler : public CrasAudioClient::Observer, // Returns true if audio output is muted. virtual bool IsOutputMuted(); + // Returns true if audio output is muted for a device. + virtual bool IsOutputMutedForDevice(uint64 device_id); + // Returns true if audio input is muted. virtual bool IsInputMuted(); + // Returns true if audio input is muted for a device. + virtual bool IsInputMutedForDevice(uint64 device_id); + // Gets volume level in 0-100% range (0 being pure silence) for the current // active node. virtual int GetOutputVolumePercent(); |