OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 6 |
7 #include "base/threading/thread_restrictions.h" | 7 #include "base/threading/thread_restrictions.h" |
8 #include "media/base/limits.h" | 8 #include "media/base/limits.h" |
9 | 9 |
10 namespace { | 10 namespace { |
11 const int kMaxInputChannels = 2; | 11 const int kMaxInputChannels = 2; |
12 const int kTimerResetInterval = 1; // One second. | 12 const int kTimerResetInterval = 1; // One second. |
13 } | 13 } |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 // static | 17 // static |
18 AudioInputController::Factory* AudioInputController::factory_ = NULL; | 18 AudioInputController::Factory* AudioInputController::factory_ = NULL; |
19 | 19 |
20 AudioInputController::AudioInputController(EventHandler* handler, | 20 AudioInputController::AudioInputController(EventHandler* handler, |
21 SyncWriter* sync_writer) | 21 SyncWriter* sync_writer) |
22 : handler_(handler), | 22 : handler_(handler), |
23 stream_(NULL), | 23 stream_(NULL), |
24 ALLOW_THIS_IN_INITIALIZER_LIST(no_data_timer_(FROM_HERE, | 24 ALLOW_THIS_IN_INITIALIZER_LIST(no_data_timer_( |
25 base::TimeDelta::FromSeconds(kTimerResetInterval), | 25 base::TimeDelta::FromSeconds(kTimerResetInterval), |
26 this, | 26 this, |
27 &AudioInputController::DoReportNoDataError)), | 27 &AudioInputController::DoReportNoDataError)), |
28 state_(kEmpty), | 28 state_(kEmpty), |
29 thread_("AudioInputControllerThread"), | 29 thread_("AudioInputControllerThread"), |
30 sync_writer_(sync_writer) { | 30 sync_writer_(sync_writer) { |
31 } | 31 } |
32 | 32 |
33 AudioInputController::~AudioInputController() { | 33 AudioInputController::~AudioInputController() { |
34 DCHECK(kClosed == state_ || kCreated == state_ || kEmpty == state_); | 34 DCHECK(kClosed == state_ || kCreated == state_ || kEmpty == state_); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 217 } |
218 | 218 |
219 void AudioInputController::OnError(AudioInputStream* stream, int code) { | 219 void AudioInputController::OnError(AudioInputStream* stream, int code) { |
220 // Handle error on the audio controller thread. | 220 // Handle error on the audio controller thread. |
221 thread_.message_loop()->PostTask( | 221 thread_.message_loop()->PostTask( |
222 FROM_HERE, | 222 FROM_HERE, |
223 NewRunnableMethod(this, &AudioInputController::DoReportError, code)); | 223 NewRunnableMethod(this, &AudioInputController::DoReportError, code)); |
224 } | 224 } |
225 | 225 |
226 } // namespace media | 226 } // namespace media |
OLD | NEW |