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

Unified Diff: chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.cc

Issue 23536034: Set up hdmi output device default volume to 100. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits. Created 7 years, 3 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
Index: chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.cc
diff --git a/chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.cc b/chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.cc
index 2d25fb82a477462b0904e9ea715ddcdc96c4801f..b0449c58506586035cf05f1b886f98075c3111a4 100644
--- a/chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.cc
+++ b/chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.cc
@@ -16,31 +16,37 @@
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/common/pref_names.h"
#include "chromeos/audio/audio_device.h"
-#include "chromeos/audio/cras_audio_handler.h"
namespace {
+const double kDefaultOutputVolume = 75.0;
+const double kDefaultHDMIOutputVolume = 100.0;
+
+// Values used for muted preference.
+const int kPrefMuteOff = 0;
+const int kPrefMuteOn = 1;
+
std::string GetDeviceIdString(const chromeos::AudioDevice& device) {
return device.device_name + " : " +
base::Uint64ToString(device.id & static_cast<uint64>(0xffffffff));
}
-}
+} // namespace
namespace chromeos {
-double AudioDevicesPrefHandlerImpl::GetVolumeGainValue(
- const AudioDevice& device) {
- UpdateDevicesVolumePref();
-
- std::string device_id_str = GetDeviceIdString(device);
- if (!device_volume_settings_->HasKey(device_id_str))
- MigrateDeviceVolumeSettings(device_id_str);
-
- double volume = kDefaultVolumeGainPercent;
- device_volume_settings_->GetDouble(device_id_str, &volume);
+double AudioDevicesPrefHandlerImpl::GetOutputVolumeValue(
+ const AudioDevice* device) {
+ if (!device)
+ return kDefaultOutputVolume;
+ else
+ return GetVolumeGainPrefValue(*device);
+}
- return volume;
+double AudioDevicesPrefHandlerImpl::GetInputGainValue(
+ const AudioDevice* device) {
+ DCHECK(device);
+ return GetVolumeGainPrefValue(*device);
}
void AudioDevicesPrefHandlerImpl::SetVolumeGainValue(
@@ -89,6 +95,31 @@ void AudioDevicesPrefHandlerImpl::RemoveAudioPrefObserver(
observers_.RemoveObserver(observer);
}
+double AudioDevicesPrefHandlerImpl::GetVolumeGainPrefValue(
+ const AudioDevice& device) {
+ UpdateDevicesVolumePref();
+
+ std::string device_id_str = GetDeviceIdString(device);
+ if (!device_volume_settings_->HasKey(device_id_str))
+ MigrateDeviceVolumeSettings(device_id_str);
+
+ // TODO(jennyz, rkc): Return a meaningful input gain default value, when
+ // cras has added support for normalizing input gain range.
+ double value = device.is_input ?
+ 0.0 : GetDeviceDefaultOutputVolume(device);
+ device_volume_settings_->GetDouble(device_id_str, &value);
+
+ return value;
+}
+
+double AudioDevicesPrefHandlerImpl::GetDeviceDefaultOutputVolume(
+ const AudioDevice& device) {
+ if (device.type == AUDIO_TYPE_HDMI)
+ return kDefaultHDMIOutputVolume;
+ else
+ return kDefaultOutputVolume;
+}
+
AudioDevicesPrefHandlerImpl::AudioDevicesPrefHandlerImpl(
PrefService* local_state)
: device_mute_settings_(new base::DictionaryValue()),
@@ -142,8 +173,9 @@ void AudioDevicesPrefHandlerImpl::SaveDevicesVolumePref() {
prefs::kAudioDevicesVolumePercent);
base::DictionaryValue::Iterator it(*device_volume_settings_);
while (!it.IsAtEnd()) {
- double volume = kDefaultVolumeGainPercent;
- it.value().GetAsDouble(&volume);
+ double volume = kDefaultOutputVolume;
+ bool success = it.value().GetAsDouble(&volume);
+ DCHECK(success);
dict_update->SetDouble(it.key(), volume);
it.Advance();
}
@@ -182,7 +214,7 @@ void AudioDevicesPrefHandlerImpl::RegisterPrefs(PrefRegistrySimple* registry) {
// Register the legacy audio prefs for migration.
registry->RegisterDoublePref(prefs::kAudioVolumePercent,
- kDefaultVolumeGainPercent);
+ kDefaultOutputVolume);
registry->RegisterIntegerPref(prefs::kAudioMute, kPrefMuteOff);
}
« no previous file with comments | « chrome/browser/chromeos/audio/audio_devices_pref_handler_impl.h ('k') | chromeos/audio/audio_devices_pref_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698