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 | 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 { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 handler_->OnCreated(this); | 103 handler_->OnCreated(this); |
104 } | 104 } |
105 | 105 |
106 void AudioInputController::DoRecord() { | 106 void AudioInputController::DoRecord() { |
107 DCHECK_EQ(thread_.message_loop(), MessageLoop::current()); | 107 DCHECK_EQ(thread_.message_loop(), MessageLoop::current()); |
108 | 108 |
109 if (state_ != kCreated) | 109 if (state_ != kCreated) |
110 return; | 110 return; |
111 | 111 |
112 { | 112 { |
113 AutoLock auto_lock(lock_); | 113 base::AutoLock auto_lock(lock_); |
114 state_ = kRecording; | 114 state_ = kRecording; |
115 } | 115 } |
116 | 116 |
117 stream_->Start(this); | 117 stream_->Start(this); |
118 handler_->OnRecording(this); | 118 handler_->OnRecording(this); |
119 } | 119 } |
120 | 120 |
121 void AudioInputController::DoClose() { | 121 void AudioInputController::DoClose() { |
122 DCHECK_EQ(thread_.message_loop(), MessageLoop::current()); | 122 DCHECK_EQ(thread_.message_loop(), MessageLoop::current()); |
123 DCHECK_NE(kClosed, state_); | 123 DCHECK_NE(kClosed, state_); |
(...skipping 12 matching lines...) Expand all Loading... |
136 } | 136 } |
137 | 137 |
138 void AudioInputController::DoReportError(int code) { | 138 void AudioInputController::DoReportError(int code) { |
139 DCHECK_EQ(thread_.message_loop(), MessageLoop::current()); | 139 DCHECK_EQ(thread_.message_loop(), MessageLoop::current()); |
140 handler_->OnError(this, code); | 140 handler_->OnError(this, code); |
141 } | 141 } |
142 | 142 |
143 void AudioInputController::OnData(AudioInputStream* stream, const uint8* data, | 143 void AudioInputController::OnData(AudioInputStream* stream, const uint8* data, |
144 uint32 size) { | 144 uint32 size) { |
145 { | 145 { |
146 AutoLock auto_lock(lock_); | 146 base::AutoLock auto_lock(lock_); |
147 if (state_ != kRecording) | 147 if (state_ != kRecording) |
148 return; | 148 return; |
149 } | 149 } |
150 handler_->OnData(this, data, size); | 150 handler_->OnData(this, data, size); |
151 } | 151 } |
152 | 152 |
153 void AudioInputController::OnClose(AudioInputStream* stream) { | 153 void AudioInputController::OnClose(AudioInputStream* stream) { |
154 // TODO(satish): Sometimes the device driver closes the input stream without | 154 // TODO(satish): Sometimes the device driver closes the input stream without |
155 // us asking for it (may be if the device was unplugged?). Check how to handle | 155 // us asking for it (may be if the device was unplugged?). Check how to handle |
156 // such cases here. | 156 // such cases here. |
157 } | 157 } |
158 | 158 |
159 void AudioInputController::OnError(AudioInputStream* stream, int code) { | 159 void AudioInputController::OnError(AudioInputStream* stream, int code) { |
160 // Handle error on the audio controller thread. | 160 // Handle error on the audio controller thread. |
161 thread_.message_loop()->PostTask( | 161 thread_.message_loop()->PostTask( |
162 FROM_HERE, | 162 FROM_HERE, |
163 NewRunnableMethod(this, &AudioInputController::DoReportError, code)); | 163 NewRunnableMethod(this, &AudioInputController::DoReportError, code)); |
164 } | 164 } |
165 | 165 |
166 } // namespace media | 166 } // namespace media |
OLD | NEW |