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

Unified Diff: media/audio/cras/audio_manager_cras.cc

Issue 12316131: Moved AudioUtil static functions to AudioManager interfaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: made the GetPreferredOutputStreamParameters protected Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/cras/audio_manager_cras.h ('k') | media/audio/ios/audio_manager_ios.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « media/audio/cras/audio_manager_cras.h ('k') | media/audio/ios/audio_manager_ios.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698