| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "media/audio/alsa/alsa_util.h" | 5 #include "media/audio/alsa/alsa_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "media/audio/alsa/alsa_wrapper.h" | 10 #include "media/audio/alsa/alsa_wrapper.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 const char kMixerPrefix[] = "hw"; | 47 const char kMixerPrefix[] = "hw"; |
| 48 std::string control_name; | 48 std::string control_name; |
| 49 size_t pos1 = device_name.find(':'); | 49 size_t pos1 = device_name.find(':'); |
| 50 if (pos1 == std::string::npos) { | 50 if (pos1 == std::string::npos) { |
| 51 control_name = device_name; | 51 control_name = device_name; |
| 52 } else { | 52 } else { |
| 53 // Examples: | 53 // Examples: |
| 54 // deviceName: "front:CARD=Intel,DEV=0", controlName: "hw:CARD=Intel". | 54 // deviceName: "front:CARD=Intel,DEV=0", controlName: "hw:CARD=Intel". |
| 55 // deviceName: "default:CARD=Intel", controlName: "CARD=Intel". | 55 // deviceName: "default:CARD=Intel", controlName: "CARD=Intel". |
| 56 size_t pos2 = device_name.find(','); | 56 size_t pos2 = device_name.find(','); |
| 57 control_name = (pos2 == std::string::npos) ? | 57 control_name = (pos2 == std::string::npos) |
| 58 device_name.substr(pos1) : | 58 ? device_name.substr(pos1 + 1) |
| 59 kMixerPrefix + device_name.substr(pos1, pos2 - pos1); | 59 : kMixerPrefix + device_name.substr(pos1, pos2 - pos1); |
| 60 } | 60 } |
| 61 | 61 |
| 62 return control_name; | 62 return control_name; |
| 63 } | 63 } |
| 64 | 64 |
| 65 snd_pcm_format_t BitsToFormat(int bits_per_sample) { | 65 snd_pcm_format_t BitsToFormat(int bits_per_sample) { |
| 66 switch (bits_per_sample) { | 66 switch (bits_per_sample) { |
| 67 case 8: | 67 case 8: |
| 68 return SND_PCM_FORMAT_U8; | 68 return SND_PCM_FORMAT_U8; |
| 69 | 69 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 else if (strcmp(elem_name, kMicElemName) == 0) | 191 else if (strcmp(elem_name, kMicElemName) == 0) |
| 192 mic_elem = elem; | 192 mic_elem = elem; |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 | 195 |
| 196 // Did not find any Capture handle, use the Mic handle. | 196 // Did not find any Capture handle, use the Mic handle. |
| 197 return mic_elem; | 197 return mic_elem; |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace alsa_util | 200 } // namespace alsa_util |
| OLD | NEW |