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

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

Issue 1275783003: Add a virtual beamforming audio device on ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix more constructors and disable for now. Created 5 years, 4 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
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 <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/sys_info.h"
13 #include "chromeos/audio/audio_devices_pref_handler.h" 14 #include "chromeos/audio/audio_devices_pref_handler.h"
14 #include "chromeos/audio/audio_devices_pref_handler_stub.h" 15 #include "chromeos/audio/audio_devices_pref_handler_stub.h"
15 #include "chromeos/dbus/dbus_thread_manager.h" 16 #include "chromeos/dbus/dbus_thread_manager.h"
16 17
17 using std::max; 18 using std::max;
18 using std::min; 19 using std::min;
19 20
20 namespace chromeos { 21 namespace chromeos {
21 22
22 namespace { 23 namespace {
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 858
858 while (!input_devices_pq_.empty()) 859 while (!input_devices_pq_.empty())
859 input_devices_pq_.pop(); 860 input_devices_pq_.pop();
860 while (!output_devices_pq_.empty()) 861 while (!output_devices_pq_.empty())
861 output_devices_pq_.pop(); 862 output_devices_pq_.pop();
862 863
863 size_t new_output_device_size = 0; 864 size_t new_output_device_size = 0;
864 size_t new_input_device_size = 0; 865 size_t new_input_device_size = 0;
865 for (size_t i = 0; i < nodes.size(); ++i) { 866 for (size_t i = 0; i < nodes.size(); ++i) {
866 AudioDevice device(nodes[i]); 867 AudioDevice device(nodes[i]);
868
869 // TODO(ajm): This is a temporary proof-of-concept hack. These values should
870 // come from the cras configs for each board.
871 if (device.type == AUDIO_TYPE_INTERNAL_MIC) {
872 const std::string& board = base::SysInfo::GetLsbReleaseBoard();
873 if (board.find("nyan_kitty") != std::string::npos) {
874 device.mic_positions = "-0.03 0 0 0.03 0 0";
875 } else if (board.find("peach_pi") != std::string::npos) {
876 device.mic_positions = "-0.025 0 0 0.025 0 0";
877 } else if (board.find("samus") != std::string::npos) {
878 device.mic_positions = "-0.032 0 0 0.032 0 0";
879 } else if (board.find("swanky") != std::string::npos) {
880 device.mic_positions = "-0.026 0 0 0.026 0 0";
881 }
882 }
883
867 audio_devices_[device.id] = device; 884 audio_devices_[device.id] = device;
868 885
869 if (!has_alternative_input_ && 886 if (!has_alternative_input_ &&
870 device.is_input && 887 device.is_input &&
871 device.type != AUDIO_TYPE_INTERNAL_MIC && 888 device.type != AUDIO_TYPE_INTERNAL_MIC &&
872 device.type != AUDIO_TYPE_KEYBOARD_MIC) { 889 device.type != AUDIO_TYPE_KEYBOARD_MIC) {
873 has_alternative_input_ = true; 890 has_alternative_input_ = true;
874 } else if (!has_alternative_output_ && 891 } else if (!has_alternative_output_ &&
875 !device.is_input && 892 !device.is_input &&
876 device.type != AUDIO_TYPE_INTERNAL_SPEAKER) { 893 device.type != AUDIO_TYPE_INTERNAL_SPEAKER) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 hdmi_rediscover_grace_period_duration_in_ms_), 1057 hdmi_rediscover_grace_period_duration_in_ms_),
1041 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod); 1058 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod);
1042 } 1059 }
1043 1060
1044 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting( 1061 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting(
1045 int duration_in_ms) { 1062 int duration_in_ms) {
1046 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms; 1063 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms;
1047 } 1064 }
1048 1065
1049 } // namespace chromeos 1066 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698