OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/audio_input_controller.h" | 5 #include "media/audio/audio_input_controller.h" |
6 #include "media/base/limits.h" | 6 #include "media/base/limits.h" |
7 | 7 |
8 namespace { | 8 namespace { |
9 | 9 |
10 const int kMaxInputChannels = 2; | 10 const int kMaxInputChannels = 2; |
(...skipping 24 matching lines...) Expand all Loading... |
35 int samples_per_packet) { | 35 int samples_per_packet) { |
36 if (!params.IsValid() || | 36 if (!params.IsValid() || |
37 (params.channels > kMaxInputChannels) || | 37 (params.channels > kMaxInputChannels) || |
38 (samples_per_packet > kMaxSamplesPerPacket) || (samples_per_packet < 0)) | 38 (samples_per_packet > kMaxSamplesPerPacket) || (samples_per_packet < 0)) |
39 return NULL; | 39 return NULL; |
40 | 40 |
41 if (factory_) { | 41 if (factory_) { |
42 return factory_->Create(event_handler, params, samples_per_packet); | 42 return factory_->Create(event_handler, params, samples_per_packet); |
43 } | 43 } |
44 | 44 |
45 scoped_refptr<AudioInputController> controller = new AudioInputController( | 45 scoped_refptr<AudioInputController> controller(new AudioInputController( |
46 event_handler); | 46 event_handler)); |
47 | 47 |
48 // Start the thread and post a task to create the audio input stream. | 48 // Start the thread and post a task to create the audio input stream. |
49 controller->thread_.Start(); | 49 controller->thread_.Start(); |
50 controller->thread_.message_loop()->PostTask( | 50 controller->thread_.message_loop()->PostTask( |
51 FROM_HERE, | 51 FROM_HERE, |
52 NewRunnableMethod(controller.get(), &AudioInputController::DoCreate, | 52 NewRunnableMethod(controller.get(), &AudioInputController::DoCreate, |
53 params, samples_per_packet)); | 53 params, samples_per_packet)); |
54 return controller; | 54 return controller; |
55 } | 55 } |
56 | 56 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 152 } |
153 | 153 |
154 void AudioInputController::OnError(AudioInputStream* stream, int code) { | 154 void AudioInputController::OnError(AudioInputStream* stream, int code) { |
155 // Handle error on the audio controller thread. | 155 // Handle error on the audio controller thread. |
156 thread_.message_loop()->PostTask( | 156 thread_.message_loop()->PostTask( |
157 FROM_HERE, | 157 FROM_HERE, |
158 NewRunnableMethod(this, &AudioInputController::DoReportError, code)); | 158 NewRunnableMethod(this, &AudioInputController::DoReportError, code)); |
159 } | 159 } |
160 | 160 |
161 } // namespace media | 161 } // namespace media |
OLD | NEW |