| 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/audio_manager_alsa.h" | 5 #include "media/audio/alsa/audio_manager_alsa.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // In addition, note that we support no more than 2 channels for recording, | 45 // In addition, note that we support no more than 2 channels for recording, |
| 46 // hence surround devices are not stored in the list. | 46 // hence surround devices are not stored in the list. |
| 47 static const char* kInvalidAudioInputDevices[] = { | 47 static const char* kInvalidAudioInputDevices[] = { |
| 48 "default", | 48 "default", |
| 49 "dmix", | 49 "dmix", |
| 50 "null", | 50 "null", |
| 51 "pulse", | 51 "pulse", |
| 52 "surround", | 52 "surround", |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 namespace { |
| 56 const char kAudioManagerName[] = "ALSA"; |
| 57 } |
| 58 |
| 55 // static | 59 // static |
| 56 void AudioManagerAlsa::ShowLinuxAudioInputSettings() { | 60 void AudioManagerAlsa::ShowLinuxAudioInputSettings() { |
| 57 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 61 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 58 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 62 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 59 switch (base::nix::GetDesktopEnvironment(env.get())) { | 63 switch (base::nix::GetDesktopEnvironment(env.get())) { |
| 60 case base::nix::DESKTOP_ENVIRONMENT_GNOME: | 64 case base::nix::DESKTOP_ENVIRONMENT_GNOME: |
| 61 command_line.SetProgram(base::FilePath("gnome-volume-control")); | 65 command_line.SetProgram(base::FilePath("gnome-volume-control")); |
| 62 break; | 66 break; |
| 63 case base::nix::DESKTOP_ENVIRONMENT_KDE3: | 67 case base::nix::DESKTOP_ENVIRONMENT_KDE3: |
| 64 case base::nix::DESKTOP_ENVIRONMENT_KDE4: | 68 case base::nix::DESKTOP_ENVIRONMENT_KDE4: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 124 |
| 121 AudioParameters AudioManagerAlsa::GetInputStreamParameters( | 125 AudioParameters AudioManagerAlsa::GetInputStreamParameters( |
| 122 const std::string& device_id) { | 126 const std::string& device_id) { |
| 123 static const int kDefaultInputBufferSize = 1024; | 127 static const int kDefaultInputBufferSize = 1024; |
| 124 | 128 |
| 125 return AudioParameters( | 129 return AudioParameters( |
| 126 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, | 130 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, |
| 127 kDefaultSampleRate, 16, kDefaultInputBufferSize); | 131 kDefaultSampleRate, 16, kDefaultInputBufferSize); |
| 128 } | 132 } |
| 129 | 133 |
| 134 const char* AudioManagerAlsa::GetName() { |
| 135 return kAudioManagerName; |
| 136 } |
| 137 |
| 130 void AudioManagerAlsa::GetAlsaAudioDevices(StreamType type, | 138 void AudioManagerAlsa::GetAlsaAudioDevices(StreamType type, |
| 131 AudioDeviceNames* device_names) { | 139 AudioDeviceNames* device_names) { |
| 132 // Constants specified by the ALSA API for device hints. | 140 // Constants specified by the ALSA API for device hints. |
| 133 static const char kPcmInterfaceName[] = "pcm"; | 141 static const char kPcmInterfaceName[] = "pcm"; |
| 134 int card = -1; | 142 int card = -1; |
| 135 | 143 |
| 136 // Loop through the sound cards to get ALSA device hints. | 144 // Loop through the sound cards to get ALSA device hints. |
| 137 while (!wrapper_->CardNext(&card) && card >= 0) { | 145 while (!wrapper_->CardNext(&card) && card >= 0) { |
| 138 void** hints = NULL; | 146 void** hints = NULL; |
| 139 int error = wrapper_->DeviceNameHint(card, kPcmInterfaceName, &hints); | 147 int error = wrapper_->DeviceNameHint(card, kPcmInterfaceName, &hints); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 371 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 364 switches::kAlsaInputDevice)) { | 372 switches::kAlsaInputDevice)) { |
| 365 device_name = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 373 device_name = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 366 switches::kAlsaInputDevice); | 374 switches::kAlsaInputDevice); |
| 367 } | 375 } |
| 368 | 376 |
| 369 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get()); | 377 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get()); |
| 370 } | 378 } |
| 371 | 379 |
| 372 } // namespace media | 380 } // namespace media |
| OLD | NEW |