OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chromeos/audio/audio_devices_pref_handler_impl.h" | 5 #include "chromeos/audio/audio_devices_pref_handler_impl.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <algorithm> | 9 #include <algorithm> |
8 | 10 |
9 #include "base/bind.h" | 11 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
11 #include "base/logging.h" | 13 #include "base/logging.h" |
12 #include "base/prefs/pref_registry_simple.h" | 14 #include "base/prefs/pref_registry_simple.h" |
13 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
14 #include "base/prefs/scoped_user_pref_update.h" | 16 #include "base/prefs/scoped_user_pref_update.h" |
15 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
16 #include "chromeos/audio/audio_device.h" | 18 #include "chromeos/audio/audio_device.h" |
17 #include "chromeos/chromeos_pref_names.h" | 19 #include "chromeos/chromeos_pref_names.h" |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 // Values used for muted preference. | 23 // Values used for muted preference. |
22 const int kPrefMuteOff = 0; | 24 const int kPrefMuteOff = 0; |
23 const int kPrefMuteOn = 1; | 25 const int kPrefMuteOn = 1; |
24 | 26 |
25 // Gets the device id string for storing audio preference. The format of | 27 // Gets the device id string for storing audio preference. The format of |
26 // device string is a string consisting of 3 parts. | 28 // device string is a string consisting of 3 parts. |
27 // |device_name| : |integer from lower 32 bit of device id| : | 29 // |device_name| : |integer from lower 32 bit of device id| : |
28 // |0(output device) or 1(input device)| | 30 // |0(output device) or 1(input device)| |
29 // If an audio device has both integrated input and output devices, the first 2 | 31 // If an audio device has both integrated input and output devices, the first 2 |
30 // parts of the string could be identical, only the last part will differentiate | 32 // parts of the string could be identical, only the last part will differentiate |
31 // them. | 33 // them. |
32 std::string GetDeviceIdString(const chromeos::AudioDevice& device) { | 34 std::string GetDeviceIdString(const chromeos::AudioDevice& device) { |
33 std::string device_id_string = | 35 std::string device_id_string = |
34 device.device_name + " : " + | 36 device.device_name + " : " + |
35 base::Uint64ToString(device.id & static_cast<uint64>(0xffffffff)) + | 37 base::Uint64ToString(device.id & static_cast<uint64_t>(0xffffffff)) + |
36 " : " + (device.is_input ? "1" : "0"); | 38 " : " + (device.is_input ? "1" : "0"); |
37 // Replace any periods from the device id string with a space, since setting | 39 // Replace any periods from the device id string with a space, since setting |
38 // names cannot contain periods. | 40 // names cannot contain periods. |
39 std::replace(device_id_string.begin(), device_id_string.end(), '.', ' '); | 41 std::replace(device_id_string.begin(), device_id_string.end(), '.', ' '); |
40 return device_id_string; | 42 return device_id_string; |
41 } | 43 } |
42 | 44 |
43 } // namespace | 45 } // namespace |
44 | 46 |
45 namespace chromeos { | 47 namespace chromeos { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 // media system. | 218 // media system. |
217 registry->RegisterBooleanPref(prefs::kAudioOutputAllowed, true); | 219 registry->RegisterBooleanPref(prefs::kAudioOutputAllowed, true); |
218 | 220 |
219 // Register the legacy audio prefs for migration. | 221 // Register the legacy audio prefs for migration. |
220 registry->RegisterDoublePref(prefs::kAudioVolumePercent, | 222 registry->RegisterDoublePref(prefs::kAudioVolumePercent, |
221 kDefaultOutputVolumePercent); | 223 kDefaultOutputVolumePercent); |
222 registry->RegisterIntegerPref(prefs::kAudioMute, kPrefMuteOff); | 224 registry->RegisterIntegerPref(prefs::kAudioMute, kPrefMuteOff); |
223 } | 225 } |
224 | 226 |
225 } // namespace chromeos | 227 } // namespace chromeos |
OLD | NEW |