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

Side by Side Diff: chromeos/audio/cras_audio_handler.cc

Issue 2802343002: Fix static initializers in CrasAudioHandler. (Closed)
Patch Set: Just the fix Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/cras_audio_handler.h" 5 #include "chromeos/audio/cras_audio_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 19 matching lines...) Expand all
30 // Used when sound is unmuted, but volume was less than kMuteThresholdPercent. 30 // Used when sound is unmuted, but volume was less than kMuteThresholdPercent.
31 const int kDefaultUnmuteVolumePercent = 4; 31 const int kDefaultUnmuteVolumePercent = 4;
32 32
33 // Volume value which should be considered as muted in range [0, 100]. 33 // Volume value which should be considered as muted in range [0, 100].
34 const int kMuteThresholdPercent = 1; 34 const int kMuteThresholdPercent = 1;
35 35
36 // The duration of HDMI output re-discover grace period in milliseconds. 36 // The duration of HDMI output re-discover grace period in milliseconds.
37 const int kHDMIRediscoverGracePeriodDurationInMs = 2000; 37 const int kHDMIRediscoverGracePeriodDurationInMs = 2000;
38 38
39 // Mixer matrix, [0.5, 0.5; 0.5, 0.5] 39 // Mixer matrix, [0.5, 0.5; 0.5, 0.5]
40 const std::vector<double> kStereoToMono = {0.5, 0.5, 0.5, 0.5}; 40 const double kStereoToMono[] = {0.5, 0.5, 0.5, 0.5};
41 // Mixer matrix, [1, 0; 0, 1] 41 // Mixer matrix, [1, 0; 0, 1]
42 const std::vector<double> kStereoToStereo = {1, 0, 0, 1}; 42 const double kStereoToStereo[] = {1, 0, 0, 1};
43 43
44 static CrasAudioHandler* g_cras_audio_handler = nullptr; 44 static CrasAudioHandler* g_cras_audio_handler = nullptr;
45 45
46 bool IsSameAudioDevice(const AudioDevice& a, const AudioDevice& b) { 46 bool IsSameAudioDevice(const AudioDevice& a, const AudioDevice& b) {
47 return a.stable_device_id == b.stable_device_id && a.is_input == b.is_input && 47 return a.stable_device_id == b.stable_device_id && a.is_input == b.is_input &&
48 a.type == b.type && a.device_name == b.device_name; 48 a.type == b.type && a.device_name == b.device_name;
49 } 49 }
50 50
51 bool IsDeviceInList(const AudioDevice& device, const AudioNodeList& node_list) { 51 bool IsDeviceInList(const AudioDevice& device, const AudioNodeList& node_list) {
52 for (const AudioNode& node : node_list) { 52 for (const AudioNode& node : node_list) {
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 chromeos::DBusThreadManager::Get()->GetCrasAudioClient()->SwapLeftRight( 423 chromeos::DBusThreadManager::Get()->GetCrasAudioClient()->SwapLeftRight(
424 device.id, swap); 424 device.id, swap);
425 break; 425 break;
426 } 426 }
427 } 427 }
428 } 428 }
429 429
430 void CrasAudioHandler::SetOutputMono(bool mono_on) { 430 void CrasAudioHandler::SetOutputMono(bool mono_on) {
431 output_mono_on_ = mono_on; 431 output_mono_on_ = mono_on;
432 if (mono_on) { 432 if (mono_on) {
433 chromeos::DBusThreadManager::Get()->GetCrasAudioClient()-> 433 chromeos::DBusThreadManager::Get()
434 SetGlobalOutputChannelRemix(output_channels_, kStereoToMono); 434 ->GetCrasAudioClient()
Lei Zhang 2017/04/18 21:35:51 BTW, this is clang-format rewriting code however i
jennyz 2017/04/18 21:46:13 Acknowledged.
435 ->SetGlobalOutputChannelRemix(
436 output_channels_,
437 std::vector<double>(kStereoToMono, std::end(kStereoToMono)));
435 } else { 438 } else {
436 chromeos::DBusThreadManager::Get()->GetCrasAudioClient()-> 439 chromeos::DBusThreadManager::Get()
437 SetGlobalOutputChannelRemix(output_channels_, kStereoToStereo); 440 ->GetCrasAudioClient()
441 ->SetGlobalOutputChannelRemix(
442 output_channels_,
443 std::vector<double>(kStereoToStereo, std::end(kStereoToStereo)));
438 } 444 }
439 445
440 for (auto& observer : observers_) 446 for (auto& observer : observers_)
441 observer.OnOuputChannelRemixingChanged(mono_on); 447 observer.OnOuputChannelRemixingChanged(mono_on);
442 } 448 }
443 449
444 bool CrasAudioHandler::IsOutputMonoEnabled() const { 450 bool CrasAudioHandler::IsOutputMonoEnabled() const {
445 return output_mono_on_; 451 return output_mono_on_;
446 } 452 }
447 453
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 bool CrasAudioHandler::HasExternalDevice(bool is_input) const { 1592 bool CrasAudioHandler::HasExternalDevice(bool is_input) const {
1587 for (const auto& item : audio_devices_) { 1593 for (const auto& item : audio_devices_) {
1588 const AudioDevice& device = item.second; 1594 const AudioDevice& device = item.second;
1589 if (is_input == device.is_input && device.IsExternalDevice()) 1595 if (is_input == device.is_input && device.IsExternalDevice())
1590 return true; 1596 return true;
1591 } 1597 }
1592 return false; 1598 return false;
1593 } 1599 }
1594 1600
1595 } // namespace chromeos 1601 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698