Index: media/audio/cras/audio_manager_cras.cc |
diff --git a/media/audio/cras/audio_manager_cras.cc b/media/audio/cras/audio_manager_cras.cc |
index 3401cc5f62310cd41b423084013c9f30e2a0827f..977fba935cb14c98c4fb89f991ad354a05fb3b64 100644 |
--- a/media/audio/cras/audio_manager_cras.cc |
+++ b/media/audio/cras/audio_manager_cras.cc |
@@ -10,15 +10,18 @@ |
#include "base/nix/xdg_util.h" |
#include "base/process_util.h" |
#include "base/stl_util.h" |
-#include "media/audio/audio_util.h" |
#include "media/audio/cras/cras_input.h" |
#include "media/audio/cras/cras_output.h" |
+#include "media/base/channel_layout.h" |
namespace media { |
// Maximum number of output streams that can be open simultaneously. |
static const int kMaxOutputStreams = 50; |
+// Default sample rate for input and output streams. |
+static const int kDefaultSampleRate = 48000; |
+ |
static const char kCrasAutomaticDeviceName[] = "Automatic"; |
static const char kCrasAutomaticDeviceId[] = "automatic"; |
@@ -49,6 +52,15 @@ void AudioManagerCras::GetAudioInputDeviceNames( |
return; |
} |
+AudioParameters AudioManagerCras::GetInputStreamParameters( |
+ const std::string& device_id) { |
+ static const int kDefaultInputBufferSize = 1024; |
+ |
+ return AudioParameters( |
+ AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, |
+ kDefaultSampleRate, 16, kDefaultInputBufferSize); |
+} |
+ |
void AudioManagerCras::GetCrasAudioInputDevices( |
media::AudioDeviceNames* device_names) { |
// Cras will route audio from a proper physical device automatically. |
@@ -80,6 +92,28 @@ AudioInputStream* AudioManagerCras::MakeLowLatencyInputStream( |
return MakeInputStream(params, device_id); |
} |
+AudioParameters AudioManagerCras::GetPreferredOutputStreamParameters( |
+ const AudioParameters& input_params) { |
+ static const int kDefaultOutputBufferSize = 512; |
+ |
+ ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; |
+ int sample_rate = kDefaultSampleRate; |
+ int buffer_size = kDefaultOutputBufferSize; |
+ int bits_per_sample = 16; |
+ int input_channels = 0; |
+ if (input_params.IsValid()) { |
+ sample_rate = input_params.sample_rate(); |
+ bits_per_sample = input_params.bits_per_sample(); |
+ channel_layout = input_params.channel_layout(); |
+ input_channels = input_params.input_channels(); |
+ buffer_size = input_params.frames_per_buffer(); |
+ } |
+ |
+ return AudioParameters( |
+ AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, |
+ sample_rate, bits_per_sample, buffer_size, input_channels); |
+} |
+ |
AudioOutputStream* AudioManagerCras::MakeOutputStream( |
const AudioParameters& params) { |
return new CrasOutputStream(params, this); |
@@ -90,13 +124,4 @@ AudioInputStream* AudioManagerCras::MakeInputStream( |
return new CrasInputStream(params, this); |
} |
-AudioParameters AudioManagerCras::GetPreferredLowLatencyOutputStreamParameters( |
- const AudioParameters& input_params) { |
- // TODO(dalecurtis): This should include bits per channel and channel layout |
- // eventually. |
- return AudioParameters( |
- AudioParameters::AUDIO_PCM_LOW_LATENCY, input_params.channel_layout(), |
- input_params.sample_rate(), 16, input_params.frames_per_buffer()); |
-} |
- |
} // namespace media |