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/cras/audio_manager_cras.h" | 5 #include "media/audio/cras/audio_manager_cras.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/environment.h" | 8 #include "base/environment.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/nix/xdg_util.h" | 10 #include "base/nix/xdg_util.h" |
11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "media/audio/audio_util.h" | |
14 #include "media/audio/cras/cras_input.h" | 13 #include "media/audio/cras/cras_input.h" |
15 #include "media/audio/cras/cras_output.h" | 14 #include "media/audio/cras/cras_output.h" |
| 15 #include "media/base/channel_layout.h" |
16 | 16 |
17 namespace media { | 17 namespace media { |
18 | 18 |
19 // Maximum number of output streams that can be open simultaneously. | 19 // Maximum number of output streams that can be open simultaneously. |
20 static const int kMaxOutputStreams = 50; | 20 static const int kMaxOutputStreams = 50; |
21 | 21 |
| 22 // Default sample rate for input and output streams. |
| 23 static const int kDefaultSampleRate = 48000; |
| 24 |
22 static const char kCrasAutomaticDeviceName[] = "Automatic"; | 25 static const char kCrasAutomaticDeviceName[] = "Automatic"; |
23 static const char kCrasAutomaticDeviceId[] = "automatic"; | 26 static const char kCrasAutomaticDeviceId[] = "automatic"; |
24 | 27 |
25 bool AudioManagerCras::HasAudioOutputDevices() { | 28 bool AudioManagerCras::HasAudioOutputDevices() { |
26 return true; | 29 return true; |
27 } | 30 } |
28 | 31 |
29 bool AudioManagerCras::HasAudioInputDevices() { | 32 bool AudioManagerCras::HasAudioInputDevices() { |
30 return true; | 33 return true; |
31 } | 34 } |
(...skipping 10 matching lines...) Expand all Loading... |
42 NOTIMPLEMENTED(); | 45 NOTIMPLEMENTED(); |
43 } | 46 } |
44 | 47 |
45 void AudioManagerCras::GetAudioInputDeviceNames( | 48 void AudioManagerCras::GetAudioInputDeviceNames( |
46 media::AudioDeviceNames* device_names) { | 49 media::AudioDeviceNames* device_names) { |
47 DCHECK(device_names->empty()); | 50 DCHECK(device_names->empty()); |
48 GetCrasAudioInputDevices(device_names); | 51 GetCrasAudioInputDevices(device_names); |
49 return; | 52 return; |
50 } | 53 } |
51 | 54 |
| 55 AudioParameters AudioManagerCras::GetDefaultOutputStreamParameters() { |
| 56 static const int kDefaultOutputBufferSize = 512; |
| 57 |
| 58 return AudioParameters( |
| 59 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, |
| 60 kDefaultSampleRate, 16, kDefaultOutputBufferSize); |
| 61 } |
| 62 |
| 63 AudioParameters AudioManagerCras::GetDefaultInputStreamParameters( |
| 64 const std::string& device_id) { |
| 65 static const int kDefaultInputBufferSize = 1024; |
| 66 |
| 67 return AudioParameters( |
| 68 AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, |
| 69 kDefaultSampleRate, 16, kDefaultInputBufferSize); |
| 70 } |
| 71 |
52 void AudioManagerCras::GetCrasAudioInputDevices( | 72 void AudioManagerCras::GetCrasAudioInputDevices( |
53 media::AudioDeviceNames* device_names) { | 73 media::AudioDeviceNames* device_names) { |
54 // Cras will route audio from a proper physical device automatically. | 74 // Cras will route audio from a proper physical device automatically. |
55 device_names->push_back(media::AudioDeviceName( | 75 device_names->push_back(media::AudioDeviceName( |
56 kCrasAutomaticDeviceName, kCrasAutomaticDeviceId)); | 76 kCrasAutomaticDeviceName, kCrasAutomaticDeviceId)); |
57 } | 77 } |
58 | 78 |
59 AudioOutputStream* AudioManagerCras::MakeLinearOutputStream( | 79 AudioOutputStream* AudioManagerCras::MakeLinearOutputStream( |
60 const AudioParameters& params) { | 80 const AudioParameters& params) { |
61 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); | 81 DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 AudioParameters AudioManagerCras::GetPreferredLowLatencyOutputStreamParameters( | 113 AudioParameters AudioManagerCras::GetPreferredLowLatencyOutputStreamParameters( |
94 const AudioParameters& input_params) { | 114 const AudioParameters& input_params) { |
95 // TODO(dalecurtis): This should include bits per channel and channel layout | 115 // TODO(dalecurtis): This should include bits per channel and channel layout |
96 // eventually. | 116 // eventually. |
97 return AudioParameters( | 117 return AudioParameters( |
98 AudioParameters::AUDIO_PCM_LOW_LATENCY, input_params.channel_layout(), | 118 AudioParameters::AUDIO_PCM_LOW_LATENCY, input_params.channel_layout(), |
99 input_params.sample_rate(), 16, input_params.frames_per_buffer()); | 119 input_params.sample_rate(), 16, input_params.frames_per_buffer()); |
100 } | 120 } |
101 | 121 |
102 } // namespace media | 122 } // namespace media |
OLD | NEW |