summaryrefslogtreecommitdiffstats
path: root/media/audio/audio_input_controller.cc
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 23:18:48 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-31 23:18:48 +0000
commit2f6d086da79c737bc2a0ee3023ca80c608c75d19 (patch)
tree6943204cb1c9c7d7cbe722f91a64a1c326601fef /media/audio/audio_input_controller.cc
parent87949cc2b85979964ca9de9483ba1ba2758e0b81 (diff)
downloadchromium_src-2f6d086da79c737bc2a0ee3023ca80c608c75d19.zip
chromium_src-2f6d086da79c737bc2a0ee3023ca80c608c75d19.tar.gz
chromium_src-2f6d086da79c737bc2a0ee3023ca80c608c75d19.tar.bz2
Add AudioParameters struct. Use it everywhere.
BUG=None TEST=unittests Review URL: http://codereview.chromium.org/3226012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58097 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/audio_input_controller.cc')
-rw-r--r--media/audio/audio_input_controller.cc26
1 files changed, 9 insertions, 17 deletions
diff --git a/media/audio/audio_input_controller.cc b/media/audio/audio_input_controller.cc
index 9c143c1..fc4b97d 100644
--- a/media/audio/audio_input_controller.cc
+++ b/media/audio/audio_input_controller.cc
@@ -3,13 +3,12 @@
// found in the LICENSE file.
#include "media/audio/audio_input_controller.h"
+#include "media/base/limits.h"
namespace {
-const int kMaxSampleRate = 192000;
-const int kMaxBitsPerSample = 64;
const int kMaxInputChannels = 2;
-const int kMaxSamplesPerPacket = kMaxSampleRate;
+const int kMaxSamplesPerPacket = media::Limits::kMaxSampleRate;
} // namespace
@@ -32,20 +31,15 @@ AudioInputController::~AudioInputController() {
// static
scoped_refptr<AudioInputController> AudioInputController::Create(
EventHandler* event_handler,
- AudioManager::Format format,
- int channels,
- int sample_rate,
- int bits_per_sample,
+ AudioParameters params,
int samples_per_packet) {
- if ((channels > kMaxInputChannels) || (channels <= 0) ||
- (sample_rate > kMaxSampleRate) || (sample_rate <= 0) ||
- (bits_per_sample > kMaxBitsPerSample) || (bits_per_sample <= 0) ||
+ if (!params.IsValid() ||
+ (params.channels > kMaxInputChannels) ||
(samples_per_packet > kMaxSamplesPerPacket) || (samples_per_packet < 0))
return NULL;
if (factory_) {
- return factory_->Create(event_handler, format, channels, sample_rate,
- bits_per_sample, samples_per_packet);
+ return factory_->Create(event_handler, params, samples_per_packet);
}
scoped_refptr<AudioInputController> controller = new AudioInputController(
@@ -56,8 +50,7 @@ scoped_refptr<AudioInputController> AudioInputController::Create(
controller->thread_.message_loop()->PostTask(
FROM_HERE,
NewRunnableMethod(controller.get(), &AudioInputController::DoCreate,
- format, channels, sample_rate, bits_per_sample,
- samples_per_packet));
+ params, samples_per_packet));
return controller;
}
@@ -82,11 +75,10 @@ void AudioInputController::Close() {
thread_.Stop();
}
-void AudioInputController::DoCreate(AudioManager::Format format, int channels,
- int sample_rate, int bits_per_sample,
+void AudioInputController::DoCreate(AudioParameters params,
uint32 samples_per_packet) {
stream_ = AudioManager::GetAudioManager()->MakeAudioInputStream(
- format, channels, sample_rate, bits_per_sample, samples_per_packet);
+ params, samples_per_packet);
if (!stream_) {
// TODO(satish): Define error types.