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

Side by Side Diff: media/audio/audio_input_controller.cc

Issue 12611030: Remove unused parameter to OnError() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits + rebase Created 7 years, 9 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 unified diff | Download patch
« no previous file with comments | « media/audio/audio_input_controller.h ('k') | media/audio/audio_input_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 7 #include "base/bind.h"
8 #include "base/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 #include "media/base/limits.h" 9 #include "media/base/limits.h"
10 10
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 159
160 void AudioInputController::DoCreateForStream( 160 void AudioInputController::DoCreateForStream(
161 AudioInputStream* stream_to_control) { 161 AudioInputStream* stream_to_control) {
162 DCHECK(message_loop_->BelongsToCurrentThread()); 162 DCHECK(message_loop_->BelongsToCurrentThread());
163 163
164 DCHECK(!stream_); 164 DCHECK(!stream_);
165 stream_ = stream_to_control; 165 stream_ = stream_to_control;
166 166
167 if (!stream_) { 167 if (!stream_) {
168 // TODO(satish): Define error types. 168 handler_->OnError(this);
169 handler_->OnError(this, 0);
170 return; 169 return;
171 } 170 }
172 171
173 if (stream_ && !stream_->Open()) { 172 if (stream_ && !stream_->Open()) {
174 stream_->Close(); 173 stream_->Close();
175 stream_ = NULL; 174 stream_ = NULL;
176 // TODO(satish): Define error types. 175 handler_->OnError(this);
177 handler_->OnError(this, 0);
178 return; 176 return;
179 } 177 }
180 178
181 DCHECK(!no_data_timer_.get()); 179 DCHECK(!no_data_timer_.get());
182 // Create the data timer which will call DoCheckForNoData(). The timer 180 // Create the data timer which will call DoCheckForNoData(). The timer
183 // is started in DoRecord() and restarted in each DoCheckForNoData() callback. 181 // is started in DoRecord() and restarted in each DoCheckForNoData() callback.
184 no_data_timer_.reset(new base::Timer( 182 no_data_timer_.reset(new base::Timer(
185 FROM_HERE, base::TimeDelta::FromSeconds(kTimerInitialIntervalSeconds), 183 FROM_HERE, base::TimeDelta::FromSeconds(kTimerInitialIntervalSeconds),
186 base::Bind(&AudioInputController::DoCheckForNoData, 184 base::Bind(&AudioInputController::DoCheckForNoData,
187 base::Unretained(this)), false)); 185 base::Unretained(this)), false));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 SetDataIsActive(false); 217 SetDataIsActive(false);
220 218
221 if (LowLatencyMode()) { 219 if (LowLatencyMode()) {
222 sync_writer_->Close(); 220 sync_writer_->Close();
223 } 221 }
224 222
225 state_ = kClosed; 223 state_ = kClosed;
226 } 224 }
227 } 225 }
228 226
229 void AudioInputController::DoReportError(int code) { 227 void AudioInputController::DoReportError() {
230 DCHECK(message_loop_->BelongsToCurrentThread()); 228 DCHECK(message_loop_->BelongsToCurrentThread());
231 handler_->OnError(this, code); 229 handler_->OnError(this);
232 } 230 }
233 231
234 void AudioInputController::DoSetVolume(double volume) { 232 void AudioInputController::DoSetVolume(double volume) {
235 DCHECK(message_loop_->BelongsToCurrentThread()); 233 DCHECK(message_loop_->BelongsToCurrentThread());
236 DCHECK_GE(volume, 0); 234 DCHECK_GE(volume, 0);
237 DCHECK_LE(volume, 1.0); 235 DCHECK_LE(volume, 1.0);
238 236
239 if (state_ != kCreated && state_ != kRecording) 237 if (state_ != kCreated && state_ != kRecording)
240 return; 238 return;
241 239
(...skipping 23 matching lines...) Expand all
265 stream_->SetAutomaticGainControl(enabled); 263 stream_->SetAutomaticGainControl(enabled);
266 } 264 }
267 265
268 void AudioInputController::DoCheckForNoData() { 266 void AudioInputController::DoCheckForNoData() {
269 DCHECK(message_loop_->BelongsToCurrentThread()); 267 DCHECK(message_loop_->BelongsToCurrentThread());
270 268
271 if (!GetDataIsActive()) { 269 if (!GetDataIsActive()) {
272 // The data-is-active marker will be false only if it has been more than 270 // The data-is-active marker will be false only if it has been more than
273 // one second since a data packet was recorded. This can happen if a 271 // one second since a data packet was recorded. This can happen if a
274 // capture device has been removed or disabled. 272 // capture device has been removed or disabled.
275 handler_->OnError(this, 0); 273 handler_->OnError(this);
276 return; 274 return;
277 } 275 }
278 276
279 // Mark data as non-active. The flag will be re-enabled in OnData() each 277 // Mark data as non-active. The flag will be re-enabled in OnData() each
280 // time a data packet is received. Hence, under normal conditions, the 278 // time a data packet is received. Hence, under normal conditions, the
281 // flag will only be disabled during a very short period. 279 // flag will only be disabled during a very short period.
282 SetDataIsActive(false); 280 SetDataIsActive(false);
283 281
284 // Restart the timer to ensure that we check the flag again in 282 // Restart the timer to ensure that we check the flag again in
285 // |kTimerResetIntervalSeconds|. 283 // |kTimerResetIntervalSeconds|.
(...skipping 26 matching lines...) Expand all
312 handler_->OnData(this, data, size); 310 handler_->OnData(this, data, size);
313 } 311 }
314 312
315 void AudioInputController::OnClose(AudioInputStream* stream) { 313 void AudioInputController::OnClose(AudioInputStream* stream) {
316 DVLOG(1) << "AudioInputController::OnClose()"; 314 DVLOG(1) << "AudioInputController::OnClose()";
317 // TODO(satish): Sometimes the device driver closes the input stream without 315 // TODO(satish): Sometimes the device driver closes the input stream without
318 // us asking for it (may be if the device was unplugged?). Check how to handle 316 // us asking for it (may be if the device was unplugged?). Check how to handle
319 // such cases here. 317 // such cases here.
320 } 318 }
321 319
322 void AudioInputController::OnError(AudioInputStream* stream, int code) { 320 void AudioInputController::OnError(AudioInputStream* stream) {
323 // Handle error on the audio-manager thread. 321 // Handle error on the audio-manager thread.
324 message_loop_->PostTask(FROM_HERE, base::Bind( 322 message_loop_->PostTask(FROM_HERE, base::Bind(
325 &AudioInputController::DoReportError, this, code)); 323 &AudioInputController::DoReportError, this));
326 } 324 }
327 325
328 void AudioInputController::DoStopCloseAndClearStream( 326 void AudioInputController::DoStopCloseAndClearStream(
329 base::WaitableEvent *done) { 327 base::WaitableEvent *done) {
330 DCHECK(message_loop_->BelongsToCurrentThread()); 328 DCHECK(message_loop_->BelongsToCurrentThread());
331 329
332 // Allow calling unconditionally and bail if we don't have a stream to close. 330 // Allow calling unconditionally and bail if we don't have a stream to close.
333 if (stream_ != NULL) { 331 if (stream_ != NULL) {
334 stream_->Stop(); 332 stream_->Stop();
335 stream_->Close(); 333 stream_->Close();
336 stream_ = NULL; 334 stream_ = NULL;
337 } 335 }
338 336
339 // Should be last in the method, do not touch "this" from here on. 337 // Should be last in the method, do not touch "this" from here on.
340 if (done != NULL) 338 if (done != NULL)
341 done->Signal(); 339 done->Signal();
342 } 340 }
343 341
344 void AudioInputController::SetDataIsActive(bool enabled) { 342 void AudioInputController::SetDataIsActive(bool enabled) {
345 base::subtle::Release_Store(&data_is_active_, enabled); 343 base::subtle::Release_Store(&data_is_active_, enabled);
346 } 344 }
347 345
348 bool AudioInputController::GetDataIsActive() { 346 bool AudioInputController::GetDataIsActive() {
349 return (base::subtle::Acquire_Load(&data_is_active_) != false); 347 return (base::subtle::Acquire_Load(&data_is_active_) != false);
350 } 348 }
351 349
352 } // namespace media 350 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_input_controller.h ('k') | media/audio/audio_input_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698